Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mv3 migration build updates #594

Merged
merged 27 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d434669
chore: wip - build updates
lucaslovato Jun 27, 2024
a01c220
chore: improve webpack files readability
lucaslovato Jun 28, 2024
d02c9db
revert commit, adjust package
lucaslovato Jul 8, 2024
970bbdb
chore: migrate accounts from mv2 to mv3 state
vieiraricardo Aug 1, 2024
fc307d6
Merge branch 'feat/mv3-migration' into mv3-migration-build-updates
lucaslovato Aug 1, 2024
3648033
Merge branch 'mv3-migration-build-updates' into feat/mv3-account-migr…
lucaslovato Aug 1, 2024
35fff4b
chore: change structure to test migration behavior
lucasgabrielgsp Aug 2, 2024
98fbb84
chore: injects MV2 state
vieiraricardo Aug 2, 2024
dfea9b2
chore: increase main yml node v
lucaslovato Aug 5, 2024
23b67ed
chore: avoid lint errors
lucaslovato Aug 5, 2024
539a46d
Merge branch 'mv3-migration-build-updates' into feat/mv3-account-migr…
lucaslovato Aug 5, 2024
d5435a2
chore: move wallet state migration code into a function
vieiraricardo Aug 6, 2024
cd703b8
Merge branch 'feat/mv3-migration' into mv3-migration-build-updates
lucaslovato Aug 9, 2024
88e28b1
chore: initial changes to share background controller state using events
vieiraricardo Aug 13, 2024
ab3d727
chore: change getController to controllerEmitter
vieiraricardo Aug 21, 2024
0196fdc
fix: signing messages and dapps connection
vieiraricardo Aug 22, 2024
6f0f67d
feat: add support for trezor in pali mv3
lucasgabrielgsp Aug 22, 2024
40b07d1
Merge pull request #611 from syscoin/feat/trezor-mv3
lucasgabrielgsp Aug 26, 2024
78c72a1
chore: update .env.example
lucasgabrielgsp Aug 26, 2024
e80ef50
fix: issues sending transactions
vieiraricardo Aug 27, 2024
4e1f8a7
chore: remove unused vars
vieiraricardo Aug 28, 2024
5500b8d
fix: solve bug in SwitchNetworkUtxoEvm page and fix event emission issue
lucasgabrielgsp Aug 28, 2024
d29f214
chore: increase UTXO polling value
lucasgabrielgsp Aug 29, 2024
6d1bc9d
Merge pull request #609 from syscoin/feat/background-controller-state…
lucasgabrielgsp Aug 29, 2024
e4e8985
chore: resolve conflicts
lucasgabrielgsp Aug 29, 2024
219cb86
Merge pull request #607 from syscoin/feat/mv3-account-migration
lucasgabrielgsp Aug 29, 2024
d079001
chore: resolve conflicts
lucasgabrielgsp Aug 29, 2024
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# MANIFEST_TYPE values: MV2 or MV3
MANIFEST_TYPE=MV3
MANIFEST_TYPE=MV3
NODE_ENV=development
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
check-latest: true
- run: yarn install
- run: yarn test-all
Expand All @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
check-latest: true
- run: yarn install
- run: |
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
},
"scripts": {
"generate-manifest": "node ./source/config/generateManifest.js",
"dev:chrome": "yarn generate-manifest && jq 'del(.environment) | .permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --watch",
"dev:chrome": "yarn generate-manifest && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack.dev.js --watch",
"build:chrome": "yarn generate-manifest && cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack.prod.js",
"dev-watch-requests:chrome": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end | .environment = {\"WATCH_REQUESTS\": \"active\"}' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --watch",
"dev:firefox": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=firefox webpack --watch",
"dev:opera": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=opera webpack --watch",
"build:chrome": "jq '.permissions = if .permissions then (.permissions | map(select(. != \"webRequest\"))) else .permissions end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack",
"build:firefox": "jq '.permissions = if .permissions then (.permissions | map(select(. != \"webRequest\"))) else .permissions end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=production cross-env TARGET_BROWSER=firefox webpack",
"build:opera": "jq '.permissions = if .permissions then (.permissions | map(select(. != \"webRequest\"))) else .permissions end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=production cross-env TARGET_BROWSER=opera webpack",
"build": "yarn run build:chrome && yarn run build:firefox && yarn run build:opera",
Expand Down Expand Up @@ -170,10 +170,12 @@
"ts-jest": "^27.1.3",
"typescript": "4.1.5",
"webpack": "^5.82.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.0.2",
"webpack-dev-server": "^4.13.3",
"webpack-merge": "^5.10.0",
"wext-manifest-loader": "^3.0.0",
"wext-manifest-webpack-plugin": "^1.2.1"
"wext-manifest-webpack-plugin": "^1.4.1"
},
"main": "index.js",
"bugs": {
Expand Down
21 changes: 0 additions & 21 deletions patches/webextension-polyfill+0.8.0.patch

This file was deleted.

This file was deleted.

139 changes: 0 additions & 139 deletions patches/wext-manifest-webpack-plugin+1.2.1.patch

This file was deleted.

35 changes: 27 additions & 8 deletions source/components/Header/AccountHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
DefaultModal,
} from 'components/index';
import { useUtils } from 'hooks/index';
import { getController } from 'scripts/Background';
import { useController } from 'hooks/useController';
import { RootState } from 'state/store';
import { ellipsis } from 'utils/index';

Expand Down Expand Up @@ -288,7 +288,7 @@ const RenderAccountsListByBitcoinBased = (

export const AccountMenu: React.FC = () => {
const { navigate } = useUtils();
const { wallet, dapp } = getController();
const { controllerEmitter } = useController();
const isBitcoinBased = useSelector(
(state: RootState) => state.vault.isBitcoinBased
);
Expand All @@ -301,11 +301,20 @@ export const AccountMenu: React.FC = () => {
currentWindow: true,
});
const host = new URL(tabs[0].url).hostname;
const connectedAccount = dapp.getAccount(host);
wallet.setAccount(Number(id), type, host, connectedAccount);

await controllerEmitter(['dapp', 'getAccount'], [host]).then(
async (res) => {
await controllerEmitter(
['wallet', 'setAccount'],
[Number(id), type, host, res]
);
}
);

return;
}
wallet.setAccount(Number(id), type);

await controllerEmitter(['wallet', 'setAccount'], [Number(id), type]);
};

