Skip to content

Commit 8b70aa9

Browse files
authored
feat: display wallet address in billing commands (#55)
1 parent f751ea0 commit 8b70aa9

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

packages/cli/src/commands/billing/cancel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class BillingCancel extends Command {
3232
const billing = await createBillingClient(flags);
3333

3434
// Check subscription status first
35-
this.log(`\nChecking subscription status for ${flags.product}...`);
35+
this.debug(`\nChecking subscription status for ${flags.product}...`);
3636
const status = await billing.getStatus({
3737
productId: flags.product as "compute",
3838
});
@@ -47,7 +47,7 @@ export default class BillingCancel extends Command {
4747
// Confirm cancellation unless --force flag is used
4848
if (!flags.force) {
4949
const confirmed = await confirm({
50-
message: `${chalk.yellow("Warning:")} This will cancel your ${flags.product} subscription. Continue?`,
50+
message: `${chalk.yellow("Warning:")} This will cancel the ${flags.product} subscription for wallet ${chalk.bold(billing.address)}. Continue?`,
5151
});
5252
if (!confirmed) {
5353
this.log(chalk.gray("\nCancellation aborted."));

packages/cli/src/commands/billing/status.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default class BillingStatus extends Command {
5858
};
5959

6060
this.log(`\n${chalk.bold("Subscription Status:")}`);
61+
this.log(` Wallet: ${billing.address}`);
6162
this.log(` Status: ${formatStatus(result.subscriptionStatus)}`);
6263
this.log(` Product: ${result.productId}`);
6364

packages/cli/src/commands/billing/subscribe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class BillingSubscribe extends Command {
3737

3838
// Handle already active subscription
3939
if (result.type === "already_active") {
40-
this.log(`\n${chalk.green("✓")} You're already subscribed to ${flags.product}.`);
40+
this.log(`\n${chalk.green("✓")} Wallet ${chalk.bold(billing.address)} is already subscribed to ${flags.product}.`);
4141
this.log(chalk.gray("Run 'ecloud billing status' for details."));
4242
return;
4343
}
@@ -57,7 +57,7 @@ export default class BillingSubscribe extends Command {
5757
}
5858

5959
// Open checkout URL in browser
60-
this.log(`\n${chalk.gray("Opening checkout in your browser...")}`);
60+
this.log(`\nOpening checkout for wallet ${chalk.bold(billing.address)}...`);
6161
this.log(chalk.gray(`\nURL: ${result.checkoutUrl}`));
6262
await open(result.checkoutUrl);
6363

packages/sdk/src/client/modules/billing/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import { BillingApiClient } from "../../common/utils/billingapi";
66
import { getBillingEnvironmentConfig, getBuildType } from "../../common/config/environment";
77
import { getLogger, isSubscriptionActive, addHexPrefix } from "../../common/utils";
8+
import { getAddressFromPrivateKey } from "../../common/auth";
89
import { withSDKTelemetry } from "../../common/telemetry/wrapper";
910

10-
import type { Hex } from "viem";
11+
import type { Address, Hex } from "viem";
1112
import type {
1213
ProductID,
1314
SubscriptionOpts,
@@ -17,6 +18,7 @@ import type {
1718
} from "../../common/types";
1819

1920
export interface BillingModule {
21+
address: Address;
2022
subscribe: (opts?: SubscriptionOpts) => Promise<SubscribeResponse>;
2123
getStatus: (opts?: SubscriptionOpts) => Promise<ProductSubscriptionResponse>;
2224
cancel: (opts?: SubscriptionOpts) => Promise<CancelResponse>;
@@ -31,6 +33,7 @@ export interface BillingModuleConfig {
3133
export function createBillingModule(config: BillingModuleConfig): BillingModule {
3234
const { verbose = false, skipTelemetry = false } = config;
3335
const privateKey = addHexPrefix(config.privateKey);
36+
const address = getAddressFromPrivateKey(privateKey) as Address;
3437

3538
const logger = getLogger(verbose);
3639

@@ -41,6 +44,7 @@ export function createBillingModule(config: BillingModuleConfig): BillingModule
4144
const billingApi = new BillingApiClient(billingEnvConfig, privateKey);
4245

4346
return {
47+
address,
4448
async subscribe(opts) {
4549
return withSDKTelemetry(
4650
{

0 commit comments

Comments
 (0)