Skip to content

Commit

Permalink
Merge pull request #643 from airgap-it/feat/run-prettier
Browse files Browse the repository at this point in the history
chore: run prettier
  • Loading branch information
AndreasGassmann authored Nov 3, 2023
2 parents 693ef93 + 5d61cd5 commit 5466f7e
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/beacon-core/src/managers/AccountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AccountManager {
}

public async getAccounts(): Promise<AccountInfo[]> {
return await this.storageManager.getAll() ?? []
return (await this.storageManager.getAll()) ?? []
}

public async getAccount(accountIdentifier: string): Promise<AccountInfo | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-core/src/managers/AppMetadataManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class AppMetadataManager {
}

public async getAppMetadataList(): Promise<AppMetadata[]> {
return await this.storageManager.getAll() ?? []
return (await this.storageManager.getAll()) ?? []
}

public async getAppMetadata(senderId: string): Promise<AppMetadata | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-core/src/managers/PeerManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class PeerManager<
}

public async getPeers(): Promise<StorageKeyReturnType[T]> {
return await this.storageManager.getAll() ?? []
return (await this.storageManager.getAll()) ?? []
}

public async getPeer(publicKey: string): Promise<ArrayElem<StorageKeyReturnType[T]> | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-core/src/managers/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class StorageManager<
}

public async getAll(): Promise<StorageKeyReturnType[T]> {
return await this.storage.get(this.storageKey) ?? []
return (await this.storage.get(this.storageKey)) ?? []
}

