Skip to content

Commit

Permalink
Merge branch 'main' into refactor/9083-logger-class
Browse files Browse the repository at this point in the history
  • Loading branch information
Cal-L authored Apr 18, 2024
2 parents d3fa3b2 + a9eef46 commit 687807e
Show file tree
Hide file tree
Showing 27 changed files with 319 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/guidelines/LABELING_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Every PR shall include one the QA labels below:
Once PR has been tested by QA (only if the PR was labeled with `needs-qa`):
- **QA Passed**: If the PR was labeled with `needs-qa`, this label must be added once QA has signed off

### Optional labels:
- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on development branch (i.e. `main`), but is not yet released in production.

### Labels prohibited when PR needs to be merged:
Any PR that includes one of the following labels can not be merged:

Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/crowdin-branch-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Crowdin - Branch and Label Cleanup for merged localization PR
# This action should delete the branch from Crowdin after the localization PR is
# merged to the original branch. It should also remove the "ready-for-translation" label

# TODO: Add trigger for merge of localization PR.
on: workflow_dispatch

jobs:
prestep:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.extract_current_branch.outputs.branch }}
pr: ${{ steps.get-prs.outputs.pr }}
steps:
- name: Extract current branch name
shell: bash
run: |
echo "running on branch ${GITHUB_REF##*/}"
echo "other version: ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
id: extract_current_branch

- name: Get PR with Label for this branch
id: get-prs
run: |
LABEL="ready-for-translation"
API_URL="https://api.github.com/repos/Metamask/crowdin-sandbox/pulls?head:${{steps.extract_current_branch.outputs.branch}}&state=open&per_page=100"
# Fetch the list of open pull requests with the specified label using curl
PRS=$(curl -sS --header "Authorization: Bearer $GITHUB_TOKEN" "$API_URL")
PR=$(echo "$PRS" | jq -r '.[] | select(.labels[].name == "'"$LABEL"'") | .number | @json')
echo "Found PR: $PR"
echo "pr=$PR" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURRENT_BRANCH: ${{ steps.extract_current_branch.outputs.branch }}

github_cleanup:
runs-on: ubuntu-latest
needs: prestep
steps:
- name: Remove label from PR
uses: actions/github-script@v3
if: needs.prestep.outputs.pr != null || needs.prestep.outputs.pr != ''
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const label = "ready-for-translation";
await github.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ needs.prestep.outputs.pr }},
name: label
});
crowdin_cleanup:
runs-on: ubuntu-latest
needs: prestep
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.prestep.outputs.branch }}

- name: Delete branch within Crowdin
if: needs.prestep.outputs.branch != 'main'
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
command: branch delete ${{ needs.prestep.outputs.branch }}
command_args: -v
50 changes: 50 additions & 0 deletions .github/workflows/crowdin-branch-pr-ready-for-translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Crowdin - Ready for translations label added, push to crowdin

# When an individual is working on a feature which requires translations, they can
# add a label "ready-for-translation" which will trigger this action to push the
# source and translation files to Crowdin. We will always push main as the base of
# the crowdin branch creation and then push in the changes over the top. This ensures
# that the translations which have already been done and approved previously do not
# show as needing to be translated again in the crowdin branch.

# TODO: switch to trigger on label add once testing complete
on: workflow_dispatch

jobs:
crowdin-upload:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

steps:
- name: Extract current branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
id: extract_current_branch

- name: Checkout
uses: actions/checkout@v3
with:
ref: main

- name: Crowdin push main as baseline
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }}
upload_sources: true
upload_translations_args: --import-eq-suggestions --auto-approve-imported --verbose
upload_translations: true

- name: Checkout Branch and push to crowdin
uses: actions/checkout@v3
with:
ref: ${{ steps.extract_current_branch.outputs.branch }}
- name: Crowdin sources push
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }}
upload_sources: true
upload_sources_args: --auto-update --verbose
upload_translations: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Crowdin - Find all branches with translations and trigger completion checks
# This workflow will run on a schedule. It will pull all pull requests with a label of
# ready-for-translation and create a matrix of the associated branches to run the
# crowdin-reusable-translation-download.yml workflow on.
# That workflow will check the status of the translations and if complete create a pull
# request with the translations off of the branch.

permissions:
contents: write
pull-requests: write

# TODO: Add a schedule to run this workflow twice a day(?) once the testing is complete
on: workflow_dispatch

