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 Mar 1, 2023
2 parents 8e23f59 + cdea54b commit 3609d9c
Show file tree
Hide file tree
Showing 140 changed files with 2,637 additions and 679 deletions.
4 changes: 2 additions & 2 deletions .env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HIDE_IMPORT_DERIVATION_PATH=true
HIDE_SWAP_REWARDS=true
GAS_PRICE_POOLING_FREQUENCY=120
ETHEREUM_NETWORK=mainnet
WEBSITE_ORIGIN=https://tallyho.org
WEBSITE_ORIGIN=https://taho.xyz
USE_MAINNET_FORK=false
MAINNET_FORK_URL="ws://mainnet-fork.tally.cash:2096/"
MAINNET_FORK_CHAIN_ID=1337
Expand All @@ -26,7 +26,7 @@ SUPPORT_SWAP_QUOTE_REFRESH=false
ENABLE_ACHIEVEMENTS_TAB=true
SUPPORT_ACHIEVEMENTS_BANNER=false
SWITCH_RUNTIME_FLAGS=false
SUPPORT_NFT_TAB=false
SUPPORT_NFT_TAB=true
SUPPORT_NFT_SEND=false
UNS_API_KEY="4a77c949-511b-4c16-9862-6edfb6ae6012"
REACT_DEVTOOLS_DEFAULT_PORT=8097
Expand Down
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ body:
label: Version
description: What version of the extension are you running?
options:
- v0.26.2
- v0.26.1
- v0.26.0
- v0.25.4
- v0.25.3
- v0.25.2
- v0.25.1
- v0.25.0
- v0.24.1
- v0.24.0
- v0.23.1
- v0.23.0
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/FEATURE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ body:
label: What would you like to be able to do?
description: >-
Please describe what you would like to be able to achieve/what problem
you would like to be able to solve with Tally that you currently can't.
you would like to be able to solve with Taho that you currently can't.
validations:
required: true
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
env:
ALCHEMY_KEY: ${{ secrets.DEV_ALCHEMY_API_KEY || 'oV1Rtjh61hGa97X2MTqMY9kEUcpxP-6K' }}
BLOCKNATIVE_API_KEY: ${{ secrets.DEV_BLOCKNATIVE_API_KEY || 'f60816ff-da02-463f-87a6-67a09c6d53fa' }}
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }}
COMMIT_SHA: ${{ github.sha }}
- name: Production build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
Expand All @@ -55,6 +56,7 @@ jobs:
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }}
COMMIT_SHA: ${{ github.sha }}
POAP_API_KEY: ${{ secrets.POAP_API_KEY }}
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }}
- name: Upload build asset
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -98,7 +100,7 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn lint
e2e-tests:
if: github.ref == 'refs/heads/main'
if: (github.ref == 'refs/heads/main') || contains(github.head_ref, 'e2e')
needs: build
timeout-minutes: 60
runs-on: ubuntu-latest
Expand All @@ -125,7 +127,7 @@ jobs:
#env:
# DEBUG: pw:api*
- uses: actions/upload-artifact@v3
if: always()
if: failure()
with:
name: debug-output
path: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ app/extension-scripts/api/playground/
*.rest
.DS_Store
.vscode
playwright-report
playwright-report
test-results/
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Tally Ho Contribution Guide
# Taho Contribution Guide

👍🎉 First off, thanks for taking the time to contribute! 🎉👍 Contributions
are welcome from anyone on the internet, and even the smallest of fixes are
appreciated!

The following is a set of guidelines for contributing to Tally Ho and its
The following is a set of guidelines for contributing to Taho and its
packages. These are mostly guidelines, not rules. Use your best judgment, and
feel free to propose changes to this document in a pull request. While the team
works towards a first release, bigger contributions will be slow-rolled or
Expand All @@ -13,26 +13,26 @@ to them very soon! More below.

## Deciding What to Work On

