Skip to content

Commit

Permalink
feat(9544): clean unused test signing related changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Akaryatrh committed Oct 21, 2024
1 parent 928b8c8 commit 2852ddf
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 70 deletions.
64 changes: 58 additions & 6 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,73 @@ logFilters:
nodeLinker: node-modules

npmAuditIgnoreAdvisories:
### Advisories:

# Issue: yargs-parser Vulnerable to Prototype Pollution
# URL - https://github.com/advisories/GHSA-p9pc-299p-vxgp
# The affected version (<5.0.0) is only included via @ensdomains/ens via
# 'solc' which is not used in the imports we use from this package.
- 1088783

# Issue: protobufjs Prototype Pollution vulnerability
# URL - https://github.com/advisories/GHSA-h755-8qp9-cq85
# Not easily patched. Minimally effects the extension due to usage of
# LavaMoat lockdown. Additional id added that resolves to the same advisory
# but has a different entry due to it being a new dependency of
# @trezor/connect-web. Upgrading
- 1092429
- 1095136

# Issue: Regular Expression Denial of Service (ReDOS)
# URL: https://github.com/advisories/GHSA-257v-vj4p-3w2h
# color-string is listed as a dependency of 'color' which is brought in by
# @metamask/jazzicon v2.0.0 but there is work done on that repository to
# remove the color dependency. We should upgrade
- 1089718

# Issue: semver vulnerable to Regular Expression Denial of Service
# URL: https://github.com/advisories/GHSA-c2qf-rxjj-qqgw
# semver is used in the solidity compiler portion of @truffle/codec that does
# not appear to be used.
- 1092461
- ts-custom-error (deprecation)
- text-encoding (deprecation)
- popper.js (deprecation)
- mini-create-react-context (deprecation)
- uuid (deprecation)

# Temp fix for https://github.com/MetaMask/metamask-extension/pull/16920 for the sake of 11.7.1 hotfix
# This will be removed in this ticket https://github.com/MetaMask/metamask-extension/issues/22299
- 'ts-custom-error (deprecation)'
- 'text-encoding (deprecation)'

### Package Deprecations:

# React-tippy brings in popper.js and react-tippy has not been updated in
# three years.
- 'popper.js (deprecation)'

# React-router is out of date and brings in the following deprecated package
- 'mini-create-react-context (deprecation)'

# The affected version, which is less than 7.0.0, is brought in by
# ethereumjs-wallet version 0.6.5 used in the extension but only in a single
# file app/scripts/account-import-strategies/index.js, which may be easy to
# upgrade.
- 'uuid (deprecation)'

# @npmcli/move-file is brought in via CopyWebpackPlugin used in the storybook
# main.js file, which can be upgraded to remove this dependency in favor of
# @npmcli/fs
- '@npmcli/move-file (deprecation)'
- core-js (deprecation)

# Upgrading babel will result in the following deprecated packages being
# updated:
- 'core-js (deprecation)'

# Material UI dependencies are planned for removal
- '@material-ui/core (deprecation)'
- '@material-ui/styles (deprecation)'
- '@material-ui/system (deprecation)'

# @ensdomains/ens should be explored for upgrade. The following packages are
# deprecated and would be resolved by upgrading to newer versions of
# ensdomains packages:
- '@ensdomains/ens (deprecation)'
- '@ensdomains/resolver (deprecation)'
- 'testrpc (deprecation)'
Expand Down
1 change: 0 additions & 1 deletion app/scripts/lib/metaRPCClientFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class MetaRPCClient {
}

