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

Renamed App and Repo #93

Merged
merged 4 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api-reference/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Install a new app into the organization from a given [aragonPM repository](https

| Name | Type | Description |
| :------------------------ | :--------------------------- | :------------------------------------------------------------------------------------------------------------ |
| `repoName` | `String` | Repository name \(e.g. `voting.aragonpm.eth`\). |
| `repoName` | `String` | Name of the repo \(e.g. `voting.aragonpm.eth`\). |
| `options` | `Object` | Options object. |
| `options.initFuncName` | `String` | Name of the function that gets called to initialize the app. Set to `none` to skip. Defaults to `initialize`. |
| `options.initFuncArgs` | `Array<String>` | Arguments passed to the function set as `options.initFuncName`. Defaults to `[]`. |
Expand Down
6 changes: 2 additions & 4 deletions examples/nodejs/src/organization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect, Application, Organization } from '@aragon/connect'
import { connect, App, Organization } from '@aragon/connect'

const ORG_ADDRESS = '0x0c188b183ff758500d1d18b432313d10e9f6b8a4'

Expand All @@ -18,9 +18,7 @@ async function main() {
apps.map(console.log)

console.log('\nA voting app:')
const votingApp = apps.find(
(app: Application) => app.name == 'dandelion-voting'
)!
const votingApp = apps.find((app: App) => app.name == 'dandelion-voting')!
console.log(votingApp)

console.log('\nRoles of an app:')
Expand Down
6 changes: 3 additions & 3 deletions examples/nodejs/src/transaction-path.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from 'ethers'
import { connect, Application, Organization } from '@aragon/connect'
import { connect, App, Organization } from '@aragon/connect'

const network = 'mainnet'

Expand All @@ -14,7 +14,7 @@ async function main() {
})) as Organization

const apps = await org.apps()
const finance = apps.find((app: Application) => app.name == 'finance')!
const finance = apps.find((app: App) => app.name == 'finance')!

