Skip to content

Commit

Permalink
Merge pull request #331 from enkryptcom/develop
Browse files Browse the repository at this point in the history
Release: v1.24.0
  • Loading branch information
kvhnuke authored Aug 2, 2023
2 parents 94ad2bc + 65bb63a commit ccb0895
Show file tree
Hide file tree
Showing 122 changed files with 1,346 additions and 513 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"devDependencies": {
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@swc/core": "^1.3.68",
"@swc/core": "^1.3.70",
"concurrently": "^7.6.0",
"devmoji": "^2.3.0",
"husky": "^8.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-bridge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"bumpp": "^8.2.1",
"eslint": "^8.44.0",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-alias": "^1.1.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enkryptcom/extension",
"version": "1.23.0",
"version": "1.24.0",
"private": true,
"scripts": {
"zip": "cd dist; zip -r release.zip *;",
Expand Down Expand Up @@ -29,7 +29,7 @@
"@enkryptcom/utils": "workspace:^",
"@ethereumjs/common": "^3.2.0",
"@ethereumjs/tx": "^4.2.0",
"@ledgerhq/hw-transport-webusb": "^6.27.16",
"@ledgerhq/hw-transport-webusb": "^6.27.17",
"@metamask/eth-sig-util": "^6.0.0",
"@types/chrome": "^0.0.241",
"@types/events": "^3.0.0",
Expand All @@ -45,7 +45,7 @@
"chai": "^4.3.7",
"concurrently": "^7.6.0",
"core-js": "^3.31.1",
"echarts": "^5.4.2",
"echarts": "^5.4.3",
"ethereumjs-abi": "^0.6.8",
"ethereumjs-util": "^7.1.5",
"ethereumjs-wallet": "^1.0.2",
Expand Down Expand Up @@ -100,7 +100,7 @@
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"crypto-browserify": "^3.12.0",
"eslint": "^8.44.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^8.7.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/extension/src/libs/dapp-list/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const lists: Partial<Record<NetworkNames, string>> = {
"https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/klay.json",
[NetworkNames.Aurora]:
"https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/aurora.json",
[NetworkNames.Base]:
"https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/base.json",
[NetworkNames.Celo]:
"https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/celo.json",
[NetworkNames.MaticZK]:
"https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/dapps/matic-zkevm.json",
};

export default lists;
2 changes: 1 addition & 1 deletion packages/extension/src/libs/nft-handlers/rarible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const getBestImageURL = (content: NFTContent[]) => {
cont.representation === pri &&
!cont.url.includes("rarible.mypinata.cloud")
)
return cont.url;
return `https://img.mewapi.io/?image=${cont.url}`;
}
}
return "";
Expand Down
28 changes: 23 additions & 5 deletions packages/extension/src/libs/nft-handlers/simplehash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { NetworkNames } from "@enkryptcom/types";
import { SHNFTType, SHResponse } from "./types/simplehash";
const SH_ENDPOINT = "https://partners.mewapi.io/nfts/";
const CACHE_TTL = 60 * 1000;
const getExternalURL = (network: NodeType, contract: string, id: string) => {
if (network.name === NetworkNames.Gnosis)
return `https://niftyfair.io/gc/asset/${contract}/${id}/`;
return "";
};
export default async (
network: NodeType,
address: string
Expand All @@ -15,6 +20,11 @@ export default async (
[NetworkNames.Arbitrum]: "arbitrum",
[NetworkNames.Gnosis]: "gnosis",
[NetworkNames.Avalanche]: "avalanche",
[NetworkNames.MaticZK]: "polygon-zkevm",
[NetworkNames.ZkSync]: "zksync-era",
[NetworkNames.ZkSyncGoerli]: "zksync-era-testnet",
[NetworkNames.Goerli]: "ethereum-goerli",
[NetworkNames.Base]: "base",
};
if (!Object.keys(supportedNetworks).includes(network.name))
throw new Error("Simplehash: network not supported");
Expand All @@ -40,14 +50,20 @@ export default async (
if (!allItems || !allItems.length) return [];
const collections: Record<string, NFTCollection> = {};
allItems.forEach((item) => {
if (!item.image_url || !item.collection.image_url) return;
if (
(!item.image_url && !item.previews.image_medium_url) ||
!item.collection.image_url
)
return;
if (collections[item.contract_address]) {
const tItem: NFTItem = {
contract: item.contract_address,
id: item.token_id,
image: item.image_url,
image: item.image_url || item.previews.image_medium_url,
name: item.name,
url: item.external_url,
url:
item.external_url ||
getExternalURL(network, item.contract_address, item.token_id),
};
collections[item.contract_address].items.push(tItem);
} else {
Expand All @@ -60,9 +76,11 @@ export default async (
{
contract: item.contract_address,
id: item.token_id,
image: item.image_url,
image: item.image_url || item.previews.image_medium_url,
name: item.name,
url: item.external_url,
url:
item.external_url ||
getExternalURL(network, item.contract_address, item.token_id),
},
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const bitcoinOptions: BitcoinNetworkOptions = {
currencyNameLong: "Test Bitcoin",
icon: require("./icons/tbtc.svg"),
decimals: 8,
gradient: "#F7931A",
node: "https://api.blockchain.info/haskoin-store/btc-testnet/",
activityHandler: wrapActivityHandler(haskoinHandler),
basePath: "m/49'/1'/0'/0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const bitcoinOptions: BitcoinNetworkOptions = {
currencyNameLong: "Bitcoin",
icon: require("./icons/btc.svg"),
decimals: 8,
gradient: "#F7931A",
node: "https://api.blockchain.info/haskoin-store/btc/",
coingeckoID: "bitcoin",
activityHandler: wrapActivityHandler(haskoinHandler),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface BitcoinNetworkOptions {
currencyNameLong: string;
icon: string;
decimals: number;
gradient: string;
node: string;
coingeckoID?: string;
basePath: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
<span>${{ $filters.formatFiatValue(fiatEquivalent).value }}</span>
</div>

<a class="send-input-amount__max" @click="emit('update:inputSetMax')">
<a
v-show="showMax"
class="send-input-amount__max"
@click="emit('update:inputSetMax')"
>
Max
</a>
</div>
Expand Down Expand Up @@ -49,6 +53,10 @@ const props = defineProps({
type: String,
default: "",
},
showMax: {
type: Boolean,
default: true,
},
});
const fiatEquivalent = computed(() => {
return new BigNumber(props.fiatValue).times(props.amount).toString();
Expand Down
13 changes: 10 additions & 3 deletions packages/extension/src/providers/ethereum/inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { EXTENSION_VERSION } from "@/configs/constants";
import { SettingsType } from "@/libs/settings-state/types";
import { EnkryptWindow } from "@/types/globals";
import { v4 as randomUUID } from "uuid";
import { InternalMethods } from "@/types/messenger";

export class Provider extends EventEmitter implements ProviderInterface {
chainId: string | null;
Expand Down Expand Up @@ -144,11 +145,17 @@ const injectDocument = (
options: ProviderOptions
): void => {
const provider = new Provider(options);
const globalSettings: SettingsType = document.enkrypt.settings;
const proxiedProvider = new Proxy(provider, ProxyHandler);
if (!globalSettings.evm.inject.disabled)
document[options.name] = proxiedProvider; //proxy is needed due to web3js 1.3.0 callbackify issue. Used in superrare
document["enkrypt"]["providers"][options.name] = provider;
options
.sendMessageHandler(
ProviderName.enkrypt,
JSON.stringify({ method: InternalMethods.getSettings, params: [] })
)
.then((settings: SettingsType) => {
if (!settings.evm.inject.disabled)
document[options.name] = proxiedProvider; //proxy is needed due to web3js 1.3.0 callbackify issue. Used in superrare
});
const ENKRYPT_UUID_V4 = randomUUID();
// EIP-6963
const eip6963AnnounceProvider = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const NetworkEndpoints: Record<string, string> = {
[NetworkNames.Fantom]: "https://api.ftmscan.com/",
[NetworkNames.Aurora]: "https://explorer.mainnet.aurora.dev/",
[NetworkNames.PuppyNet]: "https://puppyscan.shib.io/",
[NetworkNames.MaticZK]: "https://api-zkevm.polygonscan.com/",
[NetworkNames.Base]: "https://api.basescan.org/",
[NetworkNames.Celo]: "https://explorer.celo.org/mainnet/",
};

export { NetworkEndpoints };
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { EvmNetwork } from "../../types/evm-network";
import { getKnownNetworkTokens } from "./token-lists";
import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types";
import { NATIVE_TOKEN_ADDRESS } from "../common";
import getZKSyncBalances from "./zksync";
import getTomoBalances from "./tomochain";
import { CoinGeckoTokenMarket } from "@/libs/market-data/types";

const API_ENPOINT = "https://tokenbalance.mewapi.io/";
const API_ENPOINT2 = "https://partners.mewapi.io/balances/";
Expand Down Expand Up @@ -95,25 +95,28 @@ const supportedNetworks: Record<SupportedNetworkNames, SupportedNetwork> = {
tbName: "aurora",
cgPlatform: CoingeckoPlatform.Aurora,
},
[NetworkNames.TomoChain]: {
tbName: "",
cgPlatform: CoingeckoPlatform.TomoChain,
[NetworkNames.ZkSync]: {
tbName: "era",
cgPlatform: CoingeckoPlatform.Zksync,
},
[NetworkNames.ZkSyncGoerli]: {
tbName: "",
[NetworkNames.MaticZK]: {
tbName: "pze",
cgPlatform: CoingeckoPlatform.MaticZK,
},
[NetworkNames.ZkSync]: {
[NetworkNames.Celo]: {
tbName: "celo",
cgPlatform: CoingeckoPlatform.Celo,
},
[NetworkNames.TomoChain]: {
tbName: "",
cgPlatform: CoingeckoPlatform.TomoChain,
},
};

const getTokens = (
chain: SupportedNetworkNames,
address: string
): Promise<TokenBalance[]> => {
if (chain === NetworkNames.ZkSyncGoerli || chain === NetworkNames.ZkSync) {
return getZKSyncBalances(chain, address);
}
if (chain === NetworkNames.TomoChain) {
return getTomoBalances(chain, address);
}
Expand Down Expand Up @@ -165,7 +168,10 @@ export default (
),
supportedNetworks[networkName].cgPlatform as CoingeckoPlatform
)
: tokens.reduce((obj, cur) => ({ ...obj, [cur.contract]: null }), {});
: tokens.reduce(
(obj, cur) => ({ ...obj, [cur.contract]: null }),
{} as Record<string, CoinGeckoTokenMarket | null>
);
if (network.coingeckoID) {
const nativeMarket = await marketData.getMarketData([
network.coingeckoID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const TokenList: Record<SupportedNetworkNames, string> = {
[NetworkNames.Binance]: `https://tokens.coingecko.com/${CoingeckoPlatform.Binance}/all.json`,
[NetworkNames.Ethereum]: `https://tokens.coingecko.com/${CoingeckoPlatform.Ethereum}/all.json`,
[NetworkNames.Matic]: `https://tokens.coingecko.com/${CoingeckoPlatform.Matic}/all.json`,
[NetworkNames.MaticZK]: `https://tokens.coingecko.com/${CoingeckoPlatform.MaticZK}/all.json`,
[NetworkNames.AstarEVM]: `https://tokens.coingecko.com/${CoingeckoPlatform.Astar}/all.json`,
[NetworkNames.Okc]: `https://tokens.coingecko.com/${CoingeckoPlatform.Okc}/all.json`,
[NetworkNames.Optimism]: `https://tokens.coingecko.com/${CoingeckoPlatform.Optimism}/all.json`,
Expand All @@ -14,14 +15,14 @@ const TokenList: Record<SupportedNetworkNames, string> = {
[NetworkNames.ShidenEVM]: `https://tokens.coingecko.com/${CoingeckoPlatform.Shiden}/all.json`,
[NetworkNames.Canto]: `https://tokens.coingecko.com/${CoingeckoPlatform.Canto}/all.json`,
[NetworkNames.Rootstock]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/rsk.json`,
[NetworkNames.ZkSyncGoerli]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/zksyncgoerli.json`,
[NetworkNames.ZkSync]: `https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/tokenlists/zksync.json`,
[NetworkNames.ZkSync]: `https://tokens.coingecko.com/${CoingeckoPlatform.Zksync}/all.json`,
[NetworkNames.Arbitrum]: `https://tokens.coingecko.com/${CoingeckoPlatform.Arbitrum}/all.json`,
[NetworkNames.Gnosis]: `https://tokens.coingecko.com/${CoingeckoPlatform.Gnosis}/all.json`,
[NetworkNames.Avalanche]: `https://tokens.coingecko.com/${CoingeckoPlatform.Avalanche}/all.json`,
[NetworkNames.Fantom]: `https://tokens.coingecko.com/${CoingeckoPlatform.Fantom}/all.json`,
[NetworkNames.Klaytn]: `https://tokens.coingecko.com/${CoingeckoPlatform.Klaytn}/all.json`,
[NetworkNames.Aurora]: `https://tokens.coingecko.com/${CoingeckoPlatform.Aurora}/all.json`,
[NetworkNames.Celo]: `https://tokens.coingecko.com/${CoingeckoPlatform.Celo}/all.json`,
[NetworkNames.TomoChain]: `https://tokens.coingecko.com/${CoingeckoPlatform.TomoChain}/all.json`,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type SupportedNetworkNames =
| NetworkNames.Fantom
| NetworkNames.Klaytn
| NetworkNames.Aurora
| NetworkNames.ZkSyncGoerli
| NetworkNames.ZkSync
| NetworkNames.TomoChain;
| NetworkNames.TomoChain
| NetworkNames.MaticZK
| NetworkNames.Celo
| NetworkNames.ZkSync;

This file was deleted.

5 changes: 4 additions & 1 deletion packages/extension/src/providers/ethereum/libs/common.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import { NetworkNames } from "@enkryptcom/types";

const NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
export { NATIVE_TOKEN_ADDRESS };
const MAX_UNAVAILABLE_NETWORKS = [NetworkNames.Optimism];
export { NATIVE_TOKEN_ADDRESS, MAX_UNAVAILABLE_NETWORKS };
Loading

2 comments on commit ccb0895

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.