rocketh 0.15.15 → 0.16.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/environment/deployment-store.d.ts +3 -0
  5. package/dist/environment/deployment-store.d.ts.map +1 -0
  6. package/dist/environment/deployment-store.js +49 -0
  7. package/dist/environment/deployment-store.js.map +1 -0
  8. package/dist/environment/utils/artifacts.d.ts +4 -4
  9. package/dist/executor/index.d.ts +15 -6
  10. package/dist/executor/index.d.ts.map +1 -1
  11. package/dist/executor/index.js +39 -316
  12. package/dist/executor/index.js.map +1 -1
  13. package/dist/index.d.ts +9 -7
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +8 -7
  16. package/dist/index.js.map +1 -1
  17. package/dist/internal/logging.d.ts +1 -1
  18. package/dist/internal/logging.d.ts.map +1 -1
  19. package/package.json +9 -12
  20. package/src/cli.ts +2 -1
  21. package/src/environment/deployment-store.ts +72 -0
  22. package/src/executor/index.ts +89 -398
  23. package/src/index.ts +10 -11
  24. package/src/environment/deployments.ts +0 -135
  25. package/src/environment/index.ts +0 -696
  26. package/src/environment/providers/BaseProvider.ts +0 -13
  27. package/src/environment/providers/TransactionHashTracker.ts +0 -22
  28. package/src/environment/utils/artifacts.ts +0 -176
  29. package/src/environment/utils/chains.ts +0 -192
  30. package/src/executor/setup.test.ts +0 -151
  31. package/src/internal/logging.ts +0 -80
  32. package/src/internal/types.ts +0 -5
  33. package/src/types.ts +0 -601
  34. package/src/utils/eth.ts +0 -96
  35. package/src/utils/extensions.test.ts +0 -53
  36. package/src/utils/extensions.ts +0 -72
  37. package/src/utils/json.ts +0 -33
