Skip to content

Commit f8812ac

Browse files
Merge branch 'main' into extension
2 parents 9736b34 + f6b26b7 commit f8812ac

File tree

48 files changed

+1571
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1571
-128
lines changed

.env.defaults

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ SUPPORT_NFT_SEND=false
3333
SHOW_ISLAND_UI=false
3434
SUPPORT_THE_ISLAND=false
3535
SUPPORT_THE_ISLAND_ON_TENDERLY=false
36-
SUPPORT_MEZO_NETWORK=false
36+
SUPPORT_MEZO_NETWORK=true
3737
USE_MAINNET_FORK=false
3838
ARBITRUM_FORK_RPC=https://rpc.tenderly.co/fork/2fc2cf12-5c58-439f-9b5e-967bfd02191a
3939
TESTNET_TAHO_DEPLOYER_ADDRESS=0x55B180c3470dA8E31761d45468e4E61DbE13Eb9B
4040
TESTNET_TAHO_ADDRESS=0x78f04eC76df38Fcb37971Efa8EcbcB33f52dae0F
41+
USE_CAMPAIGN_NFT_CONTRACT=
42+

.github/ISSUE_TEMPLATE/BUG.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ body:
5151
label: Version
5252
description: What version of the extension are you running?
5353
options:
54+
- v0.65.0
55+
- v0.64.0
5456
- v0.63.1
5557
- v0.63.0
5658
- v0.62.0

background/constants/networks.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const ZK_SYNC: EVMNetwork = {
104104
}
105105

106106
export const MEZO_TESTNET: EVMNetwork = {
107-
name: "Matsnet",
107+
name: "Mezo matsnet",
108108
baseAsset: MEZO_BTC,
109109
chainID: "31611",
110110
family: "EVM",
@@ -169,7 +169,7 @@ export const NETWORK_BY_CHAIN_ID = {
169169
}
170170

171171
export const TEST_NETWORK_BY_CHAIN_ID = new Set(
172-
[SEPOLIA, ARBITRUM_SEPOLIA].map((network) => network.chainID),
172+
[MEZO_TESTNET, SEPOLIA, ARBITRUM_SEPOLIA].map((network) => network.chainID),
173173
)
174174

175175
// Networks that are not added to this struct will
@@ -213,28 +213,26 @@ export const CHAIN_ID_TO_RPC_URLS: {
213213
[POLYGON.chainID]: [
214214
// This one sometimes returns 0 for eth_getBalance
215215
"https://polygon-rpc.com",
216+
"https://polygon.drpc.org",
216217
"https://1rpc.io/matic",
217218
],
218219
[OPTIMISM.chainID]: [
219-
"https://rpc.ankr.com/optimism",
220+
"https://optimism.drpc.org",
220221
"https://1rpc.io/op",
221222
"https://optimism-mainnet.public.blastapi.io",
222223
],
223-
[ETHEREUM.chainID]: ["https://rpc.ankr.com/eth", "https://1rpc.io/eth"],
224-
[ARBITRUM_ONE.chainID]: [
225-
"https://rpc.ankr.com/arbitrum",
226-
"https://1rpc.io/arb",
227-
],
224+
[ETHEREUM.chainID]: ["https://eth.drpc.org", "https://1rpc.io/eth"],
225+
[ARBITRUM_ONE.chainID]: ["https://arbitrum.drpc.org", "https://1rpc.io/arb"],
228226
[ARBITRUM_NOVA.chainID]: ["https://nova.arbitrum.io/rpc "],
229227
[SEPOLIA.chainID]: ["https://endpoints.omniatech.io/v1/eth/sepolia/public"],
230228
[ARBITRUM_SEPOLIA.chainID]: ["https://sepolia-rollup.arbitrum.io/rpc"],
231229
[AVALANCHE.chainID]: [
232230
"https://api.avax.network/ext/bc/C/rpc",
233231
"https://1rpc.io/avax/c",
234-
"https://rpc.ankr.com/avalanche",
232+
"https://avalanche.drpc.org",
235233
],
236234
[BINANCE_SMART_CHAIN.chainID]: [
237-
"https://rpc.ankr.com/bsc",
235+
"https://bsc.drpc.org",
238236
"https://bsc-dataseed.binance.org",
239237
],
240238
}

background/features.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Used to keep in memory feature settings that were asynchronously
3+
* resolved during extension startup.
4+
*/
5+
export const storage = new Map<string, string>()
6+
7+
export const DynamicSettingsStorageKey = "tally-dynamic-settings"
8+
19
/**
210
* Feature flags which are set at build time.
311
*/
@@ -28,6 +36,7 @@ export const RuntimeFlag = {
2836
SUPPORT_THE_ISLAND_ON_TENDERLY:
2937
process.env.SUPPORT_THE_ISLAND_ON_TENDERLY === "true",
3038
SUPPORT_MEZO_NETWORK: process.env.SUPPORT_MEZO_NETWORK === "true",
39+
USE_CAMPAIGN_NFT_CONTRACT: process.env.USE_CAMPAIGN_NFT_CONTRACT,
3140
} as const
3241

3342
type BuildTimeFlagType = keyof typeof BuildTimeFlag
@@ -36,6 +45,17 @@ export type RuntimeFlagType = keyof typeof RuntimeFlag
3645

3746
export type FeatureFlagType = RuntimeFlagType | BuildTimeFlagType
3847

48+
/**
49+
* Resolves runtime flag values by overriding them with in memory values
50+
* set during extension startup
51+
*/
52+
export const getRuntimeFlagValue = <K extends RuntimeFlagType>(flag: K) => {
53+
const initialValue = RuntimeFlag[flag]
54+
const storedValue = storage.get(flag)
55+
56+
return (storedValue ?? initialValue) as (typeof RuntimeFlag)[K]
57+
}
58+
3959
/**
4060
* Object with all feature flags. The key is the same as the value.
4161
*/
@@ -73,12 +93,19 @@ export function isEnabled(
7393
return BuildTimeFlag[flagName]
7494
}
7595

96+
const flagValue = getRuntimeFlagValue(flagName)
97+
98+
// Non boolean flags
99+
if (typeof flagValue === "string" || typeof flagValue === "undefined") {
100+
return flagValue === "true"
101+
}
102+
76103
if (checkBrowserStorage) {
77104
const state = "" as string // localStorage.getItem(flagName)
78-
return state !== null ? state === "true" : RuntimeFlag[flagName]
105+
return state !== null ? state === "true" : flagValue
79106
}
80107

81-
return RuntimeFlag[flagName]
108+
return flagValue
82109
}
83110

