@hsuite/smart-engines-sdk 4.2.0 → 5.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/index.js CHANGED
@@ -11329,6 +11329,41 @@ var RulesClient = class {
11329
11329
  };
11330
11330
 
11331
11331
  // src/baas/entities/client.ts
11332
+ function normalizeEntityInfo(raw) {
11333
+ const r = raw;
11334
+ const entityId = String(r.entityId ?? "");
11335
+ const entityType = r.entityType ?? "account";
11336
+ const ownerWallet = String(r.ownerWallet ?? "");
11337
+ const ruleRef = r.ruleRef ?? {};
11338
+ const chainAccounts = r.chainAccounts ?? {};
11339
+ const createdAt = String(r.createdAt ?? "");
11340
+ let chain = r.chain ?? ruleRef.chain;
11341
+ if (!chain) {
11342
+ const firstChain = Object.keys(chainAccounts)[0];
11343
+ chain = firstChain ?? "hedera";
11344
+ }
11345
+ const rawAgentId = r.agentId;
11346
+ const agentId = rawAgentId ?? entityId;
11347
+ return {
11348
+ entityId,
11349
+ type: entityType,
11350
+ entityType,
11351
+ owner: ownerWallet,
11352
+ ownerWallet,
11353
+ chain,
11354
+ ruleRef,
11355
+ chainAccounts,
11356
+ createdAt,
11357
+ agentId
11358
+ };
11359
+ }
11360
+ function normalizeEntityCreationResult(raw) {
11361
+ const r = raw;
11362
+ return {
11363
+ ...r,
11364
+ agentId: r.agentId ?? r.entityId
11365
+ };
11366
+ }
11332
11367
  var EntitiesClient = class _EntitiesClient {
11333
11368
  constructor(http) {
11334
11369
  this.http = http;
@@ -11384,12 +11419,13 @@ var EntitiesClient = class _EntitiesClient {
11384
11419
  */
11385
11420
  async executeCreateToken(req) {
11386
11421
  const { createTxId, signedFundingBlob, ...rest } = req;
11387
- return this.http.post("/api/v3/baas/entities/execute-create", {
11422
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
11388
11423
  ...rest,
11389
11424
  ...createTxId !== void 0 ? { createTxId } : {},
11390
11425
  ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
11391
11426
  entityType: "token"
11392
11427
  });
11428
+ return normalizeEntityCreationResult(result);
11393
11429
  }
11394
11430
  /**
11395
11431
  * Create a canonical token entity bound to a published rule.
@@ -11436,7 +11472,8 @@ var EntitiesClient = class _EntitiesClient {
11436
11472
  securityMode: _ignoredSecurityMode,
11437
11473
  ...legacyReq
11438
11474
  } = req;
11439
- return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
11475
+ const result = await this.http.post("/api/v3/baas/entities/createToken", legacyReq);
11476
+ return normalizeEntityCreationResult(result);
11440
11477
  }
11441
11478
  /**
11442
11479
  * PREPARE half of the payer-funded account-create flow.
@@ -11468,10 +11505,11 @@ var EntitiesClient = class _EntitiesClient {
11468
11505
  */
11469
11506
  async executeCreateAccount(req) {
11470
11507
  const { createTxId, ...rest } = req;
11471
- return this.http.post("/api/v3/baas/entities/execute-create", {
11508
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
11472
11509
  ...rest,
11473
11510
  ...createTxId !== void 0 ? { createTxId } : {}
11474
11511
  });
11512
+ return normalizeEntityCreationResult(result);
11475
11513
  }
11476
11514
  /**
11477
11515
  * Chains whose account-create routes through the payer-funded 3-step
@@ -11558,7 +11596,8 @@ var EntitiesClient = class _EntitiesClient {
11558
11596
  securityMode: _ignoredSecurityMode,
11559
11597
  ...legacyReq
11560
11598
  } = req;
11561
- return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
11599
+ const result = await this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
11600
+ return normalizeEntityCreationResult(result);
11562
11601
  }
11563
11602
  /**
11564
11603
  * PREPARE half of the payer-funded topic-create flow (Hedera).
@@ -11584,10 +11623,11 @@ var EntitiesClient = class _EntitiesClient {
11584
11623
  * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
11585
11624
  */
11586
11625
  async executeCreateTopic(req) {
11587
- return this.http.post("/api/v3/baas/entities/execute-create", {
11626
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
11588
11627
  ...req,
11589
11628
  entityType: "topic"
11590
11629
  });
11630
+ return normalizeEntityCreationResult(result);
11591
11631
  }
11592
11632
  /**
11593
11633
  * Create a canonical topic entity bound to a published rule.
@@ -11632,11 +11672,13 @@ var EntitiesClient = class _EntitiesClient {
11632
11672
  securityMode: _ignoredSecurityMode,
11633
11673
  ...legacyReq
11634
11674
  } = req;
11635
- return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
11675
+ const result = await this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
11676
+ return normalizeEntityCreationResult(result);
11636
11677
  }
11637
11678
  /** Create a canonical agent entity bound to a published rule. */
11638
11679
  async createAgent(req) {
11639
- return this.http.post("/api/v3/baas/entities/createAgent", req);
11680
+ const result = await this.http.post("/api/v3/baas/entities/createAgent", req);
11681
+ return normalizeEntityCreationResult(result);
11640
11682
  }
11641
11683
  /**
11642
11684
  * PREPARE half of the payer-funded agent-create flow.
@@ -11669,12 +11711,13 @@ var EntitiesClient = class _EntitiesClient {
11669
11711
  */
11670
11712
  async executeCreateAgent(req) {
11671
11713
  const { createTxId, signedFundingBlob, ...rest } = req;
11672
- return this.http.post("/api/v3/baas/entities/execute-create", {
11714
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
11673
11715
  ...rest,
11674
11716
  ...createTxId !== void 0 ? { createTxId } : {},
11675
11717
  ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
11676
11718
  entityType: "agent"
11677
11719
  });
11720
+ return normalizeEntityCreationResult(result);
11678
11721
  }
11679
11722
  /**
11680
11723
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -11686,12 +11729,18 @@ var EntitiesClient = class _EntitiesClient {
11686
11729
  }
11687
11730
  /** Fetch an entity by its canonical `entityId`. */
11688
11731
  async get(entityId) {
11689
- return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
11732
+ const raw = await this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
11733
+ return normalizeEntityInfo(raw);
11690
11734
  }
11691
11735
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
11692
11736
  async listByOwner(filter) {
11693
11737
  const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
11694
- return this.http.get(path);
11738
+ const raw = await this.http.get(path);
11739
+ const response = raw;
11740
+ return {
11741
+ ...response,
11742
+ entities: response.entities?.map(normalizeEntityInfo) ?? []
11743
+ };
11695
11744
  }
11696
11745
  // ─── Value-movement (prepare-bytes only) ──────────────────────────────────
11697
11746
  //