@hsuite/smart-engines-sdk 3.14.0 → 4.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.1.0 — 2026-06-25
4
+
5
+ ### Added
6
+
7
+ - **`AgentRegisterRequest.primaryChain?: string`.** Agent registration mints the agent's on-chain wallet ENTITY on the chain named by `primaryChain`; the host requires it and defaults a missing value to `'hedera'` (which has no funded payer in XRPL-only deployments → `PAYER_ACCOUNT_NOT_FOUND`). The field was always accepted at runtime (`AgentsClient.register` forwards the whole body to `POST /api/v3/baas/agents/register`), but the SDK type omitted it, so consumers couldn't set it type-safely. Now declared as a plain optional `string` — valid host values: `'hedera'`, `'xrpl'`, `'polkadot'`, `'solana'`, `'ethereum'`, `'polygon'`, `'bitcoin'`, `'stellar'`. Additive and backward-compatible.
8
+
9
+ ## 4.0.0 — 2026-06-25
10
+
11
+ **SDK revision — align the surface to the REAL reachable endpoints; remove the un-ingressed-tier footguns.** Two profiles, two tiers: `BaasClient` is the app-as-proxy / external profile (host BaaS tier, `{gateway}/host/api/v3/baas/*`); `SmartEngineClient` is the in-cluster / validator-direct profile (raw `/api/v3/*` tier, un-ingressed at the gateway). The web3 authorization proxy is the HOST, which already exposes the entity value-movement routes — so value-movement now lives on `BaasClient.entities`, and the raw-tier transactions arm is removed from `BaasClient`.
12
+
13
+ ### Breaking changes
14
+
15
+ - **Removed `BaasClient.transactions` (the `TransactionsClient` sub-client) and `BaasClient`'s internal `txHttp`.** This arm rooted at the RAW `{hostUrl}/api/v3/transactions` origin — a sibling of `/host` that is un-ingressed at the public gateway (RFC #1236), so every call from a gateway-routed `BaasClient` 404'd. That was the footgun. The `TransactionsClient` class itself is unchanged and still ships on `SmartEngineClient` (the validator-direct profile). Migration: external/app-as-proxy callers use `BaasClient.entities.{transfer,withdraw,mint,burn,compliance,trustline}` (host BaaS tier) or, for in-cluster prepare/execute, construct a `SmartEngineClient` with an explicit `validatorBaseUrl`.
16
+ - **`SmartEngineClientConfig.baseUrl` → `validatorBaseUrl` (renamed, type-fence).** `SmartEngineClient` is now constructible ONLY with an explicit VALIDATOR origin. The rename makes it impossible to silently pass a gateway URL into the validator-direct client (whose raw `/api/v3/*` tier 404s at the gateway). Migration: `new SmartEngineClient({ baseUrl })` → `new SmartEngineClient({ validatorBaseUrl })`.
17
+ - **Removed `SmartEngineClient.connectToCluster()` (and its `ClusterConnectionConfig` / `ClusterConnectionSeed` / `ClusterConnectionResult` types).** It resolved a cluster's `gatewayUrl` and fed it into a gateway-pointed `SmartEngineClient` — the same footgun. To reach web3 through a cluster use `BaasClient.connectToCluster({ network })` (host BaaS tier); for an explicit in-cluster validator origin use `new SmartEngineClient({ validatorBaseUrl })` or `SmartEngineClient.connectToNetwork(...)` (which resolves a real validator `apiEndpoint` from the HCS registry — never a gateway URL). `connectToNetwork` is unchanged.
18
+
19
+ ### Added
20
+
21
+ - **`BaasClient.entities` value-movement (prepare-bytes only).** Six new methods mirroring the host's entity-scoped routes (`POST /api/v3/baas/entities/:entityId/{transfer,withdraw,mint,burn,compliance,trustline}`), each returning the host's `PreparedEntityTransactionResult` and threading `HttpCallOptions` (`onBehalfOf` / `customerToken` / `headers`) — owner-acting via the end user's Mode-1 customer-session JWT, exactly as `agents.execute`. The entity is the source / treasury / authority + fee-payer (resolved server-side; never named in the body), so a caller can never name a foreign payer or drain another account; a rule-deny surfaces as a 403 `rule_rejected` (use `isRuleRejected`), never as signed bytes. New signatures:
22
+ - `entities.transfer(entityId, body: TransferEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
23
+ - `entities.withdraw(entityId, body: WithdrawEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
24
+ - `entities.mint(entityId, body: MintEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
25
+ - `entities.burn(entityId, body: BurnEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
26
+ - `entities.compliance(entityId, body: ComplianceEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
27
+ - `entities.trustline(entityId, body: TrustlineEntityRequest, opts?) → Promise<PreparedEntityTransactionResult>`
28
+ - New exported types: `TransferEntityRequest`, `WithdrawEntityRequest`, `MintEntityRequest`, `BurnEntityRequest`, `ComplianceEntityRequest`, `ComplianceAction`, `TrustlineEntityRequest`, `PreparedEntityTransactionResult`.
29
+
3
30
  ## 3.14.0 — 2026-06-25
4
31
 
5
32
  ### Added
package/README.md CHANGED
@@ -79,15 +79,15 @@ baas.setAppId(init.appId);
79
79
  ```ts
80
80
  import { SmartEngineClient } from '@hsuite/smart-engines-sdk';
81
81
 
82
- const { client, cluster, session } = await SmartEngineClient.connectToCluster({
83
- network: 'testnet', // resolves canonical gateway entrypoint
82
+ const { client, validator, session } = await SmartEngineClient.connectToNetwork({
83
+ network: 'testnet', // resolves a real validator origin from the HCS registry
84
84
  chain: 'xrpl',
85
85
  address: wallet.address,
86
86
  publicKey: wallet.publicKey,
87
87
  signFn: (challenge) => /* sign the challenge */ '',
88
88
  });
89
89
 
90
- // All sub-clients are wired against the discovered cluster
90
+ // All sub-clients are wired against the discovered validator
91
91
  await client.tss.signMPC({ chain: 'hedera', entityId: '...', transactionBytes: '0x...' });
92
92
  await client.ipfs.upload(file, 'document.pdf');
93
93
  ```
@@ -115,8 +115,11 @@ const baas = new BaasClient({
115
115
  pathPrefix: '/host', // gateway routes /host/* → smart-host
116
116
  });
117
117
 
118
+ // `SmartEngineClient` is validator-direct: `validatorBaseUrl` MUST be a
119
+ // validator origin, NEVER the gateway. Its raw `/api/v3/*` tier is un-ingressed
120
+ // at the gateway (RFC #1236), so a gateway URL here 404s every call.
118
121
  const client = new SmartEngineClient({
119
- baseUrl: 'https://v3-testnet-gateway.hsuite.network',
122
+ validatorBaseUrl: 'http://smart-validator:3000', // in-cluster validator origin
120
123
  authToken: '<jwt-from-validator-auth-verify>',
121
124
  });
122
125
  ```
@@ -357,12 +360,12 @@ await baas.deployment.rollback(init.appId, { toTag: 'v0' });
357
360
 
358
361
  For direct chain operations independent of BaaS — e.g., a custodial backend
359
362
  that creates accounts and tokens on behalf of users — use the methods on the
360
- `SmartEngineClient` returned by `connectToCluster`:
363
+ `SmartEngineClient` returned by `connectToNetwork`:
361
364
 
362
365
  ```ts
363
366
  import { SmartEngineClient } from '@hsuite/smart-engines-sdk';
364
367
 
365
- const { client } = await SmartEngineClient.connectToCluster({
368
+ const { client } = await SmartEngineClient.connectToNetwork({
366
369
  network: 'testnet',
367
370
  chain: 'xrpl',
368
371
  address: wallet.address,
@@ -420,7 +423,7 @@ import { SmartEngineModule } from '@hsuite/smart-engines-sdk/nestjs';
420
423
  SmartEngineModule.forRootAsync({
421
424
  imports: [ConfigModule],
422
425
  useFactory: (config: ConfigService) => ({
423
- baseUrl: config.get('VALIDATOR_URL')!,
426
+ validatorBaseUrl: config.get('VALIDATOR_URL')!,
424
427
  timeout: 30000,
425
428
  testConnection: true,
426
429
  autoReconnect: true,
package/dist/index.d.ts CHANGED
@@ -3825,6 +3825,7 @@ export type AgentRegisterRequest = {
3825
3825
  description?: string;
3826
3826
  capabilities: string[];
3827
3827
  rules: AgentRules;
3828
+ primaryChain?: string;
3828
3829
  fundingConfig?: {
3829
3830
  chain: string;
3830
3831
  maxAmount: string;
@@ -4741,7 +4742,7 @@ export declare class OperatorClient {
4741
4742
  getTopup(chain: OperatorChain, accountId: string): Promise<OperatorTopUpResponse>;
4742
4743
  }
4743
4744
  export interface SmartEngineClientConfig {
4744
- baseUrl: string;
4745
+ validatorBaseUrl: string;
4745
4746
  apiKey?: string;
4746
4747
  authToken?: string;
4747
4748
  timeout?: number;
@@ -4761,35 +4762,6 @@ export interface NetworkConnectionConfig {
4761
4762
  mirrorNodeUrl?: string;
4762
4763
  allowInsecure?: boolean;
4763
4764
  }
4764
- export interface ClusterConnectionAuth {
4765
- chain: AuthChain;
4766
- address: string;
4767
- publicKey: string;
4768
- signFn: (challenge: string) => string | Promise<string>;
4769
- metadata?: {
4770
- appId?: string;
4771
- appName?: string;
4772
- };
4773
- trustAnchor?: {
4774
- network: "mainnet" | "testnet" | "previewnet";
4775
- registryTopicId: string;
4776
- mirrorNodeUrl?: string;
4777
- };
4778
- allowInsecure?: boolean;
4779
- }
4780
- export type ClusterConnectionSeed = {
4781
- bootstrap: string[];
4782
- network?: never;
4783
- } | {
4784
- bootstrap?: never;
4785
- network: NetworkName;
4786
- };
4787
- export type ClusterConnectionConfig = ClusterConnectionSeed & ClusterConnectionAuth;
4788
- export interface ClusterConnectionResult {
4789
- client: SmartEngineClient;
4790
- cluster: ClusterInfo;
4791
- session: AuthenticateResponse;
4792
- }
4793
4765
  export interface NetworkConnectionResult {
4794
4766
  client: SmartEngineClient;
4795
4767
  validator: ValidatorInfo;
@@ -4827,7 +4799,6 @@ export declare class SmartEngineClient {
4827
4799
  constructor(config: SmartEngineClientConfig);
4828
4800
  static fromEnv(env: Record<string, string | undefined>): SmartEngineClient;
4829
4801
  static connectToNetwork(config: NetworkConnectionConfig): Promise<NetworkConnectionResult>;
4830
- static connectToCluster(config: ClusterConnectionConfig): Promise<ClusterConnectionResult>;
4831
4802
  getBaseUrl(): string;
4832
4803
  isAuthenticated(): boolean;
4833
4804
  getHttpHealth(): {
@@ -25409,6 +25380,56 @@ export type LaunchpadEntityResult = {
25409
25380
  tokenId: string;
25410
25381
  chainAccounts: Record<string, string>;
25411
25382
  };
25383
+ export type TransferEntityRequest = {
25384
+ chain: ChainType;
25385
+ to: string;
25386
+ amount: string;
25387
+ tokenId?: string;
25388
+ memo?: string;
25389
+ };
25390
+ export type WithdrawEntityRequest = {
25391
+ chain: ChainType;
25392
+ destination: string;
25393
+ amount: string;
25394
+ tokenId?: string;
25395
+ memo?: string;
25396
+ };
25397
+ export type MintEntityRequest = {
25398
+ chain: ChainType;
25399
+ tokenId: string;
25400
+ amount: string;
25401
+ memo?: string;
25402
+ };
25403
+ export type BurnEntityRequest = {
25404
+ chain: ChainType;
25405
+ tokenId: string;
25406
+ amount: string;
25407
+ memo?: string;
25408
+ };
25409
+ export type ComplianceAction = "pause" | "restrict" | "wipe";
25410
+ export type ComplianceEntityRequest = {
25411
+ action: ComplianceAction;
25412
+ chain: ChainType;
25413
+ tokenId: string;
25414
+ account?: string;
25415
+ amount?: string;
25416
+ memo?: string;
25417
+ };
25418
+ export type TrustlineEntityRequest = {
25419
+ chain: ChainType;
25420
+ currency: string;
25421
+ issuerAddress: string;
25422
+ limit?: string;
25423
+ };
25424
+ export type PreparedEntityTransactionResult = {
25425
+ chain: string;
25426
+ transactionId: string;
25427
+ transactionBytes: string;
25428
+ transactionType?: string;
25429
+ payerAccountId?: string;
25430
+ expiresAt?: string;
25431
+ metadata?: Record<string, unknown>;
25432
+ };
25412
25433
  export declare class EntitiesClient {
25413
25434
  private readonly http;
25414
25435
  constructor(http: HttpClient);
@@ -25453,6 +25474,12 @@ export declare class EntitiesClient {
25453
25474
  launchpad(req: LaunchpadEntityRequest): Promise<LaunchpadEntityResult>;
25454
25475
  get(entityId: string): Promise<EntityInfo>;
25455
25476
  listByOwner(filter?: ListEntitiesFilter): Promise<ListEntitiesResponse>;
25477
+ transfer(entityId: string, body: TransferEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25478
+ withdraw(entityId: string, body: WithdrawEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25479
+ mint(entityId: string, body: MintEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25480
+ burn(entityId: string, body: BurnEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25481
+ compliance(entityId: string, body: ComplianceEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25482
+ trustline(entityId: string, body: TrustlineEntityRequest, opts?: HttpCallOptions): Promise<PreparedEntityTransactionResult>;
25456
25483
  }
25457
25484
  export type AuthenticateOptions = {
25458
25485
  chain: BaasSupportedChain;
@@ -25486,7 +25513,6 @@ export declare class BaasClient {
25486
25513
  private readonly timeout;
25487
25514
  private readonly allowInsecure;
25488
25515
  private readonly http;
25489
- private readonly txHttp;
25490
25516
  private lastHttpError?;
25491
25517
  private authContext?;
25492
25518
  readonly db: DatabaseClient;
@@ -25498,7 +25524,6 @@ export declare class BaasClient {
25498
25524
  readonly customerSession: CustomerSessionClient;
25499
25525
  readonly rules: RulesClient;
25500
25526
  readonly entities: EntitiesClient;
25501
- readonly transactions: TransactionsClient;
25502
25527
  constructor(config: BaasClientConfig);
25503
25528
  static connectToCluster(config: BaasConnectToClusterConfig): Promise<BaasClient>;
25504
25529
  setAppId(appId: string): void;
@@ -25718,7 +25743,7 @@ declare namespace personhood {
25718
25743
  export { PERSONHOOD_VERIFIER_NOT_CONFIGURED, PersonhoodAttestationMethod, PersonhoodCert, PersonhoodClient, PersonhoodProof, PersonhoodVerifyParams, isPersonhoodVerifierNotConfigured };
25719
25744
  }
25720
25745
  declare namespace baas {
25721
- export { AgentBalance, AgentCertification, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentPendingApprovalResponse, AgentPreparedTransactionResponse, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionCode, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, PreparedEntityCreation, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, ValidationResult, VersionHistoryResponse, isAgentFundPending, validateAgentRules };
25746
+ export { AgentBalance, AgentCertification, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentPendingApprovalResponse, AgentPreparedTransactionResponse, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionCode, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, BurnEntityRequest, ChannelSubscription, ComplianceAction, ComplianceEntityRequest, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, MintEntityRequest, PreparedEntityCreation, PreparedEntityTransactionResult, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, TransferEntityRequest, TrustlineEntityRequest, ValidationResult, VersionHistoryResponse, WithdrawEntityRequest, isAgentFundPending, validateAgentRules };
25722
25747
  }
25723
25748
  declare namespace pqcVerify {
25724
25749
  export { FetchRegistryOptions, PqcCertV1, PqcCertV1Schema, PqcCertV1Signer, ValidatorRegistrySnapshot, VerifyResult, fetchRegistrySnapshot, parsePqcCert, verifyPqcAttestation };
package/dist/index.js CHANGED
@@ -6478,9 +6478,11 @@ var ClusterDiscoveryClient = class {
6478
6478
  }
6479
6479
  /**
6480
6480
  * Convenience wrapper returning just the gateway URL of a random
6481
- * active cluster. The single most-used SDK entry pointmost
6482
- * downstream callers want `new SmartEngineClient({ baseUrl: ... })`
6483
- * and don't care about the rest of the metadata.
6481
+ * active cluster. Feed this to `BaasClient` (the host BaaS tier) e.g.
6482
+ * `new BaasClient({ hostUrl, pathPrefix: '/host' })` or
6483
+ * `BaasClient.connectToCluster({ network })`. Do NOT feed it to
6484
+ * `SmartEngineClient`: that client's raw `/api/v3/*` tier is un-ingressed at
6485
+ * the gateway and will 404 (it requires an explicit `validatorBaseUrl`).
6484
6486
  */
6485
6487
  async getRandomGatewayUrl(forceRefresh = false) {
6486
6488
  const cluster = await this.getRandomCluster(forceRefresh);
@@ -9245,7 +9247,7 @@ var SmartEngineClient = class _SmartEngineClient {
9245
9247
  discovery;
9246
9248
  constructor(config) {
9247
9249
  this.allowInsecure = config.allowInsecure ?? false;
9248
- this.baseUrl = validateClientUrl(config.baseUrl, this.allowInsecure);
9250
+ this.baseUrl = validateClientUrl(config.validatorBaseUrl, this.allowInsecure);
9249
9251
  this.http = createHttpClient({
9250
9252
  baseUrl: `${this.baseUrl}/api/v3`,
9251
9253
  apiKey: config.apiKey,
@@ -9307,7 +9309,7 @@ var SmartEngineClient = class _SmartEngineClient {
9307
9309
  const timeoutRaw = env["REQUEST_TIMEOUT"];
9308
9310
  const timeout = timeoutRaw ? Number.parseInt(timeoutRaw, 10) : void 0;
9309
9311
  return new _SmartEngineClient({
9310
- baseUrl,
9312
+ validatorBaseUrl: baseUrl,
9311
9313
  apiKey: env["VALIDATOR_API_KEY"],
9312
9314
  authToken: env["APP_TOKEN"],
9313
9315
  allowInsecure: env["ALLOW_INSECURE"] === "true",
@@ -9355,90 +9357,21 @@ var SmartEngineClient = class _SmartEngineClient {
9355
9357
  config.metadata
9356
9358
  );
9357
9359
  const client = new _SmartEngineClient({
9358
- baseUrl: validatorUrl,
9360
+ validatorBaseUrl: validatorUrl,
9359
9361
  authToken: session.token,
9360
9362
  allowInsecure
9361
9363
  });
9362
9364
  return { client, validator, session };
9363
9365
  }
9364
- /**
9365
- * Connect to the smart-engines network via the **service-registry**.
9366
- * Preferred over {@link connectToNetwork} once the validator pods in the
9367
- * target network have published their cluster endpoints the SDK
9368
- * auto-balances across the active cluster set and rides permissionless
9369
- * cluster join/leave without code edits.
9370
- *
9371
- * Resolution ladder:
9372
- * 1. HTTP fetch `/api/v3/discovery/clusters` from each bootstrap seed.
9373
- * 2. (Optional) HCS trust-anchor membership cross-check.
9374
- * 3. Random-pick over the verified set.
9375
- *
9376
- * @param config - Seed + auth config. See {@link ClusterConnectionConfig}.
9377
- * @returns The configured client, the selected cluster, and the auth session.
9378
- * @throws SmartEngineError 400 if neither `bootstrap` nor `network` is given.
9379
- * @throws SmartEngineError 503 if no active cluster can be reached.
9380
- *
9381
- * @example Zero-config (recommended for smart-app callers)
9382
- * ```ts
9383
- * const { client, cluster, session } = await SmartEngineClient.connectToCluster({
9384
- * network: 'testnet', // resolves canonical gateway entrypoint
9385
- * chain: 'xrpl',
9386
- * address: '...',
9387
- * publicKey: '...',
9388
- * signFn: async (challenge) => sign(challenge),
9389
- * });
9390
- * ```
9391
- *
9392
- * @example Custom seeds (private deployments / local dev)
9393
- * ```ts
9394
- * const { client, cluster, session } = await SmartEngineClient.connectToCluster({
9395
- * bootstrap: ['https://sn1.testnet.hsuite.network', 'https://sn2.testnet.hsuite.network'],
9396
- * chain: 'xrpl',
9397
- * address: '...',
9398
- * publicKey: '...',
9399
- * signFn: async (challenge) => sign(challenge),
9400
- * });
9401
- * ```
9402
- */
9403
- static async connectToCluster(config) {
9404
- const allowInsecure = config.allowInsecure ?? false;
9405
- const resolved = await resolveClusterEndpoint({
9406
- bootstrap: config.bootstrap,
9407
- network: config.network,
9408
- allowInsecure,
9409
- trustAnchor: config.trustAnchor
9410
- });
9411
- if (!resolved.ok) {
9412
- if (resolved.reason === "no-seeds") {
9413
- throw new SmartEngineError2(
9414
- "connectToCluster requires either a non-empty `bootstrap` list or a known `network` name.",
9415
- 400
9416
- );
9417
- }
9418
- throw new SmartEngineError2(
9419
- "No active clusters available via bootstrap seeds. Check bootstrap URLs and network reachability.",
9420
- 503
9421
- );
9422
- }
9423
- const cluster = resolved.cluster;
9424
- const gatewayUrl = cluster.endpoints.gatewayUrl;
9425
- validateClientUrl(gatewayUrl, allowInsecure);
9426
- const auth = new ValidatorAuthClient({ security: { allowInsecure } });
9427
- const session = await auth.authenticateWithSigner(
9428
- gatewayUrl,
9429
- config.chain,
9430
- config.address,
9431
- config.publicKey,
9432
- config.signFn,
9433
- config.metadata
9434
- );
9435
- const client = new _SmartEngineClient({
9436
- baseUrl: gatewayUrl,
9437
- authToken: session.token,
9438
- allowInsecure
9439
- });
9440
- return { client, cluster, session };
9441
- }
9366
+ // NOTE (SDK 4.0 type-fence): the former `SmartEngineClient.connectToCluster`
9367
+ // was REMOVED. It resolved a cluster's `gatewayUrl` and fed it into
9368
+ // `new SmartEngineClient({ baseUrl: gatewayUrl })` a gateway-pointed
9369
+ // validator-direct client whose raw `/api/v3/*` calls 404 (the raw tier is
9370
+ // un-ingressed at the gateway). That was the footgun. To reach web3 through a
9371
+ // cluster use `BaasClient.connectToCluster({ network })` (the host BaaS tier);
9372
+ // for an explicit in-cluster validator origin use `new SmartEngineClient({
9373
+ // validatorBaseUrl })` or `connectToNetwork` (which resolves a real validator
9374
+ // `apiEndpoint` from the HCS registry, never a gateway URL).
9442
9375
  /** Get the current validator URL */
9443
9376
  getBaseUrl() {
9444
9377
  return this.baseUrl;
@@ -11760,6 +11693,96 @@ var EntitiesClient = class _EntitiesClient {
11760
11693
  const path = filter?.type ? `/api/v3/baas/entities?type=${encodeURIComponent(filter.type)}` : "/api/v3/baas/entities";
11761
11694
  return this.http.get(path);
11762
11695
  }
11696
+ // ─── Value-movement (prepare-bytes only) ──────────────────────────────────
11697
+ //
11698
+ // Each method POSTs the host's entity-scoped value-movement route. The entity
11699
+ // is the source / treasury / authority + fee-payer (resolved server-side from
11700
+ // the entity record — never the body), so a caller can never name a foreign
11701
+ // payer or drain another account. The host authorises the call (session
11702
+ // caller identity + `loadOwnedEntity` ownership), delegates to the validator
11703
+ // preparer, and returns prepared bytes for the caller to sign + submit; the
11704
+ // host never submits and never pays. A rule-deny surfaces as an HTTP 403
11705
+ // `rule_rejected` (use `isRuleRejected`), never as signed bytes.
11706
+ //
11707
+ // `opts` threads {@link HttpCallOptions} (`onBehalfOf` / `customerToken` /
11708
+ // `headers`) so an app-as-proxy can act on behalf of an owner — the owner's
11709
+ // Mode-1 customer-session JWT rides as both `Authorization: Bearer` and
11710
+ // `X-Customer-Session-Claim`, exactly as `agents.execute` does.
11711
+ /**
11712
+ * Prepare a native or token transfer FROM an account entity.
11713
+ *
11714
+ * `POST /api/v3/baas/entities/:entityId/transfer`.
11715
+ */
11716
+ async transfer(entityId, body, opts) {
11717
+ return this.http.post(
11718
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/transfer`,
11719
+ body,
11720
+ opts
11721
+ );
11722
+ }
11723
+ /**
11724
+ * Prepare a withdrawal FROM an account entity to a destination.
11725
+ *
11726
+ * `POST /api/v3/baas/entities/:entityId/withdraw`.
11727
+ */
11728
+ async withdraw(entityId, body, opts) {
11729
+ return this.http.post(
11730
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/withdraw`,
11731
+ body,
11732
+ opts
11733
+ );
11734
+ }
11735
+ /**
11736
+ * Prepare a token/NFT mint whose supply authority is the account entity.
11737
+ *
11738
+ * `POST /api/v3/baas/entities/:entityId/mint`.
11739
+ */
11740
+ async mint(entityId, body, opts) {
11741
+ return this.http.post(
11742
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/mint`,
11743
+ body,
11744
+ opts
11745
+ );
11746
+ }
11747
+ /**
11748
+ * Prepare a token/NFT burn from the account entity's treasury.
11749
+ *
11750
+ * `POST /api/v3/baas/entities/:entityId/burn`.
11751
+ */
11752
+ async burn(entityId, body, opts) {
11753
+ return this.http.post(
11754
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/burn`,
11755
+ body,
11756
+ opts
11757
+ );
11758
+ }
11759
+ /**
11760
+ * Prepare a compliance action (pause / restrict / wipe) on a token whose
11761
+ * compliance authority is the account entity. The body `account` is the
11762
+ * per-account subject for restrict/wipe — never the payer.
11763
+ *
11764
+ * `POST /api/v3/baas/entities/:entityId/compliance`.
11765
+ */
11766
+ async compliance(entityId, body, opts) {
11767
+ return this.http.post(
11768
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/compliance`,
11769
+ body,
11770
+ opts
11771
+ );
11772
+ }
11773
+ /**
11774
+ * Prepare an XRPL TrustSet authorising the account entity to hold a currency
11775
+ * from an issuer.
11776
+ *
11777
+ * `POST /api/v3/baas/entities/:entityId/trustline`.
11778
+ */
11779
+ async trustline(entityId, body, opts) {
11780
+ return this.http.post(
11781
+ `/api/v3/baas/entities/${encodePathParam(entityId)}/trustline`,
11782
+ body,
11783
+ opts
11784
+ );
11785
+ }
11763
11786
  };
11764
11787
 
11765
11788
  // src/baas/client.ts
@@ -11770,13 +11793,6 @@ var BaasClient = class _BaasClient {
11770
11793
  timeout;
11771
11794
  allowInsecure;
11772
11795
  http;
11773
- /**
11774
- * Validator-routed HTTP client for the `/api/v3/transactions/*` prepare/execute
11775
- * surface — a SIBLING of `/host`, NOT under the `pathPrefix`. Rooted at the
11776
- * raw gateway/ingress origin (`hostUrl`) so transactions reach the validator
11777
- * even when BaaS traffic is gateway-routed at `/host/*`.
11778
- */
11779
- txHttp;
11780
11796
  /** Last HTTP error (for getHttpHealth) */
11781
11797
  lastHttpError;
11782
11798
  /**
@@ -11805,14 +11821,6 @@ var BaasClient = class _BaasClient {
11805
11821
  rules;
11806
11822
  /** Canonical entity authoring surface (token/account/topic/agent + launchpad). */
11807
11823
  entities;
11808
- /**
11809
- * Validator-routed transaction prepare/execute (sovereignty model). The
11810
- * prepare endpoints accept an explicit `payerAccountId` for the session-less
11811
- * payer path, OR carry the web3-auth session token for the JWT-wallet payer
11812
- * path (kept in sync with the main client's token — see {@link authenticate}).
11813
- * Targets `/api/v3/transactions/*`, a sibling of the `/host` BaaS surface.
11814
- */
11815
- transactions;
11816
11824
  constructor(config) {
11817
11825
  this.allowInsecure = config.allowInsecure ?? false;
11818
11826
  this.hostUrl = validateUrl2(config.hostUrl, this.allowInsecure);
@@ -11829,11 +11837,6 @@ var BaasClient = class _BaasClient {
11829
11837
  // been called (authContext set). Excludes /api/v3/{,baas/}auth/* (see http client).
11830
11838
  onUnauthorized: () => this.reauthenticate()
11831
11839
  });
11832
- this.txHttp = createHttpClient({
11833
- baseUrl: `${this.hostUrl.replace(/\/$/, "")}/api/v3/transactions`,
11834
- timeout: this.timeout,
11835
- onUnauthorized: () => this.reauthenticate()
11836
- });
11837
11840
  const getAppId = () => this.requireAppId();
11838
11841
  this.db = new DatabaseClient(this.http, getAppId);
11839
11842
  this.storage = new StorageClient(this.http, getAppId);
@@ -11844,7 +11847,6 @@ var BaasClient = class _BaasClient {
11844
11847
  this.customerSession = new CustomerSessionClient(baseUrlWithPrefix, this.timeout);
11845
11848
  this.rules = new RulesClient(this.http);
11846
11849
  this.entities = new EntitiesClient(this.http);
11847
- this.transactions = new TransactionsClient(this.txHttp);
11848
11850
  }
11849
11851
  /**
11850
11852
  * Connect to the Smart Engines BaaS via cluster auto-discovery.
@@ -11992,7 +11994,6 @@ var BaasClient = class _BaasClient {
11992
11994
  throw asBaasError(err);
11993
11995
  }
11994
11996
  this.http.setAuthToken(result.token);
11995
- this.txHttp.setAuthToken(result.token);
11996
11997
  return result;
11997
11998
  }
11998
11999
  /**
@@ -12018,7 +12019,6 @@ var BaasClient = class _BaasClient {
12018
12019
  publicKey: ctx.publicKey
12019
12020
  });
12020
12021
  this.http.setAuthToken(result.token);
12021
- this.txHttp.setAuthToken(result.token);
12022
12022
  }
12023
12023
  /** Validate the current session */
12024
12024
  async validateSession() {
@@ -12038,7 +12038,6 @@ var BaasClient = class _BaasClient {
12038
12038
  }
12039
12039
  }
12040
12040
  this.http.setAuthToken(void 0);
12041
- this.txHttp.setAuthToken(void 0);
12042
12041
  }
12043
12042
  // ========== HTTP Helpers ==========
12044
12043
  requireAuth() {