@toon-protocol/core 1.5.0 → 1.6.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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { T as ToonError } from './index-DSgMeweu.js';
2
2
  export { I as InvalidEventError, P as PeerDiscoveryError, a as ToonDecodeError, b as ToonEncodeError, c as ToonRoutingMeta, d as decodeEventFromToon, e as encodeEventToToon, f as encodeEventToToonString, s as shallowParseToon } from './index-DSgMeweu.js';
3
- import { NostrEvent } from 'nostr-tools/pure';
3
+ import { NostrEvent, Event } from 'nostr-tools/pure';
4
4
  import { SimplePool } from 'nostr-tools/pool';
5
5
  import { TurboAuthenticatedClient } from '@ardrive/turbo-sdk';
6
6
 
@@ -3719,7 +3719,7 @@ interface SolanaChainPreset {
3719
3719
  chainType: 'solana';
3720
3720
  /** Solana cluster RPC endpoint (HTTP). */
3721
3721
  rpcUrl: string;
3722
- /** Payment channel program ID (base58-encoded). TBD until deployed. */
3722
+ /** Payment channel program ID (base58-encoded). */
3723
3723
  programId: string;
3724
3724
  /** Solana cluster name for chain ID namespacing (e.g., 'devnet'). */
3725
3725
  cluster: string;
@@ -3736,7 +3736,7 @@ interface MinaChainPreset {
3736
3736
  chainType: 'mina';
3737
3737
  /** Mina GraphQL endpoint. */
3738
3738
  graphqlUrl: string;
3739
- /** zkApp address for the payment channel contract. TBD until deployed. */
3739
+ /** zkApp address for the payment channel contract. */
3740
3740
  zkAppAddress: string;
3741
3741
  /** Mina network name (e.g., 'devnet'). */
3742
3742
  network: string;
@@ -4517,6 +4517,100 @@ interface Logger {
4517
4517
  */
4518
4518
  declare function createLogger(config: LoggerConfig): Logger;
4519
4519
 
4520
+ /**
4521
+ * Pure helpers for NIP-on-TOON UI renderer resolution.
4522
+ *
4523
+ * An event may carry a `ui` tag whose value is an addressable coordinate
4524
+ * pointing at a `kind:31036` renderer event. The coordinate convention is:
4525
+ *
4526
+ * 31036:<renderer-author-pubkey>:<target-kind>
4527
+ *
4528
+ * where the trailing segment (the renderer event's `d` tag value) is the
4529
+ * kind of event the renderer knows how to render.
4530
+ *
4531
+ * These helpers are intentionally PURE: they parse coordinate strings and
4532
+ * select the latest addressable event from a set of candidates. The actual
4533
+ * resolution (relay query + cache) is client-local and lives outside core.
4534
+ *
4535
+ * Mirrors the style of `parseRepositoryReference` in `../nip34/types.ts`.
4536
+ */
4537
+
4538
+ /** The renderer event kind for NIP-on-TOON UI rendering. */
4539
+ declare const UI_RENDERER_KIND = 31036;
4540
+ /** Tag name carrying the UI renderer coordinate on a rendered event. */
4541
+ declare const UI_TAG = "ui";
4542
+ /**
4543
+ * A parsed `ui` renderer coordinate.
4544
+ * Format: "31036:<pubkey>:<targetKind>"
4545
+ */
4546
+ interface UiCoordinate {
4547
+ /** Always {@link UI_RENDERER_KIND} (31036). */
4548
+ kind: typeof UI_RENDERER_KIND;
4549
+ /** The renderer author's 64-hex pubkey. */
4550
+ pubkey: string;
4551
+ /** The kind of event this renderer targets (the renderer's `d` value). */
4552
+ targetKind: number;
4553
+ }
4554
+ /**
4555
+ * Parse a `ui` renderer coordinate string of the form
4556
+ * `31036:<pubkey>:<targetKind>`.
4557
+ *
4558
+ * Returns `null` on any malformed input: wrong segment count, a leading kind
4559
+ * other than 31036, a pubkey that is not 64-hex, or a non-integer target kind.
4560
+ *
4561
+ * Pure: no IO, no relay fetch.
4562
+ *
4563
+ * @param coord - The coordinate string (e.g. a `ui` tag value).
4564
+ * @returns The parsed {@link UiCoordinate}, or `null` if malformed.
4565
+ */
4566
+ declare function parseUiCoordinate(coord: string): UiCoordinate | null;
4567
+ /**
4568
+ * Build a `ui` renderer coordinate string of the form
4569
+ * `31036:<pubkey>:<targetKind>`.
4570
+ *
4571
+ * The inverse of {@link parseUiCoordinate}. Returns `null` if the inputs are
4572
+ * invalid (pubkey not 64-hex, or target kind not a non-negative integer), so
4573
+ * that `build`→`parse` round-trips cleanly.
4574
+ *
4575
+ * Pure: no IO, no relay fetch.
4576
+ *
4577
+ * @param ref - The renderer author pubkey and target kind.
4578
+ * @returns The coordinate string, or `null` if the inputs are invalid.
4579
+ */
4580
+ declare function buildUiCoordinate(ref: {
4581
+ pubkey: string;
4582
+ targetKind: number;
4583
+ }): string | null;
4584
+ /**
4585
+ * Read the `ui` tag value off an event and parse it into a coordinate.
4586
+ *
4587
+ * Convenience wrapper around {@link parseUiCoordinate} that pulls the first
4588
+ * `ui` tag's value from `event.tags`. Returns `null` if the event has no
4589
+ * `ui` tag or the tag value is malformed.
4590
+ *
4591
+ * Pure: no IO, no relay fetch.
4592
+ *
4593
+ * @param event - The event that may reference a renderer via a `ui` tag.
4594
+ * @returns The parsed {@link UiCoordinate}, or `null`.
4595
+ */
4596
+ declare function getUiCoordinate(event: Event): UiCoordinate | null;
4597
+ /**
4598
+ * Select the latest addressable/replaceable event from a set of candidates
4599
+ * that share an addressable coordinate.
4600
+ *
4601
+ * Implements NIP-33 latest-wins: the event with the greatest `created_at`
4602
+ * wins. Ties on `created_at` are broken by the lexicographically lowest `id`
4603
+ * per the NIP-01 convention.
4604
+ *
4605
+ * Does not itself group by coordinate — callers pass the candidate set for a
4606
+ * single coordinate (e.g. the result of a relay query filtered by author +
4607
+ * kind + `#d`). Pure: no IO, no relay fetch.
4608
+ *
4609
+ * @param events - Candidate events sharing a coordinate.
4610
+ * @returns The latest event, or `undefined` for an empty input.
4611
+ */
4612
+ declare function selectLatestAddressable<T extends Event>(events: T[]): T | undefined;
4613
+
4520
4614
  /**
4521
4615
  * @toon-protocol/core
4522
4616
  *
@@ -4524,4 +4618,4 @@ declare function createLogger(config: LoggerConfig): Logger;
4524
4618
  */
4525
4619
  declare const VERSION = "0.1.0";
4526
4620
 
4527
- export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake, balanceProofFieldsMina, balanceProofHashEvm, balanceProofHashSolana, base58Decode, base58Encode, bigintToBytes32BE, buildAttestationEvent, buildBlobStorageRequest, buildEip712Domain, buildEvmProviderEntry, buildIlpPeerInfoEvent, buildIlpPrepare, buildJobFeedbackEvent, buildJobRequestEvent, buildJobResultEvent, buildJobReviewEvent, buildMinaProviderEntry, buildPrefixClaimEvent, buildPrefixGrantEvent, buildPrefixHandshakeData, buildSeedRelayListEvent, buildServiceDiscoveryEvent, buildSolanaProviderEntry, buildSwarmRequestEvent, buildSwarmSelectionEvent, buildWorkflowDefinitionEvent, buildWotDeclarationEvent, calculateRouteAmount, checkAddressCollision, concatBytes, createAgentRuntimeClient, createDirectChannelClient, createDirectConnectorAdmin, createDirectIlpClient, createDirectRuntimeClient, createDiscoveryTracker, createHttpChannelClient, createHttpConnectorAdmin, createHttpIlpClient$1 as createHttpIlpClient, createHttpRuntimeClient, createHttpIlpClient as createHttpRuntimeClientV2, createLogger, createToonNode, deriveChildAddress, deriveFromKmsSeed, deriveMinaPublicKeyBase58, extractPrefixFromHandshake, getEventExpiration, hasMinReputation, hasRequireAttestation, hexToBytes, hexToMinaBase58PrivateKey, ilpCodeToSemantic, isEventExpired, isGenesisNode, isValidIlpAddressStructure, minaHashToField, negotiateSettlementChain, parseAttestation, parseBlobStorageRequest, parseIlpPeerInfo, parseJobFeedback, parseJobRequest, parseJobResult, parseJobReview, parsePrefixClaimEvent, parsePrefixGrantEvent, parseSeedRelayList, parseServiceDiscovery, parseSwarmRequest, parseSwarmSelection, parseWorkflowDefinition, parseWotDeclaration, publishSeedRelayEntry, readDockerfileNix, resolveChainConfig, resolveClientNetwork, resolveMinaChainConfig, resolveNetworkProfile, resolveRouteFees, resolveSolanaChainConfig, resolveTokenForChain, validateChainId, validateIlpAddress, validatePrefix, validatePrefixConsistency, verifyPcrReproducibility };
4621
+ export { AddressRegistry, type AgentRuntimeClient, ArDrivePeerRegistry, AttestationBootstrap, type AttestationBootstrapConfig, type AttestationBootstrapEvent, type AttestationBootstrapEventListener, type AttestationBootstrapResult, type AttestationEventOptions, AttestationState, AttestationVerifier, type AttestationVerifierConfig, type AttestedResultVerificationOptions, type AttestedResultVerificationResult, AttestedResultVerifier, BLOB_STORAGE_REQUEST_KIND, BLOB_STORAGE_RESULT_KIND, type BlobStorageRequestParams, type BootstrapConfig, BootstrapError, type BootstrapEvent, type BootstrapEventListener, type BootstrapPhase, type BootstrapResult, BootstrapService, type BootstrapServiceConfig, type BtpHandshakeExtension, type BuildIlpPeerInfoOptions, type BuildIlpPrepareParams, CHAIN_PRESETS, type CalculateRouteAmountParams, type ChainName, type ChainPreset, type ChainProviderConfigEntry, type ChainType, type ChannelState, type ClientNetworkPresets, type ConnectorAdminClient, type ConnectorAdminLike, type ConnectorChannelClient, type ConnectorChannelLike, type ConnectorNodeLike, type CustomEndpoints, type DeriveFromKmsSeedOptions, type DeterminismReport, type DirectRuntimeClientConfig, type DiscoveredPeer, type DiscoveryTracker, type DiscoveryTrackerConfig, type DvmJobStatus, type EVMProviderConfigEntry, EXPIRATION_TAG, type EmbeddableConnectorLike, type ForbiddenPattern, type GenesisPeer, GenesisPeerLoader, type HandlePacketAcceptResponse, type HandlePacketRejectResponse, type HandlePacketRequest, type HandlePacketResponse, ILP_PEER_INFO_KIND, ILP_ROOT_PREFIX, ILP_TO_SEMANTIC, IMAGE_GENERATION_KIND, type IlpClient, type IlpPeerInfo, type IlpPreparePacket, type IlpSendResult, JOB_FEEDBACK_KIND, JOB_REQUEST_KIND_BASE, JOB_RESULT_KIND_BASE, JOB_REVIEW_KIND, type JobFeedbackParams, type JobRequestParams, type JobResultParams, type JobReviewParams, KmsIdentityError, type KmsKeypair, type KnownPeer, type LogEntry, type LogLevel, type Logger, type LoggerConfig, MINA_CHAIN_PRESETS, MOCK_USDC_ADDRESS, MOCK_USDC_CONFIG, type MinaChainName, type MinaChainPreset, type MinaProviderConfigEntry, type MockUsdcConfig, type MultiChainName, type NetworkFamilyStatus, type NetworkMode, type NetworkNodeEnv, type NetworkProfile, type NixBuildResult, NixBuilder, type NixBuilderConfig, NostrPeerDiscovery, type OpenChannelParams, type OpenChannelResult, PET_INTERACTION_EVENT_KIND, PET_INTERACTION_REQUEST_KIND, PET_INTERACTION_RESULT_KIND, PREFIX_CLAIM_KIND, PREFIX_GRANT_KIND, type PacketHandler, type ParsedAttestation, type ParsedBlobStorageRequest, type ParsedJobFeedback, type ParsedJobRequest, type ParsedJobResult, type ParsedJobReview, type ParsedSwarmRequest, type ParsedSwarmSelection, type ParsedWorkflowDefinition, type ParsedWotDeclaration, PcrReproducibilityError, type PcrReproducibilityResult, type PeerDescriptor, type PrefixClaimContent, type PrefixGrantContent, type PrefixValidationResult, type PublishSeedRelayConfig, RELAY_ONLY_CHAIN, type RegisterPeerParams, type ReputationScore, ReputationScoreCalculator, type ReputationSignals, type ResolveRouteFeesParams, type ResolveRouteFeesResult, SEED_RELAY_LIST_KIND, SERVICE_DISCOVERY_KIND, SOLANA_CHAIN_PRESETS, SeedRelayDiscovery, type SeedRelayDiscoveryConfig, type SeedRelayDiscoveryResult, type SeedRelayEntry, type SendPacketParams, type SendPacketResult, type ServiceDiscoveryContent, type SettlementConfig, type SkillDescriptor, type SocialDiscoveryEvent, type SocialDiscoveryEventListener, SocialPeerDiscovery, type SocialPeerDiscoveryConfig, type SolanaChainName, type SolanaChainPreset, type SolanaProviderConfigEntry, type Subscription, type SwapPair, type SwarmRequestParams, type SwarmSelectionParams, TEE_ATTESTATION_KIND, TEXT_GENERATION_KIND, TEXT_TO_SPEECH_KIND, TRANSLATION_KIND, type TeeAttestation, ToonError, type ToonNode, type ToonNodeConfig, type ToonNodeStartResult, UI_RENDERER_KIND, UI_TAG, USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, type UiCoordinate, VERSION, type VerificationResult, type VerifyOptions, type Violation, WEB_OF_TRUST_KIND, WORKFLOW_CHAIN_KIND, type WorkflowDefinitionParams, type WorkflowStep, type WotDeclarationParams, analyzeDockerfileForNonDeterminism, assignAddressFromHandshake, balanceProofFieldsMina, balanceProofHashEvm, balanceProofHashSolana, base58Decode, base58Encode, bigintToBytes32BE, buildAttestationEvent, buildBlobStorageRequest, buildEip712Domain, buildEvmProviderEntry, buildIlpPeerInfoEvent, buildIlpPrepare, buildJobFeedbackEvent, buildJobRequestEvent, buildJobResultEvent, buildJobReviewEvent, buildMinaProviderEntry, buildPrefixClaimEvent, buildPrefixGrantEvent, buildPrefixHandshakeData, buildSeedRelayListEvent, buildServiceDiscoveryEvent, buildSolanaProviderEntry, buildSwarmRequestEvent, buildSwarmSelectionEvent, buildUiCoordinate, buildWorkflowDefinitionEvent, buildWotDeclarationEvent, calculateRouteAmount, checkAddressCollision, concatBytes, createAgentRuntimeClient, createDirectChannelClient, createDirectConnectorAdmin, createDirectIlpClient, createDirectRuntimeClient, createDiscoveryTracker, createHttpChannelClient, createHttpConnectorAdmin, createHttpIlpClient$1 as createHttpIlpClient, createHttpRuntimeClient, createHttpIlpClient as createHttpRuntimeClientV2, createLogger, createToonNode, deriveChildAddress, deriveFromKmsSeed, deriveMinaPublicKeyBase58, extractPrefixFromHandshake, getEventExpiration, getUiCoordinate, hasMinReputation, hasRequireAttestation, hexToBytes, hexToMinaBase58PrivateKey, ilpCodeToSemantic, isEventExpired, isGenesisNode, isValidIlpAddressStructure, minaHashToField, negotiateSettlementChain, parseAttestation, parseBlobStorageRequest, parseIlpPeerInfo, parseJobFeedback, parseJobRequest, parseJobResult, parseJobReview, parsePrefixClaimEvent, parsePrefixGrantEvent, parseSeedRelayList, parseServiceDiscovery, parseSwarmRequest, parseSwarmSelection, parseUiCoordinate, parseWorkflowDefinition, parseWotDeclaration, publishSeedRelayEntry, readDockerfileNix, resolveChainConfig, resolveClientNetwork, resolveMinaChainConfig, resolveNetworkProfile, resolveRouteFees, resolveSolanaChainConfig, resolveTokenForChain, selectLatestAddressable, validateChainId, validateIlpAddress, validatePrefix, validatePrefixConsistency, verifyPcrReproducibility };
package/dist/index.js CHANGED
@@ -4631,8 +4631,7 @@ var SOLANA_CHAIN_PRESETS = {
4631
4631
  name: "solana-devnet",
4632
4632
  chainType: "solana",
4633
4633
  rpcUrl: "http://localhost:19899",
4634
- programId: "",
4635
- // TBD: set after program deployment
4634
+ programId: "EdJxYPDxGvaJuu57DSUptf4soLv8enpdyQJJhHDLiydG",
4636
4635
  cluster: "devnet"
4637
4636
  }
4638
4637
  };
@@ -4641,8 +4640,7 @@ var MINA_CHAIN_PRESETS = {
4641
4640
  name: "mina-devnet",
4642
4641
  chainType: "mina",
4643
4642
  graphqlUrl: "http://localhost:19085/graphql",
4644
- zkAppAddress: "",
4645
- // TBD: set after zkApp deployment
4643
+ zkAppAddress: "B62qrH1As4odHiNyKpTZMHaM6tRs6gi5DJ53efZKQBtbaR5CUctbDs6",
4646
4644
  network: "devnet"
4647
4645
  }
4648
4646
  };
