@unicitylabs/sphere-sdk 0.16.0 → 0.17.1

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.
Files changed (53) hide show
  1. package/dist/connect/index.cjs +11 -5
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.d.cts +4 -1
  4. package/dist/connect/index.d.ts +4 -1
  5. package/dist/connect/index.js +11 -5
  6. package/dist/connect/index.js.map +1 -1
  7. package/dist/core/index.cjs +692 -268
  8. package/dist/core/index.cjs.map +1 -1
  9. package/dist/core/index.d.cts +69 -0
  10. package/dist/core/index.d.ts +69 -0
  11. package/dist/core/index.js +692 -268
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/impl/browser/connect/index.cjs +11 -5
  14. package/dist/impl/browser/connect/index.cjs.map +1 -1
  15. package/dist/impl/browser/connect/index.d.cts +3 -1
  16. package/dist/impl/browser/connect/index.d.ts +3 -1
  17. package/dist/impl/browser/connect/index.js +11 -5
  18. package/dist/impl/browser/connect/index.js.map +1 -1
  19. package/dist/impl/nodejs/connect/index.cjs +10 -4
  20. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  21. package/dist/impl/nodejs/connect/index.d.cts +1 -1
  22. package/dist/impl/nodejs/connect/index.d.ts +1 -1
  23. package/dist/impl/nodejs/connect/index.js +10 -4
  24. package/dist/impl/nodejs/connect/index.js.map +1 -1
  25. package/dist/impl/nodejs/index.d.cts +11 -0
  26. package/dist/impl/nodejs/index.d.ts +11 -0
  27. package/dist/impl/shared/wallet-api/index.d.cts +11 -0
  28. package/dist/impl/shared/wallet-api/index.d.ts +11 -0
  29. package/dist/impl/wallet-api-v2/index.cjs +2 -0
  30. package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
  31. package/dist/impl/wallet-api-v2/index.d.cts +13 -0
  32. package/dist/impl/wallet-api-v2/index.d.ts +13 -0
  33. package/dist/impl/wallet-api-v2/index.js +2 -0
  34. package/dist/impl/wallet-api-v2/index.js.map +1 -1
  35. package/dist/index.cjs +692 -268
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +63 -1
  38. package/dist/index.d.ts +63 -1
  39. package/dist/index.js +692 -268
  40. package/dist/index.js.map +1 -1
  41. package/dist/modules/payments-v2/index.cjs +767 -398
  42. package/dist/modules/payments-v2/index.cjs.map +1 -1
  43. package/dist/modules/payments-v2/index.d.cts +91 -14
  44. package/dist/modules/payments-v2/index.d.ts +91 -14
  45. package/dist/modules/payments-v2/index.js +767 -398
  46. package/dist/modules/payments-v2/index.js.map +1 -1
  47. package/dist/token-engine/index.cjs +132 -34
  48. package/dist/token-engine/index.cjs.map +1 -1
  49. package/dist/token-engine/index.d.cts +19 -0
  50. package/dist/token-engine/index.d.ts +19 -0
  51. package/dist/token-engine/index.js +132 -34
  52. package/dist/token-engine/index.js.map +1 -1
  53. package/package.json +1 -1
@@ -89,6 +89,11 @@ interface SendRequest {
89
89
  coinId: string;
90
90
  memo?: string;
91
91
  }
