aiprotocol-sbi 1.0.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.
- package/dist/app.module.js +67 -0
- package/dist/app.module.js.map +1 -0
- package/dist/cli.service.js +80 -0
- package/dist/cli.service.js.map +1 -0
- package/dist/common/constants/index.js +44 -0
- package/dist/common/constants/index.js.map +1 -0
- package/dist/common/interfaces/index.js +3 -0
- package/dist/common/interfaces/index.js.map +1 -0
- package/dist/common/output.service.js +76 -0
- package/dist/common/output.service.js.map +1 -0
- package/dist/main.js +25 -0
- package/dist/main.js.map +1 -0
- package/dist/modules/ai-protocol/ai-protocol.service.js +171 -0
- package/dist/modules/ai-protocol/ai-protocol.service.js.map +1 -0
- package/dist/modules/config/config.service.js +84 -0
- package/dist/modules/config/config.service.js.map +1 -0
- package/dist/modules/database/database.config.js +9 -0
- package/dist/modules/database/database.config.js.map +1 -0
- package/dist/modules/database/database.service.js +74 -0
- package/dist/modules/database/database.service.js.map +1 -0
- package/dist/modules/database/repositories/bot.repository.js +81 -0
- package/dist/modules/database/repositories/bot.repository.js.map +1 -0
- package/dist/modules/database/repositories/command-log.repository.js +73 -0
- package/dist/modules/database/repositories/command-log.repository.js.map +1 -0
- package/dist/modules/database/repositories/economy.repository.js +58 -0
- package/dist/modules/database/repositories/economy.repository.js.map +1 -0
- package/dist/modules/database/schemas/bot.schema.js +17 -0
- package/dist/modules/database/schemas/bot.schema.js.map +1 -0
- package/dist/modules/database/schemas/command-log.schema.js +21 -0
- package/dist/modules/database/schemas/command-log.schema.js.map +1 -0
- package/dist/modules/database/schemas/economy.schema.js +26 -0
- package/dist/modules/database/schemas/economy.schema.js.map +1 -0
- package/dist/modules/database/schemas/rate-limit.schema.js +12 -0
- package/dist/modules/database/schemas/rate-limit.schema.js.map +1 -0
- package/dist/modules/economy/commands/economy-info-requirements.command.js +161 -0
- package/dist/modules/economy/commands/economy-info-requirements.command.js.map +1 -0
- package/dist/modules/economy/commands/economy-launch.command.js +193 -0
- package/dist/modules/economy/commands/economy-launch.command.js.map +1 -0
- package/dist/modules/economy/commands/economy-status.command.js +131 -0
- package/dist/modules/economy/commands/economy-status.command.js.map +1 -0
- package/dist/modules/security/audit.service.js +129 -0
- package/dist/modules/security/audit.service.js.map +1 -0
- package/dist/modules/security/security.service.js +185 -0
- package/dist/modules/security/security.service.js.map +1 -0
- package/dist/modules/wallet/bot-identity.service.js +117 -0
- package/dist/modules/wallet/bot-identity.service.js.map +1 -0
- package/dist/modules/wallet/commands/wallet-connect.command.js +117 -0
- package/dist/modules/wallet/commands/wallet-connect.command.js.map +1 -0
- package/dist/modules/wallet/commands/wallet-create.command.js +168 -0
- package/dist/modules/wallet/commands/wallet-create.command.js.map +1 -0
- package/dist/modules/wallet/commands/wallet-status.command.js +96 -0
- package/dist/modules/wallet/commands/wallet-status.command.js.map +1 -0
- package/dist/modules/wallet/commands/wallet-who.command.js +110 -0
- package/dist/modules/wallet/commands/wallet-who.command.js.map +1 -0
- package/dist/modules/wallet/wallet-crypto.service.js +100 -0
- package/dist/modules/wallet/wallet-crypto.service.js.map +1 -0
- package/dist/setup.command.js +134 -0
- package/dist/setup.command.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const config_1 = require("@nestjs/config");
|
|
12
|
+
const cli_service_1 = require("./cli.service");
|
|
13
|
+
const output_service_1 = require("./common/output.service");
|
|
14
|
+
const setup_command_1 = require("./setup.command");
|
|
15
|
+
const database_service_1 = require("./modules/database/database.service");
|
|
16
|
+
const bot_repository_1 = require("./modules/database/repositories/bot.repository");
|
|
17
|
+
const command_log_repository_1 = require("./modules/database/repositories/command-log.repository");
|
|
18
|
+
const economy_repository_1 = require("./modules/database/repositories/economy.repository");
|
|
19
|
+
const config_service_1 = require("./modules/config/config.service");
|
|
20
|
+
const security_service_1 = require("./modules/security/security.service");
|
|
21
|
+
const audit_service_1 = require("./modules/security/audit.service");
|
|
22
|
+
const wallet_crypto_service_1 = require("./modules/wallet/wallet-crypto.service");
|
|
23
|
+
const bot_identity_service_1 = require("./modules/wallet/bot-identity.service");
|
|
24
|
+
const wallet_create_command_1 = require("./modules/wallet/commands/wallet-create.command");
|
|
25
|
+
const wallet_connect_command_1 = require("./modules/wallet/commands/wallet-connect.command");
|
|
26
|
+
const wallet_who_command_1 = require("./modules/wallet/commands/wallet-who.command");
|
|
27
|
+
const wallet_status_command_1 = require("./modules/wallet/commands/wallet-status.command");
|
|
28
|
+
const economy_launch_command_1 = require("./modules/economy/commands/economy-launch.command");
|
|
29
|
+
const economy_status_command_1 = require("./modules/economy/commands/economy-status.command");
|
|
30
|
+
const economy_info_requirements_command_1 = require("./modules/economy/commands/economy-info-requirements.command");
|
|
31
|
+
const ai_protocol_service_1 = require("./modules/ai-protocol/ai-protocol.service");
|
|
32
|
+
let AppModule = class AppModule {
|
|
33
|
+
};
|
|
34
|
+
exports.AppModule = AppModule;
|
|
35
|
+
exports.AppModule = AppModule = __decorate([
|
|
36
|
+
(0, common_1.Module)({
|
|
37
|
+
imports: [
|
|
38
|
+
config_1.ConfigModule.forRoot({
|
|
39
|
+
isGlobal: true,
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
providers: [
|
|
43
|
+
cli_service_1.CliService,
|
|
44
|
+
output_service_1.OutputService,
|
|
45
|
+
setup_command_1.SetupCommand,
|
|
46
|
+
database_service_1.DatabaseService,
|
|
47
|
+
bot_repository_1.BotRepository,
|
|
48
|
+
command_log_repository_1.CommandLogRepository,
|
|
49
|
+
economy_repository_1.EconomyRepository,
|
|
50
|
+
config_service_1.ConfigService,
|
|
51
|
+
security_service_1.SecurityService,
|
|
52
|
+
audit_service_1.AuditService,
|
|
53
|
+
wallet_crypto_service_1.WalletCryptoService,
|
|
54
|
+
bot_identity_service_1.BotIdentityService,
|
|
55
|
+
wallet_create_command_1.WalletCreateCommand,
|
|
56
|
+
wallet_connect_command_1.WalletConnectCommand,
|
|
57
|
+
wallet_who_command_1.WalletWhoCommand,
|
|
58
|
+
wallet_status_command_1.WalletStatusCommand,
|
|
59
|
+
economy_launch_command_1.EconomyLaunchCommand,
|
|
60
|
+
economy_status_command_1.EconomyStatusCommand,
|
|
61
|
+
economy_info_requirements_command_1.EconomyInfoCommand,
|
|
62
|
+
economy_info_requirements_command_1.EconomyRequirementsCommand,
|
|
63
|
+
ai_protocol_service_1.AiProtocolService,
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
], AppModule);
|
|
67
|
+
//# sourceMappingURL=app.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAA8C;AAE9C,+CAA2C;AAC3C,4DAAwD;AACxD,mDAA+C;AAG/C,0EAAsE;AACtE,mFAA+E;AAC/E,mGAA8F;AAC9F,2FAAuF;AAGvF,oEAAgE;AAGhE,0EAAsE;AACtE,oEAAgE;AAGhE,kFAA6E;AAC7E,gFAA2E;AAC3E,2FAAsF;AACtF,6FAAwF;AACxF,qFAAgF;AAChF,2FAAsF;AAGtF,8FAAyF;AACzF,8FAAyF;AACzF,oHAGsE;AAGtE,mFAA8E;AAwDvE,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IA3CrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;SACH;QACD,SAAS,EAAE;YAET,wBAAU;YACV,8BAAa;YACb,4BAAY;YAGZ,kCAAe;YACf,8BAAa;YACb,6CAAoB;YACpB,sCAAiB;YAGjB,8BAAa;YAGb,kCAAe;YACf,4BAAY;YAGZ,2CAAmB;YACnB,yCAAkB;YAClB,2CAAmB;YACnB,6CAAoB;YACpB,qCAAgB;YAChB,2CAAmB;YAGnB,6CAAoB;YACpB,6CAAoB;YACpB,sDAAkB;YAClB,8DAA0B;YAG1B,uCAAiB;SAClB;KACF,CAAC;GACW,SAAS,CAAG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 CliService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CliService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const commander_1 = require("commander");
|
|
16
|
+
const constants_1 = require("./common/constants");
|
|
17
|
+
const setup_command_1 = require("./setup.command");
|
|
18
|
+
const wallet_create_command_1 = require("./modules/wallet/commands/wallet-create.command");
|
|
19
|
+
const wallet_connect_command_1 = require("./modules/wallet/commands/wallet-connect.command");
|
|
20
|
+
const wallet_who_command_1 = require("./modules/wallet/commands/wallet-who.command");
|
|
21
|
+
const wallet_status_command_1 = require("./modules/wallet/commands/wallet-status.command");
|
|
22
|
+
const economy_launch_command_1 = require("./modules/economy/commands/economy-launch.command");
|
|
23
|
+
const economy_status_command_1 = require("./modules/economy/commands/economy-status.command");
|
|
24
|
+
const economy_info_requirements_command_1 = require("./modules/economy/commands/economy-info-requirements.command");
|
|
25
|
+
let CliService = CliService_1 = class CliService {
|
|
26
|
+
constructor(setup, walletCreate, walletConnect, walletWho, walletStatus, economyLaunch, economyStatus, economyInfo, economyRequirements) {
|
|
27
|
+
this.setup = setup;
|
|
28
|
+
this.walletCreate = walletCreate;
|
|
29
|
+
this.walletConnect = walletConnect;
|
|
30
|
+
this.walletWho = walletWho;
|
|
31
|
+
this.walletStatus = walletStatus;
|
|
32
|
+
this.economyLaunch = economyLaunch;
|
|
33
|
+
this.economyStatus = economyStatus;
|
|
34
|
+
this.economyInfo = economyInfo;
|
|
35
|
+
this.economyRequirements = economyRequirements;
|
|
36
|
+
this.logger = new common_1.Logger(CliService_1.name);
|
|
37
|
+
this.program = new commander_1.Command();
|
|
38
|
+
this.buildProgram();
|
|
39
|
+
}
|
|
40
|
+
async run(argv) {
|
|
41
|
+
this.logger.debug(`Running CLI with args: ${argv.slice(2).join(" ")}`);
|
|
42
|
+
await this.program.parseAsync(argv);
|
|
43
|
+
}
|
|
44
|
+
buildProgram() {
|
|
45
|
+
this.program
|
|
46
|
+
.name(constants_1.CLI_NAME)
|
|
47
|
+
.description("Launch a self-sustaining SBI economy on the AI Protocol")
|
|
48
|
+
.version(constants_1.CLI_VERSION)
|
|
49
|
+
.action(() => this.program.help());
|
|
50
|
+
this.setup.register(this.program);
|
|
51
|
+
const wallet = this.program
|
|
52
|
+
.command("wallet")
|
|
53
|
+
.description("Manage the agent wallet and bot identity");
|
|
54
|
+
this.walletCreate.register(wallet);
|
|
55
|
+
this.walletConnect.register(wallet);
|
|
56
|
+
this.walletWho.register(wallet);
|
|
57
|
+
this.walletStatus.register(wallet);
|
|
58
|
+
const economy = this.program
|
|
59
|
+
.command("economy")
|
|
60
|
+
.description("Launch and inspect an SBI economy");
|
|
61
|
+
this.economyLaunch.register(economy);
|
|
62
|
+
this.economyStatus.register(economy);
|
|
63
|
+
this.economyInfo.register(economy);
|
|
64
|
+
this.economyRequirements.register(economy);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.CliService = CliService;
|
|
68
|
+
exports.CliService = CliService = CliService_1 = __decorate([
|
|
69
|
+
(0, common_1.Injectable)(),
|
|
70
|
+
__metadata("design:paramtypes", [setup_command_1.SetupCommand,
|
|
71
|
+
wallet_create_command_1.WalletCreateCommand,
|
|
72
|
+
wallet_connect_command_1.WalletConnectCommand,
|
|
73
|
+
wallet_who_command_1.WalletWhoCommand,
|
|
74
|
+
wallet_status_command_1.WalletStatusCommand,
|
|
75
|
+
economy_launch_command_1.EconomyLaunchCommand,
|
|
76
|
+
economy_status_command_1.EconomyStatusCommand,
|
|
77
|
+
economy_info_requirements_command_1.EconomyInfoCommand,
|
|
78
|
+
economy_info_requirements_command_1.EconomyRequirementsCommand])
|
|
79
|
+
], CliService);
|
|
80
|
+
//# sourceMappingURL=cli.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.service.js","sourceRoot":"","sources":["../src/cli.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yCAAoC;AACpC,kDAA2D;AAC3D,mDAA+C;AAC/C,2FAAsF;AACtF,6FAAwF;AACxF,qFAAgF;AAChF,2F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AM,GAAG,IAAI,CAAC,OAAO;aACxB,OAAO,CAAC,QAAQ,CAAC;aACjB,WAAW,CAAC,0CAA0C,CAAC,CAAC;QAC3D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAGnC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO;aACzB,OAAO,CAAC,SAAS,CAAC;aAClB,WAAW,CAAC,mCAAmC,CAAC,CAAC;QACpD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AA3DY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAMe,4BAAY;QACL,2CAAmB;QAClB,6CAAoB;QACxB,qCAAgB;QACb,2CAAmB;QAClB,6CAAoB;QACpB,6CAAoB;QACtB,sDAAkB;QACV,8DAA0B;GAbvD,UAAU,CA2DtB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POLL_TIMEOUT_MS = exports.POLL_INTERVAL_MS = exports.ACTIVE_ECONOMY_STATUSES = exports.COMMAND_LOG_TTL_SECS = exports.VALIDATION = exports.SENSITIVE_ARG_KEYS = exports.FAILED_ATTEMPTS_BLOCK_THRESHOLD = exports.ECONOMY_LAUNCH_COMMANDS = exports.RATE_LIMITS = exports.CLI_VERSION = exports.CLI_NAME = void 0;
|
|
4
|
+
exports.CLI_NAME = "aiprotocol-sbi";
|
|
5
|
+
exports.CLI_VERSION = "1.0.0";
|
|
6
|
+
exports.RATE_LIMITS = {
|
|
7
|
+
setup: { max: 5, windowSecs: 3600 },
|
|
8
|
+
"wallet:create": { max: 3, windowSecs: 3600 },
|
|
9
|
+
"wallet:connect": { max: 10, windowSecs: 3600 },
|
|
10
|
+
"wallet:status": { max: 30, windowSecs: 60 },
|
|
11
|
+
"wallet:who": { max: 2, windowSecs: 60 },
|
|
12
|
+
"economy:launch": { max: 2, windowSecs: 86400 },
|
|
13
|
+
"economy:status": { max: 60, windowSecs: 60 },
|
|
14
|
+
"economy:info": { max: 60, windowSecs: 60 },
|
|
15
|
+
"economy:requirements": { max: 30, windowSecs: 60 },
|
|
16
|
+
__default__: { max: 20, windowSecs: 60 },
|
|
17
|
+
};
|
|
18
|
+
exports.ECONOMY_LAUNCH_COMMANDS = new Set(["economy:launch"]);
|
|
19
|
+
exports.FAILED_ATTEMPTS_BLOCK_THRESHOLD = 10;
|
|
20
|
+
exports.SENSITIVE_ARG_KEYS = new Set([
|
|
21
|
+
"password",
|
|
22
|
+
"keystorepassword",
|
|
23
|
+
"privatekey",
|
|
24
|
+
"mnemonic",
|
|
25
|
+
"apikey",
|
|
26
|
+
"secret",
|
|
27
|
+
"token",
|
|
28
|
+
"seed",
|
|
29
|
+
]);
|
|
30
|
+
exports.VALIDATION = {
|
|
31
|
+
TICKER: /^[A-Z0-9]{2,10}$/,
|
|
32
|
+
BOT_NAME: /^[\w\s\-\.]{2,64}$/,
|
|
33
|
+
ADDRESS: /^0x[0-9a-fA-F]{40}$/,
|
|
34
|
+
INJECTION: /(\$where|\$regex|\$gt|\$lt|\$ne|\$in|\$exists|\.\.\/|<script)/i,
|
|
35
|
+
};
|
|
36
|
+
exports.COMMAND_LOG_TTL_SECS = 60 * 60 * 24 * 90;
|
|
37
|
+
exports.ACTIVE_ECONOMY_STATUSES = [
|
|
38
|
+
"pending",
|
|
39
|
+
"deploying",
|
|
40
|
+
"live",
|
|
41
|
+
];
|
|
42
|
+
exports.POLL_INTERVAL_MS = 5000;
|
|
43
|
+
exports.POLL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/constants/index.ts"],"names":[],"mappings":";;;AAMa,QAAA,QAAQ,GAAG,gBAAgB,CAAC;AAG5B,QAAA,WAAW,GAAG,OAAO,CAAC;AAOtB,QAAA,WAAW,GACtB;IACE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE;IACnC,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7C,gBAAgB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;IAC/C,eAAe,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC5C,YAAY,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;IACxC,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE;IAC/C,gBAAgB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC7C,cAAc,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAC3C,sBAAsB,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IACnD,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;CACzC,CAAC;AAMS,QAAA,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAKtD,QAAA,+BAA+B,GAAG,EAAE,CAAC;AAMrC,QAAA,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACxC,UAAU;IACV,kBAAkB;IAClB,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAKU,QAAA,UAAU,GAAG;IAExB,MAAM,EAAE,kBAAkB;IAE1B,QAAQ,EAAE,oBAAoB;IAE9B,OAAO,EAAE,qBAAqB;IAE9B,SAAS,EAAE,gEAAgE;CACnE,CAAC;AAOE,QAAA,oBAAoB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAGzC,QAAA,uBAAuB,GAAG;IACrC,SAAS;IACT,WAAW;IACX,MAAM;CACE,CAAC;AAGE,QAAA,gBAAgB,GAAG,IAAK,CAAC;AACzB,QAAA,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,IAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/interfaces/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OutputService = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
let OutputService = class OutputService {
|
|
12
|
+
json(data) {
|
|
13
|
+
const envelope = { ok: true, data };
|
|
14
|
+
console.log(JSON.stringify(envelope, null, 2));
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
jsonError(message, details) {
|
|
18
|
+
const envelope = {
|
|
19
|
+
ok: false,
|
|
20
|
+
error: message,
|
|
21
|
+
...(details !== undefined ? { details } : {}),
|
|
22
|
+
};
|
|
23
|
+
console.log(JSON.stringify(envelope, null, 2));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
envelope(data) {
|
|
27
|
+
return { ok: true, data };
|
|
28
|
+
}
|
|
29
|
+
header(title) {
|
|
30
|
+
console.log("");
|
|
31
|
+
console.log(`━━━ ${title} ━━━`);
|
|
32
|
+
console.log("");
|
|
33
|
+
}
|
|
34
|
+
row(label, value) {
|
|
35
|
+
console.log(` ${label.padEnd(26)}${value}`);
|
|
36
|
+
}
|
|
37
|
+
divider() {
|
|
38
|
+
console.log(` ${"─".repeat(46)}`);
|
|
39
|
+
}
|
|
40
|
+
blank() {
|
|
41
|
+
console.log("");
|
|
42
|
+
}
|
|
43
|
+
section(title) {
|
|
44
|
+
console.log(`\n ${title}`);
|
|
45
|
+
this.divider();
|
|
46
|
+
}
|
|
47
|
+
statusBadge(status) {
|
|
48
|
+
var _a;
|
|
49
|
+
const badges = {
|
|
50
|
+
live: "[ LIVE ]",
|
|
51
|
+
deploying: "[ DEPLOYING ]",
|
|
52
|
+
pending: "[ PENDING ]",
|
|
53
|
+
failed: "[ FAILED ]",
|
|
54
|
+
eligible: "[ ELIGIBLE ]",
|
|
55
|
+
ineligible: "[ INELIGIBLE ]",
|
|
56
|
+
};
|
|
57
|
+
return (_a = badges[status.toLowerCase()]) !== null && _a !== void 0 ? _a : `[ ${status.toUpperCase()} ]`;
|
|
58
|
+
}
|
|
59
|
+
success(message) {
|
|
60
|
+
console.log(` ✔ ${message}`);
|
|
61
|
+
}
|
|
62
|
+
warn(message) {
|
|
63
|
+
console.log(` ⚠ ${message}`);
|
|
64
|
+
}
|
|
65
|
+
error(message) {
|
|
66
|
+
console.error(` ✖ ${message}`);
|
|
67
|
+
}
|
|
68
|
+
info(message) {
|
|
69
|
+
console.log(` ℹ ${message}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.OutputService = OutputService;
|
|
73
|
+
exports.OutputService = OutputService = __decorate([
|
|
74
|
+
(0, common_1.Injectable)()
|
|
75
|
+
], OutputService);
|
|
76
|
+
//# sourceMappingURL=output.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.service.js","sourceRoot":"","sources":["../../src/common/output.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAiBrC,IAAM,aAAa,GAAnB,MAAM,aAAa;IASxB,IAAI,CAAI,IAAO;QACb,MAAM,QAAQ,GAAoB,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAQD,SAAS,CAAC,OAAe,EAAE,OAAiB;QAC1C,MAAM,QAAQ,GAAsB;YAClC,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,OAAO;YACd,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAMD,QAAQ,CAAI,IAAO;QACjB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI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AC,OAAe;QACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC;IACnC,CAAC;IAOD,IAAI,CAAC,OAAe;QAClB,OAAO,CAAC,GAAG,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAA;AAxIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAwIzB"}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const core_1 = require("@nestjs/core");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const app_module_1 = require("./app.module");
|
|
8
|
+
const cli_service_1 = require("./cli.service");
|
|
9
|
+
const database_service_1 = require("./modules/database/database.service");
|
|
10
|
+
const logger = new common_1.Logger("Bootstrap");
|
|
11
|
+
async function bootstrap() {
|
|
12
|
+
const app = await core_1.NestFactory.createApplicationContext(app_module_1.AppModule, {
|
|
13
|
+
logger: false,
|
|
14
|
+
});
|
|
15
|
+
const cli = app.get(cli_service_1.CliService);
|
|
16
|
+
await cli.run(process.argv);
|
|
17
|
+
await app.get(database_service_1.DatabaseService).disconnect();
|
|
18
|
+
await app.close();
|
|
19
|
+
}
|
|
20
|
+
bootstrap().catch((err) => {
|
|
21
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
22
|
+
logger.error(`Fatal error: ${message}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AAWA,4BAA0B;AAC1B,uCAA2C;AAC3C,2CAAwC;AACxC,6CAAyC;AACzC,+CAA2C;AAC3C,0EAAsE;AAEtE,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,WAAW,CAAC,CAAC;AAEvC,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,wBAAwB,CAAC,sBAAS,EAAE;QAEhE,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAU,CAAC,CAAC;IAChC,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAG5B,MAAM,GAAG,CAAC,GAAG,CAAC,kCAAe,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5C,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACjC,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,CAAC,KAAK,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
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 AiProtocolService_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AiProtocolService = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const axios_1 = require("axios");
|
|
13
|
+
const delay = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14
|
+
function stubWalletStatus(address, network) {
|
|
15
|
+
return {
|
|
16
|
+
address,
|
|
17
|
+
network,
|
|
18
|
+
balance: { ali: "2500.00", native: "0.05" },
|
|
19
|
+
isEligibleForLaunch: true,
|
|
20
|
+
requiredAli: "1000.00",
|
|
21
|
+
shortfallAli: "0",
|
|
22
|
+
lastCheckedAt: new Date().toISOString(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function stubEconomyInfo(identifier) {
|
|
26
|
+
return {
|
|
27
|
+
economyId: "eco_stub_001",
|
|
28
|
+
name: "Demo Economy",
|
|
29
|
+
ticker: "DEMO",
|
|
30
|
+
description: "Stub economy for development.",
|
|
31
|
+
status: "live",
|
|
32
|
+
network: "base",
|
|
33
|
+
contractAddress: "0xDummy00ContractAddress000000000000000001",
|
|
34
|
+
tokenAddress: "0xDummy00TokenAddress0000000000000000002",
|
|
35
|
+
bondingCurveAddress: "0xDummy00BondingCurve000000000000000003",
|
|
36
|
+
uniswapPoolAddress: "0xDummy00UniswapPool0000000000000000004",
|
|
37
|
+
decimals: 18,
|
|
38
|
+
totalSupply: "1000000.00",
|
|
39
|
+
currentPrice: "0.00250",
|
|
40
|
+
marketCap: "2500.00",
|
|
41
|
+
liquidityReserve: "1000.00",
|
|
42
|
+
holders: 42,
|
|
43
|
+
transactions24h: 17,
|
|
44
|
+
volume24h: "340.00",
|
|
45
|
+
feeRate: "0.3%",
|
|
46
|
+
feesEarned: "8.50",
|
|
47
|
+
feesEarned24h: "1.02",
|
|
48
|
+
ownerAddress: "0xDummy00OwnerAddress00000000000000005",
|
|
49
|
+
createdAt: new Date(Date.now() - 7 * 86400000).toISOString(),
|
|
50
|
+
updatedAt: new Date().toISOString(),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function stubRequirements(network) {
|
|
54
|
+
return {
|
|
55
|
+
network,
|
|
56
|
+
minimumAliToLaunch: "1000.00",
|
|
57
|
+
recommendedAliToLaunch: "5000.00",
|
|
58
|
+
launchFeeAli: "100.00",
|
|
59
|
+
bondingCurveType: "linear",
|
|
60
|
+
uniswapPoolFeeRate: "0.3%",
|
|
61
|
+
tickerMaxLength: 10,
|
|
62
|
+
tickerAllowedChars: "A-Z, 0-9",
|
|
63
|
+
nameMaxLength: 64,
|
|
64
|
+
soulboundNote: "The economy is permanently and irreversibly fused to the agent. It cannot be transferred, paused, or revoked.",
|
|
65
|
+
retrievedAt: new Date().toISOString(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const USE_STUBS = true;
|
|
69
|
+
let AiProtocolService = AiProtocolService_1 = class AiProtocolService {
|
|
70
|
+
constructor() {
|
|
71
|
+
this.logger = new common_1.Logger(AiProtocolService_1.name);
|
|
72
|
+
}
|
|
73
|
+
configure(config) {
|
|
74
|
+
this.client = axios_1.default.create({
|
|
75
|
+
baseURL: config.apiBaseUrl,
|
|
76
|
+
timeout: 30000,
|
|
77
|
+
headers: {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
...(config.apiKey ? { "x-api-key": config.apiKey } : {}),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
this.logger.debug(`API client configured: ${config.apiBaseUrl}`);
|
|
83
|
+
}
|
|
84
|
+
async getWalletBalance(address, network) {
|
|
85
|
+
if (USE_STUBS) {
|
|
86
|
+
await delay(400);
|
|
87
|
+
return { address, network, balance: { ali: "2500.00", native: "0.05" } };
|
|
88
|
+
}
|
|
89
|
+
const res = await this.client.get(`/wallets/${address}/balance`, { params: { network } });
|
|
90
|
+
return res.data;
|
|
91
|
+
}
|
|
92
|
+
async getWalletStatus(address, network) {
|
|
93
|
+
if (USE_STUBS) {
|
|
94
|
+
await delay(600);
|
|
95
|
+
return stubWalletStatus(address, network);
|
|
96
|
+
}
|
|
97
|
+
const res = await this.client.get(`/wallets/${address}/status`, { params: { network } });
|
|
98
|
+
return res.data;
|
|
99
|
+
}
|
|
100
|
+
async launchEconomy(payload) {
|
|
101
|
+
if (USE_STUBS) {
|
|
102
|
+
await delay(1200);
|
|
103
|
+
return {
|
|
104
|
+
economyId: "eco_stub_001",
|
|
105
|
+
name: payload.name,
|
|
106
|
+
ticker: payload.ticker,
|
|
107
|
+
status: "deploying",
|
|
108
|
+
contractAddress: "0xDummy00ContractAddress000000000000000001",
|
|
109
|
+
tokenAddress: "0xDummy00TokenAddress0000000000000000002",
|
|
110
|
+
bondingCurveAddress: "0xDummy00BondingCurve000000000000000003",
|
|
111
|
+
uniswapPoolAddress: "0xDummy00UniswapPool0000000000000000004",
|
|
112
|
+
transactionHash: "0xDummyTxHash000000000000000000000000000000000000000000000000000000",
|
|
113
|
+
createdAt: new Date().toISOString(),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const res = await this.client.post("/economies", payload);
|
|
117
|
+
return res.data;
|
|
118
|
+
}
|
|
119
|
+
async getEconomyStatus(identifier) {
|
|
120
|
+
if (USE_STUBS) {
|
|
121
|
+
await delay(500);
|
|
122
|
+
return {
|
|
123
|
+
economyId: "eco_stub_001",
|
|
124
|
+
name: "Demo Economy",
|
|
125
|
+
ticker: "DEMO",
|
|
126
|
+
status: "live",
|
|
127
|
+
network: "base",
|
|
128
|
+
contractAddress: "0xDummy00ContractAddress000000000000000001",
|
|
129
|
+
tokenAddress: "0xDummy00TokenAddress0000000000000000002",
|
|
130
|
+
metrics: {
|
|
131
|
+
tokenPrice: "0.00250",
|
|
132
|
+
marketCap: "2500.00",
|
|
133
|
+
totalSupply: "1000000.00",
|
|
134
|
+
holders: 42,
|
|
135
|
+
volume24h: "340.00",
|
|
136
|
+
feesEarned: "8.50",
|
|
137
|
+
feesEarned24h: "1.02",
|
|
138
|
+
},
|
|
139
|
+
wallet: {
|
|
140
|
+
address: "0xDummy00OwnerAddress00000000000000005",
|
|
141
|
+
aliBalance: "2400.00",
|
|
142
|
+
nativeBalance: "0.05",
|
|
143
|
+
},
|
|
144
|
+
updatedAt: new Date().toISOString(),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const res = await this.client.get(`/economies/${identifier}`);
|
|
148
|
+
return res.data;
|
|
149
|
+
}
|
|
150
|
+
async getEconomyInfo(identifier) {
|
|
151
|
+
if (USE_STUBS) {
|
|
152
|
+
await delay(500);
|
|
153
|
+
return stubEconomyInfo(identifier);
|
|
154
|
+
}
|
|
155
|
+
const res = await this.client.get(`/economies/${identifier}/info`);
|
|
156
|
+
return res.data;
|
|
157
|
+
}
|
|
158
|
+
async getEconomyRequirements(network) {
|
|
159
|
+
if (USE_STUBS) {
|
|
160
|
+
await delay(300);
|
|
161
|
+
return stubRequirements(network);
|
|
162
|
+
}
|
|
163
|
+
const res = await this.client.get("/economies/requirements", { params: { network } });
|
|
164
|
+
return res.data;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
exports.AiProtocolService = AiProtocolService;
|
|
168
|
+
exports.AiProtocolService = AiProtocolService = AiProtocolService_1 = __decorate([
|
|
169
|
+
(0, common_1.Injectable)()
|
|
170
|
+
], AiProtocolService);
|
|
171
|
+
//# sourceMappingURL=ai-protocol.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-protocol.service.js","sourceRoot":"","sources":["../../../src/modules/ai-protocol/ai-protocol.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,iCAA6C;AA6G7C,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAE1E,SAAS,gBAAgB,CAAC,OAAe,EAAE,OAAe;IACxD,OAAO;QACL,OAAO;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CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CA4K7B"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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 ConfigService_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ConfigService = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const os = require("os");
|
|
15
|
+
const DEFAULT_CONFIG = {
|
|
16
|
+
apiBaseUrl: "https://api.aiprotocol.info/v1",
|
|
17
|
+
network: "base",
|
|
18
|
+
setupComplete: false,
|
|
19
|
+
};
|
|
20
|
+
let ConfigService = ConfigService_1 = class ConfigService {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.logger = new common_1.Logger(ConfigService_1.name);
|
|
23
|
+
this.configDir = path.join(os.homedir(), ".aiprotocol-sbi");
|
|
24
|
+
this.configPath = path.join(this.configDir, "config.json");
|
|
25
|
+
}
|
|
26
|
+
load() {
|
|
27
|
+
if (!fs.existsSync(this.configPath)) {
|
|
28
|
+
return { ...DEFAULT_CONFIG };
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const raw = fs.readFileSync(this.configPath, "utf-8");
|
|
32
|
+
return { ...DEFAULT_CONFIG, ...JSON.parse(raw) };
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
36
|
+
this.logger.warn(`Could not parse config file (${msg}) — using defaults`);
|
|
37
|
+
return { ...DEFAULT_CONFIG };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
save(partial) {
|
|
41
|
+
const merged = { ...this.load(), ...partial };
|
|
42
|
+
if (!fs.existsSync(this.configDir)) {
|
|
43
|
+
fs.mkdirSync(this.configDir, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
fs.writeFileSync(this.configPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
46
|
+
this.logger.debug(`Config saved to ${this.configPath}`);
|
|
47
|
+
return merged;
|
|
48
|
+
}
|
|
49
|
+
clear() {
|
|
50
|
+
if (fs.existsSync(this.configPath)) {
|
|
51
|
+
fs.unlinkSync(this.configPath);
|
|
52
|
+
this.logger.log("Config file cleared");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
requireSetup() {
|
|
56
|
+
const cfg = this.load();
|
|
57
|
+
if (!cfg.setupComplete) {
|
|
58
|
+
throw new Error("Not configured. Run `aiprotocol-sbi setup` first.");
|
|
59
|
+
}
|
|
60
|
+
return cfg;
|
|
61
|
+
}
|
|
62
|
+
requireWallet() {
|
|
63
|
+
const cfg = this.requireSetup();
|
|
64
|
+
if (!cfg.walletAddress) {
|
|
65
|
+
throw new Error("No wallet configured. Run `aiprotocol-sbi wallet create`.");
|
|
66
|
+
}
|
|
67
|
+
return cfg;
|
|
68
|
+
}
|
|
69
|
+
requireKeystorePassword() {
|
|
70
|
+
const cfg = this.requireSetup();
|
|
71
|
+
if (!cfg.keystorePassword) {
|
|
72
|
+
throw new Error("No keystore password set. Run `aiprotocol-sbi setup` to configure one.");
|
|
73
|
+
}
|
|
74
|
+
return cfg.keystorePassword;
|
|
75
|
+
}
|
|
76
|
+
get configFilePath() {
|
|
77
|
+
return this.configPath;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.ConfigService = ConfigService;
|
|
81
|
+
exports.ConfigService = ConfigService = ConfigService_1 = __decorate([
|
|
82
|
+
(0, common_1.Injectable)()
|
|
83
|
+
], ConfigService);
|
|
84
|
+
//# sourceMappingURL=config.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.service.js","sourceRoot":"","sources":["../../../src/modules/config/config.service.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,yBAAyB;AACzB,6BAA6B;AAC7B,yBAAyB;AAwCzB,MAAM,cAAc,GAAc;IAChC,UAAU,EAAE,gCAAgC;IAC5C,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,KAAK;CACrB,CAAC;AAeK,IAAM,aAAa,qBAAnB,MAAM,aAAa;IAAnB;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,eAAa,CAAC,IAAI,CAAC,CAAC;QAExC,cAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;QACvD,eAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAmGzE,CAAC;IA3FC,IAAI;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,OAAO,EAAE,GAAG,cAAc,EAAE,CAAC;QAC/B,CAAC;QACD,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACtD,OAAO,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CA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AY,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAOD,uBAAuB;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,gBAAgB,CAAC;IAC9B,CAAC;IAGD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF,CAAA;AAvGY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CAuGzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MONGO_OPTIONS = void 0;
|
|
4
|
+
exports.MONGO_OPTIONS = {
|
|
5
|
+
serverSelectionTimeoutMS: 2000,
|
|
6
|
+
connectTimeoutMS: 2000,
|
|
7
|
+
maxPoolSize: 2,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=database.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.config.js","sourceRoot":"","sources":["../../../src/modules/database/database.config.ts"],"names":[],"mappings":";;;AAWa,QAAA,aAAa,GAAG;IAE3B,wBAAwB,EAAE,IAAI;IAC9B,gBAAgB,EAAE,IAAI;IAEtB,WAAW,EAAE,CAAC;CACN,CAAC"}
|