@@ -5310,6 +5308,74 @@ function createLogger(config) {
5310
5308
  return logger;
5311
5309
  }
5312
5310
 
5311
+ // src/ui/coordinate.ts
5312
+ var UI_RENDERER_KIND = 31036;
5313
+ var UI_TAG = "ui";
5314
+ var HEX64_RE = /^[0-9a-f]{64}$/;
5315
+ function parseUiCoordinate(coord) {
5316
+ if (typeof coord !== "string") {
5317
+ return null;
5318
+ }
5319
+ const parts = coord.split(":");
5320
+ if (parts.length !== 3) {
5321
+ return null;
5322
+ }
5323
+ const [kindStr, pubkey, targetKindStr] = parts;
5324
+ if (kindStr === void 0 || pubkey === void 0 || targetKindStr === void 0) {
5325
+ return null;
5326
+ }
5327
+ if (kindStr !== String(UI_RENDERER_KIND)) {
5328
+ return null;
5329
+ }
5330
+ if (!HEX64_RE.test(pubkey)) {
5331
+ return null;
5332
+ }
5333
+ if (!/^\d+$/.test(targetKindStr)) {
5334
+ return null;
5335
+ }
5336
+ const targetKind = Number(targetKindStr);
5337
+ if (!Number.isInteger(targetKind)) {
5338
+ return null;
5339
+ }
5340
+ return {
5341
+ kind: UI_RENDERER_KIND,
5342
+ pubkey,
5343
+ targetKind
5344
+ };
5345
+ }
5346
+ function buildUiCoordinate(ref) {
5347
+ const { pubkey, targetKind } = ref;
5348
+ if (typeof pubkey !== "string" || !HEX64_RE.test(pubkey)) {
5349
+ return null;
5350
+ }
5351
+ if (!Number.isInteger(targetKind) || targetKind < 0) {
5352
+ return null;
5353
+ }
5354
+ return `${UI_RENDERER_KIND}:${pubkey}:${targetKind}`;
5355
+ }
5356
+ function getUiCoordinate(event) {
5357
+ const value = event.tags.find((t) => t[0] === UI_TAG)?.[1];
5358
+ if (value === void 0) {
5359
+ return null;
5360
+ }
5361
+ return parseUiCoordinate(value);
5362
+ }
5363
+ function selectLatestAddressable(events) {
5364
+ let latest;
5365
+ for (const event of events) {
5366
+ if (latest === void 0) {
5367
+ latest = event;
5368
+ continue;
5369
+ }
5370
+ if (event.created_at > latest.created_at) {
5371
+ latest = event;
5372
+ } else if (event.created_at === latest.created_at && event.id < latest.id) {
5373
+ latest = event;
5374
+ }
5375
+ }
5376
+ return latest;
5377
+ }
5378
+
5313
5379
  // src/index.ts
