Skip to content

Commit

Permalink
Merge branch 'main' into typoPatch
Browse files Browse the repository at this point in the history
  • Loading branch information
jagodarybacka authored Dec 14, 2023
2 parents 9c5f02c + 99f77e6 commit 4450bfd
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 25 deletions.
1 change: 1 addition & 0 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SUPPORT_ARBITRUM_NOVA=false
SUPPORT_SWAP_QUOTE_REFRESH=false
SUPPORT_ACHIEVEMENTS_BANNER=false
SUPPORT_NFT_SEND=false
HIDE_ISLAND_UI=true
SUPPORT_THE_ISLAND=true
SUPPORT_THE_ISLAND_ON_TENDERLY=false
USE_MAINNET_FORK=false
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/BUG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ body:
label: Version
description: What version of the extension are you running?
options:
- v0.53.0
- v0.52.0
- v0.51.0
- v0.50.0
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/pledge-signer-sync/pledge-export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// @ts-check
/* eslint-disable no-console */ // need logging
/* eslint-disable no-await-in-loop */ // need to process items in sequence
import { getAuth, signInWithEmailAndPassword } from "firebase/auth"
import { initializeApp } from "firebase/app"
import {
getFirestore,
query,
orderBy,
limit,
getDocs,
collection,
startAfter,
where,
} from "firebase/firestore"
import fs from "fs"

const { FIRESTORE_USER, FIRESTORE_PASSWORD } = process.env

if (!FIRESTORE_USER || !FIRESTORE_PASSWORD) {
console.error("Missing credentials")
process.exit(1)
}

// Limit sync range to last X days (here: 30 days)
const TARGET_DATE = new Date(Date.now() - 30 * 24 * 60 * 60_000)
const CHUNK_SIZE = 10_000

const wait = (ms) =>
new Promise((r) => {
setTimeout(r, ms)
})

const saveSnapshot = async (addresses, index) => {
if (!addresses) {
throw new Error("Unable to retrieve pledge signers addresses")
}

console.log(
`Saving snapshot of ${addresses.length} addresses to ./exports/pledge-export-${index}.json`,
)

const jsonContent = {
score: addresses.map((address) => ({ address, score: 1 })),
}

try {
fs.writeFileSync(
`./exports/pledge-export-${index}.json`,
JSON.stringify(jsonContent),
)
console.log("Snapshot saved!\n")
} catch (err) {
console.error(err)
}
}

const exportSnapshot = async () => {
const app = initializeApp({
apiKey: "AIzaSyAa78OwfLesUAW8hdzbhUkc5U8LSVH3y7s",
authDomain: "tally-prd.firebaseapp.com",
projectId: "tally-prd",
storageBucket: "tally-prd.appspot.com",
messagingSenderId: "567502050788",
appId: "1:567502050788:web:bb953a931a98e396d363f1",
})

await signInWithEmailAndPassword(
getAuth(app),
FIRESTORE_USER,
FIRESTORE_PASSWORD,
)

const db = getFirestore(app)
const dbCollection = collection(db, "address")

const fetchNextBatch = async (offset) => {
let currentQuery = query(
dbCollection,
orderBy("signedManifesto.timestamp", "desc"),
limit(CHUNK_SIZE),
where("signedManifesto.timestamp", ">=", TARGET_DATE), // Comment this line to export all addresses
)

if (offset) {
currentQuery = query(currentQuery, startAfter(offset))
}

return getDocs(currentQuery).then((snapshot) => snapshot.docs)
}

let allDocsCount = 0
let exportIndex = 0

let offsetDoc
let nextBatch = []

do {
nextBatch = await fetchNextBatch(offsetDoc)

offsetDoc = nextBatch[nextBatch.length - 1]

allDocsCount += nextBatch.length

console.log("Retrieved:", allDocsCount, "addresses")

await saveSnapshot(
nextBatch.map((doc) => doc.id),
exportIndex,
)

exportIndex += 1

await wait(1500)
} while (nextBatch.length === CHUNK_SIZE)
}

