Skip to content

Commit

Permalink
Merge branch 'main' into fix/rsk/ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
jagodarybacka authored Feb 8, 2023
2 parents 512dc72 + 9e6ac6c commit 5ed8a8f
Show file tree
Hide file tree
Showing 147 changed files with 4,373 additions and 987 deletions.
3 changes: 0 additions & 3 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ MAINNET_FORK_CHAIN_ID=1337
FILE_DIRECTORY_IPFS_HASH="QmYwYkRdYMBCtMqbimgaXjf7UL4RUb5zBQu4TDE67oZbq5"
PART_GLOSSARY_IPFS_HASH="bafybeibytsozn7qsvqgecogv5urg5en34r7v3zxo326vacumi56ckah5b4"
RESOLVE_RNS_NAMES=true
SUPPORT_RSK=true
USE_UPDATED_SIGNING_UI=true
SUPPORT_MULTIPLE_LANGUAGES=false
SUPPORT_TABBED_ONBOARDING=false
SUPPORT_KEYRING_LOCKING=true
SUPPORT_FORGOT_PASSWORD=false
SUPPORT_AVALANCHE=true
SUPPORT_BINANCE_SMART_CHAIN=true
SUPPORT_ARBITRUM_NOVA=false
SUPPORT_SWAP_QUOTE_REFRESH=false
ENABLE_ACHIEVEMENTS_TAB=true
Expand Down
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ body:
label: Version
description: What version of the extension are you running?
options:
- v0.21.2
- v0.21.1
- v0.21.0
- v0.20.0
- v0.19.3
- v0.19.2
- v0.19.1
- v0.19.0
- v0.18.9
- v0.18.8
- v0.18.7
Expand Down
7 changes: 7 additions & 0 deletions __mocks__/webextension-polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ module.exports = {
Promise.resolve(undefined as unknown as Tabs.Tab)
),
},
windows: {
writable: true,
value: {
getCurrent: () => {},
create: () => {},
},
},
runtime: {
...browserMock.runtime,
setUninstallURL: jest.fn(),
Expand Down
69 changes: 69 additions & 0 deletions background/abilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { NormalizedEVMAddress } from "./types"

type HoldERC20 = {
type: "hold"
address: string
}

type OwnNFT = {
type: "own"
nftAddress: string
}

type AllowList = {
type: "allowList"
}

type Unknown = {
type: "unknown"
}

export type AbilityRequirement = HoldERC20 | OwnNFT | AllowList | Unknown

export const ABILITY_TYPES_ENABLED = [
"mint",
"airdrop",
"vote",
"access",
] as const
// https://docs.daylight.xyz/reference/ability-model#ability-types
export const ABILITY_TYPES = [
...ABILITY_TYPES_ENABLED,
"claim",
"product",
"event",
"article",
"result",
"misc",
] as const

export type AbilityType = typeof ABILITY_TYPES[number]

export type Ability = {
type: AbilityType
title: string
description: string | null
abilityId: string
slug: string
linkUrl: string
imageUrl?: string
openAt?: string
closeAt?: string
completed: boolean
removedFromUi: boolean
address: NormalizedEVMAddress
requirement: AbilityRequirement
}

export const ABILITY_TYPE_COLOR = {
mint: "#20c580",
airdrop: "#FF1E6F",
vote: "#E3C10B",
result: "#E3C10B",
access: "#02C0EA",
product: "#D824DC",
event: "#FF8A1E",
article: "#B2B2B2",
misc: "#CBCBCB",
claim: "#F4D530",
}
36 changes: 36 additions & 0 deletions background/constants/base-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,90 @@ const ETH: NetworkBaseAsset = {
name: "Ether",
symbol: "ETH",
decimals: 18,
metadata: {
coinGeckoID: "ethereum",
tokenLists: [],
},
}

const ARBITRUM_ONE_ETH: NetworkBaseAsset = {
...ETH,
chainID: "42161",
metadata: {
coinGeckoID: "arbitrum-one",
tokenLists: [],
},
}

const ARBITRUM_NOVA_ETH: NetworkBaseAsset = {
...ETH,
chainID: "42170",
metadata: {
coinGeckoID: "arbitrum-nova",
tokenLists: [],
},
}

const OPTIMISTIC_ETH: NetworkBaseAsset = {
...ETH,
chainID: "10",
metadata: {
coinGeckoID: "optimistic-ethereum",
tokenLists: [],
},
}

const GOERLI_ETH: NetworkBaseAsset = {
...ETH,
chainID: "5",
metadata: {
coinGeckoID: "ethereum",
tokenLists: [],
},
}

const RBTC: NetworkBaseAsset = {
chainID: "30",
name: "RSK Token",
symbol: "RBTC",
decimals: 18,
metadata: {
coinGeckoID: "rootstock",
tokenLists: [],
},
}

const MATIC: NetworkBaseAsset = {
chainID: "137",
name: "Matic Token",
symbol: "MATIC",
decimals: 18,
metadata: {
coinGeckoID: "polygon-pos",
tokenLists: [],
},
}

const AVAX: NetworkBaseAsset = {
chainID: "43114",
name: "Avalanche",
symbol: "AVAX",
decimals: 18,
metadata: {
coinGeckoID: "avalanche",
tokenLists: [],
},
}

const BNB: NetworkBaseAsset = {
chainID: "56",
name: "Binance Coin",
symbol: "BNB",
decimals: 18,
metadata: {
coinGeckoID: "binance-smart-chain",
tokenLists: [],
},
}

export const BASE_ASSETS_BY_CUSTOM_NAME = {
Expand Down
36 changes: 31 additions & 5 deletions background/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ROOTSTOCK: EVMNetwork = {
name: "Rootstock",
baseAsset: RBTC,
chainID: "30",
derivationPath: "m/44'/137'/0'/0",
family: "EVM",
coingeckoPlatformID: "rootstock",
}
Expand Down Expand Up @@ -90,11 +91,9 @@ export const DEFAULT_NETWORKS = [
OPTIMISM,
GOERLI,
ARBITRUM_ONE,
...(isEnabled(FeatureFlags.SUPPORT_RSK) ? [ROOTSTOCK] : []),
...(isEnabled(FeatureFlags.SUPPORT_AVALANCHE) ? [AVALANCHE] : []),
...(isEnabled(FeatureFlags.SUPPORT_BINANCE_SMART_CHAIN)
? [BINANCE_SMART_CHAIN]
: []),
ROOTSTOCK,
AVALANCHE,
BINANCE_SMART_CHAIN,
...(isEnabled(FeatureFlags.SUPPORT_ARBITRUM_NOVA) ? [ARBITRUM_NOVA] : []),
]

Expand Down Expand Up @@ -192,6 +191,33 @@ export const CHAIN_ID_TO_RPC_URLS: {
],
}

// Taken from https://api.coingecko.com/api/v3/asset_platforms
export const CHAIN_ID_TO_COINGECKO_PLATFORM_ID: {
[chainId: string]: string
} = {
"250": "fantom",
"122": "fuse",
"361": "theta",
"199": "bittorent",
"106": "velas",
"128": "huobi-token",
"96": "bitkub-chain",
"333999": "polis-chain",
"321": "kucoin-community-chain",
"1285": "moonriver",
"25": "cronos",
"10000": "smartbch",
"1313161554": "aurora",
"88": "tomochain",
"1088": "metis-andromeda",
"2001": "milkomeda-cardano",
"9001": "evmos",
"288": "boba",
"42220": "celo",
"1284": "moonbeam",
"66": "okex-chain",
}

/**
* Method list, to describe which rpc method calls on which networks should
* prefer alchemy provider over the generic ones.
Expand Down
4 changes: 0 additions & 4 deletions background/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const RuntimeFlag = {
SUPPORT_FORGOT_PASSWORD: process.env.SUPPORT_FORGOT_PASSWORD === "true",
ENABLE_ACHIEVEMENTS_TAB: process.env.ENABLE_ACHIEVEMENTS_TAB === "true",
HIDE_TOKEN_FEATURES: process.env.HIDE_TOKEN_FEATURES === "true",
SUPPORT_RSK: process.env.SUPPORT_RSK === "true",
SUPPORT_AVALANCHE: process.env.SUPPORT_AVALANCHE === "true",
SUPPORT_BINANCE_SMART_CHAIN:
process.env.SUPPORT_BINANCE_SMART_CHAIN === "true",
SUPPORT_ARBITRUM_NOVA: process.env.SUPPORT_ARBITRUM_NOVA === "true",
SUPPORT_ACHIEVEMENTS_BANNER:
process.env.SUPPORT_ACHIEVEMENTS_BANNER === "true",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import { fetchJson } from "@ethersproject/web"
import { AbilityType } from "../abilities"
import logger from "./logger"

const DAYLIGHT_BASE_URL = "https://api.daylight.xyz/v1/wallets"

// https://docs.daylight.xyz/reference/ability-model#ability-types
type DaylightAbilityType =
| "vote"
| "claim"
| "airdrop"
| "mint"
| "access"
| "product"
| "event"
| "article"
| "result"
| "misc"
const DAYLIGHT_BASE_URL = "https://api.daylight.xyz/v1"

type Community = {
chain: string
Expand Down Expand Up @@ -63,7 +52,7 @@ type DaylightAbilityAction = {
}

export type DaylightAbility = {
type: DaylightAbilityType
type: AbilityType
title: string
description: string | null
imageUrl: string | null
Expand All @@ -85,16 +74,56 @@ type AbilitiesResponse = {
status: string
}

// eslint-disable-next-line import/prefer-default-export
type SpamReportResponse = {
success: boolean
}

export const getDaylightAbilities = async (
address: string
): Promise<DaylightAbility[]> => {
const response: AbilitiesResponse = await fetchJson(
// Abilities whose deadline has not yet passed - we will probably
// want to turn this on once the feature is ready to go live
// `${DAYLIGHT_BASE_URL}/${address}/abilities?deadline=set&type=mint&type=airdrop&type=access`
`${DAYLIGHT_BASE_URL}/${address}/abilities?type=mint&type=airdrop&type=access`
)

return response.abilities
try {
const response: AbilitiesResponse = await fetchJson(
`${DAYLIGHT_BASE_URL}/wallets/${address}/abilities?deadline=all`
)

return response.abilities
} catch (err) {
logger.error("Error getting abilities", err)
}

return []
}

/**
* Report ability as spam.
*
* Learn more at https://docs.daylight.xyz/reference/create-spam-report
*
* @param address the address that reports the ability
* @param abilitySlug the slug of the ability being reported
* @param reason the reason why ability is reported
*/
export const createSpamReport = async (
address: string,
abilitySlug: string,
reason: string
): Promise<boolean> => {
try {
const options = JSON.stringify({
submitter: address,
abilitySlug,
reason,
})

const response: SpamReportResponse = await fetchJson(
`${DAYLIGHT_BASE_URL}/spam-report`,
options
)

return response.success
} catch (err) {
logger.error("Error reporting spam", err)
}

return false
}
5 changes: 4 additions & 1 deletion background/lib/poap_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logger from "./logger"
import { ETHEREUM } from "../constants"
import { NFT, NFTCollection, NFTsWithPagesResponse } from "../nfts"

export const POAP_CONTRACT = "poap_contract"
export const POAP_CONTRACT = "0x22C1f6050E56d2876009903609a2cC3fEf83B415" // POAP contract address https://etherscan.io/address/0x22C1f6050E56d2876009903609a2cC3fEf83B415
export const POAP_COLLECTION_ID = "POAP"

type PoapNFTModel = {
Expand Down Expand Up @@ -39,6 +39,7 @@ function poapNFTModelToNFT(original: PoapNFTModel, owner: string): NFT {
country,
city,
year,
supply,
},
} = original
return {
Expand All @@ -58,7 +59,9 @@ function poapNFTModelToNFT(original: PoapNFTModel, owner: string): NFT {
contract: POAP_CONTRACT, // contract address doesn't make sense for POAPs
owner,
network: ETHEREUM,
supply,
isBadge: true,
rarity: {}, // no rarity rankings for POAPs
}
}

Expand Down
Loading

0 comments on commit 5ed8a8f

Please sign in to comment.