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

package updates and improvements #866

Merged
merged 6 commits into from
Dec 4, 2023
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"prepare": "husky install"
},
"dependencies": {
"@airswap/libraries": "4.1.10",
"@airswap/metadata": "4.1.8",
"@airswap/libraries": "4.1.13",
"@airswap/metadata": "4.1.12",
"@craco/craco": "^6.2.0",
"@fontsource/dm-mono": "^4.5.0",
"@greypixel_/nicenumbers": "^0.0.18",
Expand Down
Binary file modified public/images/networks/41.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 6 additions & 23 deletions src/constants/nativeCurrency.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import { ChainIds, chainCurrencies, ADDRESS_ZERO } from "@airswap/constants";
import {
ChainIds,
chainCurrencies,
currencyIcons,
ADDRESS_ZERO,
} from "@airswap/constants";
import { TokenInfo } from "@airswap/types";

export const nativeCurrencyDecimals = 18;

const nativeCurrency: Record<number, TokenInfo> = {};

const currencyIcons: Record<number, number> = {
[ChainIds.MAINNET]: ChainIds.MAINNET,
[ChainIds.GOERLI]: ChainIds.MAINNET,
[ChainIds.RSK]: ChainIds.RSK,
[ChainIds.RSKTESTNET]: ChainIds.RSK,
[ChainIds.TELOS]: ChainIds.TELOS,
[ChainIds.TELOSTESTNET]: ChainIds.TELOS,
[ChainIds.BSC]: ChainIds.BSC,
[ChainIds.BSCTESTNET]: ChainIds.BSC,
[ChainIds.POLYGON]: ChainIds.POLYGON,
[ChainIds.BASE]: ChainIds.MAINNET,
[ChainIds.ARBITRUM]: ChainIds.MAINNET,
[ChainIds.FUJI]: ChainIds.AVALANCHE,
[ChainIds.AVALANCHE]: ChainIds.AVALANCHE,
[ChainIds.LINEAGOERLI]: ChainIds.MAINNET,
[ChainIds.LINEA]: ChainIds.MAINNET,
[ChainIds.MUMBAI]: ChainIds.POLYGON,
[ChainIds.BASEGOERLI]: ChainIds.MAINNET,
[ChainIds.ARBITRUMGOERLI]: ChainIds.MAINNET,
[ChainIds.SEPOLIA]: ChainIds.MAINNET,
};

for (let chainId in ChainIds) {
nativeCurrency[chainId] = {
chainId: Number(chainId),
Expand Down
14 changes: 8 additions & 6 deletions src/constants/rpcUrls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const rpcUrls: { [chainId: number]: string | undefined } = {
1: process.env.REACT_APP_RPC_URL_1,
5: process.env.REACT_APP_RPC_URL_5,
59140: process.env.REACT_APP_RPC_URL_59140,
59144: process.env.REACT_APP_RPC_URL_59144,
};
import { apiUrls, ChainIds } from "@airswap/constants";

const rpcUrls: Record<number, string> = {};
for (let chainId in ChainIds) {
rpcUrls[chainId] =
process.env[`REACT_APP_RPC_URL_${chainId}`] || apiUrls[chainId];
}
export default rpcUrls;
8 changes: 2 additions & 6 deletions src/constants/supportedWalletProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WalletConnectConnector } from "@web3-react/walletconnect-connector";

import metamaskLogo from "../assets/wallet-provider-logos/metamask.svg";
import walletconnectLogo from "../assets/wallet-provider-logos/walletconnect.svg";
import rpcUrls from "./rpcUrls";

declare let window: any;

Expand Down Expand Up @@ -41,12 +42,7 @@ const SUPPORTED_WALLET_PROVIDERS: WalletProvider[] = [
getConnector: () => {
if (!cachedConnectors.WalletConnect) {
cachedConnectors.WalletConnect = new WalletConnectConnector({
rpc: {
1: process.env.REACT_APP_RPC_URL_1 || "",
5: process.env.REACT_APP_RPC_URL_5 || "",
59140: process.env.REACT_APP_RPC_URL_59140 || "",
59144: process.env.REACT_APP_RPC_URL_59144 || "",
},
rpc: rpcUrls,
});
}
return cachedConnectors.WalletConnect;
Expand Down
24 changes: 1 addition & 23 deletions src/features/metadata/metadataApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SwapERC20 } from "@airswap/libraries";
import { getKnownTokens, getTokenInfo } from "@airswap/metadata";
import { getTokenInfo } from "@airswap/metadata";
import { TokenInfo } from "@airswap/types";
import { Web3Provider } from "@ethersproject/providers";

Expand Down Expand Up @@ -27,16 +27,6 @@ export const getCustomTokensLocalStorageKey: (
export const getAllTokensLocalStorageKey = (chainId: number): string =>
`airswap/metadataCache/${chainId}`;

export const getAllTokens = async (chainId: number) => {
let tokens;
if (!tokensCache[chainId]) {
tokensCache[chainId] = (await getKnownTokens(chainId)).tokens;
//TODO: handle failure here, need to decide what to do with errors
}
tokens = tokensCache[chainId];
return tokens;
};

export const getUnknownTokens = async (
chainId: number,
supportedTokenAddresses: string[],
Expand Down Expand Up @@ -100,18 +90,6 @@ export const getAllTokensFromLocalStorage = (
return localStorageItem ? JSON.parse(localStorageItem) : {};
};

export const getSavedActiveTokensInfo = async (
account: string,
chainId: number
) => {
const tokens = await getAllTokens(chainId);
const activeTokens = getActiveTokensFromLocalStorage(account, chainId);
const matchingTokens = tokens.filter((tokenInfo) =>
activeTokens.includes(tokenInfo.address)
);
return uniqBy(matchingTokens, (token) => token.address);
};

export const getProtocolFee = async (
chainId: number,
provider: Web3Provider
Expand Down
6 changes: 5 additions & 1 deletion src/features/metadata/metadataSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export const fetchAllTokens = createAsyncThunk<
state: RootState;
}
>("metadata/getKnownTokens", async (chainId, thunkApi) => {
return (await getKnownTokens(chainId)).tokens;
const res = await getKnownTokens(chainId);
if (res.errors.length) {
console.log("Errors fetching metadata", res.errors);
return [];
} else return res.tokens;
});

export const fetchUnkownTokens = createAsyncThunk<
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/getRpcUrl.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { rpcUrls } from "../constants/rpcUrls";
import rpcUrls from "../constants/rpcUrls";

export const getRpcUrl = (chainId: number): string | undefined => {
const rpcUrl = rpcUrls[chainId];
Expand Down
125 changes: 62 additions & 63 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# yarn lockfile v1


"@airswap/balances@4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@airswap/balances/-/balances-4.0.2.tgz#3c7fdea917d75dd1a82ea0cd4ba2f96988260c0f"
integrity sha512-GrVhTjjtyGbw9AXufSzbR67DkqIl1xR55M9INY3VfuITQYHbsHxmWY9gpR6BAp3mNO8yIrYiO8fvqq0MubNAeg==
"@airswap/balances@4.0.4":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@airswap/balances/-/balances-4.0.4.tgz#dcfafaefe7a378b3b3a66eb33bcd494bcdfbc8c9"
integrity sha512-vTusKqir6aWUAYEQMGzCBr5n6Pdagpm99YGbuETkmImQqBUPrQGbUTxtTMvVHcPzhy0NdVHZb7sFfQmwk/M2bg==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/constants@^4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@airswap/constants/-/constants-4.1.3.tgz#ef1647ab8684affd7f02949a2a3e7a9736ad1739"
integrity sha512-OGVnw6LaBydrtrRAg1aGZUxuOa+j569kSH0xjq0jYwoduATfJOIKFNJi3xlqQinRJMHoXZLsgFYs+5XLVc7WEA==
"@airswap/constants@4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@airswap/constants/-/constants-4.1.6.tgz#a44d87563e504e922952dadeef2760c38604c2d6"
integrity sha512-uEk1+IfYUrhVK8QzVvSp+h4msI5VAEh/gzjzxeJGtrGMT97Kl0zYAxl32T5K6/if33Zo3HSkTyuE8/7tYTGELg==

"@airswap/jsonrpc-client-websocket@0.0.1":
version "0.0.1"
Expand All @@ -21,103 +21,102 @@
dependencies:
get-parameter-names "^0.3.0"

"@airswap/libraries@4.1.10":
version "4.1.10"
resolved "https://registry.yarnpkg.com/@airswap/libraries/-/libraries-4.1.10.tgz#f5b87f8c2e3e6e1bca7cbb476eb1aef970330312"
integrity sha512-Pz5Kb4bn58UOdvm9bk7wNH2OxH6A2mQVxqwHWf72Z/NLVX9hVCUSkTqNlGRxP7UC59WZNu+VLSWXrpMiN7B9Rg==
"@airswap/libraries@4.1.13":
version "4.1.13"
resolved "https://registry.yarnpkg.com/@airswap/libraries/-/libraries-4.1.13.tgz#0f9587f4ae7bb301b7ed8e770e689001f6c9d755"
integrity sha512-+M0akobOym0SHp11jI9DHssGABAQUYXfBrh9DgHTir63fi+OqPzk7UxuV8z+Wn5Z+E9UztTD1VLLAxvjD/9xwg==
dependencies:
"@airswap/balances" "4.0.2"
"@airswap/constants" "^4.1.3"
"@airswap/balances" "4.0.4"
"@airswap/constants" "4.1.6"
"@airswap/jsonrpc-client-websocket" "0.0.1"
"@airswap/pool" "4.1.3"
"@airswap/registry" "4.1.2"
"@airswap/staking" "4.0.4"
"@airswap/swap" "4.1.1"
"@airswap/swap-erc20" "4.1.5"
"@airswap/types" "^4.1.1"
"@airswap/utils" "^4.1.6"
"@airswap/wrapper" "4.1.4"
"@airswap/pool" "4.1.4"
"@airswap/registry" "4.1.3"
"@airswap/staking" "4.0.5"
"@airswap/swap" "4.1.2"
"@airswap/swap-erc20" "4.1.6"
"@airswap/types" "4.1.1"
"@airswap/utils" "4.1.8"
"@airswap/wrapper" "4.1.5"
browser-or-node "^2.1.1"
ethers "^5.6.9"
jayson "^4.0.0"
tiny-typed-emitter "^2.1.0"
websocket "^1.0.34"

"@airswap/metadata@4.1.8":
version "4.1.8"
resolved "https://registry.yarnpkg.com/@airswap/metadata/-/metadata-4.1.8.tgz#1fc7ab4f8008dbd62fbc9f5a5246844269d77f03"
integrity sha512-CAulN2L0nKC5TuSXzUxVW2jFXNEh5ZQsCV9MU9nND0Cln6kMo4JtYYmRUqIvwmz77eSkcuIdGkOjwgYlvC5jMg==
"@airswap/metadata@4.1.12":
version "4.1.12"
resolved "https://registry.yarnpkg.com/@airswap/metadata/-/metadata-4.1.12.tgz#4a3af064be2943d7814b8d73ba5b0590564c5441"
integrity sha512-IpOVnVtICHLs9KQjXnbx7rortJJ1AckvBTlqXls9uF6Syv6KUcCEVfm2LrprmcqEuNqMWVhr5kkyOLJNqy29KQ==
dependencies:
"@airswap/constants" "^4.1.3"
"@airswap/types" "^4.1.1"
"@airswap/wrapper" "4.1.4"
"@airswap/constants" "4.1.6"
"@airswap/types" "4.1.1"
"@airswap/wrapper" "4.1.5"
"@openzeppelin/contracts" "^4.8.3"
"@uniswap/token-lists" "^1.0.0-beta.24"
axios "^0.21.4"
ethers "^5.6.9"
valid-url "^1.0.9"

"@airswap/pool@4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@airswap/pool/-/pool-4.1.3.tgz#a2011b8f08365d1d200635dbed6df8356c0dc7df"
integrity sha512-TwJS+XfG7FZdAe0yiW2zeWKyzfNnT6KWirVAAzT/0rHFfr9VYnzV64lYFNEkiwValWVwSNrb5YfoAaS9kBVMsg==
"@airswap/pool@4.1.4":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@airswap/pool/-/pool-4.1.4.tgz#1b684472d4ff389c0273c238d6d41473968954cc"
integrity sha512-gqeqqFmfCh4xwpQg4b78P2JkeZHDPqzFGPtNf6HVQZZm/Y5iNOcWInYHk3mu2STn7+s8nVOiXigjOqQSsVQOQQ==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/registry@4.1.2":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@airswap/registry/-/registry-4.1.2.tgz#e3090be3cf8f695bf1af78b712468e7f85ad634e"
integrity sha512-Pffr+4O+SvRCl+iJLDAQgtFwRcovAHC1+si4rEaQia2UqJWdO5WqhgieGR8pQeZDkvw85aaSoyYrQSQjJJx9bg==
"@airswap/registry@4.1.3":
version "4.1.3"
resolved "https://registry.yarnpkg.com/@airswap/registry/-/registry-4.1.3.tgz#c3dd45fca0439436b8e93cb282c7239f102c1920"
integrity sha512-YD/Azfq4MhxYr+gZo/FKB68wuO0+zEzjTjAFH+VzoEMDA0kIzBx9UHL4HtC2a5SYByd5lBg9Pid7ORMAs+gZSg==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/staking@4.0.4":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@airswap/staking/-/staking-4.0.4.tgz#c3dff1bb7d0e079a94a8985233f6a15330be7124"
integrity sha512-ZOcagR7ME3SJhwJR3gGwtW55+6nIohPn6SpfqACzW00Opm7ibjdn0orzXGmzs1+cuQmRhqF5KXY48jhLlIrPcA==
"@airswap/staking@4.0.5":
version "4.0.5"
resolved "https://registry.yarnpkg.com/@airswap/staking/-/staking-4.0.5.tgz#2233c74974785fda66c71c85cb368643c09fa40a"
integrity sha512-iR8oZLeSK8BylhRynZKD4zthQdH69vyKUJBVH+PtSmeP+ZvggfyT+bSYykHEyXzjWwDE8AqrBApDr2ZDRh7JjA==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/swap-erc20@4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@airswap/swap-erc20/-/swap-erc20-4.1.5.tgz#61ef2fde43c3fc62198f9d164a7305b4d1f17a2a"
integrity sha512-XopV5ZTMfoHvSmE5lySO/OcfruxqGhYSAspLo2ixUtFHtOFNLwJkFls9mF6nwoKHFuFk9vwKDs7nqQ0AerH0rA==
"@airswap/swap-erc20@4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@airswap/swap-erc20/-/swap-erc20-4.1.6.tgz#e78cd9c5f35bbeea7107481eaf671e9ba9e6d4db"
integrity sha512-jg4ZXp7Dj3wDGgSDi3bPXjprrzyxCV1pMJOxmHgILvAzPIGJOEEvlxJrTXKXdf4djRuuXGl7bDy9VxwmzqEO8g==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/swap@4.1.1":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@airswap/swap/-/swap-4.1.1.tgz#1c1bb0db4023d39c81509997615a5c9759913bfe"
integrity sha512-LTTbMftG9yJ/OARjXsJTWsj0YU96o6w82HdmhpCj+BlrBhMd5boRUf24akAYM1GKz6WYYSR2sv+H0FcKkhfGrQ==
"@airswap/swap@4.1.2":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@airswap/swap/-/swap-4.1.2.tgz#c25e2f3cd09ba8bad3a9ff79047910d21a58e1c2"
integrity sha512-avMzfzjZoGySgMerVDvl5y58BVfrHYEpb2z7/aYwPCwHUpTwpmPubfyDgz9NNMRGRhYfU9IjBZ5PGnxEwLXaOQ==
dependencies:
"@openzeppelin/contracts" "^4.8.3"

"@airswap/types@^4.1.1":
"@airswap/types@4.1.1":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@airswap/types/-/types-4.1.1.tgz#1296674bca2838c6612c2c1bff6d094544608056"
integrity sha512-geOn5AuyBqley3MIHYvIQ5MGF1ElHoC+VPHmG5UD+1qPP273/cYiy7QfjALkKeM6URXeMiQo5/95E5zye0wzlQ==
dependencies:
"@uniswap/token-lists" "^1.0.0-beta.31"

"@airswap/utils@^4.1.6":
version "4.1.6"
resolved "https://registry.yarnpkg.com/@airswap/utils/-/utils-4.1.6.tgz#aecb3dc934bc0f6e866e04c3dc9ec18c11b2e960"
integrity sha512-VvqBht+XpBvblpqy2tJeri98eG+zYGe8dQdTduN1FR8YTL9FXXacMqLKCiwyvpL91XEDydi2gMaQnft0/3c9Iw==
"@airswap/utils@4.1.8":
version "4.1.8"
resolved "https://registry.yarnpkg.com/@airswap/utils/-/utils-4.1.8.tgz#c4c0752077eb5385c31c6b2e47a8b3eca9307273"
integrity sha512-kv7pJ/0CKlJT5shljMBA/vLajtLTwGW1Q+k1QyL6OMtUUbq+Q4rihqaqw3QEWBmJWGqFmD2y6xlQ7DpZDm8lXA==
dependencies:
"@airswap/constants" "^4.1.3"
"@airswap/types" "^4.1.1"
"@airswap/constants" "4.1.6"
"@airswap/types" "4.1.1"
"@metamask/eth-sig-util" "^5.0.2"
bignumber.js "^9.0.1"
ethereumjs-util "^7.1.5"
ethers "^5.6.9"
lz-string "^1.5.0"

"@airswap/wrapper@4.1.4":
version "4.1.4"
resolved "https://registry.yarnpkg.com/@airswap/wrapper/-/wrapper-4.1.4.tgz#1ed5476529ec81c49de261fb559bf8c5237fea9d"
integrity sha512-nMuw+s628TLaSmCCMNDapPCoqNE5GI9cxZv6vfOOjjWl+tCOYcF1hSRRCMY2ZMDH9oCJ8N5oaAuChtIX98M1zw==
"@airswap/wrapper@4.1.5":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@airswap/wrapper/-/wrapper-4.1.5.tgz#d9b6d77cf4f5bef33b2cdcf20d9878d2aac3a0dd"
integrity sha512-6oQ0HpCSiXfhdiS5tvcKRLWlIcfR6fqdqBKRLvssLofdJ80Ga/e18gvRrQw064yt6fKnWt9gtr9OQz6STBw3aQ==
dependencies:
"@airswap/swap-erc20" "4.1.5"
"@airswap/swap-erc20" "4.1.6"
"@openzeppelin/contracts" "^4.8.3"

"@ampproject/remapping@^2.2.0":
Expand Down Expand Up @@ -4067,7 +4066,7 @@ axe-core@^4.6.2:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.6.3.tgz#fc0db6fdb65cc7a80ccf85286d91d64ababa3ece"
integrity sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg==

axios@^0.21.0, axios@^0.21.4:
axios@^0.21.0:
version "0.21.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
Expand Down
Loading