aiprotocol-sbi 1.2.2 → 1.2.3

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.
@@ -34,6 +34,7 @@ const list_comment_command_1 = require("./modules/comments/list-comment.command"
34
34
  const reply_comment_command_1 = require("./modules/comments/reply-comment.command");
35
35
  const list_replies_command_1 = require("./modules/comments/list-replies.command");
36
36
  const comment_vote_command_1 = require("./modules/comments/comment-vote.command");
37
+ const economy_rewards_command_1 = require("./modules/economy/commands/economy-rewards.command");
37
38
  let AppModule = class AppModule {
38
39
  };
39
40
  exports.AppModule = AppModule;
@@ -64,6 +65,7 @@ exports.AppModule = AppModule = __decorate([
64
65
  economy_list_command_1.EconomyListCommand,
65
66
  payment_status_command_1.PaymentVerifyCommand,
66
67
  grant_status_command_1.GrantStatusCommand,
68
+ economy_rewards_command_1.EconomyRewardsCommand,
67
69
  create_comment_command_1.CreateCommentCommand,
68
70
  list_comment_command_1.CommentListCommand,
69
71
  reply_comment_command_1.CommentReplyCommand,
@@ -13,6 +13,7 @@ import { CommentListCommand } from "./modules/comments/list-comment.command";
13
13
  import { CommentReplyCommand } from "./modules/comments/reply-comment.command";
14
14
  import { CommentRepliesCommand } from "./modules/comments/list-replies.command";
15
15
  import { CommentVoteCommand } from "./modules/comments/comment-vote.command";
16
+ import { EconomyRewardsCommand } from "./modules/economy/commands/economy-rewards.command";
16
17
  export declare class CliService {
17
18
  private readonly setup;
18
19
  private readonly walletConnect;
@@ -29,9 +30,10 @@ export declare class CliService {
29
30
  private readonly commentVoteCommand;
30
31
  private readonly paymentVerify;
31
32
  private readonly grantStatus;
33
+ private readonly economyRewards;
32
34
  private readonly logger;
33
35
  private readonly program;
34
- constructor(setup: SetupCommand, walletConnect: WalletConnectCommand, walletWho: WalletWhoCommand, walletStatus: WalletStatusCommand, economyLaunch: EconomyLaunchCommand, economyStatus: EconomyStatusCommand, economyInfo: EconomyInfoCommand, economyList: EconomyListCommand, createCommentCommand: CreateCommentCommand, commentListCommand: CommentListCommand, commentReplyCommand: CommentReplyCommand, commentRepliesCommand: CommentRepliesCommand, commentVoteCommand: CommentVoteCommand, paymentVerify: PaymentVerifyCommand, grantStatus: GrantStatusCommand);
36
+ constructor(setup: SetupCommand, walletConnect: WalletConnectCommand, walletWho: WalletWhoCommand, walletStatus: WalletStatusCommand, economyLaunch: EconomyLaunchCommand, economyStatus: EconomyStatusCommand, economyInfo: EconomyInfoCommand, economyList: EconomyListCommand, createCommentCommand: CreateCommentCommand, commentListCommand: CommentListCommand, commentReplyCommand: CommentReplyCommand, commentRepliesCommand: CommentRepliesCommand, commentVoteCommand: CommentVoteCommand, paymentVerify: PaymentVerifyCommand, grantStatus: GrantStatusCommand, economyRewards: EconomyRewardsCommand);
35
37
  run(argv: string[]): Promise<void>;
36
38
  private buildProgram;
37
39
  }
@@ -29,8 +29,9 @@ const list_comment_command_1 = require("./modules/comments/list-comment.command"
29
29
  const reply_comment_command_1 = require("./modules/comments/reply-comment.command");
30
30
  const list_replies_command_1 = require("./modules/comments/list-replies.command");
31
31
  const comment_vote_command_1 = require("./modules/comments/comment-vote.command");
32
+ const economy_rewards_command_1 = require("./modules/economy/commands/economy-rewards.command");
32
33
  let CliService = CliService_1 = class CliService {
33
- constructor(setup, walletConnect, walletWho, walletStatus, economyLaunch, economyStatus, economyInfo, economyList, createCommentCommand, commentListCommand, commentReplyCommand, commentRepliesCommand, commentVoteCommand, paymentVerify, grantStatus) {
34
+ constructor(setup, walletConnect, walletWho, walletStatus, economyLaunch, economyStatus, economyInfo, economyList, createCommentCommand, commentListCommand, commentReplyCommand, commentRepliesCommand, commentVoteCommand, paymentVerify, grantStatus, economyRewards) {
34
35
  this.setup = setup;
35
36
  this.walletConnect = walletConnect;
36
37
  this.walletWho = walletWho;
@@ -46,6 +47,7 @@ let CliService = CliService_1 = class CliService {
46
47
  this.commentVoteCommand = commentVoteCommand;
47
48
  this.paymentVerify = paymentVerify;
48
49
  this.grantStatus = grantStatus;
50
+ this.economyRewards = economyRewards;
49
51
  this.logger = new common_1.Logger(CliService_1.name);
50
52
  this.program = new commander_1.Command();
51
53
  this.buildProgram();
@@ -74,6 +76,7 @@ let CliService = CliService_1 = class CliService {
74
76
  this.economyStatus.register(economy);
75
77
  this.economyInfo.register(economy);
76
78
  this.economyList.register(economy);
79
+ this.economyRewards.register(economy);
77
80
  const payment = this.program
78
81
  .command("payment")
79
82
  .description("Manage fund applications and payments");
@@ -109,5 +112,6 @@ exports.CliService = CliService = CliService_1 = __decorate([
109
112
  list_replies_command_1.CommentRepliesCommand,
110
113
  comment_vote_command_1.CommentVoteCommand,
111
114
  payment_status_command_1.PaymentVerifyCommand,
112
- grant_status_command_1.GrantStatusCommand])
115
+ grant_status_command_1.GrantStatusCommand,
116
+ economy_rewards_command_1.EconomyRewardsCommand])
113
117
  ], CliService);
@@ -75,5 +75,6 @@ export declare class BackendApiService {
75
75
  value: number;
76
76
  }): Promise<any>;
77
77
  getWalletStatus(bot_id: string): Promise<any>;
78
+ getAgentRewards(bot_id: string, rpc_url: string): Promise<any>;
78
79
  isConfigured(): boolean;
79
80
  }
@@ -287,6 +287,16 @@ let BackendApiService = class BackendApiService {
287
287
  process.exit(1);
288
288
  }
289
289
  }
290
+ async getAgentRewards(bot_id, rpc_url) {
291
+ try {
292
+ const res = await this.client.get(`bots/agent/rewards?bot_id=${bot_id}&rpc_url=${rpc_url}`);
293
+ return res.data;
294
+ }
295
+ catch (err) {
296
+ this.output.warn(`❌ [GET-AGENT-REWARDS] Failed to fetch rewards | botId=${bot_id}: ${err instanceof Error ? err.message : String(err)}`);
297
+ process.exit(1);
298
+ }
299
+ }
290
300
  isConfigured() {
291
301
  return this.configured;
292
302
  }
@@ -0,0 +1,15 @@
1
+ import { Command } from "commander";
2
+ import { AuditService } from "../../security/audit.service";
3
+ import { ConfigService } from "../../config/config.service";
4
+ import { OutputService } from "../../../common/output.service";
5
+ import { BackendApiService } from "src/modules/backend-api/backend-api.service";
6
+ export declare class EconomyRewardsCommand {
7
+ private readonly backend;
8
+ private readonly audit;
9
+ private readonly config;
10
+ private readonly output;
11
+ private readonly logger;
12
+ constructor(backend: BackendApiService, audit: AuditService, config: ConfigService, output: OutputService);
13
+ register(program: Command): void;
14
+ private fetchAndDisplay;
15
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var EconomyRewardsCommand_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.EconomyRewardsCommand = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const audit_service_1 = require("../../security/audit.service");
16
+ const config_service_1 = require("../../config/config.service");
17
+ const output_service_1 = require("../../../common/output.service");
18
+ const backend_api_service_1 = require("../../backend-api/backend-api.service");
19
+ let EconomyRewardsCommand = EconomyRewardsCommand_1 = class EconomyRewardsCommand {
20
+ constructor(backend, audit, config, output) {
21
+ this.backend = backend;
22
+ this.audit = audit;
23
+ this.config = config;
24
+ this.output = output;
25
+ this.logger = new common_1.Logger(EconomyRewardsCommand_1.name);
26
+ }
27
+ register(program) {
28
+ program
29
+ .command("rewards")
30
+ .description("Fetch total rewards earned by this agent")
31
+ .requiredOption("--rpc <rpc>", 'RPC emdpoint"')
32
+ .option("--json", "Output result as JSON")
33
+ .action(async (opts) => {
34
+ const cfg = this.config.requireSetup();
35
+ if (!opts.json) {
36
+ this.output.header("Agent Rewards");
37
+ }
38
+ await this.fetchAndDisplay(cfg.botId, opts?.rpc, opts.json);
39
+ });
40
+ }
41
+ async fetchAndDisplay(botId, rpcUrl, json) {
42
+ await this.audit.run({
43
+ botId,
44
+ command: "economy:rewards",
45
+ args: { rpcUrl },
46
+ json,
47
+ }, async () => {
48
+ this.logger.log(`Fetching agent rewards using RPC: ${rpcUrl}`);
49
+ const result = await this.backend.getAgentRewards(botId, rpcUrl);
50
+ if (json) {
51
+ return this.output.json(this.output.envelope(result));
52
+ }
53
+ this.output.blank();
54
+ this.output.row("Agent ID", botId);
55
+ this.output.row("Network RPC", rpcUrl);
56
+ this.output.divider();
57
+ this.output.section("Rewards Summary");
58
+ this.output.row("Allocated", `${result?.allocated} ALI`);
59
+ this.output.row("Claimable", `${result?.claimable} ALI`);
60
+ this.output.row("Claimed", `${result?.claimed} ALI`);
61
+ this.output.divider();
62
+ });
63
+ }
64
+ };
65
+ exports.EconomyRewardsCommand = EconomyRewardsCommand;
66
+ exports.EconomyRewardsCommand = EconomyRewardsCommand = EconomyRewardsCommand_1 = __decorate([
67
+ (0, common_1.Injectable)(),
68
+ __metadata("design:paramtypes", [backend_api_service_1.BackendApiService,
69
+ audit_service_1.AuditService,
70
+ config_service_1.ConfigService,
71
+ output_service_1.OutputService])
72
+ ], EconomyRewardsCommand);