const keyLabelStorageName = 'poly_keylabels';

const noLabelDefault = '[No label]';

const keyLabelStorage = JSON.parse(
  localStorage.getItem(keyLabelStorageName) || '{}'
);

const saveKeyLabel = (address: string, label: string) => {
  keyLabelStorage[address] = label;
  localStorage.setItem(keyLabelStorageName, JSON.stringify(keyLabelStorage));
};

export const keyLabel = {
  storageName: keyLabelStorageName,
  noLabelDefault,
  storage: keyLabelStorage,
  save: saveKeyLabel,
};
