diff --git a/packages/extension/package.json b/packages/extension/package.json index adf4328ff..b3af75bf9 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -1,6 +1,6 @@ { "name": "@enkryptcom/extension", - "version": "2.0.1", + "version": "2.0.2", "private": true, "type": "module", "scripts": { diff --git a/packages/extension/src/libs/recently-sent-addresses/index.ts b/packages/extension/src/libs/recently-sent-addresses/index.ts new file mode 100644 index 000000000..73f9a56ed --- /dev/null +++ b/packages/extension/src/libs/recently-sent-addresses/index.ts @@ -0,0 +1,41 @@ +import { InternalStorageNamespace } from "@/types/provider"; +import BrowserStorage from "../common/browser-storage"; +import { IState, } from "./types"; +import { NetworkNames } from "@enkryptcom/types"; +import { BaseNetwork } from "@/types/base-network"; + +class RecentlySentAddressesState { + #storage: BrowserStorage + + constructor() { + this.#storage = new BrowserStorage( + InternalStorageNamespace.recentlySentAddresses, + ); + } + + async addRecentlySentAddress( + network: Pick, + address: string, + ): Promise { + const key = network.name + const state: IState | undefined = await this.#storage.get(key) + const newState: IState = { + ...state, + addresses: Array.from(new Set([ + network.displayAddress(address), + ...(state?.addresses ?? []), + ])).slice(0, 5), + } + await this.#storage.set(key, newState) + } + + async getRecentlySentAddresses(networkName: NetworkNames): Promise { + const key = networkName + const out: IState | undefined = await this.#storage.get(key) + if (!out) return [] + return out.addresses + } +} + +export default RecentlySentAddressesState + diff --git a/packages/extension/src/libs/recently-sent-addresses/types.ts b/packages/extension/src/libs/recently-sent-addresses/types.ts new file mode 100644 index 000000000..44976940a --- /dev/null +++ b/packages/extension/src/libs/recently-sent-addresses/types.ts @@ -0,0 +1,3 @@ +export type IState = { + addresses: string[] +} diff --git a/packages/extension/src/libs/utils/networks.ts b/packages/extension/src/libs/utils/networks.ts index 6bbe422bc..7634ac299 100644 --- a/packages/extension/src/libs/utils/networks.ts +++ b/packages/extension/src/libs/utils/networks.ts @@ -75,12 +75,13 @@ const DEFAULT_SOLANA_NETWORK = Solana; const POPULAR_NAMES = [ NetworkNames.Bitcoin, NetworkNames.Ethereum, + NetworkNames.Solana, NetworkNames.Matic, NetworkNames.Polkadot, NetworkNames.Binance, NetworkNames.Rootstock, NetworkNames.Optimism, - NetworkNames.Kadena, + NetworkNames.Arbitrum, ]; export { getAllNetworks, diff --git a/packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue b/packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue index 8ba300e2c..e62d46777 100644 --- a/packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue +++ b/packages/extension/src/providers/bitcoin/ui/send-transaction/components/send-alert.vue @@ -1,7 +1,8 @@