const cursorType = isBitcoinBased ? 'cursor-not-allowed' : 'cursor-pointer';
Expand Down Expand Up @@ -409,7 +418,7 @@ export const AccountHeader: React.FC = () => {
const [isLoading, setIsLoading] = useState(false);
const [isOpenModal, setIsOpenModal] = useState(false);
const [isReconectModalOpen, setIsReconectModalOpen] = useState(false);
const controller = getController();
const { controllerEmitter } = useController();
const isLedger = activeAccount.type === KeyringAccountType.Ledger;
const url = chrome.runtime.getURL('app.html');

Expand Down Expand Up @@ -443,25 +452,35 @@ export const AccountHeader: React.FC = () => {
const handleVerifyAddress = async () => {
try {
setIsLoading(true);
await controller.wallet.ledgerSigner.utxo.verifyUtxoAddress(
activeAccount.id

await controllerEmitter(
['wallet', 'ledgerSigner', 'utxo', 'verifyUtxoAddress'],
[activeAccount.id]
);

setIsLoading(false);

setIsOpenModal(false);

alert.success(t('home.addressVerified'));
} catch (error) {
const isNecessaryReconnect = error.message.includes(
'read properties of undefined'
);

if (isNecessaryReconnect) {
setIsReconectModalOpen(true);
return;
}

const wasDeniedByUser = error?.message?.includes('denied by the user');

if (wasDeniedByUser) {
alert.error(t('home.verificationDeniedByUser'));
}

setIsOpenModal(false);

setIsLoading(false);
}
};
Expand Down
28 changes: 19 additions & 9 deletions source/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSelector } from 'react-redux';
import { INetwork } from '@pollum-io/sysweb3-network';

import { ErrorModal, Icon, Modal, PrimaryButton, SecondaryButton } from '..';
import { getController } from 'scripts/Background';
import { useController } from 'hooks/useController';
import { RootState } from 'state/store';

import { AccountHeader } from '.';
Expand All @@ -18,7 +18,7 @@ interface IHeader {
}

export const Header: React.FC<IHeader> = ({ accountHeader = false }) => {
const { wallet, dapp } = getController();
const { controllerEmitter } = useController();
const { t } = useTranslation();
const error = useSelector((state: RootState) => state.vault.error);

Expand Down Expand Up @@ -54,18 +54,26 @@ export const Header: React.FC<IHeader> = ({ accountHeader = false }) => {
title: t('header.errorSwitching'),
});

wallet.resolveError();
controllerEmitter(['wallet', 'resolveError']);
}
}, [error]);

const hanldeDisconnectFromDapp = () => {
dapp.disconnect(host);
wallet.resolveAccountConflict();
controllerEmitter(['dapp', 'disconnect'], [host]);
controllerEmitter(['wallet', 'resolveAccountConflict']);
};
const handleChangeConnectedAccount = () => {
dapp.changeAccount(host, newConnectedAccount.id, connectedAccountType);
wallet.setAccount(newConnectedAccount.id, connectedAccountType);
wallet.resolveAccountConflict();
controllerEmitter(
['dapp', 'changeAccount'],
[host, newConnectedAccount.id, connectedAccountType]
);

controllerEmitter(
['wallet', 'setAccount'],
[newConnectedAccount.id, connectedAccountType]
);

controllerEmitter(['wallet', 'resolveAccountConflict']);
};

return (
Expand Down Expand Up @@ -100,7 +108,9 @@ export const Header: React.FC<IHeader> = ({ accountHeader = false }) => {

<Modal
show={isChangingConnectedAccount}
onClose={() => wallet.resolveAccountConflict()}
onClose={() =>
controllerEmitter(['wallet', 'resolveAccountConflict'])
}
>
<div className="inline-block align-middle my-8 p-6 w-full max-w-2xl text-center font-poppins bg-bkg-4 border border-brand-royalblue rounded-2xl shadow-xl overflow-hidden transform transition-all">
<Dialog.Title
Expand Down
Loading
Loading