jobs:
run-check-and-download-for-branch:
needs: get-branches
if: ${{ needs.get-branches.outputs.matrix != '[]' && needs.get-branches.outputs.matrix != '' }}
strategy:
fail-fast: false
matrix:
branch: ${{fromJson(needs.get-branches.outputs.matrix)}}
uses: ./.github/workflows/crowdin-reusable-translation-download.yml
with:
branch: ${{ matrix.branch }}
secrets:
gh_token: ${{ secrets.GITHUB_TOKEN }}
crowdin_personal_token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
crowdin_project_id: ${{ secrets.CROWDIN_PROJECT_ID }}

get-branches:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix-outputs.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get Branches with Label
id: get-branches
run: |
GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}"
LABEL="ready-for-translation"
API_URL="https://api.github.com/repos/Metamask/crowdin-sandbox/pulls?state=open&per_page=100"
# Fetch the list of open pull requests with the specified label using curl
PRS=$(curl -sS --header "Authorization: Bearer $GITHUB_TOKEN" "$API_URL")
BRANCHES=$(echo "$PRS" | jq -r '[.[] | select(.labels[].name == "'"$LABEL"'") | .head.ref] | @json')
echo "Found branches: $BRANCHES"
echo "branches=$BRANCHES" >> "$GITHUB_OUTPUT"
- name: Set up matrix
id: matrix-outputs
run: |
# Parse the branches output and create a matrix
BRANCHES="${{ toJson(steps.get-branches.outputs.branches) }}"
echo "Creating matrix from branches..."
MATRIX="${BRANCHES}"
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
64 changes: 64 additions & 0 deletions .github/workflows/crowdin-reusable-translation-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Crowdin - Check translation progress and download if complete (unless main)
# This is a reusable workflow that is called by crowdin-pull-branch-pr-completed-translations
# across all branches which have a label of "ready-for-translation" aka being translated.
# This workflow will check the translation progress and download the translations if
# they are 100% translated. If the branch that is running this is main it will skip completion
# check and just pull whatever translations are available.


permissions:
contents: write
pull-requests: write

on:
workflow_call:
inputs:
branch:
required: true
type: string
secrets:
gh_token:
required: true
crowdin_project_id:
required: true
crowdin_personal_token:
required: true

jobs:
crowdin:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.gh_token }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.crowdin_personal_token }}
CROWDIN_PROJECT_ID: ${{ secrets.crowdin_project_id }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}

- name: Check translation progress
# when main just pull whatever you have (aka skip this) - need to test
if: ${{ inputs.branch != 'main' }}
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
command: 'status translation'
command_args: '-b ${{ inputs.branch }} --fail-if-incomplete'

- name: Synchronize with Crowdin
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
crowdin_branch_name: ${{ inputs.branch }}
upload_sources: false
upload_translations: false
download_translations: true
skip_untranslated_strings: true
export_only_approved: true
localization_branch_name: l10n_crowdin_translations_${{ inputs.branch }}

create_pull_request: true
skip_ref_checkout: true
pull_request_title: New Crowdin translations for ${{ inputs.branch }}
pull_request_body: New Crowdin pull request with translations for ${{ inputs.branch }}
pull_request_base_branch_name: ${{ inputs.branch }}
31 changes: 31 additions & 0 deletions .github/workflows/crowdin-upload-both-sources-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Crowdin - Upload Both Sources and Translations Crowdin Action
# This action is intended to ensure our main branch on crowdin is in sync with our
# main branch on github and will run on every push to main that has changes to any
# locales files.

# TODO: Change to trigger on merge to main when locales files are changed (after testing)
# This should replace the current crowdin_action.yml file (after testing)
on: workflow_dispatch

jobs:
crowdin-upload:
runs-on: ubuntu-latest
steps:
- name: Extract current branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_OUTPUT"
id: extract_current_branch
- name: Checkout
uses: actions/checkout@v3