92
+ interface SendWholeTokenRequest {
93
+ recipient: string;
94
+ tokenId: string;
95
+ memo?: string;
96
+ }
92
97
  interface MintResult {
93
98
  success: boolean;
94
99
  tokenId?: string;
@@ -158,6 +163,8 @@ interface PendingTransfer {
158
163
  recipient: string;
159
164
  coinId: string;
160
165
  amount: string;
166
+ /** Set instead of coinId/amount when the intent is a token-addressed spend. */
167
+ tokenId?: string;
161
168
  legs: {
162
169
  certified: number;
163
170
  total: number;
@@ -173,11 +180,16 @@ interface PaymentsV2 {
173
180
  tokens(filter?: {
174
181
  coinId?: string;
175
182
  }): Token[];
183
+ coinless(): CoinlessToken[];
184
+ tokenData(tokenId: string): Promise<Uint8Array | null>;
176
185
  history(page?: {
177
186
  before?: string;
178
187
  limit?: number;
179
188
  }): Promise<HistoryPage>;
180
189
  send(req: SendRequest): Promise<TransferResult>;
190
+ sendWholeToken(req: SendWholeTokenRequest): Promise<TransferResult>;
191
+ /** NFT-scoped twin: refuses a valued source. Connect's `send_nft` routes here. */
192
+ sendCoinless(req: SendWholeTokenRequest): Promise<TransferResult>;
181
193
  mint(coinId: string, amount: bigint): Promise<MintResult>;
182
194
  receive(): Promise<{
183
195
  transfers: IncomingTransfer[];
@@ -526,6 +538,31 @@ interface Token {
526
538
  */
527
539
  suspectedSpent?: boolean;
528
540
  }
541
+ /**
542
+ * A holding that names no coin (wallet-api#140) — an NFT. Deliberately NOT a
543
+ * `Token`: no amount, decimals or symbol, and never returned by `tokens()` or
544
+ * counted in `assets()`. `tokenType` names the token's CLASS and `tokenId` the
545
+ * instance (wallet-api#147). The payload is read with `payments.tokenData()`.
546
+ */
547
+ interface CoinlessToken {
548
+ readonly tokenId: string;
549
+ readonly tokenType?: string;
550
+ /**
551
+ * Class metadata resolved from the registry THIS wallet owns, when the type is
552
+ * recognised. Resolved here so callers never reach for a registry themselves:
553
+ * the process-global singleton is repointable by another Sphere's init, so a
554
+ * second wallet on another network would retarget it (#767).
555
+ */
556
+ readonly name?: string;
557
+ readonly iconUrl?: string;
558
+ readonly stateHash: string;
559
+ /** #737: reserved by a converging transfer — not spendable right now. */
560
+ readonly transferring: boolean;
561
+ /** #625: proven spent on-chain; excluded from spend selection. */
562
+ readonly suspectedSpent?: boolean;
563
+ readonly createdAt: number;
564
+ readonly updatedAt: number;
565
+ }
529
566
  interface Asset {
530
567
  readonly coinId: string;
531
568
  readonly symbol: string;
@@ -596,6 +633,8 @@ interface IncomingTransfer {
596
633
  readonly senderPubkey: string;
597
634
  readonly senderNametag?: string;
598
635
  readonly tokens: Token[];
636
+ /** Arrivals that name no coin (#777). Disjoint from `tokens`, never a zero Token. */
637
+ readonly coinless?: CoinlessToken[];
599
638
  readonly memo?: string;
600
639
  readonly receivedAt: number;
601
640
  }
@@ -2292,6 +2331,9 @@ interface DerivedAddressInfo {
2292
2331
  */
2293
2332
  declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
2294
2333
 
2334
+ /** `none_*` = coinless; `bare_collection` = a dialect this SDK cannot read. */
2335
+ type ValueEnvelope = 'sphere' | 'bare_collection' | 'none_tag' | 'none_other' | 'none_absent';
2336
+
2295
2337
  /**
2296
2338
  * token-engine/types.ts — the FROZEN, sphere-domain contract surface.
2297
2339
  *
@@ -2352,6 +2394,22 @@ interface SphereToken {
2352
2394
  readonly blob: TokenBlob;
2353
2395
  /** Decoded value (cached); null when the token carries no sphere payment data. */
2354
2396
  readonly value: SphereValue | null;
2397
+ /**
2398
+ * Which value envelope the genesis payload carried (#778). Distinguishes the
2399
+ * reasons `value` is null, which the old boolean predicate collapsed:
2400
+ * `'none_*'` means the token genuinely names no coin — a COINLESS token — while
2401
+ * `'bare_collection'` means it carries coins in the bridged dialect this SDK
2402
+ * does not decode, so a zero here is "cannot read", not "has none". A corrupt
2403
+ * envelope never reaches this field: it throws during classification.
2404
+ */
2405
+ readonly valueEnvelope: ValueEnvelope;
2406
+ /**
2407
+ * Genesis `TokenType`, lowercase hex. The token's CLASS, never its instance —
2408
+ * `blob.tokenId` is the instance key (wallet-api#147). Only as meaningful as its
2409
+ * minter made it: `mint()` and split outputs derive one per operation, so for
2410
+ * value tokens it is per-mint noise. Never a spend gate.
2411
+ */
2412
+ readonly tokenType: string;
2355
2413
  }
2356
2414
  interface MintParams {
2357
2415
  /** Recipient's 33-byte compressed chain pubkey; engine derives the predicate. */
@@ -2767,7 +2825,18 @@ interface InventoryItemWire {
2767
2825
  status: 'active' | 'removed';
2768
2826
  seq: number;
2769
2827
  stateHash: string;
2828
+ /**
2829
+ * Omitted for a tombstone AND for an ACTIVE COINLESS token (wallet-api#140),
2830
+ * so absence is never "removed" or "not loaded" — discriminate on `status`.
2831
+ */
2770
2832
  assets?: AssetWire[];
2833
+ /**
2834
+ * Genesis `TokenType`, lowercase hex (1-64 bytes ⇒ 2-128 chars). Names the
2835
+ * token's CLASS, not the instance (wallet-api#147). Absent on rows written
2836
+ * before wallet-api migration 0015. An unrecognised type is legitimate: never
2837
+ * reject or hide a token for it.
2838
+ */
2839
+ tokenType?: string;
2771
2840
  }
2772
2841
  interface InventoryPageWire {
2773
2842
  cursor: number;
@@ -89,6 +89,11 @@ interface SendRequest {
89
89
  coinId: string;
90
90
  memo?: string;
91
91
  }
92
+ interface SendWholeTokenRequest {
93
+ recipient: string;
94
+ tokenId: string;
95
+ memo?: string;
96
+ }
92
97
  interface MintResult {
93
98
  success: boolean;
94
99
  tokenId?: string;
@@ -158,6 +163,8 @@ interface PendingTransfer {
158
163
  recipient: string;
159
164
  coinId: string;
160
165
  amount: string;
166
+ /** Set instead of coinId/amount when the intent is a token-addressed spend. */
167
+ tokenId?: string;
161
168
  legs: {
162
169
  certified: number;
163
170
  total: number;
@@ -173,11 +180,16 @@ interface PaymentsV2 {
173
180
  tokens(filter?: {
174
181
  coinId?: string;
175
182
  }): Token[];
183
+ coinless(): CoinlessToken[];
184
+ tokenData(tokenId: string): Promise<Uint8Array | null>;
176
185
  history(page?: {
177
186
  before?: string;
178
187
  limit?: number;
179
188
  }): Promise<HistoryPage>;
180
189
  send(req: SendRequest): Promise<TransferResult>;
190
+ sendWholeToken(req: SendWholeTokenRequest): Promise<TransferResult>;
191
+ /** NFT-scoped twin: refuses a valued source. Connect's `send_nft` routes here. */
192
+ sendCoinless(req: SendWholeTokenRequest): Promise<TransferResult>;
181
193
  mint(coinId: string, amount: bigint): Promise<MintResult>;
182
194
  receive(): Promise<{
183
195
  transfers: IncomingTransfer[];
@@ -526,6 +538,31 @@ interface Token {
526
538
  */
527
539
  suspectedSpent?: boolean;
528
540
  }
541
+ /**
542
+ * A holding that names no coin (wallet-api#140) — an NFT. Deliberately NOT a
543
+ * `Token`: no amount, decimals or symbol, and never returned by `tokens()` or
544
+ * counted in `assets()`. `tokenType` names the token's CLASS and `tokenId` the
545
+ * instance (wallet-api#147). The payload is read with `payments.tokenData()`.
546
+ */
547
+ interface CoinlessToken {
548
+ readonly tokenId: string;
549
+ readonly tokenType?: string;
550
+ /**
551
+ * Class metadata resolved from the registry THIS wallet owns, when the type is
552
+ * recognised. Resolved here so callers never reach for a registry themselves:
553
+ * the process-global singleton is repointable by another Sphere's init, so a
554
+ * second wallet on another network would retarget it (#767).
555
+ */
556
+ readonly name?: string;
557
+ readonly iconUrl?: string;
558
+ readonly stateHash: string;
559
+ /** #737: reserved by a converging transfer — not spendable right now. */
560
+ readonly transferring: boolean;
561
+ /** #625: proven spent on-chain; excluded from spend selection. */
562
+ readonly suspectedSpent?: boolean;
563
+ readonly createdAt: number;
564
+ readonly updatedAt: number;
565
+ }
529
566
  interface Asset {
530
567
  readonly coinId: string;
531
568
  readonly symbol: string;
@@ -596,6 +633,8 @@ interface IncomingTransfer {
596
633
  readonly senderPubkey: string;
597
634
  readonly senderNametag?: string;
598
635
  readonly tokens: Token[];
636
+ /** Arrivals that name no coin (#777). Disjoint from `tokens`, never a zero Token. */
637
+ readonly coinless?: CoinlessToken[];
599
638
  readonly memo?: string;
600
639
  readonly receivedAt: number;
601
640
  }
@@ -2292,6 +2331,9 @@ interface DerivedAddressInfo {
2292
2331
  */
2293
2332
  declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
2294
2333
 
2334
+ /** `none_*` = coinless; `bare_collection` = a dialect this SDK cannot read. */
2335
+ type ValueEnvelope = 'sphere' | 'bare_collection' | 'none_tag' | 'none_other' | 'none_absent';
2336
+
2295
2337
  /**
2296
2338
  * token-engine/types.ts — the FROZEN, sphere-domain contract surface.
2297
2339
  *
@@ -2352,6 +2394,22 @@ interface SphereToken {
2352
2394
  readonly blob: TokenBlob;
2353
2395
  /** Decoded value (cached); null when the token carries no sphere payment data. */
2354
2396
  readonly value: SphereValue | null;
2397
+ /**
2398
+ * Which value envelope the genesis payload carried (#778). Distinguishes the
2399
+ * reasons `value` is null, which the old boolean predicate collapsed:
2400
+ * `'none_*'` means the token genuinely names no coin — a COINLESS token — while
2401
+ * `'bare_collection'` means it carries coins in the bridged dialect this SDK
2402
+ * does not decode, so a zero here is "cannot read", not "has none". A corrupt
2403
+ * envelope never reaches this field: it throws during classification.
2404
+ */
2405
+ readonly valueEnvelope: ValueEnvelope;
2406
+ /**
2407
+ * Genesis `TokenType`, lowercase hex. The token's CLASS, never its instance —
2408
+ * `blob.tokenId` is the instance key (wallet-api#147). Only as meaningful as its
2409
+ * minter made it: `mint()` and split outputs derive one per operation, so for
2410
+ * value tokens it is per-mint noise. Never a spend gate.
2411
+ */
2412
+ readonly tokenType: string;
2355
2413
  }
2356
2414
  interface MintParams {
2357
2415
  /** Recipient's 33-byte compressed chain pubkey; engine derives the predicate. */
@@ -2767,7 +2825,18 @@ interface InventoryItemWire {
2767
2825
  status: 'active' | 'removed';
2768
2826
  seq: number;
2769
2827
  stateHash: string;
2828
+ /**
2829
+ * Omitted for a tombstone AND for an ACTIVE COINLESS token (wallet-api#140),
2830
+ * so absence is never "removed" or "not loaded" — discriminate on `status`.
2831
+ */
2770
2832
  assets?: AssetWire[];
2833
+ /**
2834
+ * Genesis `TokenType`, lowercase hex (1-64 bytes ⇒ 2-128 chars). Names the
2835
+ * token's CLASS, not the instance (wallet-api#147). Absent on rows written
2836
+ * before wallet-api migration 0015. An unrecognised type is legitimate: never
2837
+ * reject or hide a token for it.
2838
+ */
2839
+ tokenType?: string;
2771
2840
  }
2772
2841
  interface InventoryPageWire {
2773
2842
  cursor: number;