@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.
@@ -4819,6 +4819,41 @@ var RulesClient = class {
4819
4819
  };
4820
4820
 
4821
4821
  // src/baas/entities/client.ts
4822
+ function normalizeEntityInfo(raw) {
4823
+ const r = raw;
4824
+ const entityId = String(r.entityId ?? "");
4825
+ const entityType = r.entityType ?? "account";
4826
+ const ownerWallet = String(r.ownerWallet ?? "");
4827
+ const ruleRef = r.ruleRef ?? {};
4828
+ const chainAccounts = r.chainAccounts ?? {};
4829
+ const createdAt = String(r.createdAt ?? "");
4830
+ let chain = r.chain ?? ruleRef.chain;
4831
+ if (!chain) {
4832
+ const firstChain = Object.keys(chainAccounts)[0];
4833
+ chain = firstChain ?? "hedera";
4834
+ }
4835
+ const rawAgentId = r.agentId;
4836
+ const agentId = rawAgentId ?? entityId;
4837
+ return {
4838
+ entityId,
4839
+ type: entityType,
4840
+ entityType,
4841
+ owner: ownerWallet,
4842
+ ownerWallet,
4843
+ chain,
4844
+ ruleRef,
4845
+ chainAccounts,
4846
+ createdAt,
4847
+ agentId
4848
+ };
4849
+ }
4850
+ function normalizeEntityCreationResult(raw) {
4851
+ const r = raw;
4852
+ return {
4853
+ ...r,
4854
+ agentId: r.agentId ?? r.entityId
4855
+ };
4856
+ }
4822
4857
  var EntitiesClient = class _EntitiesClient {
4823
4858
  constructor(http) {
4824
4859
  this.http = http;
@@ -4874,12 +4909,13 @@ var EntitiesClient = class _EntitiesClient {
4874
4909
  */
4875
4910
  async executeCreateToken(req) {
4876
4911
  const { createTxId, signedFundingBlob, ...rest } = req;
4877
- return this.http.post("/api/v3/baas/entities/execute-create", {
4912
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
4878
4913
  ...rest,
4879
4914
  ...createTxId !== void 0 ? { createTxId } : {},
4880
4915
  ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
4881
4916
  entityType: "token"
4882
4917
  });
4918
+ return normalizeEntityCreationResult(result);
4883
4919
  }
4884
4920
  /**
4885
4921
  * Create a canonical token entity bound to a published rule.
@@ -4926,7 +4962,8 @@ var EntitiesClient = class _EntitiesClient {
4926
4962
  securityMode: _ignoredSecurityMode,
4927
4963
  ...legacyReq
4928
4964
  } = req;
4929
- return this.http.post("/api/v3/baas/entities/createToken", legacyReq);
4965
+ const result = await this.http.post("/api/v3/baas/entities/createToken", legacyReq);
4966
+ return normalizeEntityCreationResult(result);
4930
4967
  }
4931
4968
  /**
4932
4969
  * PREPARE half of the payer-funded account-create flow.
@@ -4958,10 +4995,11 @@ var EntitiesClient = class _EntitiesClient {
4958
4995
  */
4959
4996
  async executeCreateAccount(req) {
4960
4997
  const { createTxId, ...rest } = req;
4961
- return this.http.post("/api/v3/baas/entities/execute-create", {
4998
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
4962
4999
  ...rest,
4963
5000
  ...createTxId !== void 0 ? { createTxId } : {}
4964
5001
  });
5002
+ return normalizeEntityCreationResult(result);
4965
5003
  }
4966
5004
  /**
4967
5005
  * Chains whose account-create routes through the payer-funded 3-step
@@ -5048,7 +5086,8 @@ var EntitiesClient = class _EntitiesClient {
5048
5086
  securityMode: _ignoredSecurityMode,
5049
5087
  ...legacyReq
5050
5088
  } = req;
5051
- return this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
5089
+ const result = await this.http.post("/api/v3/baas/entities/createAccount", legacyReq);
5090
+ return normalizeEntityCreationResult(result);
5052
5091
  }
5053
5092
  /**
5054
5093
  * PREPARE half of the payer-funded topic-create flow (Hedera).
@@ -5074,10 +5113,11 @@ var EntitiesClient = class _EntitiesClient {
5074
5113
  * assigned `0.0.X` topic id from the receipt and stamps `chainAccounts.hedera`.
5075
5114
  */
5076
5115
  async executeCreateTopic(req) {
5077
- return this.http.post("/api/v3/baas/entities/execute-create", {
5116
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
5078
5117
  ...req,
5079
5118
  entityType: "topic"
5080
5119
  });
5120
+ return normalizeEntityCreationResult(result);
5081
5121
  }
5082
5122
  /**
5083
5123
  * Create a canonical topic entity bound to a published rule.
@@ -5122,11 +5162,13 @@ var EntitiesClient = class _EntitiesClient {
5122
5162
  securityMode: _ignoredSecurityMode,
5123
5163
  ...legacyReq
5124
5164
  } = req;
5125
- return this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
5165
+ const result = await this.http.post("/api/v3/baas/entities/createTopic", legacyReq);
5166
+ return normalizeEntityCreationResult(result);
5126
5167
  }
5127
5168
  /** Create a canonical agent entity bound to a published rule. */
5128
5169
  async createAgent(req) {
5129
- return this.http.post("/api/v3/baas/entities/createAgent", req);
5170
+ const result = await this.http.post("/api/v3/baas/entities/createAgent", req);
5171
+ return normalizeEntityCreationResult(result);
5130
5172
  }
5131
5173
  /**
5132
5174
  * PREPARE half of the payer-funded agent-create flow.
@@ -5159,12 +5201,13 @@ var EntitiesClient = class _EntitiesClient {
5159
5201
  */
5160
5202
  async executeCreateAgent(req) {
5161
5203
  const { createTxId, signedFundingBlob, ...rest } = req;
5162
- return this.http.post("/api/v3/baas/entities/execute-create", {
5204
+ const result = await this.http.post("/api/v3/baas/entities/execute-create", {
5163
5205
  ...rest,
5164
5206
  ...createTxId !== void 0 ? { createTxId } : {},
5165
5207
  ...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
5166
5208
  entityType: "agent"
5167
5209
  });
5210
+ return normalizeEntityCreationResult(result);
5168
5211
  }
5169
5212
  /**
5170
5213
  * Mega-helper: build a token rule with a launchpad ModuleEntry attached,
@@ -5176,12 +5219,18 @@ var EntitiesClient = class _EntitiesClient {
5176
5219
  }
5177
5220
  /** Fetch an entity by its canonical `entityId`. */
5178
5221
  async get(entityId) {
5179
- return this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
5222
+ const raw = await this.http.get(`/api/v3/baas/entities/${encodePathParam(entityId)}`);
5223
+ return normalizeEntityInfo(raw);
5180
5224
  }
5181
5225
  /** List entities owned by the authenticated wallet, optionally filtered by type. */
5182
5226
  async listByOwner(filter) {
5183
5227
  const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
5184
- return this.http.get(path);
5228
+ const raw = await this.http.get(path);
5229
+ const response = raw;
5230
+ return {
5231
+ ...response,
5232
+ entities: response.entities?.map(normalizeEntityInfo) ?? []
5233
+ };
5185
5234
  }
5186
5235
  // ─── Value-movement (prepare-bytes only) ──────────────────────────────────
5187
5236
  //