From 5ec40efe156c237145c7c5bb916c8b2390d8703b Mon Sep 17 00:00:00 2001 From: jackkru69 Date: Wed, 23 Oct 2024 00:53:10 +0300 Subject: [PATCH] small fixes --- packages/cli/src/commands/acc/get-balance.ts | 2 +- packages/cli/src/commands/acc/send-sk.ts | 6 +++++- packages/cli/src/commands/container/create.ts | 7 +++++-- packages/cli/src/commands/container/list.ts | 7 +++++-- packages/cli/src/commands/container/update.ts | 7 +++++-- packages/cli/src/commands/container/upload.ts | 8 +++++++- packages/cli/src/commands/contract/deploy.ts | 2 +- packages/cli/src/commands/contract/set.ts | 7 +++++-- packages/cli/src/commands/provider/create.ts | 9 +++++++-- packages/cli/src/commands/provider/list.ts | 7 +++++-- packages/cli/src/commands/provider/set-url.ts | 9 +++++++-- packages/cli/src/commands/storage/upload.ts | 9 +++++++-- packages/cli/src/helpers/network.helper.ts | 2 +- 13 files changed, 61 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/commands/acc/get-balance.ts b/packages/cli/src/commands/acc/get-balance.ts index c659647..c56b2f4 100644 --- a/packages/cli/src/commands/acc/get-balance.ts +++ b/packages/cli/src/commands/acc/get-balance.ts @@ -29,7 +29,7 @@ export default class AccGetBalance extends BaseCommand { char: 'p', default: '', description: 'Password for the key file (env: KEY_FILE_PASSWORD)', env: 'KEY_FILE_PASSWORD', }), isEth: Flags.boolean({ - char: 'e', description: 'Get balance of an Ethereum account', exclusive: ['address'], default: false, + char: 'e', description: 'Use an ethereum address', default: false, }), }; diff --git a/packages/cli/src/commands/acc/send-sk.ts b/packages/cli/src/commands/acc/send-sk.ts index 7ed10da..5944066 100644 --- a/packages/cli/src/commands/acc/send-sk.ts +++ b/packages/cli/src/commands/acc/send-sk.ts @@ -36,6 +36,9 @@ export default class AccSendSk extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'h', description: 'Use an ethereum address', + }), }; public async run(): Promise { @@ -52,11 +55,12 @@ export default class AccSendSk extends BaseCommand { gasToken, gasValue, chain, + isEth, } = flags; ux.action.start('Loading'); - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); const networkApi = await initializeNetworkApi({ address: importedWallet.address, defaultChain: bootstrapChain, chain }); if (!networkApi) { diff --git a/packages/cli/src/commands/container/create.ts b/packages/cli/src/commands/container/create.ts index cdc57fb..22801c8 100644 --- a/packages/cli/src/commands/container/create.ts +++ b/packages/cli/src/commands/container/create.ts @@ -42,17 +42,20 @@ export default class ContainerCreate extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', description: 'Use an ethereum address', + }), }; public async run(): Promise { const { flags } = await this.parse(ContainerCreate); const { - keyFilePath, password, containerKeyFilePath, containerName, containerPassword, ordersScAddress, sponsorAddress, chain, + keyFilePath, password, containerKeyFilePath, containerName, containerPassword, ordersScAddress, sponsorAddress, chain, isEth, } = flags; ux.action.start('Loading'); - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); const networkApi = await initializeNetworkApi({ address: importedWallet.address, chain }); const ordersContract = new EvmContract(networkApi, ordersScAddress); diff --git a/packages/cli/src/commands/container/list.ts b/packages/cli/src/commands/container/list.ts index 9a271eb..71bee2d 100644 --- a/packages/cli/src/commands/container/list.ts +++ b/packages/cli/src/commands/container/list.ts @@ -31,18 +31,21 @@ export default class ContainerList extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', description: 'Use an ethereum address', default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ContainerList); const { - keyFilePath, password, ordersScAddress, chain, + keyFilePath, password, ordersScAddress, chain, isEth, } = flags; ux.action.start('Loading'); // Initialize network API and wallet - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); const networkApi = await initializeNetworkApi({ address: importedWallet.address, chain }); // Initialize EVM core and orders contract diff --git a/packages/cli/src/commands/container/update.ts b/packages/cli/src/commands/container/update.ts index 0c07870..579a84c 100644 --- a/packages/cli/src/commands/container/update.ts +++ b/packages/cli/src/commands/container/update.ts @@ -40,18 +40,21 @@ export default class ContainerUpdate extends BaseCommand { sponsorAddress: Flags.string({ char: 'r', description: 'Address of the sponsor', }), + isEth: Flags.boolean({ + char: 'e', description: 'Use an ethereum address', default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ContainerUpdate); const { - keyFilePath, password, containerId, containerKeyFilePath, containerName, containerPassword, ordersScAddress, sponsorAddress, + keyFilePath, password, containerId, containerKeyFilePath, containerName, containerPassword, ordersScAddress, sponsorAddress, isEth, } = flags; ux.action.start('Loading'); // Load wallet - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); // Initialize network API const networkApi = await initializeNetworkApi({ address: importedWallet.address }); diff --git a/packages/cli/src/commands/container/upload.ts b/packages/cli/src/commands/container/upload.ts index df68a9c..d5ea5f9 100644 --- a/packages/cli/src/commands/container/upload.ts +++ b/packages/cli/src/commands/container/upload.ts @@ -100,6 +100,11 @@ export default class ContainerUpload extends BaseCommand { char: 'n', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', + description: 'Use an ethereum address', + default: false, + }), }; public async run(): Promise { @@ -115,8 +120,9 @@ export default class ContainerUpload extends BaseCommand { ordersScAddress, providerScAddress, chain, + isEth, } = flags; - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); // Initialize network API const networkApi = await initializeNetworkApi({ diff --git a/packages/cli/src/commands/contract/deploy.ts b/packages/cli/src/commands/contract/deploy.ts index 4e5c3fa..faaa69c 100644 --- a/packages/cli/src/commands/contract/deploy.ts +++ b/packages/cli/src/commands/contract/deploy.ts @@ -88,7 +88,7 @@ export default class ContractDeploy extends BaseCommand { ux.action.start('Loading'); // Load wallet - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, !inPlace); // Initialize network API const networkApi = await initializeNetworkApi({ diff --git a/packages/cli/src/commands/contract/set.ts b/packages/cli/src/commands/contract/set.ts index b615b3f..0a90303 100644 --- a/packages/cli/src/commands/contract/set.ts +++ b/packages/cli/src/commands/contract/set.ts @@ -63,12 +63,15 @@ export default class ContractSet extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', description: 'Use an ethereum address', default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ContractSet); const { - abiPath, address, keyFilePath, method, params, amount, password, sponsorAddress, chain, + abiPath, address, keyFilePath, method, params, amount, password, sponsorAddress, chain, isEth, } = flags; const paramsParser = new ParamsParser(); @@ -79,7 +82,7 @@ export default class ContractSet extends BaseCommand { ux.action.start('Loading'); // Load wallet - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); // Initialize network API const networkApi = await initializeNetworkApi({ diff --git a/packages/cli/src/commands/provider/create.ts b/packages/cli/src/commands/provider/create.ts index 192ecdb..3947087 100644 --- a/packages/cli/src/commands/provider/create.ts +++ b/packages/cli/src/commands/provider/create.ts @@ -33,17 +33,22 @@ export default class ProviderCreate extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', + description: 'Use an ethereum address', + default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ProviderCreate); const { - keyFilePath, password, providerName, providersScAddress, sponsorAddress, chain, + keyFilePath, password, providerName, providersScAddress, sponsorAddress, chain, isEth, } = flags; ux.action.start('Loading'); - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); const networkApi = await initializeNetworkApi({ address: importedWallet.address, chain }); const providersContract = new EvmContract(networkApi, providersScAddress); diff --git a/packages/cli/src/commands/provider/list.ts b/packages/cli/src/commands/provider/list.ts index 878f6c7..486d82c 100644 --- a/packages/cli/src/commands/provider/list.ts +++ b/packages/cli/src/commands/provider/list.ts @@ -36,12 +36,15 @@ export default class ProviderList extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', description: 'Use an ethereum address', default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ProviderList); const { - keyFilePath, password, providersScAddress, ordersScAddress, address, chain, + keyFilePath, password, providersScAddress, ordersScAddress, address, chain, isEth, } = flags; ux.action.start('Loading providers'); @@ -51,7 +54,7 @@ export default class ProviderList extends BaseCommand { if (address) { providerOwnerAddress = address; } else if (keyFilePath) { - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); providerOwnerAddress = importedWallet.address; } const networkApi = await initializeNetworkApi({ address: providerOwnerAddress || providersScAddress, chain }); diff --git a/packages/cli/src/commands/provider/set-url.ts b/packages/cli/src/commands/provider/set-url.ts index 8688c96..a9ed7c3 100644 --- a/packages/cli/src/commands/provider/set-url.ts +++ b/packages/cli/src/commands/provider/set-url.ts @@ -36,17 +36,22 @@ export default class ProviderSetUrl extends BaseCommand { char: 'c', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', + description: 'Use an ethereum address', + default: false, + }), }; public async run(): Promise { const { flags } = await this.parse(ProviderSetUrl); const { - keyFilePath, password, providerId, providerUrl, ordersScAddress, sponsorAddress, chain, + keyFilePath, password, providerId, providerUrl, ordersScAddress, sponsorAddress, chain, isEth, } = flags; ux.action.start('Loading'); - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); const networkApi = await initializeNetworkApi({ address: importedWallet.address, chain }); const ordersContract = new EvmContract(networkApi, ordersScAddress); diff --git a/packages/cli/src/commands/storage/upload.ts b/packages/cli/src/commands/storage/upload.ts index 039b9e2..35f1d60 100644 --- a/packages/cli/src/commands/storage/upload.ts +++ b/packages/cli/src/commands/storage/upload.ts @@ -32,6 +32,11 @@ export default class StorageUpload extends Command { char: 'n', description: 'Chain ID', }), + isEth: Flags.boolean({ + char: 'e', + description: 'Use an ethereum address', + default: false, + }), }; static override description = 'Upload application files to the storage'; @@ -43,7 +48,7 @@ export default class StorageUpload extends Command { async run(): Promise { const { flags } = await this.parse(StorageUpload); const { - bootstrapChain, configPath, storageScAddress, password, sponsorAddress, chain, + bootstrapChain, configPath, storageScAddress, password, sponsorAddress, chain, isEth, } = flags; // Get the current configuration @@ -92,7 +97,7 @@ export default class StorageUpload extends Command { const expire = BigInt(60 * 60 * 24 * 30); // One month - const importedWallet = await loadWallet(keyFilePath, password); + const importedWallet = await loadWallet(keyFilePath, password, isEth); // await storageSc.scSet( // importedWallet, diff --git a/packages/cli/src/helpers/network.helper.ts b/packages/cli/src/helpers/network.helper.ts index bf91f86..7d78052 100644 --- a/packages/cli/src/helpers/network.helper.ts +++ b/packages/cli/src/helpers/network.helper.ts @@ -33,7 +33,7 @@ export async function initializeNetworkApi({ return networkApi; } -export async function loadWallet(keyFilePath: string, password: string, isEth?: boolean) { +export async function loadWallet(keyFilePath: string, password: string, isEth: boolean) { const importedData = readFileSync(keyFilePath, 'utf8'); try {