Tally Ho is currently being built by a core team in collaboration with a community
on the [Tally Ho Community Discord server](https://chat.tally.cash). **Discord is
Taho is currently being built by a core team in collaboration with a community
on the [Taho Community Discord server](https://chat.taho.xyz). **Discord is
the right place to start discussions on new features and bugs.** The community
on Discord, led by a few designated folks will help to funnel these into
well-organized GitHub issues for features and bugs, as well as organize folks
to tackle any issues they’re interested in. For the time being, the core team
will be charged with reviewing, critiquing, and ultimately merging new work.

⭐️ Check out our ["good first issues" tag](https://github.com/tallycash/extension/issues?q=is%3Aopen+is%3Aissue+label%3A%22🐣+good+first+issue%22) for existing bugs that are more approachable.
⭐️ Check out our ["good first issues" tag](https://github.com/tahowallet/extension/issues?q=is%3Aopen+is%3Aissue+label%3A%22🐣+good+first+issue%22) for existing bugs that are more approachable.

## Use Feature Flags

When developing a new feature, please put it behind a feature flag. Because this enables you to open PRs in smaller chunks rather than having the feature completely finished, this will help your contributions get merged faster. It'll also help everyone better QA the feature and time its release! Feature flags are set in [`.env.defaults`](https://github.com/tallycash/extension/blob/main/.env.defaults) in tandem with [`features.ts`](https://github.com/tallycash/extension/blob/main/background/features.ts)
When developing a new feature, please put it behind a feature flag. Because this enables you to open PRs in smaller chunks rather than having the feature completely finished, this will help your contributions get merged faster. It'll also help everyone better QA the feature and time its release! Feature flags are set in [`.env.defaults`](https://github.com/tahowallet/extension/blob/main/.env.defaults) in tandem with [`features.ts`](https://github.com/tahowallet/extension/blob/main/background/features.ts)

## Getting Started

1. Fork tallycash/tally-extension
1. Fork tahowallet/tally-extension
2. Clone your fork
3. Follow the [setup
instructions](https://github.com/tallycash/tally-extension#building-and-developing).
instructions](https://github.com/tahowallet/tally-extension#building-and-developing).
4. If you find an issue you would like to work on, post a comment indicating
you’d like to pick it up. Otherwise, please file an issue indicating what
you are intending to do—there could be a duplicate issue, or someone else
Expand Down Expand Up @@ -63,14 +63,14 @@ code base.

### Commit Signing

Commits on the Tally Ho repository are all required to be signed. No PR will be
Commits on the Taho repository are all required to be signed. No PR will be
merged if it has unsigned commits. See the [GitHub documentation on commit
signing](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
to get it set up.

### Continuous Integration

Tally Ho uses GitHub Actions for continuous integration. All Actions jobs
Taho uses GitHub Actions for continuous integration. All Actions jobs
(including tests, linting) must be green to merge a PR.

### Pre-commit
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# tally-extension
# Taho Extension

<img alt="The community owned & operated wallet."
src="./github_[email protected]"
width="630" />

[Tally Ho](https://blog.tally.cash/a-community-owned-wallet-for-the-new-internet/)
[Taho](https://blog.taho.xyz/a-community-owned-wallet-for-the-new-internet/)
is a community owned and operated Web3 wallet, built as a
[browser extension](https://browserext.github.io/browserext/).

Expand All @@ -18,7 +18,7 @@ spirit of community ownership.

We can do better.

Tally Ho will be
Taho will be

- Fairly launched ⚖️
- Sustainably aligned with users 🤲
Expand Down Expand Up @@ -140,7 +140,7 @@ $ yarn start

### Commit signing

Commits on the Tally Ho repository are all required to be signed.
Commits on the Taho repository are all required to be signed.
No PR will be merged if it has unsigned commits. See the
[GitHub documentation on commit signing](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
to get it set up.
Expand Down Expand Up @@ -346,7 +346,7 @@ Firefox requires to upload source code if minifier is used and to be able to com

## Localization

Tally currently only supports English as the default language. We distill english strings to [\_locales](https://github.com/tallycash/extension/blob/main/ui/_locales/en/messages.json) to prepare for localization.
Taho currently only supports English as the default language. We distill english strings to [\_locales](https://github.com/tallycash/extension/blob/main/ui/_locales/en/messages.json) to prepare for localization.

For other languages, we will use language code defined in [Support locales](https://developer.chrome.com/docs/webstore/i18n/#choosing-locales-to-support). We will use [weblate](https://hosted.weblate.org/projects/tallycash/extension/) for crowd translation, and will commit back to the github periodically after these translations are QA'ed.

Expand Down
8 changes: 4 additions & 4 deletions __mocks__/webextension-polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ module.exports = {
),
},
windows: {
writable: true,
value: {
getCurrent: () => {},
create: () => {},
getCurrent: () => {},
create: () => {},
onRemoved: {
addListener: () => {},
},
},
runtime: {
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Global config for all babel-affected Tally Ho packages.
// Global config for all babel-affected Taho packages.
module.exports = {
plugins: ["styled-jsx/babel"],
presets: [
Expand Down
8 changes: 4 additions & 4 deletions background/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tally Ho Background
# Taho Background

The Tally Ho Background package can effectively be considered the background script for the
Tally Ho extension. It is designed to connect to external data providers including
The Taho Background package can effectively be considered the background script for the
Taho extension. It is designed to connect to external data providers including
Ethereum nodes, as well as specific providers like Alchemy and Blocknative that
may enable specific functionality beyond the standard node functions. It constructs
a data model in the form of a [Redux](https://redux.js.org) store, which is
Expand Down Expand Up @@ -93,7 +93,7 @@ try to attribute networks (through variable and method naming) in the following

## Public API

The only public API of the Tally Ho Background package is what is exported directly on
The only public API of the Taho Background package is what is exported directly on
[`index.ts`](./index.ts). No submodule API is considered public, and all such
APIs are subject to arbitrary change without warning. Any API from a child
module that is meant for public consumption is re-exported in `index.ts`.
Expand Down
2 changes: 1 addition & 1 deletion background/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export const ABILITY_TYPES_ENABLED = [
"airdrop",
"vote",
"access",
"claim",
] as const
// https://docs.daylight.xyz/reference/ability-model#ability-types
export const ABILITY_TYPES = [
...ABILITY_TYPES_ENABLED,
"claim",
"product",
"event",
"article",
Expand Down
3 changes: 2 additions & 1 deletion background/constants/assets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SmartContractFungibleAsset } from "../assets"
import { ETHEREUM } from "./networks"
import { WEBSITE_ORIGIN } from "./website"

/**
* The primary token for the wallet's DAO.
Expand All @@ -14,6 +15,6 @@ export const DOGGO: SmartContractFungibleAsset = {
homeNetwork: ETHEREUM,
metadata: {
tokenLists: [],
websiteURL: "https://tallyho.cash",
websiteURL: WEBSITE_ORIGIN,
},
}
4 changes: 2 additions & 2 deletions background/constants/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const NETWORK_ERRORS = {
// 504:
// 504:
// internal:
UNSUPORTED_NETWORK: "Currently Tally does not support this network",
UNSUPORTED_TRANSPORT: "Currently Tally does not support this transport type",
UNSUPORTED_NETWORK: "Currently Taho does not support this network",
UNSUPORTED_TRANSPORT: "Currently Taho does not support this transport type",
CONNECT_NOT_SUPPORTED:
"The provided endpoint does not support socket connections",
SOCKET_CLOSED: "Connection with node is no longer open",
Expand Down
2 changes: 1 addition & 1 deletion background/constants/website.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* eslint-disable import/prefer-default-export */
export const WEBSITE_ORIGIN = process.env.WEBSITE_ORIGIN ?? null
export const WEBSITE_ORIGIN = process.env.WEBSITE_ORIGIN ?? ""
9 changes: 6 additions & 3 deletions background/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type BuildTimeFlagType = keyof typeof BuildTimeFlag

export type RuntimeFlagType = keyof typeof RuntimeFlag

type FeatureFlagType = RuntimeFlagType | BuildTimeFlagType
export type FeatureFlagType = RuntimeFlagType | BuildTimeFlagType

/**
* Object with all feature flags. The key is the same as the value.
Expand All @@ -61,7 +61,10 @@ export const FeatureFlags = Object.keys({
* If value is not exist then is read from environment variables.
* The value for the build time flag is read from environment variables.
*/
export const isEnabled = (flagName: FeatureFlagType): boolean => {
export const isEnabled = (
flagName: FeatureFlagType,
checkBrowserStorage: boolean = BuildTimeFlag.SWITCH_RUNTIME_FLAGS
): boolean => {
// Guard to narrow flag type
const isBuildTimeFlag = (flag: string): flag is BuildTimeFlagType =>
flag in BuildTimeFlag
Expand All @@ -70,7 +73,7 @@ export const isEnabled = (flagName: FeatureFlagType): boolean => {
return BuildTimeFlag[flagName]
}

if (BuildTimeFlag.SWITCH_RUNTIME_FLAGS) {
if (checkBrowserStorage) {
const state = localStorage.getItem(flagName)
return state !== null ? state === "true" : RuntimeFlag[flagName]
}
Expand Down
65 changes: 46 additions & 19 deletions background/lib/alchemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
isValidAlchemyAssetTransferResponse,
isValidAlchemyTokenBalanceResponse,
isValidAlchemyTokenMetadataResponse,
ValidatedType,
} from "./validate"
import type SerialFallbackProvider from "../services/chain/serial-fallback-provider"
import { AddressOnNetwork } from "../accounts"
Expand Down Expand Up @@ -150,33 +151,59 @@ export async function getAssetTransfers(
*/
export async function getTokenBalances(
provider: SerialFallbackProvider,
{ address, network }: AddressOnNetwork
addressOnNetwork: AddressOnNetwork
): Promise<SmartContractAmount[]> {
const json: unknown = await provider.send("alchemy_getTokenBalances", [
address,
"erc20",
])
const fetchAndValidate = async (address: string, pageKey?: string) => {
const json: unknown = await provider.send("alchemy_getTokenBalances", [
address,
"erc20",
...(pageKey ? [{ pageKey }] : []),
])

if (!isValidAlchemyTokenBalanceResponse(json)) {
logger.warn(
"Alchemy token balance response didn't validate, did the API change?",
json,
isValidAlchemyTokenBalanceResponse.errors
)
return []
if (!isValidAlchemyTokenBalanceResponse(json)) {
logger.warn(
"Alchemy token balance response didn't validate, did the API change?",
json,
isValidAlchemyTokenBalanceResponse.errors
)
return null
}

return json
}

type TokenBalance = ValidatedType<
typeof isValidAlchemyTokenBalanceResponse
>["tokenBalances"]

const balances: TokenBalance = []

type Awaited<P> = P extends Promise<infer V> ? V : P

let currentPageKey
let response: Awaited<ReturnType<typeof fetchAndValidate>>

do {
// eslint-disable-next-line no-await-in-loop
response = await fetchAndValidate(addressOnNetwork.address, currentPageKey)

if (!response) {
break
}

balances.push(...response.tokenBalances)

currentPageKey = response.pageKey
} while (currentPageKey)

// TODO log balances with errors, consider returning an error type
return (
json.tokenBalances
balances
.filter(
(
b
): b is typeof json["tokenBalances"][0] & {
tokenBalance: Exclude<
typeof json["tokenBalances"][0]["tokenBalance"],
undefined | null
>
): b is TokenBalance[0] & {
tokenBalance: NonNullable<TokenBalance[0]["tokenBalance"]>
} =>
(b.error === null || !("error" in b)) &&
"tokenBalance" in b &&
Expand All @@ -199,7 +226,7 @@ export async function getTokenBalances(
return {
smartContract: {
contractAddress: tokenBalance.contractAddress,
homeNetwork: network,
homeNetwork: addressOnNetwork.network,
},
amount: BigInt(balance),
}
Expand Down
Loading

0 comments on commit 3609d9c

Please sign in to comment.