Skip to content

Commit

Permalink
chore(format): prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasGassmann committed Apr 30, 2020
1 parent 71c75d4 commit 100c124
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 79 deletions.
60 changes: 30 additions & 30 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or the definition README at
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node-12
{
"name": "Node.js 12 Custom",
"dockerFile": "Dockerfile",
//
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
},
//
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
// "appPort": [],
//
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "yarn install",
//
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
// On Linux, by default, the container user's UID/GID will be updated to match your local user. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "node",
//
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"dbaeumer.vscode-eslint",
// TSLint is included for backwards compatibility, but is deprecated.
// See https://github.com/palantir/tslint/issues/4534
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
}
"name": "Node.js 12 Custom",
"dockerFile": "Dockerfile",
//
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh"
},
//
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
// "appPort": [],
//
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "yarn install",
//
// Uncomment the next line to have VS Code connect as an existing non-root user in the container.
// On Linux, by default, the container user's UID/GID will be updated to match your local user. See
// https://aka.ms/vscode-remote/containers/non-root for details on adding a non-root user if none exist.
// "remoteUser": "node",
//
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"dbaeumer.vscode-eslint",
// TSLint is included for backwards compatibility, but is deprecated.
// See https://github.com/palantir/tslint/issues/4534
"ms-vscode.vscode-typescript-tslint-plugin",
"esbenp.prettier-vscode"
]
}
2 changes: 1 addition & 1 deletion src/P2PCommunicationClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class P2PCommunicationClient {
private readonly keyPair: sodium.KeyPair,
public readonly replicationCount: number,
private readonly debug: boolean = false
) { }
) {}

