-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathlib.tsx
40 lines (33 loc) · 1.38 KB
/
lib.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { BN } from "fuels";
import contractIds from "./sway-api/contract-ids.json";
export const environments = { LOCAL: "local", TESTNET: "testnet" };
export const environment =
process.env.VITE_DAPP_ENVIRONMENT || environments.LOCAL;
export const isLocal = environment === environments.LOCAL;
export const isTestnet = environment === environments.TESTNET;
export const localProviderUrl = `http://127.0.0.1:${process.env.VITE_FUEL_NODE_PORT || 4000}/v1/graphql`;
export const testnetProviderUrl = "https://testnet.fuel.network/v1/graphql";
export const providerUrl = isLocal ? localProviderUrl : testnetProviderUrl;
export const playgroundUrl = providerUrl.replace("v1/graphql", "v1/playground");
export const localContractId = contractIds.testContract;
export const testnetContractId = process.env.VITE_TESTNET_CONTRACT_ID as string;
export const contractId = isLocal ? localContractId : testnetContractId;
export const testnetFaucetUrl = "https://faucet-testnet.fuel.network/";
export const renderTransactionId = (transactionId: string) => {
if (isLocal) {
return transactionId;
}
return (
<a
href={`https://app-testnet.fuel.network/tx/${transactionId}/simple`}
target="_blank"
rel="noreferrer"
className="underline"
>
{transactionId}
</a>
);
};
export const renderFormattedBalance = (balance: BN) => {
return balance.format({ precision: 4 });
};