Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
f3ef097
update stellar-sdk for Protocol 19 (#466)
piyalbasu Apr 29, 2022
4426737
add additional tracking for payments and manage assets (#482)
piyalbasu May 11, 2022
8b0c907
when fetching balances filter out liquidity pool shares (#484)
acharb May 12, 2022
0770e01
use asset canonical ID for key in cache (#495)
acharb May 17, 2022
4749fad
add custom select inputs (#502)
acharb May 20, 2022
148805b
use recommended transaction fee by default (#503)
acharb May 23, 2022
e34de09
Merge commit 'd226474d72a8ea83915f302e6eace2986c4e3f89' into release/…
piyalbasu May 24, 2022
dcb5f15
merging 2.3.0 into 2.2.0 - swaps, removing network from onboarding sc…
acharb Jun 9, 2022
3a0a7b9
add a search asset view (#517)
piyalbasu Jun 10, 2022
c12e59d
update the collectedTags array (#524)
acharb Jun 10, 2022
374aede
merge conflicts when merging master
piyalbasu Jun 13, 2022
c6cd007
adding default and loading icons (#525)
piyalbasu Jun 14, 2022
6819df5
make sendSettings rows clickable, add pin extension view (#527)
acharb Jun 14, 2022
eb62cfd
Feature/request public key (#528)
piyalbasu Jun 15, 2022
e6eec09
fix sendAmount header moving (#532)
acharb Jun 16, 2022
2f2eaaa
Demonic Vulnerability Part 1 (#537)
piyalbasu Jun 27, 2022
ae3d18e
Merge master 2.3.0 (#552)
piyalbasu Jun 30, 2022
e1d1cd4
Just use 12 word phrases for now and cleanup UI (#553)
piyalbasu Jul 1, 2022
05361ae
Feature/ledger (#557)
acharb Jul 11, 2022
6ad62df
Feature/localization (#558)
piyalbasu Jul 11, 2022
b7fd74f
Bump jsdom from 16.4.0 to 16.5.0 (#541)
dependabot[bot] Jul 11, 2022
d1f422a
Bump eventsource from 1.0.7 to 1.1.1 (#518)
dependabot[bot] Jul 11, 2022
5ee9d05
Bump async from 2.6.3 to 2.6.4 (#462)
dependabot[bot] Jul 11, 2022
f7d868d
Bump minimist from 1.2.5 to 1.2.6 (#461)
dependabot[bot] Jul 11, 2022
fc6e84e
Bump axios from 0.21.1 to 0.21.4 (#460)
dependabot[bot] Jul 11, 2022
7e4533e
Bump urijs from 1.19.2 to 1.19.11 (#459)
dependabot[bot] Jul 11, 2022
267ad34
Bump algoliasearch-helper from 3.2.2 to 3.7.0 (#350)
dependabot[bot] Jul 11, 2022
dec3378
Bump shelljs from 0.8.4 to 0.8.5 (#349)
dependabot[bot] Jul 11, 2022
f0cfc72
Merge branch 'master' into release/2.3.0
piyalbasu Jul 11, 2022
49d9f00
fix validation issues; fix typo; rm Add Asset btn (#559)
piyalbasu Jul 13, 2022
0468093
Feature/wal 264 about links (#560)
piyalbasu Jul 13, 2022
0a0fdb9
Add Action to to auto run translations job on PR/push (#563)
piyalbasu Jul 13, 2022
7985ec8
add workflow to release branch (#566)
piyalbasu Jul 13, 2022
a54af1b
Bump async from 2.6.3 to 2.6.4 (#564)
dependabot[bot] Jul 13, 2022
03b103f
fix on statement
piyalbasu Jul 13, 2022
3948e60
fix on statement
piyalbasu Jul 13, 2022
2ba01ef
change on param
piyalbasu Jul 13, 2022
0f19172
change on param
piyalbasu Jul 13, 2022
559171d
yarn before build
piyalbasu Jul 13, 2022
026e727
yarn before build
piyalbasu Jul 13, 2022
bb50583
build freighter-api
piyalbasu Jul 13, 2022
f2aa44e
build freighter-api
piyalbasu Jul 13, 2022
98a5251
try head_ref branch
piyalbasu Jul 14, 2022
053ae3b
try head_ref
piyalbasu Jul 14, 2022
08c7e9d
moving ledger connect to own move, some refactoring to confirmPasswor…
acharb Jul 14, 2022
b000b83
sign external app transactions with hardware wallet (#573)
acharb Jul 15, 2022
97bdc14
add a check diff step
piyalbasu Jul 15, 2022
059c7cb
add check diff
piyalbasu Jul 15, 2022
14eb713
fix spacing
piyalbasu Jul 15, 2022
a60c233
fix spacing
piyalbasu Jul 15, 2022
1e05377
Merge a60c233b5f5dfbbb05e60f0eccf3edcbcf4d050c into 14eb71366979d4b8e…
piyalbasu Jul 15, 2022
d0514f1
add id
piyalbasu Jul 15, 2022
121a3b4
add id
piyalbasu Jul 15, 2022
999b810
Merge 121a3b4209ca30f73c451910a717eecca4ba39f3 into d0514f1dff1f8ec34…
piyalbasu Jul 15, 2022
54f9212
tx fee in xlm (#575)
acharb Jul 18, 2022
5fa0218
Merge 54f9212ad9cdcfe3096f6678b317dd9ac9abfa58 into d0514f1dff1f8ec34…
piyalbasu Jul 18, 2022
674a587
error message updates (#577)
piyalbasu Jul 20, 2022
c5f8448
Merge 674a5876d0472a95a77a10cdaaf6df6c4a8d9e3b into d0514f1dff1f8ec34…
piyalbasu Jul 20, 2022
e96ee7a
handle rejected ledger transaction (#578)
acharb Jul 20, 2022
bfb0390
Merge e96ee7ab1602278fb131cff5ee9db8b10c37bd21 into d0514f1dff1f8ec34…
piyalbasu Jul 20, 2022
9e827d7
return bipPath from confirmPassword (#579)
acharb Jul 20, 2022
3055a6e
Merge 9e827d7e428a817ed5417cb667ebe1f91e7621f2 into d0514f1dff1f8ec34…
piyalbasu Jul 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/buildTranslations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build translations

on:
pull_request:
paths:
- "extension/**/*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
- name: Run translation job
run: |
yarn && yarn build:freighter-api && yarn build:extension:translations
- name: Verify diff
id: verify_diff
run: |
git diff --quiet || echo "::set-output name=new_translations_exist::true"
- name: Commit files
if: steps.verify_diff.outputs.new_translations_exist == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Add translations" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
65 changes: 60 additions & 5 deletions @shared/api/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { MAINNET_NETWORK_DETAILS, NetworkDetails } from "../helpers/stellar";
import { SERVICE_TYPES } from "../constants/services";
import { APPLICATION_STATE } from "../constants/applicationState";
import { WalletType } from "../constants/hardwareWallet";
import { sendMessageToBackground } from "./helpers/extensionMessaging";
import { getIconUrlFromIssuer } from "./helpers/getIconUrlFromIssuer";

Expand Down Expand Up @@ -115,9 +116,41 @@ export const importAccount = async (
return { allAccounts, publicKey, hasPrivateKey };
};

export const importHardwareWallet = async (
publicKey: string,
hardwareWalletType: WalletType,
bipPath: string,
) => {
let _publicKey = "";
let allAccounts = [] as Array<Account>;
let hasPrivateKey = false;
let _bipPath = "";
try {
({
publicKey: _publicKey,
allAccounts,
hasPrivateKey,
bipPath: _bipPath,
} = await sendMessageToBackground({
publicKey,
hardwareWalletType,
bipPath,
type: SERVICE_TYPES.IMPORT_HARDWARE_WALLET,
}));
} catch (e) {
console.log({ e });
}
return {
allAccounts,
publicKey: _publicKey,
hasPrivateKey,
bipPath: _bipPath,
};
};

export const makeAccountActive = (
publicKey: string,
): Promise<{ publicKey: string; hasPrivateKey: boolean }> =>
): Promise<{ publicKey: string; hasPrivateKey: boolean; bipPath: string }> =>
sendMessageToBackground({
publicKey,
type: SERVICE_TYPES.MAKE_ACCOUNT_ACTIVE,
Expand All @@ -136,6 +169,7 @@ export const loadAccount = (): Promise<{
publicKey: string;
applicationState: APPLICATION_STATE;
allAccounts: Array<Account>;
bipPath: string;
}> =>
sendMessageToBackground({
type: SERVICE_TYPES.LOAD_ACCOUNT,
Expand Down Expand Up @@ -210,12 +244,14 @@ export const confirmPassword = async (
hasPrivateKey: boolean;
applicationState: APPLICATION_STATE;
allAccounts: Array<Account>;
bipPath: string;
}> => {
let response = {
publicKey: "",
hasPrivateKey: false,
applicationState: APPLICATION_STATE.MNEMONIC_PHRASE_CONFIRMED,
allAccounts: [] as Array<Account>,
bipPath: "",
};
try {
response = await sendMessageToBackground({
Expand Down Expand Up @@ -376,6 +412,21 @@ export const grantAccess = async (url: string): Promise<void> => {
}
};

export const handleSignedHwTransaction = async ({
signedTransaction,
}: {
signedTransaction: string;
}): Promise<void> => {
try {
await sendMessageToBackground({
signedTransaction,
type: SERVICE_TYPES.HANDLE_SIGNED_HW_TRANSACTION,
});
} catch (e) {
console.error(e);
}
};

export const signTransaction = async ({
transaction,
}: {
Expand Down Expand Up @@ -413,13 +464,17 @@ export const signFreighterTransaction = async ({

export const submitFreighterTransaction = async ({
signedXDR,
networkUrl,
networkDetails,
}: {
signedXDR: string;
networkUrl: string;
networkDetails: NetworkDetails;
}) => {
const server = new StellarSdk.Server(networkUrl);
return await server.submitTransaction(signedXDR);
const tx = StellarSdk.TransactionBuilder.fromXDR(
signedXDR,
networkDetails.networkPassphrase,
);
const server = new StellarSdk.Server(networkDetails.networkUrl);
return await server.submitTransaction(tx);
};

export const addRecentAddress = async ({
Expand Down
4 changes: 4 additions & 0 deletions @shared/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Types } from "@stellar/wallet-sdk";

import { SERVICE_TYPES, EXTERNAL_SERVICE_TYPES } from "../constants/services";
import { APPLICATION_STATE } from "../constants/applicationState";
import { WalletType } from "../constants/hardwareWallet";
import { NetworkDetails } from "../helpers/stellar";

export interface Response {
Expand Down Expand Up @@ -38,6 +39,8 @@ export interface Response {
iconUrl: string;
network: string;
recentAddresses: Array<string>;
hardwareWalletType: WalletType;
bipPath: string;
}

export interface ExternalRequest {
Expand All @@ -51,6 +54,7 @@ export interface Account {
publicKey: string;
name: string;
imported: boolean;
hardwareWalletType?: WalletType;
}

export interface Settings {
Expand Down
4 changes: 4 additions & 0 deletions @shared/constants/hardwareWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum WalletType {
LEDGER = "Ledger",
NONE = "",
}
2 changes: 2 additions & 0 deletions @shared/constants/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export enum SERVICE_TYPES {
FUND_ACCOUNT = "FUND_ACCOUNT",
ADD_ACCOUNT = "ADD_ACCOUNT",
IMPORT_ACCOUNT = "IMPORT_ACCOUNT",
IMPORT_HARDWARE_WALLET = "IMPORT_HARDWARE_WALLET",
LOAD_ACCOUNT = "LOAD_ACCOUNT",
MAKE_ACCOUNT_ACTIVE = "MAKE_ACCOUNT_ACTIVE",
UPDATE_ACCOUNT_NAME = "UPDATE_ACCOUNT_NAME",
Expand All @@ -13,6 +14,7 @@ export enum SERVICE_TYPES {
REJECT_ACCESS = "REJECT_ACCESS",
GRANT_ACCESS = "GRANT_ACCESS",
SIGN_TRANSACTION = "SIGN_TRANSACTION",
HANDLE_SIGNED_HW_TRANSACTION = "HANDLE_SIGNED_HW_TRANSACTION",
REJECT_TRANSACTION = "REJECT_TRANSACTION",
SIGN_FREIGHTER_TRANSACTION = "SIGN_FREIGHTER_TRANSACTION",
ADD_RECENT_ADDRESS = "ADD_RECENT_ADDRESS",
Expand Down
41 changes: 41 additions & 0 deletions extension/LOCALIZATION.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Freighter Localization

## How It Works

We're using the library `react-i18next` to translate strings for us. At runtime,
the app will detect the user's language preference from their browser settings
and translate all strings that have been wrapped in the `t` function the
`useTranslation` hook provides.

Using the selected language, it will find the corresponding json file in
`locales`. If the language is not found, it will fallback to the `en` json file.
The string that is passed to `t` acts a key in this json file. The corresponding
value is the translated string in that locale's language.

Using the english version of the string as a key in the json file allows us to
easily grep through our codebase to find specific components. For example, if
I'm looking for a button that says `Add Asset`, I can still just search for that
string to find where this component lives in this codebase. The alternative
would be to use a key called `AddAssetCopy`, that would map to the translated
string in the given language. While that works, it adds an unnecessary layer of
abstraction. In addition, this allows community members to run through a
language json file and simply translate the all the keys listed in the json.

## How To Build

As you maye have surmised, every time you add new copy, you will need to wrap
the string in `t` AND add a key/value pair for it in EVERY language json file.
This is annoying and time consuming. There is a build command you run that will
statically run through the codebase, find all `t` function calls, and add a
corresponding key/value pair to the needed json files. It will default to adding
the english language version as the value so as to not show an empty string if
the translation hasn't been done yet.

These default translations can be generated by running:
`yarn build:translations`

## How To Test Translations

1. Go into your browser settings and change your language preference.
2. `react-i18next` also saves the preferred language in the UI's localStorage.
Clear this value and refresh your dev page or reopen the popup.
13 changes: 0 additions & 13 deletions extension/package-lock.json

This file was deleted.

10 changes: 9 additions & 1 deletion extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"build": "webpack --config webpack.extension.js",
"build:experimental": "yarn build --env.EXPERIMENTAL=true",
"build:production": "yarn build --env.PRODUCTION",
"build:translations": "yarn build --env.TRANSLATIONS=true",
"start": "webpack-dev-server --config webpack.dev.js",
"start:experimental": "yarn start --env.EXPERIMENTAL=true",
"start:unpacked-extension": "yarn build --watch --info-verbosity verbose"
},
"dependencies": {
"@ledgerhq/hw-app-str": "^6.27.1",
"@ledgerhq/hw-transport-webusb": "^6.27.1",
"@reduxjs/toolkit": "^1.5.0",
"@sentry/browser": "^6.0.0",
"@sentry/tracing": "^6.0.0",
Expand Down Expand Up @@ -44,6 +47,10 @@
"history": "^4",
"html-loader": "^1.0.0",
"html-webpack-plugin": "^4.0.1",
"i18next": "^21.8.13",
"i18next-browser-languagedetector": "^6.1.4",
"i18next-resources-to-backend": "^1.0.0",
"i18next-scanner-webpack": "^0.9.1",
"lodash": "^4.17.15",
"mini-css-extract-plugin": "^1.6.2",
"prettier": "^2.0.5",
Expand All @@ -54,6 +61,7 @@
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.18.0",
"react-redux": "^7.2.6",
"react-router-dom": "^5.3.0",
"redux": "^4.0.5",
Expand All @@ -69,4 +77,4 @@
"webextension-polyfill-ts": "^0.19.0",
"yup": "^0.29.1"
}
}
}
14 changes: 4 additions & 10 deletions extension/public/static/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@
}
},
"background": {
"scripts": [
"background.min.js"
],
"scripts": ["background.min.js"],
"persistent": true
},
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"js": [
"contentScript.min.js"
],
"matches": ["<all_urls>"],
"js": ["contentScript.min.js"],
"run_at": "document_start"
}
],
Expand All @@ -42,4 +36,4 @@
"128": "images/icon128.png"
},
"manifest_version": 2
}
}
9 changes: 6 additions & 3 deletions extension/src/background/ducks/session.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createSelector, createSlice } from "@reduxjs/toolkit";

import { Account } from "@shared/api/types";
import { getIsHardwareWalletActive } from "background/helpers/account";

const initialState = {
publicKey: "",
Expand All @@ -23,6 +24,7 @@ export const sessionSlice = createSlice({
name: "session",
initialState,
reducers: {
reset: () => initialState,
logIn: (state, action: { payload: UiData }) => {
const {
publicKey,
Expand All @@ -38,7 +40,7 @@ export const sessionSlice = createSlice({
};
},
logOut: () => initialState,
grantAccountAccess: (state, action: { payload: AppData }) => {
setActivePrivateKey: (state, action: { payload: AppData }) => {
const { privateKey } = action.payload;

return {
Expand Down Expand Up @@ -87,9 +89,10 @@ export const sessionSelector = (state: { session: UiData & AppData }) =>

export const {
actions: {
reset,
logIn,
logOut,
grantAccountAccess,
setActivePrivateKey,
setActivePublicKey,
timeoutAccountAccess,
updateAllAccountsAccountName,
Expand All @@ -110,7 +113,7 @@ export const allAccountsSelector = createSelector(
);
export const hasPrivateKeySelector = createSelector(
sessionSelector,
(session) => !!session.privateKey.length,
(session) => getIsHardwareWalletActive() || !!session.privateKey.length,
);
export const privateKeySelector = createSelector(
sessionSelector,
Expand Down
13 changes: 13 additions & 0 deletions extension/src/background/helpers/account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ACCOUNT_NAME_LIST_ID,
KEY_ID_LIST,
KEY_ID,
IS_TESTNET_ID,
IS_VALIDATING_MEMO_ID,
IS_VALIDATING_SAFETY_ID,
Expand Down Expand Up @@ -41,3 +42,15 @@ export const getIsMemoValidationEnabled = () =>

export const getIsSafetyValidationEnabled = () =>
JSON.parse(localStorage.getItem(IS_VALIDATING_SAFETY_ID) || "true");

// hardware wallet helpers
export const HW_PREFIX = "hw:";

export const getIsHardwareWalletActive = () =>
(localStorage.getItem(KEY_ID) || "").indexOf(HW_PREFIX) > -1;

export const getBipPath = () => {
const keyId = localStorage.getItem(KEY_ID) || "";
const hwData = JSON.parse(localStorage.getItem(keyId) || "{}");
return hwData.bipPath || "";
};
Loading