const intent = org.appIntent(finance.address, 'newImmediatePayment', [
ethers.constants.AddressZero,
Expand All @@ -27,7 +27,7 @@ async function main() {

console.log('\nTransactions on the path:')
txPath.transactions.map((tx: any) => console.log(tx))
txPath.transactionsDescribed.map((tx: any) => console.log(tx))
// txPath.transactionsDescribed.map((tx: any) => console.log(tx))
}

main()
Expand Down
6 changes: 3 additions & 3 deletions examples/org-viewer-web/src/OrgApps.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx jsx */
import { jsx } from '@emotion/core'
import { Application, Organization } from '@aragon/connect'
import { App, Organization } from '@aragon/connect'
import Group from './Group'
import Table from './Table'
import TextButton from './TextButton'
Expand All @@ -12,7 +12,7 @@ type Props = {
}

export default function OrgApps({ onOpenApp, org }: Props) {
const [apps = [], loading] = useCancellableAsync<Application[]>(
const [apps = [], loading] = useCancellableAsync<App[]>(
async () => (org ? org.apps() : []),
[org]
)
Expand All @@ -23,7 +23,7 @@ export default function OrgApps({ onOpenApp, org }: Props) {
headers={['Name', 'Version', 'Address']}
rows={[...apps]
.sort((a, b) => (a.name || '').localeCompare(b.name || ''))
.map((app: Application) => [
.map((app: App) => [
app.name || 'unknown',
app.version || '?',
<TextButton onClick={() => onOpenApp(app.address)}>
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-core/src/connections/ConnectorInterface.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Application from '../entities/Application'
import App from '../entities/App'
import Permission from '../entities/Permission'
import Repository from '../entities/Repository'
import Repo from '../entities/Repo'
import Role from '../entities/Role'

export interface ConnectorInterface {
chainId?: number
permissionsForOrg(orgAddress: string): Promise<Permission[]>
onPermissionsForOrg(orgAddress: string, callback: Function): { unsubscribe: Function }
appsForOrg(orgAddress: string): Promise<Application[]>
appsForOrg(orgAddress: string): Promise<App[]>
onAppsForOrg(orgAddress: string, callback: Function): { unsubscribe: Function }
repoForApp(appAddress: string): Promise<Repository>
appByAddress(appAddress: string): Promise<Application>
repoForApp(appAddress: string): Promise<Repo>
appByAddress(appAddress: string): Promise<App>
rolesForAddress(appAddress: string): Promise<Role[]>
}
8 changes: 4 additions & 4 deletions packages/connect-core/src/connections/ConnectorJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { ConnectorInterface } from './ConnectorInterface'
import Permission from '../entities/Permission'
import { Application, Repository, Role } from '..'
import { App, Repo, Role } from '..'

export type ConnectorJsonConfig = { permissions: Permission[] }

Expand All @@ -26,7 +26,7 @@ class ConnectorJson implements ConnectorInterface {
}
}

appsForOrg(orgAddress: string): Promise<Application[]> {
appsForOrg(orgAddress: string): Promise<App[]> {
return new Promise((resolve) => {
resolve([])
})
Expand All @@ -38,13 +38,13 @@ class ConnectorJson implements ConnectorInterface {
}
}

repoForApp(appAddress: string): Promise<Repository> {
repoForApp(appAddress: string): Promise<Repo> {
return new Promise((resolve) => {
resolve()
})
}

appByAddress(appAddress: string): Promise<Application> {
appByAddress(appAddress: string): Promise<App> {
return new Promise((resolve) => {
resolve()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Repository from './Repository'
import Repo from './Repo'
import Role from './Role'
import CoreEntity from './CoreEntity'
import { AragonArtifact, AppIntent, Abi, AragonManifest } from '../types'
Expand All @@ -8,7 +8,7 @@ import { ConnectorInterface } from '../connections/ConnectorInterface'
// TODO:
// [ ] (ipfs) contentUrl String The HTTP URL of the app content. Uses the IPFS HTTP provider. E.g. http://gateway.ipfs.io/ipfs/QmdLEDDfi…/ (ContentUri passing through the resolver)

export interface ApplicationData {
export interface AppData {
address: string
appId: string
artifact?: string | null
Expand All @@ -25,7 +25,7 @@ export interface ApplicationData {
version?: string
}

export default class Application extends CoreEntity implements ApplicationData {
export default class App extends CoreEntity implements AppData {
readonly abi?: Abi
readonly address!: string
readonly appId!: string
Expand All @@ -50,7 +50,7 @@ export default class Application extends CoreEntity implements ApplicationData {
readonly version?: string

constructor(
{ artifact, manifest, ...data }: ApplicationData,
{ artifact, manifest, ...data }: AppData,
connector: ConnectorInterface
) {
super(connector)
Expand Down Expand Up @@ -103,7 +103,7 @@ export default class Application extends CoreEntity implements ApplicationData {
this.version = data.version
}

async repo(): Promise<Repository> {
async repo(): Promise<Repo> {
return this._connector.repoForApp(this.address)
}

Expand Down
13 changes: 5 additions & 8 deletions packages/connect-core/src/entities/Organization.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { ethers } from 'ethers'
import { Network } from '@aragon/connect-types'

import Application from './Application'
import App from './App'
import TransactionIntent from '../transactions/TransactionIntent'
import Permission from './Permission'
import { ConnectorInterface } from '../connections/ConnectorInterface'

// TODO: Implement all properties and methods from the API spec (https://github.com/aragon/connect/blob/master/docs/organization.md).
// [x] Organization#apps()
// [x] Organization#onApps(cb)
// [x] Organization#app(appAddress)
// [ ] Organization#addApp(repoName, options)
// [ ] Organization#removeApp(appAddress)
Expand All @@ -19,10 +20,6 @@ import { ConnectorInterface } from '../connections/ConnectorInterface'
// [ ] Organization#appIntent(appAddress, funcName, funcArgs)
// [ ] Organization#appCall(appAddress, methodName, args)
// [ ] Organization#appState(appAddress)
// [ ] Organization#on(event, params, callback)
// [ ] Organization#off(event, callback)
// [ ] Organization#off(event)
// [ ] Organization#off()
// [ ] Events...

export default class Organization {
Expand Down Expand Up @@ -84,17 +81,17 @@ export default class Organization {
}

///////// APPS ///////////
async apps(): Promise<Application[]> {
async apps(): Promise<App[]> {
this.checkConnected()
return this._connector.appsForOrg(this.address)
}

onApps(callback: Function): { unsubscribe: Function } {
onApps(callback: (apps: App[]) => void): { unsubscribe: Function } {
this.checkConnected()
return this._connector.onAppsForOrg(this.address, callback)
}

async app(appAddress: string): Promise<Application> {
async app(appAddress: string): Promise<App> {
this.checkConnected()
return this._connector.appByAddress(appAddress)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-core/src/entities/Permission.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CoreEntity from './CoreEntity'
import Application from './Application'
import App from './App'
import Role from './Role'
import { ConnectorInterface } from '../connections/ConnectorInterface'

Expand Down Expand Up @@ -35,7 +35,7 @@ export default class Permission extends CoreEntity implements PermissionData {
this.roleHash = data.roleHash
}

async getApp(): Promise<Application> {
async getApp(): Promise<App> {
return this._connector.appByAddress(this.appAddress)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { parseMetadata } from '../utils/parseMetadata'
import { ConnectorInterface } from '../connections/ConnectorInterface'

export interface RepositoryData {
export interface RepoData {
address: string
artifact?: string | null
contentUri?: string | null
Expand All @@ -18,7 +18,7 @@ export interface RepositoryData {
registryAddress?: string | null
}

export default class Repository extends CoreEntity implements RepositoryData {
export default class Repo extends CoreEntity implements RepoData {
readonly address!: string
readonly author?: string
readonly changelogUrl?: string
Expand All @@ -34,7 +34,7 @@ export default class Repository extends CoreEntity implements RepositoryData {
readonly sourceUrl?: string

constructor(
{ artifact, manifest, ...data }: RepositoryData,
{ artifact, manifest, ...data }: RepoData,
connector: ConnectorInterface
) {
super(connector)
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export {
default as ConnectorJson,
ConnectorJsonConfig,
} from './connections/ConnectorJson'
export { default as Application, ApplicationData as AppData } from './entities/Application'
export { default as App, AppData } from './entities/App'
export { default as Organization } from './entities/Organization'
export { default as Permission, PermissionData } from './entities/Permission'
export { default as Repository, RepositoryData as RepoData } from './entities/Repository'
export { default as Repo, RepoData } from './entities/Repo'
export { default as Role, RoleData } from './entities/Role'
4 changes: 2 additions & 2 deletions packages/connect-core/src/transactions/TransactionIntent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ethers } from 'ethers'

import TransactionPath from './TransactionPath'
import TransactionRequest from './TransactionRequest'
import Application from '../entities/Application'
import App from '../entities/App'
import Organization from '../entities/Organization'
import { calculateTransactionPath } from '../utils/path/calculatePath'
import { describeTransactionPath } from '../utils/path/describePath'
Expand Down Expand Up @@ -67,7 +67,7 @@ export default class TransactionIntent {
),
destination: apps.find(
app => app.address == this.contractAddress
) as Application,
) as App,
forwardingFeePretransaction,
transactions: transactionsDescribed.map(tx => new TransactionRequest(tx)),
})
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-core/src/transactions/TransactionPath.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import TransactionRequest from './TransactionRequest'
import Application from '../entities/Application'
import App from '../entities/App'

export interface TransactionPathData {
apps: Application[]
destination: Application
apps: App[]
destination: App
forwardingFeePretransaction?: TransactionRequest
transactions: TransactionRequest[]
}

export default class TransactionPath {
readonly apps!: Application[]
readonly destination!: Application
readonly apps!: App[]
readonly destination!: App
readonly forwardingFeePretransaction?: TransactionRequest
readonly transactions!: TransactionRequest[]

Expand Down
2 changes: 1 addition & 1 deletion packages/connect-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface AppIntent {
export interface AragonManifest {
name: string // 'Counter'
author: string // 'Aragon Association'
description: string // 'An application for Aragon'
description: string // 'An app for Aragon'
changelog_url: string // 'https://github.com/aragon/aragon-apps/releases',
details_url: string // '/meta/details.md'
source_url: string // 'https://<placeholder-repository-url>'
Expand Down
12 changes: 6 additions & 6 deletions packages/connect-core/src/utils/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ethers } from 'ethers'

import { AppIntent } from '../types'
import Application from '../entities/Application'
import App from '../entities/App'
import { TransactionRequestData } from '../transactions/TransactionRequest'

// Is the given method a full signature, e.g. 'foo(arg1,arg2,...)'
Expand All @@ -16,15 +16,15 @@ export const isFullMethodSignature = (methodSignature: string): boolean => {
export function validateMethod(
destination: string,
methodSignature: string,
destinationApp: Application
destinationApp: App
): AppIntent {
const methods = destinationApp.intents
if (!methods) {
throw new Error(`No functions specified in artifact for ${destination}`)
}

// Find the relevant method information
const method = methods.find((method) =>
const method = methods.find(method =>
isFullMethodSignature(methodSignature)
? method.sig === methodSignature
: // If the full signature isn't given, just select the first overload declared
Expand All @@ -46,7 +46,7 @@ export function validateMethod(
* @return {Object|void} Method with radspec notice and function signature, or undefined if none was found
*/
export function findAppMethodFromIntent(
app: Application,
app: App,
transaction: TransactionRequestData
): AppIntent | undefined {
const methodId = transaction.data.substring(0, 10)
Expand All @@ -62,7 +62,7 @@ export function findAppMethodFromIntent(
let method
// First try to find the method in the current functions
if (Array.isArray(intents)) {
method = intents.find((method) => checkMethodSignature(method.sig))
method = intents.find(method => checkMethodSignature(method.sig))
}

if (!method) {
Expand All @@ -75,7 +75,7 @@ export function findAppMethodFromIntent(
const allDeprecatedFunctions = ([] as AppIntent[]).concat(
...deprecatedFunctionsFromVersions
)
method = allDeprecatedFunctions.find((method) =>
method = allDeprecatedFunctions.find(method =>
checkMethodSignature(method.sig)
)
}
Expand Down
Loading