public getHandshakeInfo(): { name: string; pubKey: string; relayServer: string } {
return {
Expand Down
5 changes: 4 additions & 1 deletion src/clients/dapp-client/DAppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ export class DAppClient extends Client {
...requestInput
}

const exposed = new ExposedPromise<{ message: BeaconMessage; connectionInfo: ConnectionContext }, BeaconErrorMessage>()
const exposed = new ExposedPromise<
{ message: BeaconMessage; connectionInfo: ConnectionContext },
BeaconErrorMessage
>()
this.addOpenRequest(request.id, exposed)

const payload = await new Serializer().serialize(request)
Expand Down
42 changes: 21 additions & 21 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ const showQrCode = async (
await openAlert(alertConfig)
}

const emptyHandler = (eventType: BeaconEvent): BeaconEventHandlerFunction =>
async (data?: unknown): Promise<void> => {
logger.log('emptyHandler', eventType, data)

}
const emptyHandler = (eventType: BeaconEvent): BeaconEventHandlerFunction => async (
data?: unknown
): Promise<void> => {
logger.log('emptyHandler', eventType, data)
}

export type BeaconEventHandlerFunction<T = unknown> = (data: T) => void | Promise<void>

Expand Down Expand Up @@ -122,22 +122,22 @@ export class BeaconEventHandler {
private readonly callbackMap: {
[key in BeaconEvent]: BeaconEventHandlerFunction<any>[]
} = {
[BeaconEvent.PERMISSION_REQUEST_SENT]: [defaultEventCallbacks.PERMISSION_REQUEST_SENT],
[BeaconEvent.PERMISSION_REQUEST_ERROR]: [defaultEventCallbacks.PERMISSION_REQUEST_ERROR],
[BeaconEvent.OPERATION_REQUEST_SENT]: [defaultEventCallbacks.OPERATION_REQUEST_SENT],
[BeaconEvent.OPERATION_REQUEST_ERROR]: [defaultEventCallbacks.OPERATION_REQUEST_ERROR],
[BeaconEvent.SIGN_REQUEST_SENT]: [defaultEventCallbacks.SIGN_REQUEST_SENT],
[BeaconEvent.SIGN_REQUEST_ERROR]: [defaultEventCallbacks.SIGN_REQUEST_ERROR],
[BeaconEvent.BROADCAST_REQUEST_SENT]: [defaultEventCallbacks.BROADCAST_REQUEST_SENT],
[BeaconEvent.BROADCAST_REQUEST_ERROR]: [defaultEventCallbacks.BROADCAST_REQUEST_ERROR],
[BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: [defaultEventCallbacks.LOCAL_RATE_LIMIT_REACHED],
[BeaconEvent.NO_PERMISSIONS]: [defaultEventCallbacks.NO_PERMISSIONS],
[BeaconEvent.ACTIVE_ACCOUNT_SET]: [defaultEventCallbacks.ACTIVE_ACCOUNT_SET],
[BeaconEvent.ACTIVE_TRANSPORT_SET]: [defaultEventCallbacks.ACTIVE_TRANSPORT_SET],
[BeaconEvent.P2P_CHANNEL_CONNECT_SUCCESS]: [defaultEventCallbacks.P2P_CHANNEL_CONNECT_SUCCESS],
[BeaconEvent.P2P_LISTEN_FOR_CHANNEL_OPEN]: [defaultEventCallbacks.P2P_LISTEN_FOR_CHANNEL_OPEN],
[BeaconEvent.UNKNOWN]: [defaultEventCallbacks.UNKNOWN]
}
[BeaconEvent.PERMISSION_REQUEST_SENT]: [defaultEventCallbacks.PERMISSION_REQUEST_SENT],
[BeaconEvent.PERMISSION_REQUEST_ERROR]: [defaultEventCallbacks.PERMISSION_REQUEST_ERROR],
[BeaconEvent.OPERATION_REQUEST_SENT]: [defaultEventCallbacks.OPERATION_REQUEST_SENT],
[BeaconEvent.OPERATION_REQUEST_ERROR]: [defaultEventCallbacks.OPERATION_REQUEST_ERROR],
[BeaconEvent.SIGN_REQUEST_SENT]: [defaultEventCallbacks.SIGN_REQUEST_SENT],
[BeaconEvent.SIGN_REQUEST_ERROR]: [defaultEventCallbacks.SIGN_REQUEST_ERROR],
[BeaconEvent.BROADCAST_REQUEST_SENT]: [defaultEventCallbacks.BROADCAST_REQUEST_SENT],
[BeaconEvent.BROADCAST_REQUEST_ERROR]: [defaultEventCallbacks.BROADCAST_REQUEST_ERROR],
[BeaconEvent.LOCAL_RATE_LIMIT_REACHED]: [defaultEventCallbacks.LOCAL_RATE_LIMIT_REACHED],
[BeaconEvent.NO_PERMISSIONS]: [defaultEventCallbacks.NO_PERMISSIONS],
[BeaconEvent.ACTIVE_ACCOUNT_SET]: [defaultEventCallbacks.ACTIVE_ACCOUNT_SET],
[BeaconEvent.ACTIVE_TRANSPORT_SET]: [defaultEventCallbacks.ACTIVE_TRANSPORT_SET],
[BeaconEvent.P2P_CHANNEL_CONNECT_SUCCESS]: [defaultEventCallbacks.P2P_CHANNEL_CONNECT_SUCCESS],
[BeaconEvent.P2P_LISTEN_FOR_CHANNEL_OPEN]: [defaultEventCallbacks.P2P_LISTEN_FOR_CHANNEL_OPEN],
[BeaconEvent.UNKNOWN]: [defaultEventCallbacks.UNKNOWN]
}

public async on<K extends BeaconEvent>(
event: K,
Expand Down
4 changes: 1 addition & 3 deletions src/transports/P2PTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ export class P2PTransport extends Transport {
public async send(message: string): Promise<void> {
const knownPeers = await this.storage.get(StorageKey.TRANSPORT_P2P_PEERS)

const promises = knownPeers.map((peer) => {
return this.client.sendMessage(peer.pubKey, message)
})
const promises = knownPeers.map((peer) => this.client.sendMessage(peer.pubKey, message))

return (await Promise.all(promises))[0]
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/check-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BeaconMessageType, PermissionScope } from ".."
import { BeaconMessageType, PermissionScope } from '..'

export const checkPermissions = async (
type: BeaconMessageType,
Expand All @@ -15,4 +15,4 @@ export const checkPermissions = async (
default:
return false
}
}
}
34 changes: 16 additions & 18 deletions src/utils/exposed-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,25 @@ export class ExposedPromise<T, U = unknown> {
}

constructor() {
this._promise = new Promise<T>(
(innerResolve: Resolve<T>, innerReject: Reject<U>): void => {
this._resolve = async (value?: T | PromiseLike<T>): Promise<void> => {
this._status = ExposedPromiseStatus.PENDING
try {
this._promiseResult = await value
} catch (innerReason) {
return innerReject(innerReason)
}
this._status = ExposedPromiseStatus.RESOLVED

return innerResolve(value)
this._promise = new Promise<T>((innerResolve: Resolve<T>, innerReject: Reject<U>): void => {
this._resolve = async (value?: T | PromiseLike<T>): Promise<void> => {
this._status = ExposedPromiseStatus.PENDING
try {
this._promiseResult = await value
} catch (innerReason) {
return innerReject(innerReason)
}
this._reject = async (reason?: U | PromiseLike<U>): Promise<void> => {
this._status = ExposedPromiseStatus.REJECTED
this._promiseError = await reason
this._status = ExposedPromiseStatus.RESOLVED

return innerReject(reason)
}
return innerResolve(value)
}
this._reject = async (reason?: U | PromiseLike<U>): Promise<void> => {
this._status = ExposedPromiseStatus.REJECTED
this._promiseError = await reason

return innerReject(reason)
}
)
})
}

public isPending(): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-account-identifier.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from ".."
import { Network } from '..'

export const getAccountIdentifier = async (pubkey: string, network: Network): Promise<string> => {
const data: string[] = [pubkey, network.type]
Expand All @@ -10,4 +10,4 @@ export const getAccountIdentifier = async (pubkey: string, network: Network): Pr
}

return data.join('-')
}
}
2 changes: 1 addition & 1 deletion src/utils/is-extension-installed.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { PostMessageTransport } from "../transports/PostMessageTransport"
import { PostMessageTransport } from '../transports/PostMessageTransport'

export const isChromeExtensionInstalled = PostMessageTransport.isAvailable()

0 comments on commit 100c124

Please sign in to comment.