Skip to content

Commit

Permalink
Merge branch 'main' into fix-adding-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadowfiend committed Jul 8, 2023
2 parents 760c3a4 + 713acec commit c01bef5
Show file tree
Hide file tree
Showing 149 changed files with 8,399 additions and 2,941 deletions.
2 changes: 1 addition & 1 deletion .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ SUPPORT_SWAP_QUOTE_REFRESH=false
SUPPORT_ACHIEVEMENTS_BANNER=false
SUPPORT_NFT_SEND=false
USE_MAINNET_FORK=false
ENABLE_UPDATED_DAPP_CONNECTIONS=false
ENABLE_UPDATED_DAPP_CONNECTIONS=false
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ module.exports = {
],
},
],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
},
],
"no-unused-vars": "off",
},
ignorePatterns: [
Expand Down
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Any changes to keyring code deserve extra scrutiny to prevent key
# Any changes to internal-signer service code deserve extra scrutiny to prevent key
# exfiltration and general "roll your own crypto" mistakes. Newer
# contributions to keyring code should be assumed insecure, requiring
# contributions to internal-signer code should be assumed insecure, requiring
# agreement across the team to merge.
/background/services/keyring/* @tahowallet/extension-security-auditors
/background/services/internal-signer/* @tahowallet/extension-security-auditors
# Any changes to dependencies deserve extra scrutiny to help prevent supply
# chain attacks
yarn.lock @tahowallet/extension-dependency-auditors
Expand Down
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ body:
label: Version
description: What version of the extension are you running?
options:
- v0.40.2
- v0.40.1
- v0.40.0
- v0.39.0
- v0.38.1
- v0.38.0
- v0.37.0
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile
working-directory: .github/workflows/pledge-signer-sync
- run: yarn lint
detect-if-flag-changed:
runs-on: ubuntu-latest
Expand All @@ -114,11 +116,8 @@ jobs:
path-filter:
- '.env.defaults'
e2e-tests:
if: |
github.ref == 'refs/heads/main'
|| contains(github.head_ref, 'e2e')
|| needs.detect-if-flag-changed.outputs.path-filter == 'true'
needs: [build, detect-if-flag-changed]
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
Expand All @@ -139,10 +138,21 @@ jobs:
name: extension-builds-${{ github.event.number || github.event.head_commit.id }}
- name: Extract extension
run: unzip -o chrome.zip -d dist/chrome
- name: Run Playwright tests
run: xvfb-run npx playwright test
# Some tests that we have configured in the `e2e-tests` folder may require
# spending funds. Although they're desined to not spend much, with
# frequent execution that can accumulate. We don't want to execute such
# tests on every PR update. We'll tag those tests with the `@slow` tag.
- name: Run free Playwright tests
run: xvfb-run npx playwright test --grep-invert @slow
#env:
# DEBUG: pw:api*
# TODO: Uncomment once we have some `@slow` tagged tests in our test set.
# - name: Run costing Playwright tests
# if: |
# github.ref == 'refs/heads/main'
# || contains(github.head_ref, 'e2e')
# || needs.detect-if-flag-changed.outputs.path-filter == 'true'
# run: xvfb-run npx playwright test --grep @slow
- uses: actions/upload-artifact@v3
if: failure()
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pledge-signer-sync/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@tallyho/pledge-signer-sync",
"type": "module",
"version": "1.0.0",
"private": true,
"engines": {
"node": ">=16.0.0 <17.0.0"
},
"dependencies": {
"firebase": "^9.9.0",
"node-fetch": "3.3.1"
}
}
142 changes: 142 additions & 0 deletions .github/workflows/pledge-signer-sync/pledge-sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
// @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 fetch from "node-fetch"

const { GALXE_ACCESS_TOKEN, FIRESTORE_USER, FIRESTORE_PASSWORD } = process.env

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

// Limit sync range to last 4 days ( 2 days from last sync + 2 days from now )
const TARGET_DATE = new Date(Date.now() - 4 * 24 * 60 * 60_000)

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

const getAddresses = 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 CHUNK_SIZE = 5_000

const fetchNextBatch = async (offset) => {
let currentQuery = query(
dbCollection,
orderBy("signedManifesto.timestamp", "desc"),
limit(CHUNK_SIZE),
where("signedManifesto.timestamp", ">=", TARGET_DATE)
)

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

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

const allDocs = []

let offsetDoc
let nextBatch = []

do {
nextBatch = await fetchNextBatch(offsetDoc)

offsetDoc = nextBatch[nextBatch.length - 1]

allDocs.push(...nextBatch)

console.log("Retrieved:", allDocs.length, "addresses")

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

return allDocs.map((doc) => doc.id)
}

const syncGalxe = async () => {
const CHUNK_SIZE = 3_000

const addresses = await getAddresses().catch(console.error)

if (!addresses) {
throw new Error("Unable to retrieve pledge signers addresses")
}

for (let i = 0; i < addresses.length; i += CHUNK_SIZE) {
const batch = addresses.slice(i, i + CHUNK_SIZE)

console.log("Syncing addresses...", batch.length, "of", addresses.length)

const payload = {
operationName: "credentialItems",
query: `
mutation credentialItems($credId: ID!, $operation: Operation!, $items: [String!]!)
{
credentialItems(input: {
credId: $credId
operation: $operation
items: $items
})
{
name
}
}
`,
variables: {
credId: "194531900883902464",
operation: "APPEND",
items: batch,
},
}

try {
await fetch("https://graphigo.prd.galaxy.eco/query", {
headers: {
"access-token": GALXE_ACCESS_TOKEN,
"content-type": "application/json",
},
method: "POST",
body: JSON.stringify(payload),
})
} catch (error) {
throw new Error("Unable to sync with galxe")
}

await wait(3000)
}
}

syncGalxe().then(() => {
console.log("Sync complete!")
process.exit(0)
})
Loading

0 comments on commit c01bef5

Please sign in to comment.