Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: expose app names and identifiers in getApps() and getCurrentApp() #373

Merged
merged 1 commit into from Sep 1, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

API: expose app names and identifiers in getApps() and getCurrentApp()

  • Loading branch information...
sohkai committed Sep 1, 2019
commit de9405963b4d4528784b2bbe6adfe171df5cfe46
@@ -253,19 +253,16 @@ Returns **[Observable](https://rxjs-dev.firebaseapp.com/api/index/class/Observab
- `appAddress`: the app's contract address
- `appId`: the app's appId
- `appImplementationAddress`: the app's implementation contract, if any (only available if this app is a proxied AragonApp)
- `identifier`: the app's self-declared identifier, if any
- `isForwarder`: whether the app is a forwarder or not
- `kernelAddress`: the kernel address of the organization this app is installed on (always the same)
- `name`: the app's name, if available

### getCurrentApp

Get information about this app (e.g. `proxyAddress`, `abi`, etc.).

Returns **[Observable](https://rxjs-dev.firebaseapp.com/api/index/class/Observable)**: A single-emission observable that emits this app's details. The details include:
- `appAddress`: this app's contract address
- `appId`: this app's appId
- `appImplementationAddress`: this app's implementation contract, if any (only available if this app is a proxied AragonApp)
- `isForwarder`: whether this app is a forwarder or not
- `kernelAddress`: the kernel address of the organization this app is installed on
Returns **[Observable](https://rxjs-dev.firebaseapp.com/api/index/class/Observable)**: A single-emission observable that emits this app's details. The app's details include the same keys as in `getApps()`.

### call

@@ -106,15 +106,19 @@ test('should send a getApps request for all apps and observe the response', t =>
appAddress: '0x123',
appId: 'kernel',
appImplementationAddress: '0xkernel',
identifier: undefined,
isForwarder: false,
kernelAddress: undefined
kernelAddress: undefined,
name: 'Kernel'
}]
const endApps = [].concat(initialApps, {
appAddress: '0x456',
appId: 'counterApp',
appImplementationAddress: '0xcounterApp',
identifier: 'counter',
isForwarder: false,
kernelAddress: '0x123'
kernelAddress: '0x123',
name: 'Counter'
})

// arrange
@@ -162,8 +166,10 @@ test('should send a getApps request for the app and observe the single response'
appAddress: '0x456',
appId: 'counterApp',
appImplementationAddress: '0xcounterApp',
identifier: 'counter',
isForwarder: false,
kernelAddress: '0x123'
kernelAddress: '0x123',
name: 'Counter'
}

// arrange
@@ -1,5 +1,5 @@
// Externals
import { asyncScheduler, concat, from, merge, of, ReplaySubject, Subject, BehaviorSubject } from 'rxjs'
import { asyncScheduler, concat, from, merge, of, BehaviorSubject, ReplaySubject, Subject } from 'rxjs'
import {
concatMap,
debounceTime,
@@ -7,9 +7,9 @@ export default async function (request, proxy, wrapper) {
wrapper.decodeTransactionPath(script)
)

// TODO: remove this once the app has enough information to get this information itself
// (see https://github.com/aragon/aragon.js/issues/194)
// Add name and identifier decoration
// TODO: deprecate this now that the app has enough information to get this information itself
// through getApps()
const identifiers = await wrapper.appIdentifiers.pipe(first()).toPromise()
return Promise.all(
describedPath.map(async (step) => {
@@ -1,3 +1,4 @@
import { combineLatest } from 'rxjs'
import { first, map } from 'rxjs/operators'
import { addressesEqual } from '../../utils'

@@ -6,13 +7,17 @@ function transformAppInformation (app = {}) {
const {
appId,
contractAddress,
identifier,
isForwarder,
kernelAddress,
name,
proxyAddress
} = app

return {
identifier,
kernelAddress,
name,
appAddress: proxyAddress,
appId: appId,
appImplementationAddress: contractAddress,
@@ -32,12 +37,22 @@ export default function (request, proxy, wrapper) {
return wrapper.apps
}

const appWithIdentifier$ = combineLatest(wrapper.apps, wrapper.appIdentifiers).pipe(
map(([apps, identifiers]) =>
apps.map((app) =>
({
...app,
identifier: identifiers[app.proxyAddress]
})
)
)
)
const app$ = appCategory === 'current'
? wrapper.apps.pipe(
? appWithIdentifier$.pipe(
map(apps => apps.find(app => addressesEqual(app.proxyAddress, proxy.address))),
map((app) => transformAppInformation(app))
)
: wrapper.apps.pipe(
: appWithIdentifier$.pipe(
map((apps) => apps.map(transformAppInformation))
)
if (operation === 'observe') {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.