Skip to content

Commit e20ea86

Browse files
committed
fix: fixing tests
1 parent 8606129 commit e20ea86

File tree

9 files changed

+344
-490
lines changed

9 files changed

+344
-490
lines changed
Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable no-console */
2+
import {Command} from 'commander'
23
import {execSync} from 'child_process'
34
import {existsSync, readdirSync} from 'fs'
45
import {basename, extname, join, resolve} from 'path'
5-
import {checkLeapInstallation} from '../chain/install'
6+
import {checkLeapInstallation} from './chain/install'
67

78
/**
89
* Compile a single C++ file or all .cpp files in the current directory
@@ -128,3 +129,26 @@ async function compileSingleFile(filePath: string, outputDir: string): Promise<v
128129
)
129130
}
130131
}
132+
133+
/**
134+
* Create the compile command
135+
*/
136+
export function createCompileCommand(): Command {
137+
const compile = new Command('compile')
138+
compile
139+
.description(
140+
'Compile C++ contract files (single file or all .cpp files in current directory)'
141+
)
142+
.argument('[file]', 'Optional file to compile (compiles all .cpp files if not specified)')
143+
.option('-o, --output <directory>', 'Output directory for compiled WASM files', '.')
144+
.action(async (file, options) => {
145+
try {
146+
await compileContract(file, options.output)
147+
} catch (error: any) {
148+
console.error(`Error: ${error.message}`)
149+
process.exit(1)
150+
}
151+
})
152+
153+
return compile
154+
}

src/commands/contract/deploy.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {NonInteractiveConsoleUI} from '../../utils/wharfkit-ui'
1111
import {getKeyFromWallet, listWalletKeys} from '../wallet/utils'
1212

1313
import {Chains} from '@wharfkit/common'
14-
import {compileContract} from '../wharfkit/compile'
14+
import {compileContract} from '../compile'
1515

1616
interface DeployOptions {
1717
account?: string
@@ -68,10 +68,11 @@ export async function validateDeploy(
6868
console.log(` ✅ Table '${table}' is empty.`)
6969
}
7070
} catch (e: any) {
71-
// If check fails, ignore or warn?
72-
// Often "table not found" error if using state history or other plugins if really gone?
73-
// But if get_abi returned it, it was in ABI.
74-
// We assume no data if error, or warn.
71+
console.log(
72+
` ⚠️ Warning: Could not check table '${table}' for data: ${
73+
e.message || String(e)
74+
}`
75+
)
7576
}
7677
}
7778

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable no-console */
2+
import {Command} from 'commander'
23
import {watch} from 'fs'
34
import {extname} from 'path'
45
import {compileContract} from './compile'
5-
import {deployContract} from '../contract/deploy'
6-
import {getChainStatus, startLocalChain, stopLocalChain} from '../chain/local'
6+
import {deployContract} from './contract/deploy'
7+
import {getChainStatus, startLocalChain, stopLocalChain} from './chain/local'
78

89
interface DevOptions {
910
account?: string
@@ -154,3 +155,30 @@ process.on('SIGINT', async () => {
154155
process.on('SIGTERM', async () => {
155156
await stopDevMode()
156157
})
158+
159+
/**
160+
* Create the dev command
161+
*/
162+
export function createDevCommand(): Command {
163+
const dev = new Command('dev')
164+
dev.description(
165+
'Start local chain and watch for changes (auto-compile and auto-deploy on file changes)'
166+
)
167+
.option('-a, --account <name>', 'Contract account name (default: derived from filename)')
168+
.option('-p, --port <port>', 'Port for local blockchain', '8888')
169+
.option('-c, --clean', 'Start with a clean blockchain state')
170+
.action(async (options) => {
171+
try {
172+
await startDevMode({
173+
account: options.account,
174+
port: parseInt(options.port),
175+
clean: options.clean,
176+
})
177+
} catch (error: any) {
178+
console.error(`Error: ${error.message}`)
179+
process.exit(1)
180+
}
181+
})
182+
183+
return dev
184+
}

0 commit comments

Comments
 (0)