@xyo-network/bridge-module-resolver 2.66.9 → 2.67.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,17 +2,17 @@ import { assertEx } from '@xylabs/assert'
2
2
  import { AddressPayload, AddressSchema } from '@xyo-network/address-payload-plugin'
3
3
  import { QueryBoundWitness } from '@xyo-network/boundwitness-builder'
4
4
  import { BridgeModule } from '@xyo-network/bridge-model'
5
- import { ModuleManifest } from '@xyo-network/manifest-model'
5
+ import { ManifestPayloadSchema, ModuleManifestPayload } from '@xyo-network/manifest-model'
6
6
  import {
7
7
  AddressPreviousHashPayload,
8
8
  BaseEmitter,
9
9
  CompositeModuleResolver,
10
- Module,
11
10
  ModuleConfig,
12
11
  ModuleDescription,
13
12
  ModuleEventData,
14
13
  ModuleFilter,
15
14
  ModuleFilterOptions,
15
+ ModuleInstance,
16
16
  ModuleParams,
17
17
  ModuleQueryResult,
18
18
  } from '@xyo-network/module'
@@ -33,23 +33,24 @@ export type ProxyModuleParams = ModuleParams<
33
33
  }
34
34
  >
35
35
 
36
- export class ProxyModule extends BaseEmitter<ProxyModuleParams, ModuleEventData> implements Module<ModuleParams, ModuleEventData> {
36
+ export class ProxyModule extends BaseEmitter<ModuleParams, ModuleEventData> implements ModuleInstance<ModuleParams, ModuleEventData> {
37
37
  readonly upResolver = new CompositeModuleResolver()
38
38
 
39
- constructor(params: ProxyModuleParams) {
40
- super(params)
39
+ constructor(public proxyParams: ProxyModuleParams) {
40
+ super({ config: proxyParams.bridge.targetConfig(proxyParams.address) })
41
41
  }
42
42
 
43
43
  get address() {
44
- return this.params.address.toLowerCase()
44
+ return this.proxyParams.address.toLowerCase()
45
45
  }
46
46
 
47
47
  get bridge() {
48
- return this.params.bridge
48
+ return this.proxyParams.bridge
49
49
  }
50
50
 
51
51
  get config(): ModuleConfig {
52
- return this.bridge.targetConfig(this.address)
52
+ const config = this.bridge.targetConfig(this.address)
53
+ return config
53
54
  }
54
55
 
55
56
  get downResolver() {
@@ -89,9 +90,13 @@ export class ProxyModule extends BaseEmitter<ProxyModuleParams, ModuleEventData>
89
90
  return this.bridge.targetDiscover()
90
91
  }
91
92
 
92
- manifest(): Promisable<ModuleManifest> {
93
+ manifest(): Promisable<ModuleManifestPayload> {
93
94
  const name = this.config.name ?? 'Anonymous'
94
- return { config: { name, ...this.config } }
95
+ return { config: { name, ...this.config }, schema: ManifestPayloadSchema }
96
+ }
97
+
98
+ moduleAddress(): Promise<AddressPreviousHashPayload[]> {
99
+ throw Error('Not Implemented')
95
100
  }
96
101
 
97
102
  previousHash(): Promise<string | undefined> {
@@ -109,9 +114,12 @@ export class ProxyModule extends BaseEmitter<ProxyModuleParams, ModuleEventData>
109
114
  }
110
115
 
111
116
  /* Resolves a filter from the perspective of the module, including through the parent/gateway module */
112
- resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<Module[]>
113
- resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<Module | undefined>
114
- async resolve(nameOrAddressOrFilter?: ModuleFilter | string, options?: ModuleFilterOptions): Promise<Module | Module[] | undefined> {
117
+ resolve(filter?: ModuleFilter, options?: ModuleFilterOptions): Promise<ModuleInstance[]>
118
+ resolve(nameOrAddress: string, options?: ModuleFilterOptions): Promise<ModuleInstance | undefined>
119
+ async resolve(
120
+ nameOrAddressOrFilter?: ModuleFilter | string,
121
+ options?: ModuleFilterOptions,
122
+ ): Promise<ModuleInstance | ModuleInstance[] | undefined> {
115
123
  if (typeof nameOrAddressOrFilter === 'string') {
116
124
  return await this.bridge.targetResolve(this.address, nameOrAddressOrFilter, options)
117
125
  } else {