-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #604 from z3us-dapps/feat/connector-1.4.1
Update Connector 1.4.1
- Loading branch information
Showing
39 changed files
with
493 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import type { WalletInteractionWithOrigin } from '@radixdlt/radix-connect-schemas' | ||
import type { WalletInteraction } from '@radixdlt/radix-dapp-toolkit' | ||
|
||
export enum MessageAction { | ||
APP_PING = 'v1-app-ping', | ||
APP_INTERACTION_CANCEL = 'v1-app-interaction-cancel', | ||
} | ||
|
||
export type WalletInteractionWithTabId = WalletInteractionWithOrigin & { fromTabId: number; senderURl: string } | ||
export type WalletInteractionWithTabId = WalletInteraction & { fromTabId: number; senderURl: string } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,22 @@ | ||
import { messageSource } from '@radixdlt/connector-extension/src/chrome/messages/_types' | ||
import { createMessage } from '@radixdlt/connector-extension/src/chrome/messages/create-message' | ||
import type { Storage } from 'webextension-polyfill' | ||
import browser from 'webextension-polyfill' | ||
|
||
export const handleStorageChange = async (changes: { [key: string]: Storage.StorageChange }) => { | ||
if (changes?.connectionPassword) { | ||
const radixMsg = createMessage.setConnectionPassword('background', changes?.connectionPassword?.newValue) | ||
return browser.runtime.sendMessage(radixMsg) | ||
export const handleStorageChange = async (changes: { [key: string]: Storage.StorageChange }, area: string) => { | ||
if (changes.connections && area === 'local') { | ||
const radixMsg = createMessage.setConnections(messageSource.background, changes.connections?.newValue || {}) | ||
await browser.runtime.sendMessage(radixMsg) | ||
} | ||
|
||
if (changes.options && area === 'local') { | ||
const radixMsg = createMessage.setConnectorExtensionOptions(messageSource.background, changes.options.newValue) | ||
await browser.runtime.sendMessage(radixMsg) | ||
} | ||
|
||
if (changes.sessionRouter && area === 'local') { | ||
const radixMsg = createMessage.setSessionRouterData(changes.sessionRouter.newValue, messageSource.background) | ||
await browser.runtime.sendMessage(radixMsg) | ||
} | ||
return undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import { hasConnections } from '@radixdlt/connector-extension/src/chrome/helpers/get-connections' | ||
import { createMessage as createRadixMessage } from '@radixdlt/connector-extension/src/chrome/messages/create-message' | ||
import type { Storage } from 'webextension-polyfill' | ||
|
||
import { sharedStore } from 'ui/src/store' | ||
|
||
import { getConnectionPassword } from '@src/browser/vault/storage' | ||
|
||
import { sendRadixMessageToDapp } from './radix' | ||
import { isHandledByRadix } from './radix-connector' | ||
|
||
export const checkConnectButtonStatus = async () => { | ||
const enabled = await isHandledByRadix() | ||
if (enabled) { | ||
const connectionPassword = await getConnectionPassword() | ||
sendRadixMessageToDapp(createRadixMessage.extensionStatus(!!connectionPassword)) | ||
hasConnections().map(has => sendRadixMessageToDapp(createRadixMessage.extensionStatus(has))) | ||
} else { | ||
await sharedStore.persist.rehydrate() | ||
const sharedState = sharedStore.getState() | ||
sendRadixMessageToDapp(createRadixMessage.extensionStatus(sharedState.keystores.length > 0)) | ||
} | ||
} | ||
|
||
export const onStorageChange = (changes: { [key: string]: Storage.StorageChange }) => { | ||
if (changes.connectionPassword) checkConnectButtonStatus() | ||
export const onStorageChange = (changes: { [key: string]: Storage.StorageChange }, area: string) => { | ||
if (changes.connections && area === 'local') { | ||
checkConnectButtonStatus() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.