84111
/**

background/lib/mezo.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Interface } from "ethers/lib/utils"
2+
import { ConfirmedEVMTransaction, sameNetwork } from "../networks"
3+
import { MEZO_TESTNET } from "../constants"
4+
import { sameEVMAddress } from "./utils"
5+
import MATSNET_NFT_CAMPAIGN from "../services/campaign/matsnet-nft"
6+
7+
const BORROWER_CONTRACT_ADDRESS = "0x20fAeA18B6a1D0FCDBCcFfFe3d164314744baF30"
8+
9+
const BorrowerABI = new Interface([
10+
"function openTrove(uint256 _maxFeePercentage, uint256 debtAmount, uint256 _assetAmount, address _upperHint, address _lowerHint)",
11+
])
12+
13+
const NFTContractAbi = new Interface([
14+
"function mint(string calldata installId, bytes calldata signature)",
15+
])
16+
17+
// eslint-disable-next-line import/prefer-default-export
18+
export const checkIsBorrowingTx = (tx: ConfirmedEVMTransaction) => {
19+
if (
20+
!sameNetwork(tx.network, MEZO_TESTNET) ||
21+
!tx.blockHash ||
22+
!sameEVMAddress(tx.to, BORROWER_CONTRACT_ADDRESS) ||
23+
tx.status === 0
24+
) {
25+
return false
26+
}
27+
28+
try {
29+
const data = BorrowerABI.decodeFunctionData("openTrove", tx.input ?? "")
30+
return data.debtAmount > 0n
31+
} catch (error) {
32+
return false
33+
}
34+
}
35+
36+
export const checkIsMintTx = (tx: ConfirmedEVMTransaction) => {
37+
if (
38+
!sameNetwork(tx.network, MEZO_TESTNET) ||
39+
!tx.blockHash ||
40+
!sameEVMAddress(tx.to, MATSNET_NFT_CAMPAIGN.nftContract) ||
41+
tx.status === 0
42+
) {
43+
return false
44+
}
45+
46+
try {
47+
const data = NFTContractAbi.decodeFunctionData("mint", tx.input ?? "")
48+
return !!data.installId
49+
} catch (error) {
50+
return false
51+
}
52+
}

background/lib/nfts.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
TransferredNFT,
1414
} from "../nfts"
1515
import { UNIXTime } from "../types"
16+
import { MEZO_TESTNET } from "../constants"
17+
import { NFT_COLLECTION_ID } from "../services/campaign/matsnet-nft"
1618

1719
function groupChainsByAddress(accounts: AddressOnNetwork[]) {
1820
return accounts.reduce<{ [address: string]: string[] }>((acc, account) => {
@@ -100,6 +102,23 @@ export function getNFTCollections(
100102
collections.push(await getPoapCollections(address))
101103
}
102104

105+
const campaignChains = chainIDs.filter((chainID) =>
106+
NFT_PROVIDER_TO_CHAIN.campaign.includes(chainID),
107+
)
108+
109+
if (campaignChains.length) {
110+
collections.push({
111+
id: NFT_COLLECTION_ID,
112+
name: "TahoXMezo",
113+
nftCount: undefined,
114+
owner: address,
115+
hasBadges: false,
116+
network: MEZO_TESTNET,
117+
floorPrice: undefined,
118+
thumbnailURL: undefined,
119+
})
120+
}
121+
103122
const simpleHashChains = chainIDs.filter((chainID) =>
104123
NFT_PROVIDER_TO_CHAIN.simplehash.includes(chainID),
105124
)

background/lib/posthog.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export enum AnalyticsEvent {
1616
DAPP_CONNECTED = "Dapp Connected",
1717
VAULT_MIGRATION = "Migrate to newer vault version",
1818
VAULT_MIGRATION_FAILED = "Vault version migration failed",
19+
// Campaign events
20+
CAMPAIGN_MEZO_NFT_ELIGIBLE_BANNER = "in_wallet-claim_sats",
21+
CAMPAIGN_MEZO_NFT_BORROW_BANNER = "in_wallet-borrow_musd",
22+
CAMPAIGN_MEZO_NFT_CLAIM_NFT_BANNER = "in_wallet-visit_store",
1923
}
2024

2125
export enum OneTimeAnalyticsEvent {

background/networks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,7 @@ export const isEnrichedEVMTransactionRequest = (
422422
transactionRequest: TransactionRequest,
423423
): transactionRequest is EnrichedEVMTransactionRequest =>
424424
"annotation" in transactionRequest
425+
426+
export const isConfirmedEVMTransaction = (
427+
transaction: AnyEVMTransaction,
428+
): transaction is ConfirmedEVMTransaction => "status" in transaction

background/nfts.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ import {
66
AVALANCHE,
77
BINANCE_SMART_CHAIN,
88
ZK_SYNC,
9+
MEZO_TESTNET,
910
} from "./constants"
1011
import { EVMNetwork } from "./networks"
1112
// Networks that are not added to this struct will
1213
// not have an in-wallet NFT tab
1314
export const CHAIN_ID_TO_NFT_METADATA_PROVIDER: {
14-
[chainID: string]: ("simplehash" | "poap")[]
15+
[chainID: string]: ("simplehash" | "poap" | "campaign")[]
1516
} = {
1617
[ETHEREUM.chainID]: ["simplehash", "poap"],
1718
[POLYGON.chainID]: ["simplehash"],
@@ -20,10 +21,12 @@ export const CHAIN_ID_TO_NFT_METADATA_PROVIDER: {
2021
[AVALANCHE.chainID]: ["simplehash"],
2122
[BINANCE_SMART_CHAIN.chainID]: ["simplehash"],
2223
[ZK_SYNC.chainID]: ["simplehash"],
24+
[MEZO_TESTNET.chainID]: ["campaign"],
2325
}
2426

2527
export const NFT_PROVIDER_TO_CHAIN = {
2628
poap: [ETHEREUM.chainID],
29+
campaign: [MEZO_TESTNET.chainID],
2730
simplehash: [
2831
ETHEREUM.chainID,
2932
POLYGON.chainID,

background/redux-slices/selectors/networks.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ export const selectCustomNetworks = createSelector(
2828
(network) => !DEFAULT_NETWORKS_BY_CHAIN_ID.has(network.chainID),
2929
),
3030
)
31+
32+
export const selectTestnetNetworks = createSelector(
33+
selectEVMNetworks,
34+
(evmNetworks) =>
35+
evmNetworks.filter((network) =>
36+
TEST_NETWORK_BY_CHAIN_ID.has(network.chainID),
37+
),
38+
)

0 commit comments

Comments
 (0)