@@ -1,22 +0,0 @@
1
- import {EIP1193GenericRequest, EIP1193ProviderWithoutEvents} from 'eip-1193';
2
- import {BaseProvider} from './BaseProvider.js';
3
-
4
- export class TransactionHashTrackerProvider extends BaseProvider implements EIP1193ProviderWithoutEvents {
5
- public transactionHashes: `0x${string}`[] = [];
6
-
7
- constructor(provider: EIP1193ProviderWithoutEvents) {
8
- super(provider);
9
- }
10
-
11
- protected async _request<T = unknown, V extends EIP1193GenericRequest = EIP1193GenericRequest>(args: V): Promise<T> {
12
- const response = await this.provider.request(args as any);
13
- if (args.method === 'eth_sendRawTransaction' || args.method === 'eth_sendTransaction') {
14
- this.transactionHashes.push(response as `0x${string}`);
15
- }
16
- return response as T;
17
- }
18
- }
19
-
20
- export type TransactionHashTracker = EIP1193ProviderWithoutEvents & {
21
- transactionHashes: `0x${string}`[];
22
- };
@@ -1,176 +0,0 @@
1
- import {Abi} from 'abitype';
2
- import {Artifact, DevDoc, UserDoc} from '../../types.js';
3
- import {FunctionFragment} from 'ethers';
4
-
5
- type CreateMutable<Type> = {
6
- -readonly [Property in keyof Type]: Type[Property];
7
- };
8
-
9
- type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]
10
- ? ElementType
11
- : never;
12
-
13
- // from https://gist.github.com/egardner/efd34f270cc33db67c0246e837689cb9
14
- function deepEqual(obj1: any, obj2: any): boolean {
15
- // Private
16
- function isObject(obj: any) {
17
- if (typeof obj === 'object' && obj != null) {
18
- return true;
19
- } else {
20
- return false;
21
- }
22
- }
23
-
24
- if (obj1 === obj2) {
25
- return true;
26
- } else if (isObject(obj1) && isObject(obj2)) {
27
- if (Object.keys(obj1).length !== Object.keys(obj2).length) {
28
- return false;
29
- }
30
- for (var prop in obj1) {
31
- if (!deepEqual(obj1[prop], obj2[prop])) {
32
- return false;
33
- }
34
- }
35
- return true;
36
- }
37
- return false;
38
- }
39
-
40
- function mergeDoc(values: any, mergedDevDocs: any, field: string) {
41
- if (values[field]) {
42
- const mergedEventDocs = (mergedDevDocs[field] = mergedDevDocs[field] || {});
43
- for (const signature of Object.keys(values[field])) {
44
- if (mergedEventDocs[signature] && !deepEqual(mergedEventDocs[signature], values[field][signature])) {
45
- throw new Error(`Doc ${field} conflict: "${signature}" `);
46
- }
47
- mergedEventDocs[signature] = values[field][signature];
48
- }
49
- }
50
- }
51
-
52
- export function mergeABIs(list: {name: string; abi: Abi}[], options?: {doNotCheckForConflicts?: boolean}) {
53
- const added: Map<string, ArrayElement<Abi>> = new Map();
54
- const mergedABI: CreateMutable<Abi> = [];
55
- const sigJSMap: Map<`0x${string}`, {index: number; routeName: string; functionName: string}> = new Map();
56
- for (let i = 0; i < list.length; i++) {
57
- const listElem = list[i];
58
- for (const element of listElem.abi) {
59
- if (element.type === 'function') {
60
- // const selector = getFunctionSelector(element);
61
- const selector = FunctionFragment.from(element).selector as `0x${string}`;
62
- if (sigJSMap.has(selector)) {
63
- if (!options?.doNotCheckForConflicts) {
64
- const existing = sigJSMap.get(selector);
65
- throw new Error(
66
- `ABI conflict: ${existing!.routeName} has function "${existing!.functionName}" which conflict with ${
67
- listElem.name
68
- }'s "${element.name}" (selector: "${selector}") `
69
- );
70
- } else {
71
- continue;
72
- }
73
- }
74
- sigJSMap.set(selector, {index: i, routeName: listElem.name, functionName: element.name});
75
-
76
- const exists = added.has(element.name);
77
- if (exists) {
78
- // TODO check if same
79
- } else {
80
- added.set(element.name, element);
81
- mergedABI.push(element);
82
- }
83
- } else if (element.type === 'constructor') {
84
- // we skip it
85
- } else if (element.type === 'error') {
86
- const exists = added.has(element.name);
87
- if (exists) {
88
- // TODO check if same
89
- } else {
90
- added.set(element.name, element);
91
- mergedABI.push(element);
92
- }
93
- } else if (element.type === 'event') {
94
- const exists = added.has(element.name);
95
- if (exists) {
96
- // TODO check if same
97
- } else {
98
- added.set(element.name, element);
99
- mergedABI.push(element);
100
- }
101
- } else if (element.type === 'fallback') {
102
- } else if (element.type === 'receive') {
103
- } else {
104
- // if ('name' in element) {
105
- // const exists = added.has(element.name);
106
- // if (exists) {
107
- // // TODO check if same
108
- // } else {
109
- // added.set(element.name, element);
110
- // mergedABI.push(element);
111
- // }
112
- // }
113
- }
114
- }
115
- }
116
-
117
- return {
118
- mergedABI,
119
- added,
120
- sigJSMap,
121
- };
122
- }
123
-
124
- export function mergeArtifacts(
125
- list: {name: string; artifact: Partial<Artifact<Abi>> & {abi: Abi}}[],
126
- options?: {doNotCheckForConflicts?: boolean}
127
- ) {
128
- const {mergedABI, added, sigJSMap} = mergeABIs(
129
- list.map((v) => ({name: v.name, abi: v.artifact.abi})),
130
- options
131
- );
132
-
133
- const mergedDevDocs: CreateMutable<DevDoc> = {kind: 'dev', version: 1, methods: {}};
134
- const mergedUserDocs: CreateMutable<UserDoc> = {kind: 'user', version: 1, methods: {}};
135
-
136
- for (let i = 0; i < list.length; i++) {
137
- const listElem = list[i];
138
-
139
- const devdoc = listElem.artifact.devdoc;
140
- if (devdoc) {
141
- mergeDoc(devdoc, mergedDevDocs, 'events');
142
- mergeDoc(devdoc, mergedDevDocs, 'errors');
143
- mergeDoc(devdoc, mergedDevDocs, 'methods');
144
- if (devdoc.author) {
145
- if (mergedDevDocs.author && mergedDevDocs.author != devdoc.author) {
146
- throw new Error(`DevDoc author conflict `);
147
- }
148
- mergedDevDocs.author = devdoc.author;
149
- if (mergedDevDocs.title && mergedDevDocs.title != devdoc.title) {
150
- throw new Error(`DevDoc title conflict `);
151
- }
152
- mergedDevDocs.title = devdoc.title;
153
- }
154
- }
155
-
156
- const userdoc = listElem.artifact.userdoc;
157
- if (userdoc) {
158
- mergeDoc(userdoc, mergedUserDocs, 'events');
159
- mergeDoc(userdoc, mergedUserDocs, 'errors');
160
- mergeDoc(userdoc, mergedUserDocs, 'methods');
161
- if (userdoc.notice) {
162
- if (mergedUserDocs.notice && mergedUserDocs.notice != userdoc.notice) {
163
- throw new Error(`UserDoc notice conflict `);
164
- }
165
- mergedUserDocs.notice = userdoc.notice;
166
- }
167
- }
168
- }
169
- return {
170
- mergedABI,
171
- added,
172
- mergedDevDocs,
173
- mergedUserDocs,
174
- sigJSMap,
175
- };
176
- }
@@ -1,192 +0,0 @@
1
- import * as chains from 'viem/chains';
2
- import {kebabCase} from 'change-case';
3
- import {
4
- ChainConfig,
5
- ChainInfo,
6
- ChainUserConfig,
7
- Create2DeterministicDeploymentInfo,
8
- Create3DeterministicDeploymentInfo,
9
- ResolvedUserConfig,
10
- } from '../../types.js';
11
-
12
- export type ChainType = 'zksync' | 'op-stack' | 'celo' | 'default';
13
-
14
- const chainTypesByNames: {[chainExportName: string]: ChainType} = {
15
- base: 'op-stack',
16
- baseGoerli: 'op-stack',
17
- baseSepolia: 'op-stack',
18
- optimism: 'op-stack',
19
- optimismGoerli: 'op-stack',
20
- optimismSepolia: 'op-stack',
21
- pgn: 'op-stack',
22
- pgnTestnet: 'op-stack',
23
- zora: 'op-stack',
24
- zoraSepolia: 'op-stack',
25
- zoraTestnet: 'op-stack',
26
- ancient8: 'op-stack',
27
- ancient8Sepolia: 'op-stack',
28
- celoAlfajores: 'celo',
29
- celo: 'celo',
30
- zkSync: 'zksync',
31
- zkSyncTestnet: 'zksync',
32
- zkSyncSepoliaTestnet: 'zksync',
33
- };
34
-
35
- export const chainTypes: {[chainId: string]: ChainType} = {};
36
-
37
- export const chainById: {[chainId: string]: ChainInfo} = {};
38
- export const allChains: {[chainExportName: string]: ChainInfo} = {...((chains as any).default || chains)};
39
- allChains['localhost'] = allChains['hardhat'];
40
-
41
- for (const key of Object.keys(allChains)) {
42
- const chain = (allChains as any)[key] as ChainInfo;
43
- const chainId = chain.id.toString();
44
- const specificChainType = chainTypesByNames[key];
45
- if (specificChainType) {
46
- chainTypes[chainId] = specificChainType;
47
- }
48
- chainById[chainId] = {...chain, chainType: specificChainType};
49
- }
50
-
51
- export const chainByCanonicalName: {[canonicalName: string]: ChainInfo} = {};
52
- for (const key of Object.keys(chainById)) {
53
- const chain = (chainById as any)[key] as ChainInfo;
54
- const canonicalName = kebabCase(chain.name);
55
- chainByCanonicalName[canonicalName] = chain;
56
- }
57
-
58
- export function getChainById(id: string | number): ChainInfo | undefined {
59
- const chain = chainById['' + id];
60
-
61
- return chain;
62
- }
63
-
64
- export function getChainByName(name: string): ChainInfo | undefined {
65
- const chain = chainByCanonicalName[name];
66
- return chain;
67
- }
68
-
69
- export function getChainConfig(id: number, config: ResolvedUserConfig): ChainConfig {
70
- const defaultChainInfo = getChainById(id);
71
- const canonicalName = defaultChainInfo ? kebabCase(defaultChainInfo.name) : undefined;
72
- if (canonicalName) {
73
- if (config.chains?.[id] && config.chains?.[canonicalName]) {
74
- throw new Error(
75
- `chain should be configured by chainId or name but not both, remove either ${id} or ${canonicalName}`
76
- );
77
- }
78
- }
79
-
80
- let chainConfig: ChainUserConfig | undefined = config.chains?.[id];
81
- if (!chainConfig && canonicalName) {
82
- chainConfig = config.chains?.[canonicalName];
83
- }
84
- if (!chainConfig) {
85
- chainConfig = {info: defaultChainInfo};
86
- }
87
-
88
- let chainInfo = chainConfig?.info || defaultChainInfo;
89
-
90
- let rpcUrl = process.env['ETH_NODE_URI_' + id];
91
- if (canonicalName) {
92
- const fromEnv = process.env['ETH_NODE_URI_' + canonicalName];
93
- if (fromEnv) {
94
- rpcUrl = fromEnv;
95
- }
96
- }
97
-
98
- if (!rpcUrl) {
99
- rpcUrl = chainConfig.rpcUrl;
100
- }
101
-
102
- if (!rpcUrl) {
103
- rpcUrl = chainConfig.info?.rpcUrls.default.http[0];
104
- }
105
-
106
- if (!rpcUrl) {
107
- if (id === 31337 || id === 1337) {
108
- rpcUrl = 'http://127.0.0.1:8545';
109
- }
110
- }
111
-
112
- if (!chainInfo) {
113
- if (!rpcUrl) {
114
- throw new Error(`no chain info found for chain with id ${id}`);
115
- } else {
116
- console.error(`chain with id ${id} has no public info`);
117
- }
118
-
119
- chainInfo = {
120
- id,
121
- name: 'unkwown',
122
- nativeCurrency: {
123
- name: 'Unknown Currency',
124
- symbol: 'UNKNOWN',
125
- decimals: 18,
126
- },
127
- rpcUrls: {
128
- default: {
129
- http: [rpcUrl],
130
- },
131
- },
132
- chainType: 'default',
133
- };
134
- }
135
-
136
- const create2Info = {
137
- factory: '0x4e59b44847b379578588920ca78fbf26c0b4956c',
138
- deployer: '0x3fab184622dc19b6109349b94811493bf2a45362',
139
- funding: '10000000000000000',
140
- signedTx:
141
- '0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222',
142
- } as const;
143
- const create3Info = {
144
- factory: '0x000000000004d4f168daE7DB3C610F408eE22F57',
145
- salt: '0x5361109ca02853ca8e22046b7125306d9ec4ae4cdecc393c567b6be861df3db6',
146
- bytecode:
147
- '0x6080604052348015600f57600080fd5b506103ca8061001f6000396000f3fe6080604052600436106100295760003560e01c8063360d0fad1461002e5780639881d19514610077575b600080fd5b34801561003a57600080fd5b5061004e610049366004610228565b61008a565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b61004e61008536600461029c565b6100ee565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606084901b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e78261014c565b9392505050565b6040517fffffffffffffffffffffffffffffffffffffffff0000000000000000000000003360601b166020820152603481018290526000906054016040516020818303038152906040528051906020012091506100e734848461015e565b600061015882306101ce565b92915050565b60006f67363d3d37363d34f03d5260086018f3600052816010806000f58061018e5763301164256000526004601cfd5b8060145261d69460005260016034536017601e20915060008085516020870188855af1823b026101c65763301164256000526004601cfd5b509392505050565b60006040518260005260ff600b53836020527f21c35dbe1b344a2488cf3321d6ce542f8e9f305544ff09e4993a62319a497c1f6040526055600b20601452806040525061d694600052600160345350506017601e20919050565b6000806040838503121561023b57600080fd5b823573ffffffffffffffffffffffffffffffffffffffff8116811461025f57600080fd5b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156102af57600080fd5b823567ffffffffffffffff8111156102c657600080fd5b8301601f810185136102d757600080fd5b803567ffffffffffffffff8111156102f1576102f161026d565b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160116810181811067ffffffffffffffff8211171561035d5761035d61026d565b60405281815282820160200187101561037557600080fd5b816020840160208301376000602092820183015296940135945050505056fea264697066735822122059dcc5dc6453397d13ff28021e28472a80a45bbd97f3135f69bd2650773aeb0164736f6c634300081a0033',
148
- proxyBytecode: '0x67363d3d37363d34f03d5260086018f3',
149
- } as const;
150
-
151
- const pollingInterval = chainConfig.pollingInterval || config.defaultPollingInterval;
152
-
153
- let deterministicDeployment: {
154
- create2: Create2DeterministicDeploymentInfo;
155
- create3: Create3DeterministicDeploymentInfo;
156
- } = {
157
- create2: (() => {
158
- const deterministicDeployment = chainConfig.deterministicDeployment;
159
- if (!deterministicDeployment) {
160
- return create2Info;
161
- }
162
-
163
- return 'create2' in deterministicDeployment && deterministicDeployment.create2
164
- ? deterministicDeployment.create2
165
- : !('create2' in deterministicDeployment) && !('create3' in deterministicDeployment)
166
- ? (deterministicDeployment as Create2DeterministicDeploymentInfo)
167
- : create2Info;
168
- })(),
169
- create3:
170
- chainConfig.deterministicDeployment &&
171
- 'create3' in chainConfig.deterministicDeployment &&
172
- chainConfig.deterministicDeployment.create3
173
- ? chainConfig.deterministicDeployment.create3
174
- : create3Info,
175
- };
176
-
177
- const defaultTags: string[] = [];
178
- if (chainInfo.testnet) {
179
- defaultTags.push('testnet');
180
- }
181
-
182
- const properties = chainConfig.properties || config.defaultChainProperties || {};
183
-
184
- return {
185
- info: {...chainInfo},
186
- deterministicDeployment,
187
- pollingInterval,
188
- properties,
189
- rpcUrl: rpcUrl || chainInfo.rpcUrls.default.http[0],
190
- tags: chainConfig.tags || [...defaultTags],
191
- };
192
- }
@@ -1,151 +0,0 @@
1
- import type {Environment} from '../types.js';
2
- import {setup} from './index.js';
3
-
4
- // Mock environment for testing
5
- const mockEnv = {} as Environment;
6
-
7
- // Example utility functions that take Environment as first parameter
8
- const utilityFunctions = {
9
- deployContract:
10
- (env: Environment) =>
11
- async (contractName: string, args: any[] = []): Promise<string> => {
12
- console.log(`Deploying ${contractName} with args:`, args);
13
- return '0x1234567890123456789012345678901234567890';
14
- },
15
-
16
- verifyContract:
17
- (env: Environment) =>
18
- async (address: string): Promise<boolean> => {
19
- console.log(`Verifying contract at ${address}`);
20
- return true;
21
- },
22
-
23
- getBalance:
24
- (env: Environment) =>
25
- async (address: string): Promise<bigint> => {
26
- console.log(`Getting balance for ${address}`);
27
- return BigInt('1000000000000000000'); // 1 ETH
28
- },
29
-
30
- calculateGas:
31
- (env: Environment) =>
32
- (operation: string): number => {
33
- console.log(`Calculating gas for ${operation}`);
34
- return 21000;
35
- },
36
-
37
- isDeployed:
38
- (env: Environment) =>
39
- (contractName: string): boolean => {
40
- console.log(`Checking if ${contractName} is deployed`);
41
- return false;
42
- },
43
-
44
- test: (env: Environment) => true,
45
- };
46
-
47
- // Create the enhanced execute function using setup
48
- const {deployScript} = setup(utilityFunctions);
49
-
50
- // Test the enhanced execute function
51
- const testScript = deployScript(
52
- async (env, args) => {
53
- // Type test: env should have both original Environment properties AND curried functions
54
-
55
- // Test curried functions (no need to pass env)
56
- const address = await env.deployContract('MyToken', ['TokenName', 'TKN']);
57
- const isVerified = await env.verifyContract(address);
58
- const balance = await env.getBalance(address);
59
- const gasEstimate = env.calculateGas('transfer');
60
- const deployed = env.isDeployed('MyToken');
61
-
62
- // Test that original environment properties are still accessible
63
- // (These would normally be available on a real environment)
64
- // console.log('Network name:', env.network?.name);
65
- // console.log('Chain ID:', env.network?.chain?.id);
66
-
67
- console.log('Test results:', {
68
- address,
69
- isVerified,
70
- balance: balance.toString(),
71
- gasEstimate,
72
- deployed,
73
- });
74
-
75
- return true; // Return true to indicate successful completion
76
- },
77
- {
78
- tags: ['test'],
79
- dependencies: [],
80
- id: 'test-setup-function',
81
- }
82
- );
83
-
84
- // Type tests - these should compile without errors
85
- async function testTypes() {
86
- // The script should be a valid DeployScriptModule
87
- console.log('Script tags:', testScript.tags);
88
- console.log('Script dependencies:', testScript.dependencies);
89
- console.log('Script ID:', testScript.id);
90
-
91
- // The script should be callable with an environment
92
- try {
93
- const result = await testScript(mockEnv, undefined);
94
- console.log('Script execution result:', result);
95
- } catch (error) {
96
- console.log('Script execution test completed (expected with mock env)');
97
- }
98
- }
99
-
100
- // Example of how this would be used in a real deployment script
101
- export const exampleUsage = () => {
102
- // Define your utility functions
103
- const myFunctions = {
104
- deployERC20:
105
- (env: Environment) =>
106
- async (name: string, symbol: string): Promise<string> => {
107
- // Implementation would use env.save, env.network.provider, etc.
108
- return '0x...';
109
- },
110
-
111
- setupPermissions:
112
- (env: Environment) =>
113
- async (contractAddress: string, admin: string): Promise<void> => {
114
- // Implementation would interact with contracts
115
- },
116
-
117
- verifyOnEtherscan:
118
- (env: Environment) =>
119
- async (address: string, constructorArgs: any[]): Promise<boolean> => {
120
- // Implementation would call verification service
121
- return true;
122
- },
123
- };
124
-
125
- // Create the enhanced execute function
126
- const {deployScript} = setup(myFunctions);
127
-
128
- // Export your deployment script
129
- return deployScript(
130
- async (env, args) => {
131
- // Now you can use the functions without passing env each time
132
- const tokenAddress = await env.deployERC20('MyToken', 'MTK');
133
- await env.setupPermissions(tokenAddress, env.namedAccounts.deployer);
134
- await env.verifyOnEtherscan(tokenAddress, ['MyToken', 'MTK']);
135
-
136
- // Original environment is still fully accessible
137
- console.log(`Deployed on environment: ${env.name}`);
138
- const deployment = env.get('MyToken');
139
-
140
- return true;
141
- },
142
- {
143
- tags: ['token', 'deploy'],
144
- dependencies: ['setup'],
145
- id: 'deploy-my-token',
146
- }
147
- );
148
- };
149
-
150
- // Export for potential use in actual tests
151
- export {testTypes, testScript, utilityFunctions};
@@ -1,80 +0,0 @@
1
- import {logs} from 'named-logs';
2
-
3
- import {hookup, factory as Logging} from 'named-logs-console';
4
- // import ora from 'ora-cjs';
5
- hookup();
6
-
7
- export function setLogLevel(level: number) {
8
- Logging.level = level;
9
- if (Logging.level > 0) {
10
- Logging.enable();
11
- } else {
12
- Logging.disable();
13
- }
14
- }
15
-
16
- export const logger = logs('rocketh');
17
-
18
- export type ProgressIndicator = {
19
- start(msg?: string): ProgressIndicator;
20
- stop(): ProgressIndicator;
21
- succeed(msg?: string): ProgressIndicator;
22
- fail(msg?: string): ProgressIndicator;
23
- };
24
- const loggerProgressIndicator: ProgressIndicator = {
25
- start(msg?: string) {
26
- if (msg) {
27
- console.log(msg);
28
- }
29
- return this;
30
- },
31
- stop() {
32
- return this;
33
- },
34
- succeed(msg?: string) {
35
- if (msg) {
36
- console.log(msg);
37
- }
38
- return this;
39
- },
40
- fail(msg?: string) {
41
- if (msg) {
42
- console.error(msg);
43
- }
44
- return this;
45
- },
46
- };
47
- const voidProgressIndicator: ProgressIndicator = {
48
- start() {
49
- return this;
50
- },
51
- stop() {
52
- return this;
53
- },
54
- succeed() {
55
- return this;
56
- },
57
- fail() {
58
- return this;
59
- },
60
- };
61
- // export function spin(message: string): PartialOra {
62
- // return Logging.level > 0 ? ora(message).start() : voidProgressIndicator;
63
- // }
64
-
65
- // let lastSpin = ora('rocketh');
66
- let lastSpin = loggerProgressIndicator;
67
- export function spin(message?: string): ProgressIndicator {
68
- if (Logging.level > 0) {
69
- lastSpin = lastSpin.start(message);
70
- return lastSpin;
71
- } else {
72
- return voidProgressIndicator;
73
- }
74
- }
75
-
76
- export function log(message: string) {
77
- if (Logging.level > 0) {
78
- console.log(message);
79
- }
80
- }
@@ -1,5 +0,0 @@
1
- export type InternalEnvironment = {
2
- exportDeploymentsAsTypes(): Promise<void>;
3
- recoverTransactionsIfAny(): Promise<void>;
4
- recordMigration(id: string): void;
5
- };