Skip to content

Commit

Permalink
refactor(create): update for namespaced core libs
Browse files Browse the repository at this point in the history
  • Loading branch information
egasimus committed Jan 13, 2024
1 parent cc77c28 commit df4036c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions create/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. **/
import assert from 'node:assert'
import projectMain, {
Deployment, ContractTemplate, ContractInstance, Stub
} from '@hackbg/fadroma'
import type { ChainId } from '@fadroma/agent'
import { Base, Deploy } from '@fadroma/agent'
const { Error, bold, timestamp, bip39, bip39EN } = Base
const { Deployment, ContractCode } = Deploy
'
import { tmpDir, TestProjectDeployment } from '@fadroma/fixtures'
import * as Projects from './create'
import { withTmpDir } from '@hackbg/file'
Expand All @@ -17,7 +19,7 @@ export default new Suite([
])
export async function testProjectCommands () {
await projectMain()
//await projectMain()
//for (const project of [
//await Projects.ScriptProject.create({
Expand Down
11 changes: 7 additions & 4 deletions create/create.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/** Fadroma. Copyright (C) 2023 Hack.bg. License: GNU AGPLv3 or custom.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. **/
import { Error, Deployment, bold, timestamp, bip39, bip39EN } from '@fadroma/agent'
import type { ChainId, ContractCode } from '@fadroma/agent'
import type { ChainId } from '@fadroma/agent'
import { Core, Deploy } from '@fadroma/agent'
const { Error, bold, timestamp, bip39, bip39EN } = Core
const { Deployment, ContractCode } = Deploy

import $, { Directory, TextFile, TOMLFile, JSONFile } from '@hackbg/file'
import type { Path } from '@hackbg/file'
import { console, packageRoot } from './package'
Expand Down Expand Up @@ -272,11 +275,11 @@ export class Project extends ProjectDirectory {
}
return console
}
createDeployment (): Deployment {
createDeployment (): Deploy.Deployment {
console.warn('createDeployment: not implemented')
return new Deployment()
}
async getDeployment (): Promise<Deployment> {
async getDeployment (): Promise<Deploy.Deployment> {
const {default: deployment} = await import(this.path)
return deployment()
}
Expand Down
9 changes: 5 additions & 4 deletions create/tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { bold, colors } from '@fadroma/agent'
import type { DeployStore, UploadedCode } from '@fadroma/agent'
import { Core, Deploy, Store } from '@fadroma/agent'
import $, { Path, TextFile, JSONFile, TOMLFile, Directory } from '@hackbg/file'

import { execSync } from 'node:child_process'
Expand All @@ -14,6 +13,8 @@ import type { Project } from './create'

export const NOT_INSTALLED = 'not installed'

const { bold, colors } = Core

export class SystemTools {
constructor (readonly verbose: boolean = true) {}

Expand Down Expand Up @@ -369,7 +370,7 @@ export class Prompter {

export class ProjectPrompter extends Prompter {

deployment (store: DeployStore & { root?: Path }): Promise<string|undefined> {
deployment (store: Store.DeployStore & { root?: Path }): Promise<string|undefined> {
const label = store.root
? `Select a deployment from ${store.root.shortPath}:`
: `Select a deployment:`
Expand Down Expand Up @@ -423,7 +424,7 @@ export class ProjectPrompter extends Prompter {
choice('One workspace plus scripts.', Infinity),
])

contractCrates = (name: string): Promise<Record<string, Partial<UploadedCode>>> =>
contractCrates = (name: string): Promise<Record<string, Partial<Deploy.UploadedCode>>> =>
this.untilDone({}, state => {
const message = [
`Project ${name} contains ${Object.keys(state).length} contract(s):\n`,
Expand Down

0 comments on commit df4036c

Please sign in to comment.