Skip to content

Commit c1499ae

Browse files
committed
cloud_functions: convert env var NETWORK to sdk Network
Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
1 parent fd37c95 commit c1499ae

4 files changed

+13
-18
lines changed

cloud_functions/src/computeNTTRateLimits.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {
2-
assertEnvironmentVariable,
32
NTT_MANAGER_CONTRACT,
43
NTT_TOKENS,
54
NTT_TRANSCEIVER_CONTRACT,
65
NTT_SUPPORTED_CHAINS,
76
getEvmTokenDecimals,
87
getSolanaTokenDecimals,
98
NTTRateLimit,
9+
getNetwork,
1010
} from '@wormhole-foundation/wormhole-monitor-common';
1111
import { EvmPlatform, EvmChains } from '@wormhole-foundation/sdk-evm';
1212
import { SolanaPlatform } from '@wormhole-foundation/sdk-solana';
@@ -17,7 +17,8 @@ import { Storage } from '@google-cloud/storage';
1717

1818
const storage = new Storage();
1919
let bucketName: string = 'wormhole-ntt-cache';
20-
if (assertEnvironmentVariable('NETWORK') === 'Testnet') {
20+
const network = getNetwork();
21+
if (network === 'Testnet') {
2122
bucketName = 'wormhole-ntt-cache-testnet';
2223
}
2324

@@ -115,7 +116,6 @@ export async function computeNTTRateLimits(req: any, res: any) {
115116
}
116117

117118
try {
118-
const network = assertEnvironmentVariable('NETWORK') as Network;
119119
const managerContracts = NTT_MANAGER_CONTRACT[network];
120120

121121
const rateLimits = await Promise.all(

cloud_functions/src/computeTotalSupplyAndLocked.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import {
22
NTT_MANAGER_CONTRACT,
33
NTT_TOKENS,
4-
assertEnvironmentVariable,
4+
NTTTotalSupplyAndLockedData,
55
derivePda,
6+
getCustody,
7+
getCustodyAmount,
68
getEvmTokenDecimals,
79
getEvmTotalSupply,
10+
getNetwork,
811
normalizeToDecimals,
912
} from '@wormhole-foundation/wormhole-monitor-common';
1013
import { PublicKey } from '@solana/web3.js';
11-
import {
12-
getCustody,
13-
getCustodyAmount,
14-
NTTTotalSupplyAndLockedData,
15-
} from '@wormhole-foundation/wormhole-monitor-common';
1614
import { Network, rpc, Chain, chainToChainId } from '@wormhole-foundation/sdk-base';
1715
import { Storage } from '@google-cloud/storage';
1816

1917
const storage = new Storage();
2018
let bucketName: string = 'wormhole-ntt-cache';
21-
if (assertEnvironmentVariable('NETWORK') === 'Testnet') {
19+
const network = getNetwork();
20+
if (network === 'Testnet') {
2221
bucketName = 'wormhole-ntt-cache-testnet';
2322
}
2423

@@ -96,7 +95,6 @@ export async function computeTotalSupplyAndLocked(req: any, res: any) {
9695
}
9796

9897
try {
99-
const network = assertEnvironmentVariable('NETWORK') as Network;
10098
const totalSupplyAndLocked = await fetchTotalSupplyAndLocked(network);
10199
await cloudStorageCache.save(JSON.stringify(totalSupplyAndLocked));
102100
res.status(200).send('Total supply and locked saved');

cloud_functions/src/getNTTRateLimits.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Storage } from '@google-cloud/storage';
22
import { chainIdToChain } from '@wormhole-foundation/sdk-base';
33
import {
44
NTTRateLimit,
5-
assertEnvironmentVariable,
5+
getNetwork,
66
normalizeToDecimals,
77
} from '@wormhole-foundation/wormhole-monitor-common';
88
import { Gauge, register } from 'prom-client';
@@ -33,7 +33,7 @@ async function setCapacityGauge(
3333
const storage = new Storage();
3434

3535
let bucketName: string = 'wormhole-ntt-cache';
36-
const network = assertEnvironmentVariable('NETWORK');
36+
const network = getNetwork();
3737
if (network === 'Testnet') {
3838
bucketName = 'wormhole-ntt-cache-testnet';
3939
}

cloud_functions/src/getTotalSupplyAndLocked.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { Storage } from '@google-cloud/storage';
2-
import {
3-
NTTRateLimit,
4-
assertEnvironmentVariable,
5-
} from '@wormhole-foundation/wormhole-monitor-common';
2+
import { NTTRateLimit, getNetwork } from '@wormhole-foundation/wormhole-monitor-common';
63

74
const storage = new Storage();
8-
const network = assertEnvironmentVariable('NETWORK');
5+
const network = getNetwork();
96
let bucketName: string = 'wormhole-ntt-cache';
107
if (network === 'Testnet') {
118
bucketName = 'wormhole-ntt-cache-testnet';

0 commit comments

Comments
 (0)