Skip to content

Commit

Permalink
Release (#640)
Browse files Browse the repository at this point in the history
* u

* u

* f

* u

* u

* u

* u

* u
  • Loading branch information
felicio authored Jan 7, 2025
1 parent 1274bd9 commit 5d34c08
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 44 deletions.
14 changes: 13 additions & 1 deletion apps/connector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Status Desktop Wallet extended to decentralized applications in your browser.

Depends on:

- Status Desktop https://github.com/status-im/status-desktop/tree/release/2.30.x
- **[Status Desktop](https://github.com/status-im/status-desktop/releases)** >=2.32.x

Tested with these browsers:

Expand Down Expand Up @@ -87,6 +87,18 @@ Firefox Developer Edition > Tools > Add-ons and Themes > click on gear icon (Too

> Note: Does not reload automatically, requires build and load on change.
### Status Desktop

#### Run

##### macOS

```bash
FLAG_CONNECTOR_ENABLED=1 '/Volumes/Status Desktop/Status.app/Contents/MacOS/nim_status_client'
```

> Tip: Point to the installer package location without dropping and replacing current app.
## Testing

Download latest build from last merged PR or build from source. To use the extension see the load steps from [Development](#development) section.
10 changes: 7 additions & 3 deletions apps/connector/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default [
...configs,
...tailwindcssConfigs,
{
files: ['*.ts', '*.tsx'],
files: ['**/*.ts', '**/*.tsx'],
rules: {
'no-constant-binary-expression': 'error',
'no-restricted-globals': ['error', 'process'],
Expand All @@ -15,10 +15,11 @@ export default [
img: [],
},
],
'no-empty': 'warn',
},
},
{
files: ['*.mjs'],
files: ['**/*.mjs'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
Expand All @@ -27,11 +28,14 @@ export default [
},
},
{
files: ['*.js'],
files: ['**/*.js'],
languageOptions: {
parserOptions: {
ecmaVersion: 'latest',
},
},
},
{
ignores: ['.plasmo'],
},
]
11 changes: 7 additions & 4 deletions apps/connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@
},
"manifest": {
"manifest_version": 3,
"name": "A wallet connector by Status BETA",
"description": "THIS EXTENSION IS FOR BETA TESTING. Status Desktop Wallet extended to decentralised applications in your browser.",
"name": "A wallet connector by Status",
"description": "Status Desktop Wallet extended to decentralised applications in your browser.",
"externally_connectable": {
"ids": [],
"matches": []
},
"host_permissions": [
"https://*/*",
"https://chromewebstore.google.com/*"
"https://*/*"
],
"permissions": [
"storage"
Expand Down
22 changes: 6 additions & 16 deletions apps/connector/src/contents/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,18 @@ export class Provider {
this.#listeners.get('connect')?.({ chainId: '0x1' })
this.#listeners.get('connected')?.({ chainId: '0x1' })
this.connected = true

console.log('connected::')
}

if (method === 'wallet_switchEthereumChain') {
this.#listeners.get('chainChanged')?.(message.data)
this.#listeners.get('networkChanged')?.(message.data)

console.log('chainChanged::')
}

resolve(message.data)

return
}
case 'status:proxy:error': {
console.error(message.error)

// note: for those dApps that make call after having permissions revoked
if (
message.error.message === 'dApp is not permitted by user' &&
Expand Down Expand Up @@ -154,21 +148,15 @@ export class Provider {
}

public on(event: Event, handler: (args: unknown) => void): void {
console.log('on::', event, handler)

this.#listeners.set(event, handler)
}

/** @deprecated */
public async close(...args: unknown[]): Promise<void> {
console.log('close::', args)

public async close(): Promise<void> {
this.disconnect()
}

public removeListener(event: Event, handler: (args: unknown) => void): void {
console.log('removeListener::', event, handler)

public removeListener(event: Event): void {
// note: not all dapps remove these on disconnect
if (event === 'close' || event === 'disconnect') {
this.disconnect()
Expand All @@ -177,15 +165,17 @@ export class Provider {
this.#listeners.delete(event)
}

public async enable() {
return true
}

private async disconnect() {
if (!this.connected) {
return
}

this.connected = false

console.log('disconnect::')

await this.request({
method: 'wallet_revokePermissions',
params: [
Expand Down
4 changes: 0 additions & 4 deletions apps/connector/src/contents/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,13 @@ const handleMessage = async (event: MessageEvent) => {
}

try {
console.log('request::', message.data)

const response = await desktopClient.send({
...message.data,
name: window.location.hostname,
url: window.origin,
iconUrl: getFaviconUrl() ?? '',
})

console.log('response::', response)

event.ports[0].postMessage({
type: 'status:proxy:success',
data: response,
Expand Down
7 changes: 2 additions & 5 deletions apps/connector/src/hooks/use-local-storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export function useLocalStorage<T>(
try {
const item = window.localStorage.getItem(key)
setStoredValue(item ? JSON.parse(item) : initialValue)
} catch (error) {
console.log(error)
} catch {
setStoredValue(initialValue)
}
}, [])
Expand Down Expand Up @@ -40,9 +39,7 @@ export function useLocalStorage<T>(
setStoredValue(valueToStore)
window.localStorage.setItem(key, JSON.stringify(valueToStore))
window.dispatchEvent(new Event('storage'))
} catch (error) {
console.log(error)
}
} catch {}
}

return [storedValue, setValue]
Expand Down
11 changes: 0 additions & 11 deletions apps/connector/src/lib/desktop-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class DesktopClient {
return
}

console.log('stop::')
this.#rpcClient?.destroy()
this.#rpcClient = null

Expand All @@ -28,7 +27,6 @@ export class DesktopClient {

public async send(args: DesktopRequestArguments) {
if (!this.#rpcClient) {
console.log('start::')
this.#rpcClient = new WebSocketProvider(
config.desktop.rpc.url,
'mainnet',
Expand All @@ -43,11 +41,6 @@ export class DesktopClient {

await waitUntilOpen(this.#rpcClient.websocket)

console.log('client::', {
method: config.desktop.rpc.method,
params: [JSON.stringify(args)],
})

return await this.#rpcClient.send(config.desktop.rpc.method, [
JSON.stringify(args),
])
Expand Down Expand Up @@ -78,10 +71,6 @@ async function waitUntilOpen(websocket: WebSocketLike) {
reject(new Error('Timed out to connect to the RPC server'))
}, 30 * 1000)

if (websocket.readyState === WebSocket.CONNECTING) {
console.info('Waiting for the RPC server to connect')
}

const onopen = websocket.onopen?.bind(websocket)
websocket.onopen = event => {
onopen?.(event)
Expand Down

0 comments on commit 5d34c08

Please sign in to comment.