devPHAse
Development tool for Phala Phat contracts.
Install
Add to your projects using package manager (yarn@^1
/ npm
)
yarn add -D devphase
yarn add -D typescript ts-node # required peer dependencies
Features
- Init project (creates required files and directories)
yarn devphase init
- Starting local stack (node + pruntime + pherry)
yarn devphase stack
yarn devphase compile [contractName] [--watch]
- Contracts TS bindings creation
yarn devphase typings [contractName]
yarn devphase test
Configuration
Create devphase.config.ts
in root directory (init
command in TODO)
Here is default configuration. All values are optional (merged recuresivly)
import { ProjectConfigOptions } from 'devphase';
const config : ProjectConfigOptions = {
directories: {
artifacts: 'artifacts',
contracts: 'contracts',
logs: 'logs',
tests: 'tests',
typings: 'typings'
},
stack: {
node: {
port: 9944,
binary: '#DEVPHASE#/phala-dev-stack/bin/node',
workingDir: '#DEVPHASE#/phala-dev-stack/.data/node',
envs: {},
args: {
'--dev': true,
'--rpc-methods': 'Unsafe',
'--block-millisecs': 6000,
'--ws-port': '{{stack.port.port}}'
},
timeout: 10000,
},
pruntime: {
port: 8000,
binary: '#DEVPHASE#/phala-dev-stack/bin/pruntime',
workingDir: '#DEVPHASE#/phala-dev-stack/.data/pruntime',
envs: {},
args: {
'--allow-cors': true,
'--cores': 0,
'--port': '{{stack.pruntime.port}}'
},
timeout: 2000,
},
pherry: {
gkMnemonic: '//Alice',
binary: '#DEVPHASE#/phala-dev-stack/bin/pherry',
workingDir: '#DEVPHASE#/phala-dev-stack/.data/pherry',
envs: {},
args: {
'--no-wait': true,
'--mnemonic': '{{stack.pherry.gkMnemonic}}',
'--inject-key': '0000000000000000000000000000000000000000000000000000000000000001',
'--substrate-ws-endpoint': 'ws://localhost:{{stack.node.port}}',
'--pruntime-endpoint': 'http://localhost:{{stack.pruntime.port}}',
'--dev-wait-block-ms': 1000,
},
timeout: 2000,
}
},
devPhaseOptions: {
nodeUrl: 'ws://localhost:{{stack.node.port}}',
nodeApiOptions: {
types: {
...KhalaTypes,
...PhalaSDKTypes,
}
},
workerUrl: 'http://localhost:{{stack.pruntime.port}}',
accountsMnemonic: '',
accountsPaths: {
alice: '//Alice',
bob: '//Bob',
charlie: '//Charlie',
dave: '//Dave',
eve: '//Eve',
ferdie: '//Ferdie',
},
sudoAccount: 'alice',
ss58Prefix: 30,
clusterId: undefined,
},
testing: {
mocha: {},
envSetup: {
setup: {
custom: undefined,
timeout: 60 * 1000,
},
teardown: {
custom: undefined,
timeout: 10 * 1000,
}
},
blockTime: 100,
stackLogOutput : false,
}
};
export default config;
Usage sample
Check usage sample repo
Sandbox
Check sandbox environment repo for easy testing with up-to-date code
TODO
check here