From df08a5e71348207d35d9a7c2bacf21c4ba8d24f2 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Mon, 29 Mar 2021 11:33:34 -0600 Subject: [PATCH 01/15] added property to transaction if it was confirmed locally --- src/transaction/TransactionController.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 21681de5e93..2a6472d0e94 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -167,6 +167,7 @@ export interface EtherscanTransactionMeta { confirmations: string; tokenDecimal: string; tokenSymbol: string; + confirmedLocally: boolean; } /** @@ -411,9 +412,10 @@ export class TransactionController extends BaseController { + async addTransaction(transaction: Transaction, origin?: string, confirmedLocally: boolean): Promise { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; transaction = normalizeTransaction(transaction); @@ -434,6 +436,7 @@ export class TransactionController extends BaseController Date: Tue, 30 Mar 2021 10:15:55 -0600 Subject: [PATCH 02/15] added logic to capture the time an account was added/imported --- package.json | 2 +- src/assets/AccountTrackerController.test.ts | 5 ++++- src/assets/AccountTrackerController.ts | 8 ++++++-- src/transaction/TransactionController.ts | 9 +++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 3d69f641420..c0a9712d0d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controllers", - "version": "6.2.1", + "version": "6.2.2", "description": "Collection of platform-agnostic modules for creating secure data models for cryptocurrency wallets", "license": "MIT", "files": [ diff --git a/src/assets/AccountTrackerController.test.ts b/src/assets/AccountTrackerController.test.ts index 925464d5f0c..37e76e0b27b 100644 --- a/src/assets/AccountTrackerController.test.ts +++ b/src/assets/AccountTrackerController.test.ts @@ -25,6 +25,7 @@ describe('AccountTrackerController', () => { controller.context = { PreferencesController: { state: { identities: { [address]: {} } } } } as any; await controller.refresh(); expect(controller.state.accounts[address].balance).toBeDefined(); + expect(controller.state.accounts[address].importTime).toBeDefined(); }); it('should sync addresses', () => { @@ -39,7 +40,9 @@ describe('AccountTrackerController', () => { ); controller.context = { PreferencesController: { state: { identities: { baz: {} } } } } as any; controller.refresh(); - expect(controller.state.accounts).toEqual({ baz: { balance: '0x0' } }); + expect(controller.state.accounts.baz.balance).toEqual('0x0'); + expect(controller.state.accounts.baz.importTime).toBeDefined(); + expect(controller.state.accounts.baz.importTime).toBeLessThanOrEqual(Date.now()); }); it('should subscribe to new sibling preference controllers', async () => { diff --git a/src/assets/AccountTrackerController.ts b/src/assets/AccountTrackerController.ts index 79126524fdd..636f7741cc1 100644 --- a/src/assets/AccountTrackerController.ts +++ b/src/assets/AccountTrackerController.ts @@ -10,9 +10,11 @@ import { BNToHex, query, safelyExecuteWithTimeout } from '../util'; * Account information object * * @property balance - Hex string of an account balancec in wei + * @property importTime - Data time when an account as created/imported */ export interface AccountInformation { balance: string; + importTime?: number; } /** @@ -58,7 +60,8 @@ export class AccountTrackerController extends BaseController existing.indexOf(address) === -1); const oldAddresses = existing.filter((address) => addresses.indexOf(address) === -1); newAddresses.forEach((address) => { - accounts[address] = { balance: '0x0' }; + console.log('New Address'); + accounts[address] = { balance: '0x0', importTime: Date.now() }; }); oldAddresses.forEach((address) => { delete accounts[address]; @@ -142,7 +145,8 @@ export class AccountTrackerController extends BaseController { const balance = await query(this.ethQuery, 'getBalance', [address]); - accounts[address] = { balance: BNToHex(balance) }; + const { importTime } = accounts[address]; + accounts[address] = { balance: BNToHex(balance), importTime }; this.update({ accounts: { ...accounts } }); }); } diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 2a6472d0e94..6c9edb1ce49 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -101,6 +101,7 @@ type TransactionMetaBase = { transaction: Transaction; transactionHash?: string; blockNumber?: string; + confirmedLocal?: boolean; }; /** @@ -112,6 +113,7 @@ type TransactionMetaBase = { * @property id - Generated UUID associated with this transaction * @property networkID - Network code as per EIP-155 for this transaction * @property origin - Origin this transaction was sent from + * @property confirmedLocal - Boolean to indicate if the transaction was confirmed on local device * @property rawTransaction - Hex representation of the underlying transaction * @property status - String status of this transaction * @property time - Timestamp associated with this transaction @@ -167,7 +169,6 @@ export interface EtherscanTransactionMeta { confirmations: string; tokenDecimal: string; tokenSymbol: string; - confirmedLocally: boolean; } /** @@ -412,10 +413,10 @@ export class TransactionController extends BaseController { + async addTransaction(transaction: Transaction, origin?: string, confirmedLocalDevice?: boolean): Promise { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; transaction = normalizeTransaction(transaction); @@ -436,7 +437,7 @@ export class TransactionController extends BaseController Date: Wed, 31 Mar 2021 12:34:27 -0600 Subject: [PATCH 03/15] coverted confirmDevice to enum and removed console.logs --- package.json | 2 +- src/assets/AccountTrackerController.ts | 1 - src/transaction/TransactionController.ts | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index c0a9712d0d7..f031cb0dbfc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controllers", - "version": "6.2.2", + "version": "6.2.11-seth", "description": "Collection of platform-agnostic modules for creating secure data models for cryptocurrency wallets", "license": "MIT", "files": [ diff --git a/src/assets/AccountTrackerController.ts b/src/assets/AccountTrackerController.ts index 636f7741cc1..f1fe3c8757b 100644 --- a/src/assets/AccountTrackerController.ts +++ b/src/assets/AccountTrackerController.ts @@ -60,7 +60,6 @@ export class AccountTrackerController extends BaseController existing.indexOf(address) === -1); const oldAddresses = existing.filter((address) => addresses.indexOf(address) === -1); newAddresses.forEach((address) => { - console.log('New Address'); accounts[address] = { balance: '0x0', importTime: Date.now() }; }); oldAddresses.forEach((address) => { diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 6c9edb1ce49..53307d14871 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -84,6 +84,15 @@ export enum TransactionStatus { unapproved = 'unapproved', } +/** + * The device that confirmed a transaction. + */ +export enum ConfirmedDeviceTransaction { + MM_MOBILE = 'meta_mask_mobile', + MM_EXTENSION = 'meta_mask_extension', + OTHER = 'other_device' +} + type TransactionMetaBase = { isTransfer?: boolean; transferInformation?: { @@ -101,7 +110,7 @@ type TransactionMetaBase = { transaction: Transaction; transactionHash?: string; blockNumber?: string; - confirmedLocal?: boolean; + confirmedLocal?: ConfirmedDeviceTransaction; }; /** @@ -413,10 +422,10 @@ export class TransactionController extends BaseController { + async addTransaction(transaction: Transaction, origin?: string, confirmedLocalDevice?: ConfirmedDeviceTransaction): Promise { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; transaction = normalizeTransaction(transaction); From ffe5feedca9407acb151e4c3984adf2c52214945 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 31 Mar 2021 12:37:13 -0600 Subject: [PATCH 04/15] updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f031cb0dbfc..c0a9712d0d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controllers", - "version": "6.2.11-seth", + "version": "6.2.2", "description": "Collection of platform-agnostic modules for creating secure data models for cryptocurrency wallets", "license": "MIT", "files": [ From da0ceeec4c0e4b601c6d5ec219df3f890505f30d Mon Sep 17 00:00:00 2001 From: sethkfman <10342624+sethkfman@users.noreply.github.com> Date: Wed, 31 Mar 2021 13:01:37 -0600 Subject: [PATCH 05/15] Update src/transaction/TransactionController.ts Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com> --- src/transaction/TransactionController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 53307d14871..1309e9c3ba5 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -88,8 +88,8 @@ export enum TransactionStatus { * The device that confirmed a transaction. */ export enum ConfirmedDeviceTransaction { - MM_MOBILE = 'meta_mask_mobile', - MM_EXTENSION = 'meta_mask_extension', + MM_MOBILE = 'metamask_mobile', + MM_EXTENSION = 'metamask_extension', OTHER = 'other_device' } From 0de1181b8dc62fbd899fe80d22e723ebc03723cd Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 31 Mar 2021 13:06:55 -0600 Subject: [PATCH 06/15] format --- src/transaction/TransactionController.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 1309e9c3ba5..280ef1982bb 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -88,9 +88,9 @@ export enum TransactionStatus { * The device that confirmed a transaction. */ export enum ConfirmedDeviceTransaction { - MM_MOBILE = 'metamask_mobile', - MM_EXTENSION = 'metamask_extension', - OTHER = 'other_device' + MM_MOBILE = 'meta_mask_mobile', + MM_EXTENSION = 'meta_mask_extension', + OTHER = 'other_device', } type TransactionMetaBase = { @@ -425,7 +425,11 @@ export class TransactionController extends BaseController { + async addTransaction( + transaction: Transaction, + origin?: string, + confirmedLocalDevice?: ConfirmedDeviceTransaction, + ): Promise { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; transaction = normalizeTransaction(transaction); From 1ac4bac16ef19b68dea2ca288bc90128973a6a42 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 31 Mar 2021 13:15:23 -0600 Subject: [PATCH 07/15] updated variable name to make more sense --- src/transaction/TransactionController.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 280ef1982bb..8b2ca0fb63b 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -110,7 +110,7 @@ type TransactionMetaBase = { transaction: Transaction; transactionHash?: string; blockNumber?: string; - confirmedLocal?: ConfirmedDeviceTransaction; + deviceConfirmedOn?: ConfirmedDeviceTransaction; }; /** @@ -122,7 +122,7 @@ type TransactionMetaBase = { * @property id - Generated UUID associated with this transaction * @property networkID - Network code as per EIP-155 for this transaction * @property origin - Origin this transaction was sent from - * @property confirmedLocal - Boolean to indicate if the transaction was confirmed on local device + * @property confirmedLocal - string to indicate what device the transaction was confirmed * @property rawTransaction - Hex representation of the underlying transaction * @property status - String status of this transaction * @property time - Timestamp associated with this transaction @@ -422,13 +422,13 @@ export class TransactionController extends BaseController { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; @@ -450,7 +450,7 @@ export class TransactionController extends BaseController Date: Wed, 31 Mar 2021 13:21:35 -0600 Subject: [PATCH 08/15] Update src/transaction/TransactionController.ts Updated string enum values Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com> --- src/transaction/TransactionController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 8b2ca0fb63b..2e03f834989 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -88,8 +88,8 @@ export enum TransactionStatus { * The device that confirmed a transaction. */ export enum ConfirmedDeviceTransaction { - MM_MOBILE = 'meta_mask_mobile', - MM_EXTENSION = 'meta_mask_extension', + MM_MOBILE = 'metamask_mobile', + MM_EXTENSION = 'metamask_extension', OTHER = 'other_device', } From af339b793988b5fc8a5e335c9a7a3c1011a49fe4 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Wed, 31 Mar 2021 13:36:13 -0600 Subject: [PATCH 09/15] reverted the version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0a9712d0d7..3d69f641420 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controllers", - "version": "6.2.2", + "version": "6.2.1", "description": "Collection of platform-agnostic modules for creating secure data models for cryptocurrency wallets", "license": "MIT", "files": [ From a61898fc1be152f2aa5a935c77ece0a98301ba74 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Thu, 1 Apr 2021 11:15:16 -0600 Subject: [PATCH 10/15] move importTime to preferences controller and added test cases --- .gitignore | 1 + src/assets/AccountTrackerController.test.ts | 5 +---- src/assets/AccountTrackerController.ts | 7 ++----- src/user/AddressBookController.ts | 2 ++ src/user/PreferencesController.test.ts | 22 +++++++++------------ src/user/PreferencesController.ts | 2 +- 6 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index d7524f79db2..c7a4175bd3a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ package-lock.json # tarball from `yarn pack` *.tgz +.DS_STORE coverage dist docs diff --git a/src/assets/AccountTrackerController.test.ts b/src/assets/AccountTrackerController.test.ts index 37e76e0b27b..925464d5f0c 100644 --- a/src/assets/AccountTrackerController.test.ts +++ b/src/assets/AccountTrackerController.test.ts @@ -25,7 +25,6 @@ describe('AccountTrackerController', () => { controller.context = { PreferencesController: { state: { identities: { [address]: {} } } } } as any; await controller.refresh(); expect(controller.state.accounts[address].balance).toBeDefined(); - expect(controller.state.accounts[address].importTime).toBeDefined(); }); it('should sync addresses', () => { @@ -40,9 +39,7 @@ describe('AccountTrackerController', () => { ); controller.context = { PreferencesController: { state: { identities: { baz: {} } } } } as any; controller.refresh(); - expect(controller.state.accounts.baz.balance).toEqual('0x0'); - expect(controller.state.accounts.baz.importTime).toBeDefined(); - expect(controller.state.accounts.baz.importTime).toBeLessThanOrEqual(Date.now()); + expect(controller.state.accounts).toEqual({ baz: { balance: '0x0' } }); }); it('should subscribe to new sibling preference controllers', async () => { diff --git a/src/assets/AccountTrackerController.ts b/src/assets/AccountTrackerController.ts index f1fe3c8757b..79126524fdd 100644 --- a/src/assets/AccountTrackerController.ts +++ b/src/assets/AccountTrackerController.ts @@ -10,11 +10,9 @@ import { BNToHex, query, safelyExecuteWithTimeout } from '../util'; * Account information object * * @property balance - Hex string of an account balancec in wei - * @property importTime - Data time when an account as created/imported */ export interface AccountInformation { balance: string; - importTime?: number; } /** @@ -60,7 +58,7 @@ export class AccountTrackerController extends BaseController existing.indexOf(address) === -1); const oldAddresses = existing.filter((address) => addresses.indexOf(address) === -1); newAddresses.forEach((address) => { - accounts[address] = { balance: '0x0', importTime: Date.now() }; + accounts[address] = { balance: '0x0' }; }); oldAddresses.forEach((address) => { delete accounts[address]; @@ -144,8 +142,7 @@ export class AccountTrackerController extends BaseController { const balance = await query(this.ethQuery, 'getBalance', [address]); - const { importTime } = accounts[address]; - accounts[address] = { balance: BNToHex(balance), importTime }; + accounts[address] = { balance: BNToHex(balance) }; this.update({ accounts: { ...accounts } }); }); } diff --git a/src/user/AddressBookController.ts b/src/user/AddressBookController.ts index 5f1084e9008..b64b9189083 100644 --- a/src/user/AddressBookController.ts +++ b/src/user/AddressBookController.ts @@ -9,10 +9,12 @@ import BaseController, { BaseConfig, BaseState } from '../BaseController'; * * @property address - Hex address of a recipient account * @property name - Nickname associated with this address + * @property importTime - Data time when an account as created/imported */ export interface ContactEntry { address: string; name: string; + importTime?: number; } /** diff --git a/src/user/PreferencesController.test.ts b/src/user/PreferencesController.test.ts index a418cbde406..a0067675790 100644 --- a/src/user/PreferencesController.test.ts +++ b/src/user/PreferencesController.test.ts @@ -17,12 +17,9 @@ describe('PreferencesController', () => { const controller = new PreferencesController(); controller.addIdentities(['foo']); controller.addIdentities(['foo']); - expect(controller.state.identities).toEqual({ - '0xfoO': { - address: '0xfoO', - name: 'Account 1', - }, - }); + expect(controller.state.identities['0xfoO'].address).toEqual('0xfoO'); + expect(controller.state.identities['0xfoO'].name).toEqual('Account 1'); + expect(controller.state.identities['0xfoO'].importTime).toBeLessThanOrEqual(Date.now()); }); it('should remove identity', () => { @@ -49,14 +46,13 @@ describe('PreferencesController', () => { const controller = new PreferencesController(); controller.addIdentities(['foo', 'bar']); controller.syncIdentities(['foo', 'bar']); - expect(controller.state.identities).toEqual({ - '0xbar': { address: '0xbar', name: 'Account 2' }, - '0xfoO': { address: '0xfoO', name: 'Account 1' }, - }); + expect(controller.state.identities['0xfoO'].address).toEqual('0xfoO'); + expect(controller.state.identities['0xfoO'].name).toEqual('Account 1'); + expect(controller.state.identities['0xfoO'].importTime).toBeLessThanOrEqual(Date.now()); + expect(controller.state.identities['0xbar'].address).toEqual('0xbar'); + expect(controller.state.identities['0xbar'].name).toEqual('Account 2'); + expect(controller.state.identities['0xbar'].importTime).toBeLessThanOrEqual(Date.now()); controller.syncIdentities(['foo']); - expect(controller.state.identities).toEqual({ - '0xfoO': { address: '0xfoO', name: 'Account 1' }, - }); expect(controller.state.selectedAddress).toBe('0xfoO'); }); diff --git a/src/user/PreferencesController.ts b/src/user/PreferencesController.ts index 686ba031062..7e2586da1e3 100644 --- a/src/user/PreferencesController.ts +++ b/src/user/PreferencesController.ts @@ -90,7 +90,7 @@ export class PreferencesController extends BaseController Date: Thu, 1 Apr 2021 13:00:11 -0600 Subject: [PATCH 11/15] updated setting of import time and test cases --- src/user/PreferencesController.test.ts | 21 +++++++++++++-------- src/user/PreferencesController.ts | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/user/PreferencesController.test.ts b/src/user/PreferencesController.test.ts index a0067675790..c97c7f8a936 100644 --- a/src/user/PreferencesController.test.ts +++ b/src/user/PreferencesController.test.ts @@ -59,10 +59,13 @@ describe('PreferencesController', () => { it('should add new identities', () => { const controller = new PreferencesController(); controller.updateIdentities(['foo', 'bar']); - expect(controller.state.identities).toEqual({ - '0xbar': { address: '0xbar', name: 'Account 2' }, - '0xfoO': { address: '0xfoO', name: 'Account 1' }, - }); + expect(controller.state.identities['0xfoO'].address).toEqual('0xfoO'); + expect(controller.state.identities['0xfoO'].name).toEqual('Account 1'); + expect(controller.state.identities['0xfoO'].importTime).toBeLessThanOrEqual(Date.now()); + expect(controller.state.identities['0xbar'].address).toEqual('0xbar'); + expect(controller.state.identities['0xbar'].name).toEqual('Account 2'); + expect(controller.state.identities['0xbar'].importTime).toBeLessThanOrEqual(Date.now()); + }); it('should not update existing identities', () => { @@ -71,10 +74,12 @@ describe('PreferencesController', () => { { identities: { '0xbar': { address: '0xbar', name: 'Custom name' } } }, ); controller.updateIdentities(['foo', 'bar']); - expect(controller.state.identities).toEqual({ - '0xbar': { address: '0xbar', name: 'Custom name' }, - '0xfoO': { address: '0xfoO', name: 'Account 1' }, - }); + expect(controller.state.identities['0xfoO'].address).toEqual('0xfoO'); + expect(controller.state.identities['0xfoO'].name).toEqual('Account 1'); + expect(controller.state.identities['0xfoO'].importTime).toBeLessThanOrEqual(Date.now()); + expect(controller.state.identities['0xbar'].address).toEqual('0xbar'); + expect(controller.state.identities['0xbar'].name).toEqual('Custom name'); + expect(controller.state.identities['0xbar'].importTime).toBeUndefined(); }); it('should remove identities', () => { diff --git a/src/user/PreferencesController.ts b/src/user/PreferencesController.ts index 7e2586da1e3..4d952770cf4 100644 --- a/src/user/PreferencesController.ts +++ b/src/user/PreferencesController.ts @@ -187,6 +187,7 @@ export class PreferencesController extends BaseController Date: Thu, 1 Apr 2021 13:05:57 -0600 Subject: [PATCH 12/15] updated test case --- src/transaction/TransactionController.ts | 2 +- src/user/PreferencesController.test.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 2e03f834989..454b97a89e0 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -122,7 +122,7 @@ type TransactionMetaBase = { * @property id - Generated UUID associated with this transaction * @property networkID - Network code as per EIP-155 for this transaction * @property origin - Origin this transaction was sent from - * @property confirmedLocal - string to indicate what device the transaction was confirmed + * @property deviceConfirmedOn - string to indicate what device the transaction was confirmed * @property rawTransaction - Hex representation of the underlying transaction * @property status - String status of this transaction * @property time - Timestamp associated with this transaction diff --git a/src/user/PreferencesController.test.ts b/src/user/PreferencesController.test.ts index c97c7f8a936..68a148f9121 100644 --- a/src/user/PreferencesController.test.ts +++ b/src/user/PreferencesController.test.ts @@ -53,6 +53,8 @@ describe('PreferencesController', () => { expect(controller.state.identities['0xbar'].name).toEqual('Account 2'); expect(controller.state.identities['0xbar'].importTime).toBeLessThanOrEqual(Date.now()); controller.syncIdentities(['foo']); + expect(controller.state.identities['0xfoO'].address).toEqual('0xfoO'); + expect(controller.state.identities['0xfoO'].name).toEqual('Account 1'); expect(controller.state.selectedAddress).toBe('0xfoO'); }); From 9dfbb7d4b61c6b8731b0e4c56937adb2f40e23f4 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Thu, 1 Apr 2021 13:12:24 -0600 Subject: [PATCH 13/15] updated format --- src/user/PreferencesController.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/user/PreferencesController.test.ts b/src/user/PreferencesController.test.ts index 68a148f9121..657ceaac617 100644 --- a/src/user/PreferencesController.test.ts +++ b/src/user/PreferencesController.test.ts @@ -67,7 +67,6 @@ describe('PreferencesController', () => { expect(controller.state.identities['0xbar'].address).toEqual('0xbar'); expect(controller.state.identities['0xbar'].name).toEqual('Account 2'); expect(controller.state.identities['0xbar'].importTime).toBeLessThanOrEqual(Date.now()); - }); it('should not update existing identities', () => { From c420f02e03670decf95a8aaeffebdfe8683f1301 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 2 Apr 2021 11:17:04 -0600 Subject: [PATCH 14/15] updated enum name per PR suggestion --- src/transaction/TransactionController.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 454b97a89e0..9e961716f77 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -85,9 +85,9 @@ export enum TransactionStatus { } /** - * The device that confirmed a transaction. + * Options for wallet device. */ -export enum ConfirmedDeviceTransaction { +export enum WalletDevice { MM_MOBILE = 'metamask_mobile', MM_EXTENSION = 'metamask_extension', OTHER = 'other_device', @@ -110,7 +110,7 @@ type TransactionMetaBase = { transaction: Transaction; transactionHash?: string; blockNumber?: string; - deviceConfirmedOn?: ConfirmedDeviceTransaction; + deviceConfirmedOn?: WalletDevice; }; /** @@ -428,7 +428,7 @@ export class TransactionController extends BaseController { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; From 32fcd6c882c9c6da6ca15cfcf779f680da4be5a6 Mon Sep 17 00:00:00 2001 From: sethkfman Date: Fri, 2 Apr 2021 11:29:05 -0600 Subject: [PATCH 15/15] format --- src/transaction/TransactionController.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 9e961716f77..dd79ce4b687 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -425,11 +425,7 @@ export class TransactionController extends BaseController { + async addTransaction(transaction: Transaction, origin?: string, deviceConfirmedOn?: WalletDevice): Promise { const network = this.context.NetworkController as NetworkController; const { transactions } = this.state; transaction = normalizeTransaction(transaction);