- name: Crowdin push
uses: crowdin/github-action@c953b17499daa6be3e5afbf7a63616fb02d8b18d
with:
crowdin_branch_name: ${{ steps.extract_current_branch.outputs.branch }}
upload_sources: true
upload_translations: true
upload_translations_args: --import-eq-suggestions --verbose
download_translations: false
env:
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
4 changes: 2 additions & 2 deletions app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,9 @@ function SwapsQuotesView({
};
if (isHardwareAddress) {
TransactionController.hub.once(
`${transactionMeta.id}:finished`,
`${transactionMeta.id}:confirmed`,
(transactionMeta) => {
if (transactionMeta.status === TransactionStatus.submitted) {
if (transactionMeta.status === TransactionStatus.confirmed) {
handleSwapTransaction(
TransactionController,
newSwapsTransactions,
Expand Down
11 changes: 10 additions & 1 deletion app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ const AccountConnect = (props: AccountConnectProps) => {
);

const loadHostname = useCallback(async () => {
// walletconnect channelId format: 1713357238460272
// sdk channelId format: uuid
// inappbrowser channelId format: app.uniswap.io

// check if channelId contains dot, it comes from in-app browser and we can use it.
if (channelId.indexOf('.') !== -1) {
return origin;
}

if (sdkConnection) {
const _hostname = (
sdkConnection?.originatorInfo?.url ?? metadataOrigin
Expand All @@ -180,7 +189,7 @@ const AccountConnect = (props: AccountConnectProps) => {
}

return wc2Metadata?.url ?? channelId;
}, [channelId, metadataOrigin, sdkConnection, wc2Metadata]);
}, [channelId, metadataOrigin, sdkConnection, origin, wc2Metadata]);

// Retrieve hostname info based on channelId
useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ exports[`SecuritySettings should render correctly 1`] = `
}
}
>
Privacy preserving - no data is shared with third parties. Available on Arbitrum, Avalanche, BNB chain, Ethereum Mainnet, Optimism, Polygon and Sepolia.
Privacy preserving - no data is shared with third parties. Available on Arbitrum, Avalanche, BNB chain, Ethereum Mainnet, Optimism, Polygon, Sepolia and Base.
</Text>
<View
style={
Expand Down
19 changes: 17 additions & 2 deletions app/core/RPCMethods/RPCMethodMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,23 @@ const generateRawSignature = async ({
chainId,
channelId,
getSource,
isWalletConnect,
checkTabActive,
}: any) => {
}: {
version: string;
req: any;
hostname: string;
url: { current: string };
title: { current: string };
icon: { current: string | undefined };
analytics: { [key: string]: string | boolean };
chainId: number;
isMMSDK: boolean;
channelId?: string;
getSource: () => string;
isWalletConnect: boolean;
checkTabActive: any;
}) => {
const { SignatureController } = Engine.context;

const pageMeta = {
Expand All @@ -230,7 +245,7 @@ const generateRawSignature = async ({
channelId,
address: req.params[0],
chainId,
isWalletConnect: false,
isWalletConnect,
});

const rawSig = await SignatureController.newUnsignedTypedMessage(
Expand Down
2 changes: 2 additions & 0 deletions app/util/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const NetworkListKeys = Object.keys(NetworkList);
export const BLOCKAID_SUPPORTED_CHAIN_IDS = [
NETWORKS_CHAIN_ID.MAINNET,
NETWORKS_CHAIN_ID.BSC,
NETWORKS_CHAIN_ID.BASE,
NETWORKS_CHAIN_ID.POLYGON,
NETWORKS_CHAIN_ID.ARBITRUM,
NETWORKS_CHAIN_ID.OPTIMISM,
Expand All @@ -115,6 +116,7 @@ export const BLOCKAID_SUPPORTED_CHAIN_IDS = [
export const BLOCKAID_SUPPORTED_NETWORK_NAMES = {
[NETWORKS_CHAIN_ID.MAINNET]: 'Ethereum Mainnet',
[NETWORKS_CHAIN_ID.BSC]: 'Binance Smart Chain',
[NETWORKS_CHAIN_ID.BASE]: 'Base Mainnet',
[NETWORKS_CHAIN_ID.OPTIMISM]: 'Optimism',
[NETWORKS_CHAIN_ID.POLYGON]: 'Polygon',
[NETWORKS_CHAIN_ID.ARBITRUM]: 'Arbitrum',
Expand Down
1 change: 1 addition & 0 deletions e2e/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import Utilities from './utils/Utilities';
beforeAll(async () => {
device.appLaunchArgs.modify({
detoxURLBlacklistRegex: Utilities.BlacklistURLs,
permissions: { notifications: 'YES' },
});
});
Loading

0 comments on commit 687807e

Please sign in to comment.