Skip to content

Commit

Permalink
refactor: move accounts constants from helpers to a constants file to…
Browse files Browse the repository at this point in the history
… fix build
  • Loading branch information
ffmcgee725 committed Jan 17, 2025
1 parent dd21d31 commit 73b8c72
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 33 deletions.
4 changes: 4 additions & 0 deletions test/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export const GANACHE_PRIVATE_KEY =
export const DEFAULT_FIXTURE_ACCOUNT =
'0x5CfE73b6021E818B776b421B1c4Db2474086a7e1';

/** Address of the second default account derived from onboarding fixture. */
export const DEFAULT_FIXTURE_ACCOUNT_2 =
'0x09781764c08de8ca82e156bbf156a3ca217c7950';

/* Address of the 4337 entrypoint smart contract. */
export const ENTRYPOINT = '0x18b06605539dc02ecD3f7AB314e38eB7c1dA5c9b';

Expand Down
64 changes: 32 additions & 32 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const {
} = require('@metamask/preferences-controller');
const { mockNetworkStateOld } = require('../stub/networks');
const { CHAIN_IDS } = require('../../shared/constants/network');
const { ACCOUNT_1, ACCOUNT_2 } = require('./helpers');
const { SMART_CONTRACTS } = require('./seeder/smart-contracts');
const {
DAPP_URL,
DAPP_URL_LOCALHOST,
DAPP_ONE_URL,
DEFAULT_FIXTURE_ACCOUNT,
DEFAULT_FIXTURE_ACCOUNT_2,
} = require('./constants');
const {
defaultFixture,
Expand Down Expand Up @@ -359,7 +359,7 @@ class FixtureBuilder {
withNftControllerERC1155() {
return this.withNftController({
allNftContracts: {
[ACCOUNT_1]: {
[DEFAULT_FIXTURE_ACCOUNT]: {
[toHex(1337)]: [
{
address: `__FIXTURE_SUBSTITUTION__CONTRACT${SMART_CONTRACTS.ERC1155}`,
Expand All @@ -368,7 +368,7 @@ class FixtureBuilder {
},
},
allNfts: {
[ACCOUNT_1]: {
[DEFAULT_FIXTURE_ACCOUNT]: {
[toHex(1337)]: [
{
address: `__FIXTURE_SUBSTITUTION__CONTRACT${SMART_CONTRACTS.ERC1155}`,
Expand All @@ -391,7 +391,7 @@ class FixtureBuilder {
withNftControllerERC721() {
return this.withNftController({
allNftContracts: {
[ACCOUNT_1]: {
[DEFAULT_FIXTURE_ACCOUNT]: {
[toHex(1337)]: [
{
address: `__FIXTURE_SUBSTITUTION__CONTRACT${SMART_CONTRACTS.NFTS}`,
Expand All @@ -402,7 +402,7 @@ class FixtureBuilder {
},
},
allNfts: {
[ACCOUNT_1]: {
[DEFAULT_FIXTURE_ACCOUNT]: {
[toHex(1337)]: [
{
address: `__FIXTURE_SUBSTITUTION__CONTRACT${SMART_CONTRACTS.NFTS}`,
Expand Down Expand Up @@ -538,7 +538,7 @@ class FixtureBuilder {
caveats: [
{
type: 'restrictReturnedAccounts',
value: [ACCOUNT_1, ACCOUNT_2],
value: [DEFAULT_FIXTURE_ACCOUNT, DEFAULT_FIXTURE_ACCOUNT_2],
},
],
date: 1664388714636,
Expand All @@ -564,7 +564,7 @@ class FixtureBuilder {
caveats: [
{
type: 'restrictReturnedAccounts',
value: [ACCOUNT_2],
value: [DEFAULT_FIXTURE_ACCOUNT_2],
},
],
date: 1664388714636,
Expand All @@ -588,7 +588,7 @@ class FixtureBuilder {
caveats: [
{
type: 'restrictReturnedAccounts',
value: [ACCOUNT_1],
value: [DEFAULT_FIXTURE_ACCOUNT],
},
],
date: 1664388714636,
Expand All @@ -605,7 +605,7 @@ class FixtureBuilder {
caveats: [
{
type: 'restrictReturnedAccounts',
value: [ACCOUNT_1],
value: [DEFAULT_FIXTURE_ACCOUNT],
},
],
date: 1664388714636,
Expand Down Expand Up @@ -669,8 +669,8 @@ class FixtureBuilder {
lastSelected: 1665507600000,
name: 'Account 1',
},
[ACCOUNT_2]: {
address: ACCOUNT_2,
[DEFAULT_FIXTURE_ACCOUNT_2]: {
address: DEFAULT_FIXTURE_ACCOUNT_2,
lastSelected: 1665507800000,
name: 'Account 2',
},
Expand Down Expand Up @@ -818,7 +818,7 @@ class FixtureBuilder {
accounts: {
'd5e45e4a-3b04-4a09-a5e1-39762e5c6be4': {
id: 'd5e45e4a-3b04-4a09-a5e1-39762e5c6be4',
address: ACCOUNT_1,
address: DEFAULT_FIXTURE_ACCOUNT,
options: {},
methods: [
'personal_sign',
Expand All @@ -838,7 +838,7 @@ class FixtureBuilder {
},
'e9976a84-110e-46c3-9811-e2da7b5528d3': {
id: 'e9976a84-110e-46c3-9811-e2da7b5528d3',
address: ACCOUNT_2,
address: DEFAULT_FIXTURE_ACCOUNT_2,
options: {},
methods: [
'personal_sign',
Expand Down Expand Up @@ -940,7 +940,7 @@ class FixtureBuilder {
detectedTokens: [],
allTokens: {
[toHex(chainId)]: {
[ACCOUNT_1]: [
[DEFAULT_FIXTURE_ACCOUNT]: [
{
address: `__FIXTURE_SUBSTITUTION__CONTRACT${SMART_CONTRACTS.HST}`,
symbol: 'TST',
Expand Down Expand Up @@ -983,7 +983,7 @@ class FixtureBuilder {
status: 'unapproved',
time: 1617228030067,
txParams: {
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gas: '0x61a8',
maxFeePerGas: '0x59682f0c',
maxPriorityFeePerGas: '0x59682f00',
Expand Down Expand Up @@ -1023,7 +1023,7 @@ class FixtureBuilder {
status: 'approved',
time: 1617228030067,
txParams: {
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gas: '0x61a8',
maxFeePerGas: '0x59682f0c',
maxPriorityFeePerGas: '0x59682f00',
Expand All @@ -1036,7 +1036,7 @@ class FixtureBuilder {
status: 'approved',
time: 1617228030067,
txParams: {
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gas: '0x61a8',
maxFeePerGas: '0x59682f0c',
maxPriorityFeePerGas: '0x59682f00',
Expand Down Expand Up @@ -1064,7 +1064,7 @@ class FixtureBuilder {
status: 'unapproved',
time: 1671635506502,
txParams: {
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gas: '0x5208',
maxFeePerGas: '0x4c03c96f8',
maxPriorityFeePerGas: '0x59682f00',
Expand Down Expand Up @@ -1151,7 +1151,7 @@ class FixtureBuilder {
path: '/txReceipt',
value: {
blockNumber: '7cbf95',
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gasUsed: '5208',
status: '0x1',
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
Expand All @@ -1176,7 +1176,7 @@ class FixtureBuilder {
submittedTime: 1671635510753,
time: 1671635506502,
txParams: {
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
gas: '0x5208',
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
type: '0x2',
Expand All @@ -1189,7 +1189,7 @@ class FixtureBuilder {
negative: 0,
words: [8175509, null],
},
from: ACCOUNT_1,
from: DEFAULT_FIXTURE_ACCOUNT,
status: '0x1',
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
type: '0x2',
Expand All @@ -1214,7 +1214,7 @@ class FixtureBuilder {
from: '0xc87261ba337be737fa744f50e7aaf4a920bdfcd6',
gas: '0x5208',
gasPrice: '0x329af9707',
to: ACCOUNT_1,
to: DEFAULT_FIXTURE_ACCOUNT,
value: '0xDE0B6B3A7640000',
},
type: 'incoming',
Expand Down Expand Up @@ -1388,8 +1388,8 @@ class FixtureBuilder {
withTrezorAccount() {
return this.withAccountTracker({
accounts: {
[ACCOUNT_1]: {
address: ACCOUNT_1,
[DEFAULT_FIXTURE_ACCOUNT]: {
address: DEFAULT_FIXTURE_ACCOUNT,
balance: '0x15af1d78b58c40000',
},
'0xf68464152d7289d7ea9a2bec2e0035c45188223c': {
Expand All @@ -1400,8 +1400,8 @@ class FixtureBuilder {
currentBlockGasLimit: '0x1c9c380',
accountsByChainId: {
'0x539': {
[ACCOUNT_1]: {
address: ACCOUNT_1,
[DEFAULT_FIXTURE_ACCOUNT]: {
address: DEFAULT_FIXTURE_ACCOUNT,
balance: '0x15af1d78b58c40000',
},
'0xf68464152d7289d7ea9a2bec2e0035c45188223c': {
Expand All @@ -1419,7 +1419,7 @@ class FixtureBuilder {
accounts: {
'd5e45e4a-3b04-4a09-a5e1-39762e5c6be4': {
id: 'd5e45e4a-3b04-4a09-a5e1-39762e5c6be4',
address: ACCOUNT_1,
address: DEFAULT_FIXTURE_ACCOUNT,
options: {},
methods: [
'personal_sign',
Expand Down Expand Up @@ -1472,7 +1472,7 @@ class FixtureBuilder {
.withNameController({
names: {
ethereumAddress: {
[ACCOUNT_1]: {
[DEFAULT_FIXTURE_ACCOUNT]: {
'*': {
name: 'Account 1',
sourceId: null,
Expand All @@ -1493,8 +1493,8 @@ class FixtureBuilder {
})
.withPreferencesController({
identities: {
[ACCOUNT_1]: {
address: ACCOUNT_1,
[DEFAULT_FIXTURE_ACCOUNT]: {
address: DEFAULT_FIXTURE_ACCOUNT,
lastSelected: 1665507600000,
name: 'Account 1',
},
Expand All @@ -1505,8 +1505,8 @@ class FixtureBuilder {
},
},
lostIdentities: {
[ACCOUNT_1]: {
address: ACCOUNT_1,
[DEFAULT_FIXTURE_ACCOUNT]: {
address: DEFAULT_FIXTURE_ACCOUNT,
name: 'Account 1',
lastSelected: 1665507600000,
},
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const { Bundler } = require('./bundler');
const { SMART_CONTRACTS } = require('./seeder/smart-contracts');
const { setManifestFlags } = require('./set-manifest-flags');
const {
DEFAULT_FIXTURE_ACCOUNT_2,
ERC_4337_ACCOUNT,
DEFAULT_GANACHE_ETH_BALANCE_DEC,
} = require('./constants');
Expand Down Expand Up @@ -456,7 +457,7 @@ const PRIVATE_KEY_TWO =
'0xf444f52ea41e3a39586d7069cb8e8233e9f6b9dea9cbb700cce69ae860661cc8';

const ACCOUNT_1 = '0x5cfe73b6021e818b776b421b1c4db2474086a7e1';
const ACCOUNT_2 = '0x09781764c08de8ca82e156bbf156a3ca217c7950';
const ACCOUNT_2 = DEFAULT_FIXTURE_ACCOUNT_2;

const defaultGanacheOptions = {
accounts: [
Expand Down

0 comments on commit 73b8c72

Please sign in to comment.