Skip to content

Commit

Permalink
fix: save hex instead of uint8array
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowardx committed Apr 10, 2024
1 parent 10b6574 commit dfa715e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/chrome/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { RadixNetworkConfigById } from '@radixdlt/babylon-gateway-api-sdk'
import { openRadixDevToolsPage } from './open-radix-dev-tools-page'
import { sendMessage } from 'chrome/messages/send-message'
import { Connections } from 'pairing/state/connections'
import { createTab } from 'chrome/helpers/create-tab'
import { getExtensionOptions, setConnectorExtensionOptions } from 'options'

const logger = utilsLogger.getSubLogger({ name: 'background' })
Expand All @@ -38,7 +37,9 @@ const handleOnInstallExtension = async () => {
} catch (err) {}
}

getExtensionOptions().map(setConnectorExtensionOptions)
getExtensionOptions()
.andThen(setConnectorExtensionOptions)
.mapErr(() => logger.error('Failed to set extension options'))
}

const handleStorageChange = (
Expand Down
10 changes: 5 additions & 5 deletions src/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const privateKey = ed25519.utils.randomPrivateKey()
const publicKey = ed25519.getPublicKey(privateKey)

export type ConnectorExtensionOptions = {
publicKey: Uint8Array
privateKey: Uint8Array
publicKey: string
privateKey: string
showDAppRequestNotifications?: boolean
showTransactionResultNotifications?: boolean
radixConnectConfiguration: string
}

export const defaultConnectorExtensionOptions: ConnectorExtensionOptions = {
publicKey,
privateKey,
publicKey: Buffer.from(publicKey).toString('hex'),
privateKey: Buffer.from(privateKey).toString('hex'),
showDAppRequestNotifications: true,
showTransactionResultNotifications: true,
radixConnectConfiguration: defaultRadixConnectConfig,
Expand Down Expand Up @@ -52,5 +52,5 @@ export const setConnectorExtensionOptions = (
connectorExtensionOptions: ConnectorExtensionOptions,
) => {
logger.debug('setConnectorExtensionOptions', connectorExtensionOptions)
chromeLocalStore.setSingleItem('options', connectorExtensionOptions)
return chromeLocalStore.setSingleItem('options', connectorExtensionOptions)
}
2 changes: 1 addition & 1 deletion src/pairing/pairing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Pairing = () => {
useEffect(() => {
if (!connectorOptions) return

setPublicKey(Buffer.from(connectorOptions.publicKey).toString('hex'))
setPublicKey(connectorOptions.publicKey)

const connectorClient = ConnectorClient({
source: 'extension',
Expand Down

0 comments on commit dfa715e

Please sign in to comment.