diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 6092721aa172..a948be94930b 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -714,6 +714,10 @@ "coingecko": { "message": "CoinGecko" }, + "comboNoOptions": { + "message": "No options found", + "description": "Default text shown in the combo field dropdown if no options." + }, "configureSnapPopupDescription": { "message": "You're now leaving MetaMask to configure this snap." }, @@ -2368,6 +2372,38 @@ "name": { "message": "Name" }, + "nameAddressLabel": { + "message": "Address", + "description": "Label above address field in name component modal." + }, + "nameInstructionsNew": { + "message": "You are interacting with an unknown contract address. If you trust this author, set a personal display name to identify it going forward.", + "description": "Instruction text in name component modal when value is not recognised." + }, + "nameInstructionsSaved": { + "message": "Interactions with this address will always be identified using this personal display name.", + "description": "Instruction text in name component modal when value is saved." + }, + "nameLabel": { + "message": "Display name", + "description": "Label above name input field in name component modal." + }, + "nameModalTitleNew": { + "message": "Unknown address", + "description": "Title of the modal created by the name component when value is not recognised." + }, + "nameModalTitleSaved": { + "message": "Saved address", + "description": "Title of the modal created by the name component when value is saved." + }, + "nameNoProposedNames": { + "message": "No proposed names found", + "description": "Text shown in the proposed name dropdown if none found." + }, + "nameSetPlaceholder": { + "message": "Set a personal display name...", + "description": "Placeholder text for name input field in name component modal." + }, "nativeToken": { "message": "The native token on this network is $1. It is the token used for gas fees.", "description": "$1 represents the name of the native token on the current network" diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 0530d84fa850..e25e02879fd4 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1677,6 +1677,14 @@ "browserify>url": true } }, + "@metamask/name-controller": { + "globals": { + "fetch": true + }, + "packages": { + "@metamask/base-controller": true + } + }, "@metamask/network-controller": { "globals": { "URL": true, diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index bdd2ba925bb9..7ede24c7bbb7 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -1828,6 +1828,14 @@ "browserify>url": true } }, + "@metamask/name-controller": { + "globals": { + "fetch": true + }, + "packages": { + "@metamask/base-controller": true + } + }, "@metamask/network-controller": { "globals": { "URL": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 2f97fd964747..d807734aedf6 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1828,6 +1828,14 @@ "browserify>url": true } }, + "@metamask/name-controller": { + "globals": { + "fetch": true + }, + "packages": { + "@metamask/base-controller": true + } + }, "@metamask/network-controller": { "globals": { "URL": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 8f1f171aa469..9eae2c148db8 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1677,6 +1677,14 @@ "browserify>url": true } }, + "@metamask/name-controller": { + "globals": { + "fetch": true + }, + "packages": { + "@metamask/base-controller": true + } + }, "@metamask/network-controller": { "globals": { "URL": true, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 578f541b1d3e..da430864f696 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -1818,6 +1818,14 @@ "browserify>url": true } }, + "@metamask/name-controller": { + "globals": { + "fetch": true + }, + "packages": { + "@metamask/base-controller": true + } + }, "@metamask/network-controller": { "globals": { "URL": true, diff --git a/package.json b/package.json index 63bd13ec55a4..66a2804d8f03 100644 --- a/package.json +++ b/package.json @@ -256,6 +256,7 @@ "@metamask/logo": "^3.1.1", "@metamask/message-manager": "^7.3.0", "@metamask/metamask-eth-abis": "^3.0.0", + "@metamask/name-controller": "^1.0.0", "@metamask/network-controller": "^12.1.1", "@metamask/notification-controller": "^3.0.0", "@metamask/obs-store": "^8.1.0", diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss index c4dc26714527..c5c610d5dc51 100644 --- a/ui/components/app/app-components.scss +++ b/ui/components/app/app-components.scss @@ -95,6 +95,8 @@ @import 'network-account-balance-header/index'; @import 'approve-content-card/index'; @import 'transaction-alerts/transaction-alerts'; +@import 'name/index'; +@import 'name/name-details/index'; ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) @import '../institutional/interactive-replacement-token-notification/index'; @import '../institutional/confirm-remove-jwt-modal/index'; diff --git a/ui/components/app/name/__snapshots__/name.test.tsx.snap b/ui/components/app/name/__snapshots__/name.test.tsx.snap new file mode 100644 index 000000000000..5769227e4286 --- /dev/null +++ b/ui/components/app/name/__snapshots__/name.test.tsx.snap @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Name renders address with proposed name 1`] = ` +
+
+
+ + + 0xc0f...4978 + + + “ + TestProposedName + ” + +
+
+
+`; + +exports[`Name renders address with proposed name according to source priority 1`] = ` +
+
+
+ + + 0xc0f...4978 + + + “ + TestProposedName + ” + +
+
+
+`; + +exports[`Name renders address with saved name 1`] = ` +
+
+
+ + + TestName + +
+
+
+`; + +exports[`Name renders address without proposed name 1`] = ` +
+
+
+ + + 0xc0f...4979 + +
+
+
+`; diff --git a/ui/components/app/name/index.scss b/ui/components/app/name/index.scss new file mode 100644 index 000000000000..becff5641d2a --- /dev/null +++ b/ui/components/app/name/index.scss @@ -0,0 +1,37 @@ +.name { + border-radius: 36px; + padding: 6px 9px 6px 9px; + display: inline-flex; + align-items: center; + gap: 5px; + font-size: 12px; + + &__missing { + background-color: var(--color-warning-muted); + } + + &__saved { + background-color: var(--color-info-muted); + } + + &__missing &__icon { + color: var(--color-warning-default); + } + + &__saved &__icon { + color: var(--color-info-default); + } + + &__value, + &__proposed { + color: var(--color-warning-default); + } + + &__name { + color: var(--color-info-default); + } + + &__proposed { + font-style: italic; + } +} diff --git a/ui/components/app/name/index.ts b/ui/components/app/name/index.ts new file mode 100644 index 000000000000..f3e2e4fe0a86 --- /dev/null +++ b/ui/components/app/name/index.ts @@ -0,0 +1 @@ +export { default } from './name'; diff --git a/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap b/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap new file mode 100644 index 000000000000..2f4fc518007d --- /dev/null +++ b/ui/components/app/name/name-details/__snapshots__/name-details.test.tsx.snap @@ -0,0 +1,383 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`NameDetails renders with no saved name 1`] = ` + +
+
+
+
+
+