Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: usdc #641

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
VITE_IPFS_GATEWAY=https://unauthipfs.subquery.network/ipfs/api/v0
VITE_QUERY_REGISTRY_PROJECT=https://api.subquery.network/sq/subquery/kepler-network
VITE_SUBSCRIPTION_REGISTRY_PROJECT=wss://api.subquery.network/sq/subquery/kepler-network
VITE_QUERY_SWAP_EXCHANGE_PROJECT=https://api.subquery.network/sq/subquery/kepler-network-exchange
VITE_TOP_100_INDEXERS=https://leaderboard-api.subquery.network/graphql
VITE_CONSUMER_HOST_ENDPOINT=https://kepler-chs.subquery.network
VITE_FORUM_DOMAIN=https://forum.subquery.network
VITE_TOKEN=SQT
VITE_STABLE_TOKEN=USDC.e
VITE_STABLE_TOKEN_ADDRESS=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
VITE_FLEXPLAN_ENABLED=true
VITE_NETWORK=mainnet
VITE_GQL_PROXY=https://gql-proxy.subquery.network
VITE_AUTH_URL=https://kepler-auth.subquery.network
VITE_NETWORK_DEPLOYMENT_ID=QmWfLyhgwyhwAfbnHQfg4YhJG9Vuj4cuDH5R4oW35t6MYn
VITE_AIRDROP_DOMAIN=https://sq-airdrop-backend.subquery.network
7 changes: 0 additions & 7 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
VITE_IPFS_GATEWAY=https://unauthipfs.subquery.network/ipfs/api/v0
VITE_QUERY_REGISTRY_PROJECT=https://api.subquery.network/sq/subquery/kepler-network-staging
VITE_SUBSCRIPTION_REGISTRY_PROJECT=wss://api.subquery.network/sq/subquery/kepler-network
VITE_QUERY_SWAP_EXCHANGE_PROJECT=https://api.subquery.network/sq/subquery/kepler-network-exchange
VITE_TOP_100_INDEXERS=https://leaderboard-api.subquery.network/graphql
VITE_CONSUMER_HOST_ENDPOINT=https://kepler-chs.subquery.network
VITE_FORUM_DOMAIN=https://forum.subquery.network
VITE_TOKEN=SQT
VITE_STABLE_TOKEN=USDC.e
VITE_STABLE_TOKEN_ADDRESS=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
VITE_FLEXPLAN_ENABLED=true
VITE_NETWORK=mainnet
VITE_GQL_PROXY=https://gql-proxy.subquery.network
VITE_AUTH_URL=https://kepler-auth.subquery.network
VITE_NETWORK_DEPLOYMENT_ID=QmWfLyhgwyhwAfbnHQfg4YhJG9Vuj4cuDH5R4oW35t6MYn
VITE_AIRDROP_DOMAIN=https://sq-airdrop-backend.subquery.network
6 changes: 0 additions & 6 deletions .env.testnet
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
VITE_IPFS_GATEWAY=https://unauthipfs.subquery.network/ipfs/api/v0
VITE_QUERY_REGISTRY_PROJECT=https://api.subquery.network/sq/subquery/base-testnet
VITE_SUBSCRIPTION_REGISTRY_PROJECT=wss://api.subquery.network/sq/subquery/kepler-testnet
VITE_TOP_100_INDEXERS=https://leaderboard-api.thechaindata.com/graphql
VITE_CONSUMER_HOST_ENDPOINT=https://dev-chs.thechaindata.com
VITE_TOKEN=SQT
VITE_STABLE_TOKEN=USDC.e
VITE_STABLE_TOKEN_ADDRESS=0x7E65A71046170A5b1AaB5C5cC64242EDF95CaBEA
VITE_NETWORK=testnet
VITE_FLEXPLAN_ENABLED=true
VITE_GQL_PROXY=https://gql-proxy.thechaindata.com
VITE_AUTH_URL=https://dev-auth.thechaindata.com
VITE_NETWORK_DEPLOYMENT_ID=QmQDQa6id3QP1Tiznu7gE4ZjNw4urQnS6R9mgfvzANWgqb
VITE_AIRDROP_DOMAIN=https://sq-airdrop-backend.thechaindata.com
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@
"@subql/components": "1.0.3-27",
"@subql/contract-sdk": "0.114.0",
"@subql/network-clients": "^0.114.0",
"@subql/network-config": "^0.114.0",
"@subql/network-config": "^0.114.1-0",
"@subql/network-query": "0.112.1-2",
"@subql/react-hooks": "^0.114.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^18.2.21",
"@types/react-dom": "18",
"@subql/react-hooks": "^0.114.1-0",
"@web3-name-sdk/core": "^0.1.5",
"@web3-react/core": "^6.1.9",
"@web3-react/injected-connector": "^6.0.7",
Expand Down Expand Up @@ -87,6 +80,9 @@
"zustand": "^4.1.5"
},
"devDependencies": {
"@types/node": "^12.0.0",
"@types/react": "^18.2.21",
"@types/react-dom": "18",
"@types/crypto-js": "^4.1.1",
"@types/ethereum-checksum-address": "^0.0.0",
"@types/js-yaml": "^4.0.3",
Expand Down
28 changes: 0 additions & 28 deletions src/hooks/useAirdropKyc.ts

This file was deleted.

9 changes: 6 additions & 3 deletions src/i18n/en/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0

const TOKEN = import.meta.env.VITE_TOKEN;
import { SUPPORTED_NETWORK } from '@containers/Web3';
import { TOKEN_SYMBOLS } from '@subql/network-config';

const TOKEN = TOKEN_SYMBOLS[SUPPORTED_NETWORK] ?? 'SQT';

const translation = {
era: {
Expand Down Expand Up @@ -43,8 +46,8 @@ const translation = {
stakeInputTitle: `Enter the amount of ${TOKEN} you want to stake`,
confirmStake: 'Confirm Stake',
enterUnstakeAmount: 'Enter Unstake Amount',
maxStakeBalance: `Available stake amount: {{tokenAmount}} ${import.meta.env.VITE_TOKEN}`,
unstakeBalanceNextEra: `Available unstake amount: {{tokenAmount}} ${import.meta.env.VITE_TOKEN}`,
maxStakeBalance: `Available stake amount: {{tokenAmount}} ${TOKEN}`,
unstakeBalanceNextEra: `Available unstake amount: {{tokenAmount}} ${TOKEN}`,
unstakeValidNextEra:
'Tokens will be unstaked from next era. They will then be locked for {{duration}} before you can withdraw. During this period, tokens do not earn any rewards.',
unstakeInputTitle: `Enter the amount of ${TOKEN} you want to unstake`,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/consumer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ServiceAgreements } from './ServiceAgreements';

const { SERVICE_AGREEMENTS, FLEX_PLANS, PLAYGROUND, MY_OFFERS, OFFER_MARKETPLACE } = ROUTES;

const isFlexPlanActive = import.meta.env.VITE_FLEXPLAN_ENABLED === 'true';
const isFlexPlanActive = true;

const Consumer: React.FC = () => {
const { t } = useTranslation();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/indexer/MyPlans/Create/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { parseEther } from '@ethersproject/units';
import { useSortedIndexerDeployments } from '@hooks';
import { Button, Spinner, Typography } from '@subql/components';
import { TableTitle } from '@subql/components';
import { STABLE_COIN_DECIMAL } from '@subql/network-config';
import { PlanTemplateFieldsFragment as Template } from '@subql/network-query';
import { useGetPlanTemplatesQuery, useStableCoin } from '@subql/react-hooks';
import {
Expand All @@ -22,7 +23,6 @@ import {
mapAsync,
notEmpty,
renderAsync,
STABLE_TOKEN_DECIMAL,
TOKEN,
} from '@utils';
import { formatSecondsDuration } from '@utils/dateFormatters';
Expand Down Expand Up @@ -362,7 +362,7 @@ export const Create: React.FC = () => {
const sortedAmount =
selectedTemplateInfo?.priceToken === contracts.sqToken.address
? parseEther(amount)
: parseUnits(amount, STABLE_TOKEN_DECIMAL);
: parseUnits(amount, STABLE_COIN_DECIMAL);

return contracts.planManager.createPlan(
sortedAmount,
Expand Down
8 changes: 0 additions & 8 deletions src/setupTests.ts

This file was deleted.

35 changes: 3 additions & 32 deletions src/utils/USDC/index.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { waitForSomething } from '@utils/waitForSomething';
import { Contract, ethers } from 'ethers';
import { SUPPORTED_NETWORK } from '@containers/Web3';
import { STABLE_COIN_ADDRESSES } from '@subql/network-config';

import abi from './USDC.json';

let loading = false;
export let AUSDContract: null | Contract = null;

// NOTE: Why not use hook: plan to move to network-client
export const STABLE_TOKEN_ADDRESS = import.meta.env.VITE_STABLE_TOKEN_ADDRESS;
export const STABLE_TOKEN_DECIMAL = 6;
export const initialAUSDContract = async (): Promise<Contract> => {
if (loading) {
await waitForSomething({
func: () => loading,
});
}
if (AUSDContract) return AUSDContract;
loading = true;
try {
const ethereum = (window as any).ethereum;
const accounts = await ethereum.request({
method: 'eth_requestAccounts',
});
const provider = new ethers.providers.Web3Provider(ethereum);
const walletAddress = accounts[0]; // first account in MetaMask
const signer = provider.getSigner(walletAddress);
AUSDContract = new ethers.Contract(STABLE_TOKEN_ADDRESS, abi, signer);
return AUSDContract;
} finally {
loading = false;
}
};
export const STABLE_TOKEN_ADDRESS = STABLE_COIN_ADDRESSES[SUPPORTED_NETWORK];
11 changes: 6 additions & 5 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2020-2022 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: Apache-2.0

import { SQT_TOKEN_ADDRESS } from '@containers/Web3';
import { SQT_TOKEN_ADDRESS, SUPPORTED_NETWORK } from '@containers/Web3';
import { SQT_DECIMAL, STABLE_COIN_DECIMAL, STABLE_COIN_SYMBOLS, TOKEN_SYMBOLS } from '@subql/network-config';

import { STABLE_TOKEN_ADDRESS } from './USDC';

Expand All @@ -13,13 +14,13 @@ export enum LOCK_STATUS {
UNLOCK = 'UNLOCK',
}

export const STABLE_TOKEN = import.meta.env.VITE_STABLE_TOKEN ?? 'USDC';
export const STABLE_TOKEN = STABLE_COIN_SYMBOLS[SUPPORTED_NETWORK] ?? 'USDC';

export const TOKEN = import.meta.env.VITE_TOKEN ?? 'SQT';
export const TOKEN = TOKEN_SYMBOLS[SUPPORTED_NETWORK] ?? 'SQT';

export const tokenDecimals: { [key: string]: number } = {
[STABLE_TOKEN_ADDRESS]: 6,
[SQT_TOKEN_ADDRESS]: 18,
[STABLE_TOKEN_ADDRESS]: STABLE_COIN_DECIMAL,
[SQT_TOKEN_ADDRESS]: SQT_DECIMAL,
};

export const tokenNames: { [key: string]: string } = {
Expand Down
Loading
Loading