Skip to content

Commit

Permalink
Merge pull request #167 from thepower/feat/eth-transactions
Browse files Browse the repository at this point in the history
small fixes
  • Loading branch information
jackkru69 authored Oct 22, 2024
2 parents 33fd991 + 5ec40ef commit fec7a31
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/acc/get-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
};

Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/commands/acc/send-sk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand All @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/container/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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);
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/container/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/container/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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 });
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/container/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/contract/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/contract/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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();

Expand All @@ -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({
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/commands/provider/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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);

Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/provider/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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');
Expand All @@ -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 });
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/commands/provider/set-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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);

Expand Down
9 changes: 7 additions & 2 deletions packages/cli/src/commands/storage/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -43,7 +48,7 @@ export default class StorageUpload extends Command {
async run(): Promise<void> {
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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/helpers/network.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fec7a31

Please sign in to comment.