exportSnapshot().then(() => {
console.log("Export complete!")
process.exit(0)
})
1 change: 1 addition & 0 deletions background/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const RuntimeFlag = {
SUPPORT_SWAP_QUOTE_REFRESH: process.env.SUPPORT_SWAP_QUOTE_REFRESH === "true",
SUPPORT_CUSTOM_NETWORKS: process.env.SUPPORT_CUSTOM_NETWORKS === "true",
SUPPORT_CUSTOM_RPCS: process.env.SUPPORT_CUSTOM_RPCS === "true",
HIDE_ISLAND_UI: process.env.HIDE_ISLAND_UI === "true",
SUPPORT_THE_ISLAND: process.env.SUPPORT_THE_ISLAND === "true",
SUPPORT_THE_ISLAND_ON_TENDERLY:
process.env.SUPPORT_THE_ISLAND_ON_TENDERLY === "true",
Expand Down
1 change: 1 addition & 0 deletions background/services/chain/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class ChainDatabase extends Dexie {
this.baseAssets,
this.rpcConfig,
this.accountsToTrack,
this.customRpcConfig,
async () => {
await Promise.all([
this.networks.where({ chainID }).delete(),
Expand Down
14 changes: 8 additions & 6 deletions background/services/island/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1930,12 +1930,14 @@ export const CLAIM_WITH_FRIENDS_ABI = [
},
] as const

export const STARTING_REALM_NAMES = [
"Creators",
"Defi",
"Educate",
"Social",
"Vampire",
export const STARTING_REALM_ADDRESSES = [
"0xa5853ca1eac56bf78213b8300b695e7cfa563b4a",
"0x06894597d381542a55d2946e20117c29dbae2351",
"0xc92AF0c1f3111254b73eea97D803155b1E542Ee3",
"0x42a0b5cab976d7a2a0038138dd1279b96b73f029",
"0x26770639eB1262cfA47A4C3Aa27902fa8FCA3465",
"0x6a3d1d9a7eb615be82b5c50bba8c6ecc7606afe6",
"0xdc053c0beed726ee6316d4d04135d755466522c8",
]

export function buildRealmContract(
Expand Down
25 changes: 10 additions & 15 deletions background/services/island/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { sameNetwork } from "../../networks"
import {
ClaimWithFriends,
ISLAND_NETWORK,
STARTING_REALM_NAMES,
STARTING_REALM_ADDRESSES,
TESTNET_TAHO,
TestnetTahoDeployer,
buildRealmContract,
} from "./contracts"
import IndexingService from "../indexing"
Expand Down Expand Up @@ -108,16 +107,11 @@ export default class IslandService extends BaseService<Events> {
this.emitter.emit("monitoringTestnetAsset", TESTNET_TAHO)
}

const connectedDeployer = TestnetTahoDeployer.connect(islandProvider)
await Promise.all(
STARTING_REALM_NAMES.map(async (realmName) => {
const realmAddress =
await connectedDeployer.functions[
`${realmName.toUpperCase()}_REALM`
]()
const realmContract = buildRealmContract(realmAddress[0]).connect(
islandProvider,
)
STARTING_REALM_ADDRESSES.map(async (realmAddress) => {
const realmContract = buildRealmContract(
normalizeEVMAddress(realmAddress),
).connect(islandProvider)

const realmVeTahoAddress = (await realmContract.functions.veTaho())[0]
const realmVeAsset =
Expand All @@ -134,7 +128,7 @@ export default class IslandService extends BaseService<Events> {

if (realmXpAddress === ethers.constants.AddressZero) {
logger.debug(
`XP token for realm ${realmName} at ${realmAddress} is not yet set, throwing an error to retry tracking later.`,
`XP token for realm at ${realmAddress} is not yet set, throwing an error to retry tracking later.`,
)

throw new Error(`XP token does not exist for realm ${realmAddress}`)
Expand All @@ -148,9 +142,10 @@ export default class IslandService extends BaseService<Events> {
)
if (realmXpAsset !== undefined) {
this.emitter.emit("monitoringTestnetAsset", realmXpAsset)
realmContract.on(realmContract.filters.XpDistributed(), () => {
this.checkXPDrop()
})
// TODO: disabled because it causes `eth_getLogs` to spam the RPC node
// realmContract.on(realmContract.filters.XpDistributed(), () => {
// this.checkXPDrop()
// })
}
}),
)
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Taho",
"version": "0.52.0",
"version": "0.53.0",
"description": "The community owned and operated Web3 wallet.",
"homepage_url": "https://taho.xyz",
"author": "https://taho.xyz",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tallyho/tally-extension",
"private": true,
"version": "0.52.0",
"version": "0.53.0",
"description": "Taho, the community owned and operated Web3 wallet.",
"main": "index.js",
"repository": "[email protected]:thesis/tally-extension.git",
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default function Wallet(): ReactElement {
return (
<>
<div className="page_content">
<WalletSubspaceLink />
{!isEnabled(FeatureFlags.HIDE_ISLAND_UI) && <WalletSubspaceLink />}
<WalletAnalyticsNotificationBanner />
<div className="section">
<WalletAccountBalanceControl
Expand All @@ -116,7 +116,7 @@ export default function Wallet(): ReactElement {
{!isEnabled(FeatureFlags.HIDE_TOKEN_FEATURES) && (
<OnboardingOpenClaimFlowBanner />
)}
<PortalBanner />
{!isEnabled(FeatureFlags.HIDE_ISLAND_UI) && <PortalBanner />}
<div className="section">
<SharedPanelSwitcher
setPanelNumber={setPanelNumber}
Expand Down

0 comments on commit 4450bfd

Please sign in to comment.