Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add-new-server-regions
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasGassmann committed Nov 20, 2023
2 parents 4e07965 + 5f0b170 commit 475a0dd
Show file tree
Hide file tree
Showing 22 changed files with 77 additions and 52 deletions.
2 changes: 0 additions & 2 deletions beacon.js

This file was deleted.

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
6 changes: 4 additions & 2 deletions packages/beacon-core/src/storage/LocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Storage, StorageKey, StorageKeyReturnType, defaultValues } from '@airga
*
* A storage that can be used in the browser
*/
export class LocalStorage implements Storage {
constructor(private readonly prefix?: string) {}
export class LocalStorage extends Storage {
constructor(private readonly prefix?: string) {
super()
}
public static async isSupported(): Promise<boolean> {
return Promise.resolve(Boolean(typeof window !== 'undefined') && Boolean(window.localStorage))
}
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
2 changes: 1 addition & 1 deletion packages/beacon-dapp/src/utils/tzkt-blockexplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class TzktBlockExplorer extends BlockExplorer {
public readonly rpcUrls: { [key in NetworkType]: string } = {
[NetworkType.MAINNET]: 'https://tzkt.io',
[NetworkType.GHOSTNET]: 'https://ghostnet.tzkt.io',
[NetworkType.MONDAYNET]: 'https://mondaynet.tzkt.io',
[NetworkType.WEEKLYNET]: 'https://weeklynet.tzkt.io',
[NetworkType.DAILYNET]: 'https://dailynet.tzkt.io',
[NetworkType.DELPHINET]: 'https://delphinet.tzkt.io',
[NetworkType.EDONET]: 'https://edonet.tzkt.io',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ export class MatrixClientStore {
/**
* Listeners that will be called when the state changes
*/
private readonly onStateChangedListeners: Map<
keyof MatrixState | 'all',
OnStateChangedListener
> = new Map()
private readonly onStateChangedListeners: Map<keyof MatrixState | 'all', OnStateChangedListener> =
new Map()

/**
* A promise that resolves once the client is ready
*/
private waitReadyPromise: Promise<void> = new Promise<void>(async (resolve, reject) => {
try {
await this.initFromStorage()
resolve()
} catch (error) {
reject(error)
}
})

constructor(private readonly storage: Storage) {}
private waitReadyPromise: Promise<void>

constructor(private readonly storage: Storage) {
this.waitReadyPromise = new Promise<void>(async (resolve, reject) => {
try {
await this.initFromStorage()
resolve()
} catch (error) {
reject(error)
}
})
}

/**
* Get an item from the state
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-types/src/types/beacon/NetworkType.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export enum NetworkType {
MAINNET = 'mainnet',
GHOSTNET = 'ghostnet', // Long running testnet
MONDAYNET = 'mondaynet', // Testnet, resets every monday
WEEKLYNET = 'weeklynet', // Testnet, resets every week
DAILYNET = 'dailynet', // Testnet, resets every day
DELPHINET = 'delphinet',
EDONET = 'edonet',
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-types/src/types/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface WebApp extends AppBase {
links: {
[NetworkType.MAINNET]: string
[NetworkType.GHOSTNET]?: string
[NetworkType.MONDAYNET]?: string
[NetworkType.WEEKLYNET]?: string
[NetworkType.DAILYNET]?: string
[NetworkType.DELPHINET]?: string
[NetworkType.EDONET]?: string
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;
}
}
21 changes: 18 additions & 3 deletions packages/beacon-ui/src/components/toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,26 @@ const Toast: Component<ToastProps> = (props: ToastProps) => {

const onMouseDownHandler = (event: MouseEvent) => {
event.preventDefault() // prevents inner text highlighting
const boundinRect = (event.target as HTMLElement).getBoundingClientRect()
const target = event.target as HTMLElement

if (target.className !== 'toast-header' && target.parentElement?.className !== 'toast-header') {
return
}

const boundinRect = target.getBoundingClientRect()
offset.x = event.clientX - boundinRect.x
offset.y = event.clientY - boundinRect.y
setIsDragging(true)
}

const onMouseMoveHandler = (event: MouseEvent) => {
if (isDragging() && event.buttons === 1) {
const newX = Math.min(Math.max(event.clientX - offset.x, 0), window.innerWidth - 460)
const newY = Math.min(Math.max(event.clientY - offset.y, 0), window.innerHeight - 12)

setDivPosition({
x: event.clientX - offset.x,
y: event.clientY - offset.y
x: newX,
y: newY
})
}
}
Expand All @@ -74,6 +83,10 @@ const Toast: Component<ToastProps> = (props: ToastProps) => {
setIsDragging(false)
}

const onClickHandler = () => {
setIsDragging(false)
}

// when the mouse is out of the div boundaries but it is still pressed, keep moving the toast
createEffect(() => {
if (isDragging()) {
Expand All @@ -97,6 +110,8 @@ const Toast: Component<ToastProps> = (props: ToastProps) => {
style={{ left: `${divPosition().x}px`, top: `${divPosition().y}px` }}
class={props.open ? 'toast-wrapper-show' : 'toast-wrapper-hide'}
onMouseDown={onMouseDownHandler}
onClick={onClickHandler}
onDblClick={onClickHandler}
>
<div class="toast-header">
<Loader />
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-ui/src/components/toast/styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.toast-wrapper-show {
cursor: move;
max-width: 460px;
overflow: hidden;
background-color: white;
Expand Down Expand Up @@ -32,6 +31,7 @@
}

.toast-header {
cursor: move;
padding: 0px 0.6em 0px 1.2em;
display: flex;
align-items: center;
Expand Down
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
2 changes: 1 addition & 1 deletion scripts/blockchains/tezos-sapling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App, DesktopApp, ExtensionApp, WebApp } from 'packages/beacon-types/src
export enum NetworkType {
MAINNET = 'mainnet',
GHOSTNET = 'ghostnet', // Long running testnet
MONDAYNET = 'mondaynet', // Testnet, resets every monday
WEEKLYNET = 'weeklynet', // Testnet, resets every week
DAILYNET = 'dailynet', // Testnet, resets every day
DELPHINET = 'delphinet',
EDONET = 'edonet',
Expand Down
6 changes: 3 additions & 3 deletions scripts/blockchains/tezos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { App, DesktopApp, ExtensionApp, WebApp } from 'packages/beacon-types/src
export enum NetworkType {
MAINNET = 'mainnet',
GHOSTNET = 'ghostnet', // Long running testnet
MONDAYNET = 'mondaynet', // Testnet, resets every monday
WEEKLYNET = 'weeklynet', // Testnet, resets every week
DAILYNET = 'dailynet', // Testnet, resets every day
DELPHINET = 'delphinet',
EDONET = 'edonet',
Expand Down Expand Up @@ -61,7 +61,7 @@ export const tezosWebList: WebApp[] = [
links: {
[NetworkType.MAINNET]: 'https://metamask.tezos.com/',
[NetworkType.GHOSTNET]: 'https://metamask.tezos.com/',
[NetworkType.MONDAYNET]: 'https://metamask.tezos.com/',
[NetworkType.WEEKLYNET]: 'https://metamask.tezos.com/',
[NetworkType.DAILYNET]: 'https://metamask.tezos.com/',
[NetworkType.DELPHINET]: 'https://metamask.tezos.com/',
[NetworkType.EDONET]: 'https://metamask.tezos.com/',
Expand All @@ -86,7 +86,7 @@ export const tezosWebList: WebApp[] = [
links: {
[NetworkType.MAINNET]: 'https://wallet.kukai.app',
[NetworkType.GHOSTNET]: 'https://ghostnet.kukai.app',
[NetworkType.MONDAYNET]: 'https://mondaynet.kukai.app',
[NetworkType.WEEKLYNET]: 'https://weeklynet.kukai.app',
[NetworkType.DAILYNET]: 'https://dailynet.kukai.app',
[NetworkType.DELPHINET]: 'https://testnet.kukai.app',
[NetworkType.EDONET]: 'https://edonet.kukai.app',
Expand Down

0 comments on commit 475a0dd

Please sign in to comment.