public async getOne(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,5 @@ export abstract class CommunicationClient {
abstract unsubscribeFromEncryptedMessages(): Promise<void>
abstract unsubscribeFromEncryptedMessage(senderPublicKey: string): Promise<void>
// abstract send(message: string, recipient?: string): Promise<void>
public abstract sendMessage(
message: string,
peer?: PeerInfoType
): Promise<void>
public abstract sendMessage(message: string, peer?: PeerInfoType): Promise<void>
}
12 changes: 10 additions & 2 deletions packages/beacon-core/src/transports/clients/MessageBasedClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export abstract class MessageBasedClient extends CommunicationClient {
*/
protected abstract readonly activeListeners: Map<string, unknown>

constructor(protected readonly name: string, keyPair: KeyPair) {
constructor(
protected readonly name: string,
keyPair: KeyPair
) {
super(keyPair)
this.init().catch(console.error)
}
Expand Down Expand Up @@ -51,7 +54,12 @@ export abstract class MessageBasedClient extends CommunicationClient {
public async getPairingResponseInfo(
request: PostMessagePairingRequest
): Promise<PostMessagePairingResponse> {
return new PostMessagePairingResponse(request.id, this.name, await this.getPublicKey(), request.version)
return new PostMessagePairingResponse(
request.id,
this.name,
await this.getPublicKey(),
request.version
)
}

/**
Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-dapp/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ const showNoPermissionAlert = async (): Promise<void> => {
}

/**
* Show a
* Show a
*/
const showInvalidActiveAccountState = async (): Promise<void> => {
await openAlert({
Expand Down Expand Up @@ -744,7 +744,9 @@ export class BeaconEventHandler {
[BeaconEvent.NO_PERMISSIONS]: [defaultEventCallbacks.NO_PERMISSIONS],
[BeaconEvent.ACTIVE_ACCOUNT_SET]: [defaultEventCallbacks.ACTIVE_ACCOUNT_SET],
[BeaconEvent.ACTIVE_TRANSPORT_SET]: [defaultEventCallbacks.ACTIVE_TRANSPORT_SET],
[BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: [defaultEventCallbacks.INVALID_ACTIVE_ACCOUNT_STATE],
[BeaconEvent.INVALID_ACTIVE_ACCOUNT_STATE]: [
defaultEventCallbacks.INVALID_ACTIVE_ACCOUNT_STATE
],
[BeaconEvent.SHOW_PREPARE]: [defaultEventCallbacks.SHOW_PREPARE],
[BeaconEvent.HIDE_UI]: [defaultEventCallbacks.HIDE_UI],
[BeaconEvent.PAIR_INIT]: [defaultEventCallbacks.PAIR_INIT],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,12 @@ export class P2PCommunicationClient extends CommunicationClient {
logger.log(`Waiting for join... Try: ${retry}`)

return new Promise((resolve) => {
setTimeout(async () => {
resolve(this.waitForJoin(roomId, retry + 1))
}, 100 * (retry > 50 ? 10 : 1)) // After the initial 5 seconds, retry only once per second
setTimeout(
async () => {
resolve(this.waitForJoin(roomId, retry + 1))
},
100 * (retry > 50 ? 10 : 1)
) // After the initial 5 seconds, retry only once per second
})
} else {
throw new Error(`No one joined after ${retry} tries.`)
Expand Down Expand Up @@ -710,17 +713,15 @@ export class P2PCommunicationClient extends CommunicationClient {
? new PeerManager(this.storage, StorageKey.TRANSPORT_P2P_PEERS_DAPP)
: new PeerManager(this.storage, StorageKey.TRANSPORT_P2P_PEERS_WALLET)
const peers = await manager.getPeers()
const promiseArray = peers.map(
async (peer) => {
const hash = `@${await getHexHash(Buffer.from(peer.publicKey, 'hex'))}`
if (hash === senderHash) {
if (peer.relayServer !== relayServer) {
peer.relayServer = relayServer
await manager.addPeer(peer as ExtendedP2PPairingResponse)
}
const promiseArray = peers.map(async (peer) => {
const hash = `@${await getHexHash(Buffer.from(peer.publicKey, 'hex'))}`
if (hash === senderHash) {
if (peer.relayServer !== relayServer) {
peer.relayServer = relayServer
await manager.addPeer(peer as ExtendedP2PPairingResponse)
}
}
)
})
await Promise.all(promiseArray)
}

Expand Down
5 changes: 4 additions & 1 deletion packages/beacon-transport-walletconnect/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export class ActiveAccountUnspecified extends Error {
export class InvalidNetworkOrAccount extends Error {
name = 'InvalidNetworkOrAccount'

constructor(public network: string, public pkh: string) {
constructor(
public network: string,
public pkh: string
) {
super(
`No permission. The combinaison "${network}" and "${pkh}" is not part of the active session.`
)
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-ui/src/components/pair-other/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
align-items: center;
justify-content: center;
color: #b5b8be;
}
}
10 changes: 4 additions & 6 deletions packages/beacon-ui/src/ui/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,10 @@ const openAlert = async (config: AlertConfig): Promise<string> => {
}
description={
hasExtension()
? `Please connect below to use your ${
currentWallet()?.name
} Wallet browser extension.`
: `To connect your ${
currentWallet()?.name
} Wallet, install the browser extension.`
? `Please connect below to use your ${currentWallet()
?.name} Wallet browser extension.`
: `To connect your ${currentWallet()
?.name} Wallet, install the browser extension.`
}
buttons={
hasExtension()
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-ui/src/ui/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let globalTimeout: NodeJS.Timeout
const createToast = (config: ToastConfig) => {
const shadowRootEl = document.createElement('div')
if (document.getElementById('beacon-toast-wrapper')) {
(document.getElementById('beacon-toast-wrapper') as HTMLElement).remove()
;(document.getElementById('beacon-toast-wrapper') as HTMLElement).remove()
}
shadowRootEl.setAttribute('id', 'beacon-toast-wrapper')
shadowRootEl.style.height = '0px'
Expand Down
6 changes: 4 additions & 2 deletions packages/beacon-ui/src/utils/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ const isIpad = (win: Window): boolean => {

export const isPrivacyBrowser = (win: Window): boolean => testUserAgent(win, /Mobile DuckDuckGo/i)

export const isIOS = (win: Window): boolean => isPrivacyBrowser(win) || testUserAgent(win, /iPhone|iPod|Mobile DuckDuckGo/i) || isIpad(win)
export const isIOS = (win: Window): boolean =>
isPrivacyBrowser(win) || testUserAgent(win, /iPhone|iPod|Mobile DuckDuckGo/i) || isIpad(win)

export const isAndroid = (win: Window): boolean => !isPrivacyBrowser(win) && testUserAgent(win, /android|sink/i)
export const isAndroid = (win: Window): boolean =>
!isPrivacyBrowser(win) && testUserAgent(win, /android|sink/i)

export const isTwBrowser = (win: Window): boolean => win && (win as any).ethereum?.isTrust == true

Expand Down

0 comments on commit 5466f7e

Please sign in to comment.