handleResponse(data) {
console.log('==============> data', data);
const { id, result, error, method, params } = data;
const isNotification = id === undefined && error === undefined;
const cb = this.requests.get(id);
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4641,7 +4641,6 @@ export default class MetamaskController extends EventEmitter {
*/
async connectHardware(deviceName, page, hdPath) {
const keyring = await this.getKeyringForDevice(deviceName, hdPath);
console.log('============> keyring', keyring);

if (deviceName === HardwareDeviceNames.ledger) {
await this.setLedgerTransportPreference(keyring);
Expand All @@ -4662,7 +4661,6 @@ export default class MetamaskController extends EventEmitter {
// Merge with existing accounts
// and make sure addresses are not repeated
const oldAccounts = await this.keyringController.getAccounts();
console.log('================> accounts', accounts);

const accountsToTrack = [
...new Set(
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@
"@blockaid/ppom_release": "^1.5.3",
"@ensdomains/content-hash": "^2.5.7",
"@ethereumjs/tx": "^4.1.1",
"@ethereumjs/util": "^9.0.3",
"@ethersproject/abi": "^5.6.4",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
Expand Down Expand Up @@ -764,10 +763,7 @@
"core-js-pure": true,
"resolve-url-loader>es6-iterator>d>es5-ext": false,
"resolve-url-loader>es6-iterator>d>es5-ext>esniff>es5-ext": false,
"level>classic-level": false,
"@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false,
"@lavamoat/allow-scripts>@lavamoat/preinstall-always-fail": false,
"@metamask/notification-services-controller>firebase>@firebase/firestore>@grpc/proto-loader>protobufjs": false
"level>classic-level": false
}
},
"packageManager": "yarn@4.4.1"
Expand Down
28 changes: 14 additions & 14 deletions test/e2e/seeder/ganache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultOptions = {
port: 8545,
vmErrorsOnRPCResponse: false,
hardfork: 'muirGlacier',
verbose: true,
quiet: true,
};

export class Ganache {
Expand All @@ -34,14 +34,24 @@ export class Ganache {
});
}

async getAddressBalance(address: string) {
async getBalance(address = null): Promise<number> {
const provider = await this.getProvider();

if (!provider) {
throw new Error('No provider found');
console.log('No provider found');
return 0;
}

const accountToUse = address || (await this.getAccounts())?.[0];

if (!accountToUse) {
console.log('No accounts found');
return 0;
}

const balanceHex = await provider.request({
method: 'eth_getBalance',
params: [address, 'latest'],
params: [accountToUse, 'latest'],
});
const balanceInt = parseInt(balanceHex, 16) / 10 ** 18;

Expand All @@ -51,16 +61,6 @@ export class Ganache {
return Number(balanceFormatted);
}

async getBalance(accountIndex: number = 0): Promise<number> {
const accounts = await this.getAccounts();

if (!accounts?.[accountIndex]) {
throw new Error('Account not found');
}

return this.getAddressBalance(accounts?.[accountIndex]);
}

async getFiatBalance(): Promise<number> {
const balance = await this.getBalance();
const currencyConversionRate = 1700.0;
Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/hardware-wallets/trezor-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('Trezor Hardware', function () {
async ({ driver }) => {
await unlockWallet(driver);
await connectTrezor(driver);
await driver.delay(100000);

// Check that the first page of accounts is correct
for (const { address, index } of KNOWN_PUBLIC_KEY_ADDRESSES.slice(
Expand Down
33 changes: 0 additions & 33 deletions test/stub/keyring-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,37 +151,4 @@ export class FakeLedgerBridge extends FakeKeyringBridge {
updateTransportMethod() {
return true;
}

// async deviceSignTransaction({ tx }) {
// return ecsign(tx, Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));
// }

async deviceSignTransaction({ tx }) {
// chainId hardcoded for now
const chainId = 1337;
const common = Common.custom({
chain: {
name: 'localhost',
chainId,
networkId: chainId,
},
chainId,
hardfork: 'istanbul',
});

// return Transaction.fromTxData(tx, {
// common,
// }).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));

const txBuffer = Buffer.from(tx, 'hex');
return Transaction.fromSerializedTx(txBuffer, {
common,
}).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));
}

// async deviceSignTypedData(params) {
// console.log('=============> params', params);
// const { tx } = params;
// return ecsign(tx, Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));
// }
}
8 changes: 0 additions & 8 deletions test/stub/keyring-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ export class Common {
chainId() {
return BigInt(this.chain.chainId);
}

isActivatedEIP() {
return true;
}

param() {
return BigInt(0);
}
}

/**
Expand Down

0 comments on commit 2852ddf

Please sign in to comment.