Skip to content

Commit

Permalink
manifest now has wallet support
Browse files Browse the repository at this point in the history
  • Loading branch information
arietrouw committed Jun 28, 2023
1 parent fa30871 commit 402175e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/manifest/src/ManifestWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { assertEx } from '@xylabs/assert'
import { CreatableModuleDictionary } from '@xyo-network/module'
import { MemoryNode, NodeWrapper } from '@xyo-network/node'
import { PayloadWrapper } from '@xyo-network/payload-wrapper'
import { WalletInstance } from '@xyo-network/wallet-model'

import { standardCreatableModules } from './ModuleFactory'
import { DappManifest, ManifestPayload, ModuleManifest } from './Payload'

export class ManifestWrapper extends PayloadWrapper<ManifestPayload> {
constructor(payload: ManifestPayload) {
constructor(payload: ManifestPayload, protected wallet: WalletInstance) {
super(payload)
}

Expand Down Expand Up @@ -80,7 +81,7 @@ export class ManifestWrapper extends PayloadWrapper<ManifestPayload> {
`No module with [${manifest.id}] id available for registration`,
)

const module = await creatableModule.create(manifest.config ? { config: manifest.config } : undefined)
const module = await creatableModule.create(manifest.config ? { account: this.wallet, config: manifest.config } : undefined)
await node.module.register(module)
return module
}
Expand Down
1 change: 1 addition & 0 deletions packages/manifest/src/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface DappManifest extends Manifest {
}

export interface ModuleManifest extends Manifest {
accountPath?: string
config?: ModuleConfig
features?: string[]
language?: string
Expand Down
4 changes: 4 additions & 0 deletions packages/manifest/src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
"additionalProperties": false,
"description": "Module Definition",
"properties": {
"accountPath": {
"description": "HDWallet path to derive account",
"type": "string"
},
"architecture": {
"description": "Architecture",
"enum": [
Expand Down
9 changes: 7 additions & 2 deletions packages/manifest/src/spec/Manifest.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HDWallet } from '@xyo-network/account'
import { AddressSchema } from '@xyo-network/address-payload-plugin'
import { NodeWrapper } from '@xyo-network/node'

Expand All @@ -9,7 +10,9 @@ import simpleNodeInlineManifest from './simple-node-inline-manifest.json'
describe('Manifest', () => {
describe('Create Node from Manifest', () => {
test('Simple Node [Indirect]', async () => {
const manifest = new ManifestWrapper(simpleNodeIndirectManifest as ManifestPayload)
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
const wallet = await HDWallet.fromMnemonic(mnemonic)
const manifest = new ManifestWrapper(simpleNodeIndirectManifest as ManifestPayload, wallet)
const [node] = await manifest.loadDapps()
expect(node).toBeDefined()
const wrapper = NodeWrapper.wrap(node)
Expand All @@ -19,7 +22,9 @@ describe('Manifest', () => {
expect(await node.downResolver.resolve()).toBeArrayOfSize(3)
})
test('Simple Node [Inline]', async () => {
const manifest = new ManifestWrapper(simpleNodeInlineManifest as ManifestPayload)
const mnemonic = 'later puppy sound rebuild rebuild noise ozone amazing hope broccoli crystal grief'
const wallet = await HDWallet.fromMnemonic(mnemonic)
const manifest = new ManifestWrapper(simpleNodeInlineManifest as ManifestPayload, wallet)
const [node] = await manifest.loadDapps()
expect(node).toBeDefined()
const wrapper = NodeWrapper.wrap(node)
Expand Down
3 changes: 3 additions & 0 deletions packages/manifest/src/spec/simple-node-indirect-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
],
"modules": {
"ScratchArchivist": {
"accountPath": "1'",
"id": "network.xyo.archivist",
"language": "javascript"
},
"SimpleArchivist": {
"accountPath": "2'",
"id": "network.xyo.archivist",
"language": "javascript"
},
"SimpleSentinel": {
"accountPath": "3'",
"id": "network.xyo.sentinel",
"language": "javascript"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/manifest/src/spec/simple-node-inline-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
"modules": {
"private": [
{
"accountPath": "1'",
"id": "network.xyo.archivist",
"language": "javascript",
"name": "ScratchArchivist"
}
],
"public": [
{
"accountPath": "2'",
"id": "network.xyo.archivist",
"language": "javascript",
"name": "SimpleArchivist"
},
{
"accountPath": "3'",
"id": "network.xyo.sentinel",
"language": "javascript",
"name": "SimpleSentinel"
Expand Down

0 comments on commit 402175e

Please sign in to comment.