5314
5380
  var VERSION = "0.1.0";
5315
5381
  export {
@@ -5362,6 +5428,8 @@ export {
5362
5428
  ToonDecodeError,
5363
5429
  ToonEncodeError,
5364
5430
  ToonError,
5431
+ UI_RENDERER_KIND,
5432
+ UI_TAG,
5365
5433
  USDC_DECIMALS,
5366
5434
  USDC_NAME,
5367
5435
  USDC_SYMBOL,
@@ -5395,6 +5463,7 @@ export {
5395
5463
  buildSolanaProviderEntry,
5396
5464
  buildSwarmRequestEvent,
5397
5465
  buildSwarmSelectionEvent,
5466
+ buildUiCoordinate,
5398
5467
  buildWorkflowDefinitionEvent,
5399
5468
  buildWotDeclarationEvent,
5400
5469
  calculateRouteAmount,
@@ -5421,6 +5490,7 @@ export {
5421
5490
  encodeEventToToonString,
5422
5491
  extractPrefixFromHandshake,
5423
5492
  getEventExpiration,
5493
+ getUiCoordinate,
5424
5494
  hasMinReputation,
5425
5495
  hasRequireAttestation,
5426
5496
  hexToBytes,
@@ -5444,6 +5514,7 @@ export {
5444
5514
  parseServiceDiscovery,
5445
5515
  parseSwarmRequest,
5446
5516
  parseSwarmSelection,
5517
+ parseUiCoordinate,
5447
5518
  parseWorkflowDefinition,
5448
5519
  parseWotDeclaration,
5449
5520
  publishSeedRelayEntry,
@@ -5455,6 +5526,7 @@ export {
5455
5526
  resolveRouteFees,
5456
5527
  resolveSolanaChainConfig,
5457
5528
  resolveTokenForChain,
5529
+ selectLatestAddressable,
5458
5530
  shallowParseToon,
5459
5531
  validateChainId,
5460
5532
  validateIlpAddress,