crypto-aio 0.1.0 → 0.2.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.
Files changed (163) hide show
  1. package/CHANGELOG.md +151 -1
  2. package/README.md +32 -12
  3. package/dist/adapters/evm/builder.js +64 -4
  4. package/dist/adapters/evm/builder.js.map +1 -1
  5. package/dist/adapters/evm/decode.js +6 -1
  6. package/dist/adapters/evm/decode.js.map +1 -1
  7. package/dist/adapters/evm/ethers-client.js +4 -0
  8. package/dist/adapters/evm/ethers-client.js.map +1 -1
  9. package/dist/adapters/evm/fees.d.ts +24 -0
  10. package/dist/adapters/evm/fees.js +47 -4
  11. package/dist/adapters/evm/fees.js.map +1 -1
  12. package/dist/adapters/evm/index.d.ts +1 -1
  13. package/dist/adapters/evm/index.js +2 -1
  14. package/dist/adapters/evm/index.js.map +1 -1
  15. package/dist/adapters/evm/network.d.ts +5 -0
  16. package/dist/adapters/evm/network.js +21 -2
  17. package/dist/adapters/evm/network.js.map +1 -1
  18. package/dist/adapters/evm/plugin.d.ts +5 -6
  19. package/dist/adapters/evm/plugin.js +50 -2
  20. package/dist/adapters/evm/plugin.js.map +1 -1
  21. package/dist/adapters/evm/proofs.js +17 -5
  22. package/dist/adapters/evm/proofs.js.map +1 -1
  23. package/dist/adapters/evm/reader.d.ts +18 -0
  24. package/dist/adapters/evm/reader.js +34 -0
  25. package/dist/adapters/evm/reader.js.map +1 -1
  26. package/dist/adapters/evm/tokens.d.ts +3 -0
  27. package/dist/adapters/evm/tokens.js.map +1 -1
  28. package/dist/adapters/evm/types.d.ts +10 -0
  29. package/dist/adapters/evm/types.js.map +1 -1
  30. package/dist/adapters/evm/web3-client.d.ts +6 -3
  31. package/dist/adapters/evm/web3-client.js +19 -2
  32. package/dist/adapters/evm/web3-client.js.map +1 -1
  33. package/dist/adapters/solana/builder.js +29 -18
  34. package/dist/adapters/solana/builder.js.map +1 -1
  35. package/dist/adapters/solana/fees.d.ts +12 -3
  36. package/dist/adapters/solana/fees.js +13 -4
  37. package/dist/adapters/solana/fees.js.map +1 -1
  38. package/dist/adapters/solana/message.d.ts +15 -0
  39. package/dist/adapters/solana/message.js +120 -0
  40. package/dist/adapters/solana/message.js.map +1 -0
  41. package/dist/adapters/solana/plugin.js +4 -1
  42. package/dist/adapters/solana/plugin.js.map +1 -1
  43. package/dist/adapters/solana/types.d.ts +8 -5
  44. package/dist/adapters/solana/types.js.map +1 -1
  45. package/dist/adapters/solana/web3.js +10 -32
  46. package/dist/adapters/solana/web3.js.map +1 -1
  47. package/dist/adapters/ton/proofs.js +18 -76
  48. package/dist/adapters/ton/proofs.js.map +1 -1
  49. package/dist/adapters/ton/reader.d.ts +45 -4
  50. package/dist/adapters/ton/reader.js +200 -5
  51. package/dist/adapters/ton/reader.js.map +1 -1
  52. package/dist/adapters/ton/trace.d.ts +26 -0
  53. package/dist/adapters/ton/trace.js +35 -9
  54. package/dist/adapters/ton/trace.js.map +1 -1
  55. package/dist/adapters/tron/abi.d.ts +2 -0
  56. package/dist/adapters/tron/abi.js +2 -0
  57. package/dist/adapters/tron/abi.js.map +1 -1
  58. package/dist/adapters/tron/builder.js +20 -4
  59. package/dist/adapters/tron/builder.js.map +1 -1
  60. package/dist/adapters/tron/decode.d.ts +2 -0
  61. package/dist/adapters/tron/decode.js +1 -1
  62. package/dist/adapters/tron/decode.js.map +1 -1
  63. package/dist/adapters/tron/proofs.js +1 -0
  64. package/dist/adapters/tron/proofs.js.map +1 -1
  65. package/dist/adapters/tron/reader.d.ts +10 -0
  66. package/dist/adapters/tron/reader.js +17 -0
  67. package/dist/adapters/tron/reader.js.map +1 -1
  68. package/dist/adapters/tron/tokens.d.ts +2 -0
  69. package/dist/adapters/tron/tokens.js.map +1 -1
  70. package/dist/adapters/utxo/builder.js +1 -1
  71. package/dist/adapters/utxo/builder.js.map +1 -1
  72. package/dist/adapters/utxo/chains.js +2 -1
  73. package/dist/adapters/utxo/chains.js.map +1 -1
  74. package/dist/adapters/utxo/context.d.ts +6 -0
  75. package/dist/adapters/utxo/context.js +8 -1
  76. package/dist/adapters/utxo/context.js.map +1 -1
  77. package/dist/adapters/utxo/decode.d.ts +8 -0
  78. package/dist/adapters/utxo/decode.js +36 -0
  79. package/dist/adapters/utxo/decode.js.map +1 -1
  80. package/dist/adapters/utxo/driver.js +5 -0
  81. package/dist/adapters/utxo/driver.js.map +1 -1
  82. package/dist/adapters/utxo/esplora.d.ts +23 -2
  83. package/dist/adapters/utxo/esplora.js +49 -2
  84. package/dist/adapters/utxo/esplora.js.map +1 -1
  85. package/dist/adapters/utxo/proofs.d.ts +15 -6
  86. package/dist/adapters/utxo/proofs.js +185 -47
  87. package/dist/adapters/utxo/proofs.js.map +1 -1
  88. package/dist/adapters/utxo/rawblock.d.ts +46 -0
  89. package/dist/adapters/utxo/rawblock.js +159 -0
  90. package/dist/adapters/utxo/rawblock.js.map +1 -0
  91. package/dist/adapters/utxo/rawtx.d.ts +14 -0
  92. package/dist/adapters/utxo/rawtx.js +44 -14
  93. package/dist/adapters/utxo/rawtx.js.map +1 -1
  94. package/dist/core/blockchain/handle.d.ts +6 -27
  95. package/dist/core/blockchain/handle.js +112 -112
  96. package/dist/core/blockchain/handle.js.map +1 -1
  97. package/dist/core/config/types.d.ts +15 -0
  98. package/dist/core/config/types.js.map +1 -1
  99. package/dist/core/container/container.d.ts +1 -8
  100. package/dist/core/container/container.js +42 -8
  101. package/dist/core/container/container.js.map +1 -1
  102. package/dist/core/driver/types.d.ts +34 -1
  103. package/dist/core/driver/types.js.map +1 -1
  104. package/dist/core/errors/codes.d.ts +10 -0
  105. package/dist/core/errors/codes.js +4 -0
  106. package/dist/core/errors/codes.js.map +1 -1
  107. package/dist/core/lifecycle/engine-rules.d.ts +3 -4
  108. package/dist/core/lifecycle/engine-rules.js +16 -6
  109. package/dist/core/lifecycle/engine-rules.js.map +1 -1
  110. package/dist/core/lifecycle/engine.d.ts +2 -0
  111. package/dist/core/lifecycle/engine.js +19 -1
  112. package/dist/core/lifecycle/engine.js.map +1 -1
  113. package/dist/core/lifecycle/evaluate.js +9 -4
  114. package/dist/core/lifecycle/evaluate.js.map +1 -1
  115. package/dist/core/lifecycle/monitor.js +16 -6
  116. package/dist/core/lifecycle/monitor.js.map +1 -1
  117. package/dist/core/lifecycle/reconcile.d.ts +1 -1
  118. package/dist/core/lifecycle/reconcile.js +1 -1
  119. package/dist/core/lifecycle/reconcile.js.map +1 -1
  120. package/dist/core/lifecycle/workers.d.ts +9 -3
  121. package/dist/core/lifecycle/workers.js +32 -14
  122. package/dist/core/lifecycle/workers.js.map +1 -1
  123. package/dist/core/model/ids.d.ts +1 -0
  124. package/dist/core/model/ids.js +1 -0
  125. package/dist/core/model/ids.js.map +1 -1
  126. package/dist/core/model/ordering.d.ts +8 -0
  127. package/dist/core/model/ordering.js.map +1 -1
  128. package/dist/core/model/transaction.d.ts +7 -0
  129. package/dist/core/model/transaction.js.map +1 -1
  130. package/dist/core/observe/scanner.js +3 -0
  131. package/dist/core/observe/scanner.js.map +1 -1
  132. package/dist/core/signing/wallet.js +8 -0
  133. package/dist/core/signing/wallet.js.map +1 -1
  134. package/dist/core/store/format.d.ts +20 -0
  135. package/dist/core/store/format.js +86 -0
  136. package/dist/core/store/format.js.map +1 -0
  137. package/dist/core/store/memory.js +2 -2
  138. package/dist/core/store/memory.js.map +1 -1
  139. package/dist/core/store/types.d.ts +15 -3
  140. package/dist/core/store/types.js +2 -0
  141. package/dist/core/store/types.js.map +1 -1
  142. package/dist/core/transport/http-transport.js +21 -13
  143. package/dist/core/transport/http-transport.js.map +1 -1
  144. package/dist/core/transport/types.d.ts +16 -1
  145. package/dist/core/transport/types.js.map +1 -1
  146. package/dist/core/util/json.d.ts +7 -1
  147. package/dist/core/util/json.js +13 -4
  148. package/dist/core/util/json.js.map +1 -1
  149. package/dist/core/util/names.d.ts +6 -0
  150. package/dist/core/util/names.js +10 -0
  151. package/dist/core/util/names.js.map +1 -1
  152. package/dist/index.d.ts +2 -1
  153. package/dist/index.js +4 -2
  154. package/dist/index.js.map +1 -1
  155. package/dist/testing/contracts/operations.js +20 -1
  156. package/dist/testing/contracts/operations.js.map +1 -1
  157. package/dist/testing/env.d.ts +5 -0
  158. package/dist/testing/env.js +1 -1
  159. package/dist/testing/env.js.map +1 -1
  160. package/dist/testing/faulty-store.d.ts +2 -0
  161. package/dist/testing/faulty-store.js +5 -0
  162. package/dist/testing/faulty-store.js.map +1 -1
  163. package/package.json +17 -7
@@ -3,6 +3,7 @@ import type { Logger } from '../events/logger';
3
3
  import type { Capability } from '../model/capability';
4
4
  import type { ChainInfo, NetworkInfo } from '../model/chain';
5
5
  import type { ChainId, LibraryOf, NetworkOf } from '../model/ids';
6
+ import type { AssetRegistration } from '../registry/assets';
6
7
  import type { Plugin } from '../registry/plugin';
7
8
  import type { Secret } from '../secret/secret';
8
9
  import type { ExtendedKeyVersions } from '../signing/hd';
@@ -59,6 +60,13 @@ export interface LifecycleOptions {
59
60
  readonly droppedGracePeriodMs?: number;
60
61
  readonly rebroadcastIntervalMs?: number;
61
62
  readonly leaseMs?: number;
63
+ /**
64
+ * How long a transfer waits for its wallet's address lease while another Operation of
65
+ * the wallet holds it, before it fails with `SEQUENCE_BUSY` (default: `leaseMs`). The
66
+ * holder keeps the lease while its signer works, for up to `signTimeoutMs`, so raise this
67
+ * to queue transfers behind a slow signer instead of failing them.
68
+ */
69
+ readonly leaseWaitMs?: number;
62
70
  readonly claimLeaseMs?: number;
63
71
  readonly waitTimeoutMs?: number;
64
72
  readonly requireIdempotencyKey?: boolean;
@@ -104,6 +112,13 @@ export interface AioOptions extends ScopeOptions {
104
112
  readonly logger?: Logger;
105
113
  readonly clock?: Clock;
106
114
  readonly plugins?: readonly Plugin[];
115
+ /**
116
+ * Tokens to register on this root container, as a plugin's `assets` would: their decimals
117
+ * and symbol, and aliases such as `USDC`. A registered token's decimals scale its amounts
118
+ * instead of what the chain says, so give each only from a source you trust; a token
119
+ * whose chain gives no decimals can be sent only once they are registered.
120
+ */
121
+ readonly assets?: readonly AssetRegistration[];
107
122
  }
108
123
  export interface HandleOptions {
109
124
  readonly chain: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AdapterManifest } from '../driver/types';\nimport type { Logger } from '../events/logger';\nimport type { Capability } from '../model/capability';\nimport type { ChainInfo, NetworkInfo } from '../model/chain';\nimport type { ChainId, LibraryOf, NetworkOf } from '../model/ids';\nimport type { Plugin } from '../registry/plugin';\nimport type { Secret } from '../secret/secret';\nimport type { ExtendedKeyVersions } from '../signing/hd';\nimport type { KeyRef, Signer, SigningContext } from '../signing/types';\nimport type { Stores } from '../store/types';\nimport type { EndpointConfig, TransportOptions } from '../transport/types';\nimport type { Clock } from '../util/clock';\n\nexport type ProviderConfig =\n | {\n readonly preset: string;\n readonly apiKey?: string | Secret<string>;\n readonly options?: Readonly<Record<string, unknown>>;\n }\n | { readonly endpoints: readonly EndpointConfig[] };\n\nexport type ProviderRef = string | ProviderConfig;\n\nexport interface WalletConfig {\n readonly signer?: string;\n /** Routes requests to signers by `keyRef.id` (multi-party wallets). */\n readonly signers?: Readonly<Record<string, string>>;\n readonly address?: string;\n /** Hex public key for watch-only wallets that still prepare transactions. */\n readonly publicKey?: string;\n readonly xpub?: string;\n readonly xpubVersions?: ExtendedKeyVersions;\n /** Child path template relative to the xpub; `{index}` is replaced. Default `0/{index}`. */\n readonly xpubPath?: string;\n readonly keyRef?: KeyRef;\n /** Metadata only (passed to signing context); no built-in behaviour. */\n readonly tier?: string;\n readonly chains?: readonly string[];\n readonly utxo?: Readonly<Record<string, unknown>>;\n readonly ton?: Readonly<Record<string, unknown>>;\n readonly options?: Readonly<Record<string, unknown>>;\n}\n\nexport interface ChainDefaults {\n readonly network?: string;\n readonly library?: string;\n readonly provider?: ProviderRef | readonly ProviderRef[];\n readonly indexer?: ProviderRef | readonly ProviderRef[];\n readonly wallet?: string;\n readonly signer?: string;\n readonly options?: Readonly<Record<string, unknown>>;\n readonly confirmations?: number;\n /**\n * This chain's lag tolerance, in blocks. It wins over the root\n * `transport.maxLagBlocks`, which wins over the plugin network's own, which wins over\n * the transport's built-in default. An endpoint further behind the best known height is\n * lagging, and a monitor or scanner view further behind is stale.\n */\n readonly maxLagBlocks?: number;\n}\n\nexport interface LifecycleOptions {\n readonly pollIntervalMs?: number;\n readonly droppedGracePeriodMs?: number;\n readonly rebroadcastIntervalMs?: number;\n readonly leaseMs?: number;\n readonly claimLeaseMs?: number;\n readonly waitTimeoutMs?: number;\n readonly requireIdempotencyKey?: boolean;\n readonly broadcastFanout?: number;\n /**\n * How long `transfer` and `submitSignatures` wait for the `beforeSign` hook and the\n * signer(s) (default 120 000 ms). The wallet's address lease is kept alive meanwhile. On\n * timeout nothing is written: the Operation stays `prepared` with its reservation, and a\n * repeat asks again. Signers that need longer should answer `pending` with a ticket.\n */\n readonly signTimeoutMs?: number;\n}\n\nexport interface Hooks {\n /**\n * Throw to veto signing (policy engines, approvals). Runs before every signing request.\n * It may run more than once per Operation: once per concurrent caller, and again when a\n * `prepared` Operation is repeated. Make it idempotent; `ctx.operationId` identifies the\n * Operation. It runs while the wallet's address lease is held, so keep it short. In\n * `transfer` and `submitSignatures` the lease is kept alive for up to\n * `lifecycle.signTimeoutMs`; in `prepareTransfer` a hook running longer than\n * `lifecycle.leaseMs` can lose the lease to another transfer. A veto after that writes\n * nothing; the Operation stays `prepared` and is vetoed again on its next repeat.\n */\n readonly beforeSign?: (ctx: SigningContext) => void | Promise<void>;\n}\n\nexport interface ScopeOptions {\n readonly chains?: Readonly<Record<string, ChainDefaults>>;\n readonly providers?: Readonly<Record<string, ProviderConfig>>;\n readonly signers?: Readonly<Record<string, Signer>>;\n readonly wallets?: Readonly<Record<string, WalletConfig>>;\n readonly hooks?: Hooks;\n readonly lifecycle?: LifecycleOptions;\n}\n\nexport interface AioOptions extends ScopeOptions {\n /** Root-only: drivers and transports are shared by all scopes of a root container. */\n readonly transport?: TransportOptions;\n /** Prefixes every store key; tenants sharing a database must use distinct namespaces. */\n readonly namespace?: string;\n /** Environment source for routing config; `false` disables it. Default: `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>> | false;\n readonly profile?: string;\n readonly stores?: Partial<Stores>;\n readonly logger?: Logger;\n readonly clock?: Clock;\n readonly plugins?: readonly Plugin[];\n}\n\nexport interface HandleOptions {\n readonly chain: string;\n readonly network?: string;\n readonly library?: string;\n readonly provider?: ProviderRef | readonly ProviderRef[];\n readonly indexer?: ProviderRef | readonly ProviderRef[];\n readonly wallet?: string;\n readonly signer?: string;\n readonly options?: Readonly<Record<string, unknown>>;\n readonly confirmations?: number;\n}\n\nexport type HandleConfig<C extends ChainId> = Omit<\n HandleOptions,\n 'chain' | 'network' | 'library'\n> & {\n readonly chain: C;\n readonly network?: NetworkOf<C>;\n readonly library?: LibraryOf<C>;\n};\n\nexport interface EffectiveOptions {\n readonly chains: Readonly<Record<string, ChainDefaults>>;\n readonly providers: Readonly<Record<string, ProviderConfig>>;\n readonly signers: Readonly<Record<string, Signer>>;\n readonly wallets: Readonly<Record<string, WalletConfig>>;\n readonly hooks: Hooks;\n readonly lifecycle: LifecycleOptions;\n}\n\nexport interface ResolvedProvider {\n readonly name: string;\n readonly endpoints: readonly EndpointConfig[];\n readonly production: boolean;\n}\n\nexport interface ResolvedSelection {\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly library: string;\n readonly manifest: AdapterManifest;\n readonly providers: readonly ResolvedProvider[];\n readonly indexers: readonly ResolvedProvider[];\n readonly wallet?: { readonly name: string; readonly config: WalletConfig };\n readonly signer?: { readonly id: string; readonly instance: Signer };\n readonly options: Readonly<Record<string, unknown>>;\n readonly confirmations: number;\n /** The per-chain `maxLagBlocks` from the `chains` config, when set. */\n readonly maxLagBlocks?: number;\n readonly capabilities: ReadonlySet<Capability>;\n readonly providerNames: readonly string[];\n readonly indexerNames: readonly string[];\n /** Identity of the shared driver/transport (includes credential fingerprints). */\n readonly poolKey: string;\n /** Hash recorded in each Operation's ExecutionContext. */\n readonly configHash: string;\n /** The merged handle options, used by `with()`. */\n readonly handle: HandleOptions;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/config/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { AdapterManifest } from '../driver/types';\nimport type { Logger } from '../events/logger';\nimport type { Capability } from '../model/capability';\nimport type { ChainInfo, NetworkInfo } from '../model/chain';\nimport type { ChainId, LibraryOf, NetworkOf } from '../model/ids';\nimport type { AssetRegistration } from '../registry/assets';\nimport type { Plugin } from '../registry/plugin';\nimport type { Secret } from '../secret/secret';\nimport type { ExtendedKeyVersions } from '../signing/hd';\nimport type { KeyRef, Signer, SigningContext } from '../signing/types';\nimport type { Stores } from '../store/types';\nimport type { EndpointConfig, TransportOptions } from '../transport/types';\nimport type { Clock } from '../util/clock';\n\nexport type ProviderConfig =\n | {\n readonly preset: string;\n readonly apiKey?: string | Secret<string>;\n readonly options?: Readonly<Record<string, unknown>>;\n }\n | { readonly endpoints: readonly EndpointConfig[] };\n\nexport type ProviderRef = string | ProviderConfig;\n\nexport interface WalletConfig {\n readonly signer?: string;\n /** Routes requests to signers by `keyRef.id` (multi-party wallets). */\n readonly signers?: Readonly<Record<string, string>>;\n readonly address?: string;\n /** Hex public key for watch-only wallets that still prepare transactions. */\n readonly publicKey?: string;\n readonly xpub?: string;\n readonly xpubVersions?: ExtendedKeyVersions;\n /** Child path template relative to the xpub; `{index}` is replaced. Default `0/{index}`. */\n readonly xpubPath?: string;\n readonly keyRef?: KeyRef;\n /** Metadata only (passed to signing context); no built-in behaviour. */\n readonly tier?: string;\n readonly chains?: readonly string[];\n readonly utxo?: Readonly<Record<string, unknown>>;\n readonly ton?: Readonly<Record<string, unknown>>;\n readonly options?: Readonly<Record<string, unknown>>;\n}\n\nexport interface ChainDefaults {\n readonly network?: string;\n readonly library?: string;\n readonly provider?: ProviderRef | readonly ProviderRef[];\n readonly indexer?: ProviderRef | readonly ProviderRef[];\n readonly wallet?: string;\n readonly signer?: string;\n readonly options?: Readonly<Record<string, unknown>>;\n readonly confirmations?: number;\n /**\n * This chain's lag tolerance, in blocks. It wins over the root\n * `transport.maxLagBlocks`, which wins over the plugin network's own, which wins over\n * the transport's built-in default. An endpoint further behind the best known height is\n * lagging, and a monitor or scanner view further behind is stale.\n */\n readonly maxLagBlocks?: number;\n}\n\nexport interface LifecycleOptions {\n readonly pollIntervalMs?: number;\n readonly droppedGracePeriodMs?: number;\n readonly rebroadcastIntervalMs?: number;\n readonly leaseMs?: number;\n /**\n * How long a transfer waits for its wallet's address lease while another Operation of\n * the wallet holds it, before it fails with `SEQUENCE_BUSY` (default: `leaseMs`). The\n * holder keeps the lease while its signer works, for up to `signTimeoutMs`, so raise this\n * to queue transfers behind a slow signer instead of failing them.\n */\n readonly leaseWaitMs?: number;\n readonly claimLeaseMs?: number;\n readonly waitTimeoutMs?: number;\n readonly requireIdempotencyKey?: boolean;\n readonly broadcastFanout?: number;\n /**\n * How long `transfer` and `submitSignatures` wait for the `beforeSign` hook and the\n * signer(s) (default 120 000 ms). The wallet's address lease is kept alive meanwhile. On\n * timeout nothing is written: the Operation stays `prepared` with its reservation, and a\n * repeat asks again. Signers that need longer should answer `pending` with a ticket.\n */\n readonly signTimeoutMs?: number;\n}\n\nexport interface Hooks {\n /**\n * Throw to veto signing (policy engines, approvals). Runs before every signing request.\n * It may run more than once per Operation: once per concurrent caller, and again when a\n * `prepared` Operation is repeated. Make it idempotent; `ctx.operationId` identifies the\n * Operation. It runs while the wallet's address lease is held, so keep it short. In\n * `transfer` and `submitSignatures` the lease is kept alive for up to\n * `lifecycle.signTimeoutMs`; in `prepareTransfer` a hook running longer than\n * `lifecycle.leaseMs` can lose the lease to another transfer. A veto after that writes\n * nothing; the Operation stays `prepared` and is vetoed again on its next repeat.\n */\n readonly beforeSign?: (ctx: SigningContext) => void | Promise<void>;\n}\n\nexport interface ScopeOptions {\n readonly chains?: Readonly<Record<string, ChainDefaults>>;\n readonly providers?: Readonly<Record<string, ProviderConfig>>;\n readonly signers?: Readonly<Record<string, Signer>>;\n readonly wallets?: Readonly<Record<string, WalletConfig>>;\n readonly hooks?: Hooks;\n readonly lifecycle?: LifecycleOptions;\n}\n\nexport interface AioOptions extends ScopeOptions {\n /** Root-only: drivers and transports are shared by all scopes of a root container. */\n readonly transport?: TransportOptions;\n /** Prefixes every store key; tenants sharing a database must use distinct namespaces. */\n readonly namespace?: string;\n /** Environment source for routing config; `false` disables it. Default: `process.env`. */\n readonly env?: Readonly<Record<string, string | undefined>> | false;\n readonly profile?: string;\n readonly stores?: Partial<Stores>;\n readonly logger?: Logger;\n readonly clock?: Clock;\n readonly plugins?: readonly Plugin[];\n /**\n * Tokens to register on this root container, as a plugin's `assets` would: their decimals\n * and symbol, and aliases such as `USDC`. A registered token's decimals scale its amounts\n * instead of what the chain says, so give each only from a source you trust; a token\n * whose chain gives no decimals can be sent only once they are registered.\n */\n readonly assets?: readonly AssetRegistration[];\n}\n\nexport interface HandleOptions {\n readonly chain: string;\n readonly network?: string;\n readonly library?: string;\n readonly provider?: ProviderRef | readonly ProviderRef[];\n readonly indexer?: ProviderRef | readonly ProviderRef[];\n readonly wallet?: string;\n readonly signer?: string;\n readonly options?: Readonly<Record<string, unknown>>;\n readonly confirmations?: number;\n}\n\nexport type HandleConfig<C extends ChainId> = Omit<\n HandleOptions,\n 'chain' | 'network' | 'library'\n> & {\n readonly chain: C;\n readonly network?: NetworkOf<C>;\n readonly library?: LibraryOf<C>;\n};\n\nexport interface EffectiveOptions {\n readonly chains: Readonly<Record<string, ChainDefaults>>;\n readonly providers: Readonly<Record<string, ProviderConfig>>;\n readonly signers: Readonly<Record<string, Signer>>;\n readonly wallets: Readonly<Record<string, WalletConfig>>;\n readonly hooks: Hooks;\n readonly lifecycle: LifecycleOptions;\n}\n\nexport interface ResolvedProvider {\n readonly name: string;\n readonly endpoints: readonly EndpointConfig[];\n readonly production: boolean;\n}\n\nexport interface ResolvedSelection {\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly library: string;\n readonly manifest: AdapterManifest;\n readonly providers: readonly ResolvedProvider[];\n readonly indexers: readonly ResolvedProvider[];\n readonly wallet?: { readonly name: string; readonly config: WalletConfig };\n readonly signer?: { readonly id: string; readonly instance: Signer };\n readonly options: Readonly<Record<string, unknown>>;\n readonly confirmations: number;\n /** The per-chain `maxLagBlocks` from the `chains` config, when set. */\n readonly maxLagBlocks?: number;\n readonly capabilities: ReadonlySet<Capability>;\n readonly providerNames: readonly string[];\n readonly indexerNames: readonly string[];\n /** Identity of the shared driver/transport (includes credential fingerprints). */\n readonly poolKey: string;\n /** Hash recorded in each Operation's ExecutionContext. */\n readonly configHash: string;\n /** The merged handle options, used by `with()`. */\n readonly handle: HandleOptions;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Blockchain } from '../blockchain/handle';
1
+ import { type Blockchain } from '../blockchain/handle';
2
2
  import type { AioOptions, HandleConfig, ScopeOptions } from '../config/types';
3
3
  import type { AioEvent, AioEventName } from '../events/types';
4
4
  import { type RecoveryReport, type WorkerOptions } from '../lifecycle/monitor';
@@ -8,10 +8,6 @@ import { type Plugin } from '../registry/plugin';
8
8
  import type { OperationState } from '../store/types';
9
9
  /** How long `close()` waits for one native client's `close` before moving on. */
10
10
  export declare const NATIVE_CLOSE_TIMEOUT_MS = 5000;
11
- interface ScopeInit {
12
- readonly parent: CryptoAio;
13
- readonly overrides: ScopeOptions;
14
- }
15
11
  export interface OperationsFilter {
16
12
  readonly states?: readonly OperationState[];
17
13
  readonly chain?: string;
@@ -41,8 +37,6 @@ export declare class CryptoAio {
41
37
  #private;
42
38
  readonly namespace: string;
43
39
  constructor(options?: AioOptions);
44
- /** @internal */
45
- constructor(options: AioOptions, scope: ScopeInit);
46
40
  /**
47
41
  * Child container: inherits config, pool, stores and namespace; overrides merge on top.
48
42
  * Not a tenant boundary — a scope shares its root's pool and stores. Use a separate
@@ -66,4 +60,3 @@ export declare class CryptoAio {
66
60
  */
67
61
  close(): Promise<void>;
68
62
  }
69
- export {};
@@ -18,6 +18,7 @@ const sequence_1 = require("../ordering/sequence");
18
18
  const plugin_1 = require("../registry/plugin");
19
19
  const orchestrator_1 = require("../signing/orchestrator");
20
20
  const wallet_1 = require("../signing/wallet");
21
+ const format_1 = require("../store/format");
21
22
  const memory_1 = require("../store/memory");
22
23
  const bytes_1 = require("../util/bytes");
23
24
  const clock_1 = require("../util/clock");
@@ -55,6 +56,11 @@ async function closeWithin(close, clock, ms) {
55
56
  timer.abort();
56
57
  }
57
58
  }
59
+ /**
60
+ * Set by `scope()` for the one synchronous constructor call it makes, so a child container
61
+ * needs no constructor parameter in the public API.
62
+ */
63
+ let pendingScope;
58
64
  /**
59
65
  * Deep-clones plain objects/arrays into a frozen copy so a later mutation of the caller's
60
66
  * own input can never reach a layer already captured by a container. Class instances
@@ -96,13 +102,29 @@ function scopePart(options) {
96
102
  ...(lifecycle ? { lifecycle: cloneFrozen(lifecycle) } : {}),
97
103
  };
98
104
  }
105
+ const checkedStores = new WeakMap();
106
+ /**
107
+ * The stores as the engine, the workers and `aio.operations` use them: Operation records
108
+ * pass the format guard, so none is ever read in a format this version does not know.
109
+ */
110
+ function storesOf(runtime) {
111
+ let stores = checkedStores.get(runtime);
112
+ if (!stores) {
113
+ stores = {
114
+ ...runtime.stores,
115
+ operations: (0, format_1.formatGuard)(runtime.stores.operations, runtime.log.child('store')),
116
+ };
117
+ checkedStores.set(runtime, stores);
118
+ }
119
+ return stores;
120
+ }
99
121
  function createEngine(runtime, effective) {
100
122
  const lifecycle = () => (0, engine_1.withLifecycleDefaults)(effective().lifecycle);
101
- const { leaseMs } = lifecycle();
123
+ const { leaseMs, leaseWaitMs } = lifecycle();
102
124
  const log = runtime.log.child('lifecycle');
103
125
  return new engine_1.OperationEngine({
104
126
  namespace: runtime.namespace,
105
- stores: runtime.stores,
127
+ stores: storesOf(runtime),
106
128
  events: runtime.events,
107
129
  clock: runtime.clock,
108
130
  log,
@@ -118,7 +140,7 @@ function createEngine(runtime, effective) {
118
140
  clock: runtime.clock,
119
141
  owner: runtime.owner,
120
142
  leaseMs,
121
- acquireTimeoutMs: leaseMs,
143
+ acquireTimeoutMs: leaseWaitMs,
122
144
  // The code only: a store's error message may carry detail that logs must not.
123
145
  onReleaseError: (error) => log.warn('lease release failed', { code: (0, engine_1.errorCode)(error) }),
124
146
  }),
@@ -232,7 +254,9 @@ async function operationTarget(container, runtime, record, wallets) {
232
254
  */
233
255
  class CryptoAio {
234
256
  namespace;
235
- constructor(options = {}, scope) {
257
+ constructor(options = {}) {
258
+ const scope = pendingScope;
259
+ pendingScope = undefined;
236
260
  if (scope) {
237
261
  const parent = (0, internals_1.containerOf)(scope.parent);
238
262
  this.namespace = parent.runtime.namespace;
@@ -247,6 +271,10 @@ class CryptoAio {
247
271
  const catalogs = (0, plugin_1.createCatalogs)();
248
272
  for (const plugin of [...(0, builtins_1.builtinPlugins)(), ...(options.plugins ?? [])])
249
273
  (0, plugin_1.applyPlugin)(catalogs, plugin);
274
+ for (const asset of options.assets ?? []) {
275
+ catalogs.chains.network(asset.chain, asset.network);
276
+ catalogs.assets.register(asset);
277
+ }
250
278
  const env = options.env === false ? {} : (options.env ?? process.env);
251
279
  const events = new bus_1.EventBus(clock, log);
252
280
  // eslint-disable-next-line prefer-const -- closures below read it after assignment
@@ -290,7 +318,13 @@ class CryptoAio {
290
318
  * `new CryptoAio({ namespace })` when isolation between tenants is required.
291
319
  */
292
320
  scope(overrides) {
293
- return new CryptoAio({}, { parent: this, overrides });
321
+ pendingScope = { parent: this, overrides };
322
+ try {
323
+ return new CryptoAio();
324
+ }
325
+ finally {
326
+ pendingScope = undefined;
327
+ }
294
328
  }
295
329
  blockchain(config) {
296
330
  const internals = (0, internals_1.containerOf)(this);
@@ -340,7 +374,7 @@ class CryptoAio {
340
374
  return wallet;
341
375
  },
342
376
  };
343
- return new handle_1.Blockchain(handle);
377
+ return (0, handle_1.createBlockchain)(handle);
344
378
  }
345
379
  /** Registers a plugin on this root container (copy-on-write catalogs). */
346
380
  use(plugin) {
@@ -365,7 +399,7 @@ class CryptoAio {
365
399
  /** Stored Operations of this namespace, as views, and startup recovery. */
366
400
  get operations() {
367
401
  const internals = (0, internals_1.containerOf)(this);
368
- const store = internals.runtime.stores.operations;
402
+ const store = storesOf(internals.runtime).operations;
369
403
  const namespace = internals.runtime.namespace;
370
404
  const view = async (record) => (0, views_1.toView)(record, await (0, observations_1.loadObservations)(store, record));
371
405
  return {
@@ -450,7 +484,7 @@ class CryptoAio {
450
484
  engine: getEngine,
451
485
  monitor: () => (monitor ??= new monitor_1.Monitor({
452
486
  engine: getEngine(),
453
- stores: runtime.stores,
487
+ stores: storesOf(runtime),
454
488
  events: runtime.events,
455
489
  clock: runtime.clock,
456
490
  log: runtime.log.child('monitor'),
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/core/container/container.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AACjD,iDAAkD;AAClD,qDAA2E;AAC3E,uCAA8C;AAC9C,2CAA4E;AAC5E,+CAAqD;AAUrD,2CAA8C;AAC9C,uCAAyC;AACzC,6CAAgD;AAEhD,gDAM6B;AAC7B,kDAAwF;AACxF,4DAA6D;AAC7D,8CAAgE;AAEhE,mDAA2D;AAC3D,+CAM4B;AAC5B,0DAA8D;AAC9D,8CAAuE;AACvE,4CAAqD;AAErD,yCAAyC;AACzC,yCAAwD;AACxD,yCAA4C;AAC5C,2CAMqB;AACrB,iCAAuD;AAEvD,MAAM,SAAS,GAAG,wBAAwB,CAAC;AAE3C;;;;;GAKG;AACH,SAAS,YAAY,CACnB,OAAoB,EACpB,MAA+B;IAE/B,IAAI,OAAO,CAAC,MAAM;QAAE,MAAM,IAAA,uBAAW,GAAE,CAAC;IACxC,OAAO,MAAM;QACX,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,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,KAAK;gBACpB,SAAS,EAAE,IAAA,8BAAqB,EAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,aAAa;aACtE,CAAC;YACF,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,GAAG,EAAE,CACZ,CAAC,OAAO,KAAK,IAAI,iBAAO,CAAC;gBACvB,MAAM,EAAE,SAAS,EAAE;gBACnB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC;gBACjC,SAAS,EAAE,OAAO,CAAC,SAAS;gBAC5B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAA,8BAAqB,EAAC,SAAS,EAAE,CAAC,SAAS,CAAC;gBAC7D,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;gBACjD,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;aAC3E,CAAC,CAAC;SACN,CAAC,CAAC;IACL,CAAC;CACF;AArRD,8BAqRC","sourcesContent":["import { AssetService } from '../assets/service';\nimport { Blockchain } from '../blockchain/handle';\nimport { internalsOf, type HandleInternals } from '../blockchain/internal';\nimport { readEnvChains } from '../config/env';\nimport { assertNoCycle, isPlainObject, mergeScopes } from '../config/merge';\nimport { resolveSelection } from '../config/resolve';\nimport type {\n AioOptions,\n EffectiveOptions,\n HandleConfig,\n HandleOptions,\n ResolvedSelection,\n ScopeOptions,\n} from '../config/types';\nimport type { ChainDriver } from '../driver/types';\nimport { ConfigError } from '../errors/error';\nimport { EventBus } from '../events/bus';\nimport { createLogger } from '../events/logger';\nimport type { AioEvent, AioEventName } from '../events/types';\nimport {\n OperationEngine,\n errorCode,\n withLifecycleDefaults,\n type OperationTarget,\n type ReadTarget,\n} from '../lifecycle/engine';\nimport { Monitor, type RecoveryReport, type WorkerOptions } from '../lifecycle/monitor';\nimport { loadObservations } from '../lifecycle/observations';\nimport { toView, type OperationView } from '../lifecycle/views';\nimport type { ChainId } from '../model/ids';\nimport { SequenceCoordinator } from '../ordering/sequence';\nimport {\n applyPlugin,\n cloneCatalogs,\n createCatalogs,\n type Catalogs,\n type Plugin,\n} from '../registry/plugin';\nimport { SigningOrchestrator } from '../signing/orchestrator';\nimport { resolveWallet, type ResolvedWallet } from '../signing/wallet';\nimport { createMemoryStores } from '../store/memory';\nimport type { OperationRecord, OperationState, Stores } from '../store/types';\nimport { randomId } from '../util/bytes';\nimport { systemClock, type Clock } from '../util/clock';\nimport { builtinPlugins } from './builtins';\nimport {\n bindContainer,\n closedError,\n containerOf,\n type ContainerInternals,\n type RootRuntime,\n} from './internals';\nimport { DriverPool, type PooledDriver } from './pool';\n\nconst NAMESPACE = /^[A-Za-z0-9._-]{1,64}$/;\n\n/**\n * The signal a worker loop, pass or recovery runs under: the caller's, if any, and the\n * root's `closing`, which `close()` aborts. A closed container starts no new work: it\n * stops claiming Operations from a shared store (holding each for a lease) and no longer\n * keeps the process alive.\n */\nfunction workerSignal(\n runtime: RootRuntime,\n signal: AbortSignal | undefined,\n): AbortSignal {\n if (runtime.closed) throw closedError();\n return signal\n ? AbortSignal.any([signal, runtime.closing.signal])\n : runtime.closing.signal;\n}\n\n/** How long `close()` waits for one native client's `close` before moving on. */\nexport const NATIVE_CLOSE_TIMEOUT_MS = 5_000;\n\n/** Runs `close`, but gives up waiting after `ms` of `clock` time (the close keeps running). */\nasync function closeWithin(\n close: () => unknown,\n clock: Clock,\n ms: number,\n): Promise<'closed' | 'timeout'> {\n const timer = new AbortController();\n try {\n return await Promise.race([\n Promise.resolve()\n .then(close)\n .then(() => 'closed' as const),\n clock.sleep(ms, timer.signal).then(() => 'timeout' as const),\n ]);\n } finally {\n timer.abort();\n }\n}\n\ninterface ScopeInit {\n readonly parent: CryptoAio;\n readonly overrides: ScopeOptions;\n}\n\n/**\n * Deep-clones plain objects/arrays into a frozen copy so a later mutation of the caller's\n * own input can never reach a layer already captured by a container. Class instances\n * (Signer, Secret, ...) are referenced, not cloned — they're already immutable.\n */\nfunction cloneFrozen<T>(value: T, ancestors: Set<object> = new Set()): T {\n if (!Array.isArray(value) && !isPlainObject(value)) return value;\n assertNoCycle(value, ancestors);\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n return Object.freeze(\n value.map((item: unknown) => cloneFrozen(item, ancestors)),\n ) as T;\n }\n const out: Record<string, unknown> = {};\n for (const [key, v] of Object.entries(value)) out[key] = cloneFrozen(v, ancestors);\n return Object.freeze(out) as T;\n } finally {\n ancestors.delete(value);\n }\n}\n\n/** `chains`/`providers`/`wallets`/`signers`/`hooks`/`lifecycle` are all cloned and\n * deep-frozen at construction, so mutating the caller's options object afterwards never\n * affects handles already built from this layer. For `signers`, only the map OBJECT is\n * cloned (a fresh, frozen copy so adding/replacing a key on the caller's own map can't reach\n * an existing layer) — the `Signer` values it holds are opaque and always taken by reference,\n * never cloned or frozen, even a plain-object signer (`Signer` is an interface), so it keeps\n * its identity and its own mutable state. */\nfunction scopePart(options: ScopeOptions): ScopeOptions {\n const { chains, providers, signers, wallets, hooks, lifecycle } = options;\n return {\n ...(chains ? { chains: cloneFrozen(chains) } : {}),\n ...(providers ? { providers: cloneFrozen(providers) } : {}),\n ...(signers ? { signers: Object.freeze({ ...signers }) } : {}),\n ...(wallets ? { wallets: cloneFrozen(wallets) } : {}),\n ...(hooks ? { hooks: cloneFrozen(hooks) } : {}),\n ...(lifecycle ? { lifecycle: cloneFrozen(lifecycle) } : {}),\n };\n}\n\nfunction createEngine(\n runtime: RootRuntime,\n effective: () => EffectiveOptions,\n): OperationEngine {\n const lifecycle = () => withLifecycleDefaults(effective().lifecycle);\n const { leaseMs } = lifecycle();\n const log = runtime.log.child('lifecycle');\n return new OperationEngine({\n namespace: runtime.namespace,\n stores: runtime.stores,\n events: runtime.events,\n clock: runtime.clock,\n log,\n orchestrator: new SigningOrchestrator({\n schemes: () => runtime.catalogs.schemes,\n events: runtime.events,\n clock: runtime.clock,\n hooks: () => effective().hooks,\n }),\n sequences: new SequenceCoordinator({\n locks: runtime.stores.locks,\n sequences: runtime.stores.sequences,\n clock: runtime.clock,\n owner: runtime.owner,\n leaseMs,\n acquireTimeoutMs: leaseMs,\n // The code only: a store's error message may carry detail that logs must not.\n onReleaseError: (error) =>\n log.warn('lease release failed', { code: errorCode(error) }),\n }),\n lifecycle,\n });\n}\n\n/**\n * The signer-free read target of a stored Operation, for every check,\n * worker pass and recovery read: its chain, network and library over its own named\n * providers first, then the current defaults when those no longer resolve (inline configs\n * are recorded by hash only and cannot be rebuilt). No wallet or signer is selected, not\n * even a chain default one, so a rotated signer, a removed wallet or a hung custody\n * backend never stops monitoring.\n */\nasync function readTarget(\n container: CryptoAio,\n record: OperationRecord,\n): Promise<ReadTarget> {\n const internals = containerOf(container);\n const { runtime } = internals;\n const { chain, network, library } = record.context;\n const effective = internals.effective();\n const { wallet: _wallet, signer: _signer, ...defaults } = effective.chains[chain] ?? {};\n const signerFree = { ...effective, chains: { ...effective.chains, [chain]: defaults } };\n const select = (provider?: readonly string[]) =>\n resolveSelection({\n handle: { chain, network, library, ...(provider ? { provider } : {}) },\n effective: signerFree,\n catalogs: runtime.catalogs,\n log: runtime.log,\n });\n const named = record.context.providers.filter((name) => !name.startsWith('inline:'));\n let selection: ResolvedSelection;\n try {\n selection = select(named.length > 0 ? named : undefined);\n } catch (error) {\n // Only a config that no longer resolves (e.g. a renamed provider) falls back.\n if (!(error instanceof ConfigError)) throw error;\n selection = select();\n }\n if (runtime.closed) throw closedError();\n return { selection, pooled: await runtime.pool.get(selection) };\n}\n\n/**\n * The wallets the monitor resolved for its writes, cached per container (one public-key\n * read per wallet selection, not one per pass) and bounded by `lifecycle.signTimeoutMs`. A\n * failed resolution is not kept. The cache is dropped when the config changes: a container's\n * layers are frozen, so only a plugin (`use()`, new catalogs and env layer) changes it.\n */\nfunction walletCache(\n runtime: RootRuntime,\n internals: () => ContainerInternals,\n): (selection: ResolvedSelection, driver: ChainDriver) => Promise<ResolvedWallet> {\n let catalogs: Catalogs = runtime.catalogs;\n const wallets = new Map<string, Promise<ResolvedWallet>>();\n return (selection, driver) => {\n if (runtime.catalogs !== catalogs) {\n catalogs = runtime.catalogs;\n wallets.clear();\n }\n const key = selection.configHash;\n const cached = wallets.get(key);\n if (cached) return cached;\n const { effective, signerDeadline } = internals();\n const resolving = resolveWallet(\n selection,\n driver,\n effective().signers,\n catalogs.schemes,\n signerDeadline(),\n ).catch((error: unknown) => {\n if (wallets.get(key) === resolving) wallets.delete(key);\n throw error;\n });\n wallets.set(key, resolving);\n return resolving;\n };\n}\n\n/**\n * The wallet-bound target of a stored Operation, resolved lazily and only for the\n * writes that need one: the all-rejected verdict, nonce reconciliation and recovery's\n * resend. None of them signs, and their address lease is keyed on the Operation itself.\n * Its frozen context (chain, network, library, wallet, signer) is rebuilt against the\n * container's current config with its own named providers first; when that no longer\n * resolves (a renamed provider, a rotated signer), the wallet alone over the current\n * defaults, with neither the recorded signer nor the providers: the wallet's current\n * signer, public key or address then stands for it (a watch-only wallet is enough). The\n * engine checks the resolved wallet still owns the Operation before using it.\n */\nasync function operationTarget(\n container: CryptoAio,\n runtime: RootRuntime,\n record: OperationRecord,\n wallets: (selection: ResolvedSelection, driver: ChainDriver) => Promise<ResolvedWallet>,\n): Promise<OperationTarget> {\n const { chain, network, library, wallet, signer, providers } = record.context;\n const base = { chain, network, library, wallet } as HandleConfig<ChainId>;\n const named = providers.filter((name) => !name.startsWith('inline:'));\n let handle: Blockchain<ChainId>;\n try {\n handle = container.blockchain({\n ...base,\n ...(signer !== undefined ? { signer } : {}),\n ...(named.length > 0 ? { provider: named } : {}),\n });\n } catch (error) {\n if (!(error instanceof ConfigError)) throw error;\n handle = container.blockchain(base);\n }\n const internals = internalsOf(handle);\n const pooled = await internals.pooled();\n return {\n selection: internals.selection,\n pooled,\n wallet: await wallets(internals.selection, pooled.driver),\n assets: runtime.assets,\n };\n}\n\nexport interface OperationsFilter {\n readonly states?: readonly OperationState[];\n readonly chain?: string;\n readonly network?: string;\n readonly limit?: number;\n}\n\nexport interface OperationsApi {\n get(id: string): Promise<OperationView | null>;\n /** In creation order. */\n list(filter?: OperationsFilter): Promise<OperationView[]>;\n /** Startup recovery for this namespace (see RecoveryReport); it never signs. */\n recover(options?: { readonly signal?: AbortSignal }): Promise<RecoveryReport>;\n}\n\nexport interface MonitorApi {\n /** Runs worker passes until `signal` aborts; any number of workers may run. */\n start(options?: WorkerOptions): Promise<void>;\n /** One worker pass; resolves to the number of Operations it claimed. */\n runOnce(options?: WorkerOptions): Promise<number>;\n}\n\n/**\n * Dependency container: stores, signers, wallets, hooks, plugins and a shared driver pool.\n * Separate `new CryptoAio()` instances are fully isolated (use one per tenant).\n */\nexport class CryptoAio {\n readonly namespace: string;\n\n constructor(options?: AioOptions);\n /** @internal */\n constructor(options: AioOptions, scope: ScopeInit);\n constructor(options: AioOptions = {}, scope?: ScopeInit) {\n if (scope) {\n const parent = containerOf(scope.parent);\n this.namespace = parent.runtime.namespace;\n this.#bind(parent.runtime, [...parent.layers, scopePart(scope.overrides)], false);\n return;\n }\n const namespace = options.namespace ?? 'default';\n if (!NAMESPACE.test(namespace))\n throw new ConfigError(\n 'CONFIG_INVALID',\n 'invalid namespace: use 1 to 64 letters, digits, dots, underscores or hyphens',\n );\n const clock = options.clock ?? systemClock;\n const log = options.logger ?? createLogger();\n const catalogs = createCatalogs();\n for (const plugin of [...builtinPlugins(), ...(options.plugins ?? [])])\n applyPlugin(catalogs, plugin);\n const env = options.env === false ? {} : (options.env ?? process.env);\n const events = new EventBus(clock, log);\n // eslint-disable-next-line prefer-const -- closures below read it after assignment\n let runtime: RootRuntime;\n const pool = new DriverPool({\n catalogs: () => runtime.catalogs,\n clock,\n events,\n log,\n transport: () => runtime.transport,\n });\n runtime = {\n namespace,\n catalogs,\n envLayer: {\n chains: readEnvChains(\n env,\n catalogs.chains.list().map((c) => c.id),\n options.profile,\n ),\n },\n env,\n ...(options.profile !== undefined ? { profile: options.profile } : {}),\n clock,\n log,\n events,\n stores: {\n ...createMemoryStores(clock),\n ...(Object.fromEntries(\n Object.entries(options.stores ?? {}).filter(([, store]) => store !== undefined),\n ) as Partial<Stores>),\n },\n pool,\n assets: new AssetService(() => runtime.catalogs),\n transport: options.transport ?? {},\n owner: randomId('aio'),\n closed: false,\n closing: new AbortController(),\n natives: new Set(),\n };\n this.namespace = namespace;\n this.#bind(runtime, [scopePart(options)], true);\n }\n\n /**\n * Child container: inherits config, pool, stores and namespace; overrides merge on top.\n * Not a tenant boundary — a scope shares its root's pool and stores. Use a separate\n * `new CryptoAio({ namespace })` when isolation between tenants is required.\n */\n scope(overrides: ScopeOptions): CryptoAio {\n return new CryptoAio({}, { parent: this, overrides });\n }\n\n blockchain<C extends ChainId>(config: HandleConfig<C>): Blockchain<C> {\n const internals = containerOf(this);\n const { runtime } = internals;\n const selection = resolveSelection({\n handle: config as HandleOptions,\n effective: internals.effective(),\n catalogs: runtime.catalogs,\n log: runtime.log,\n });\n let pooled: Promise<PooledDriver> | undefined;\n let wallet: Promise<ResolvedWallet> | undefined;\n const handle: HandleInternals = {\n container: this,\n selection,\n nativeClients: new Map(),\n assertOpen: () => {\n if (runtime.closed) throw closedError();\n },\n registerNative: (native) => {\n if (runtime.closed) throw closedError();\n if (native.close) runtime.natives.add(() => native.close?.());\n },\n // A closed root refuses work even through a pooled driver this handle holds.\n pooled: () => {\n if (runtime.closed) return Promise.reject(closedError());\n pooled ??= runtime.pool.get(selection).catch((error: unknown) => {\n pooled = undefined;\n throw error;\n });\n return pooled;\n },\n wallet: () => {\n if (runtime.closed) return Promise.reject(closedError());\n wallet ??= handle\n .pooled()\n .then(({ driver }) =>\n resolveWallet(\n selection,\n driver,\n internals.effective().signers,\n runtime.catalogs.schemes,\n internals.signerDeadline(),\n ),\n )\n .catch((error: unknown) => {\n wallet = undefined;\n throw error;\n });\n return wallet;\n },\n };\n return new Blockchain<C>(handle);\n }\n\n /** Registers a plugin on this root container (copy-on-write catalogs). */\n use(plugin: Plugin): this {\n const internals = containerOf(this);\n if (!internals.isRoot)\n throw new ConfigError(\n 'CONFIG_INVALID',\n 'plugins can only be added to a root container',\n );\n const { runtime } = internals;\n const next = cloneCatalogs(runtime.catalogs);\n applyPlugin(next, plugin);\n runtime.catalogs = next;\n runtime.envLayer = {\n chains: readEnvChains(\n runtime.env,\n next.chains.list().map((c) => c.id),\n runtime.profile,\n ),\n };\n return this;\n }\n\n on<E extends AioEventName>(type: E, handler: (event: AioEvent<E>) => void): () => void {\n return containerOf(this).runtime.events.on(type, handler);\n }\n\n onAny(handler: (event: AioEvent) => void): () => void {\n return containerOf(this).runtime.events.onAny(handler);\n }\n\n /** Stored Operations of this namespace, as views, and startup recovery. */\n get operations(): OperationsApi {\n const internals = containerOf(this);\n const store = internals.runtime.stores.operations;\n const namespace = internals.runtime.namespace;\n const view = async (record: OperationRecord) =>\n toView(record, await loadObservations(store, record));\n return {\n get: async (id) => {\n const record = await store.get(namespace, id);\n return record ? view(record) : null;\n },\n list: async (filter = {}) =>\n Promise.all(\n (\n await store.list({\n namespace,\n ...(filter.states ? { states: filter.states } : {}),\n ...(filter.chain ? { chain: filter.chain } : {}),\n ...(filter.network ? { network: filter.network } : {}),\n ...(filter.limit !== undefined ? { limit: filter.limit } : {}),\n })\n ).map(view),\n ),\n recover: async (options = {}) =>\n internals.monitor().recover({\n ...options,\n signal: workerSignal(internals.runtime, options.signal),\n }),\n };\n }\n\n /** Background workers that check due Operations without anyone waiting on them. */\n get monitor(): MonitorApi {\n const internals = containerOf(this);\n return {\n start: async (options = {}) =>\n internals.monitor().start({\n ...options,\n signal: workerSignal(internals.runtime, options.signal),\n }),\n runOnce: async (options = {}) =>\n internals.monitor().runOnce({\n workerId: options.workerId ?? internals.runtime.owner,\n ...(options.batch !== undefined ? { batch: options.batch } : {}),\n signal: workerSignal(internals.runtime, options.signal),\n }),\n };\n }\n\n /**\n * Closes the root container: runs the `close` of every native client that\n * `crypto-aio/native` handed out (a failing one is logged by code and skipped), then\n * closes the pooled drivers. Its handles and `native()` then fail with\n * `INVALID_TRANSITION`. A scope's `close()` does nothing; scopes share their root's pool.\n */\n async close(): Promise<void> {\n const internals = containerOf(this);\n if (!internals.isRoot) return;\n const { runtime } = internals;\n runtime.closed = true;\n // Every worker loop, pass and recovery stops at its next check, and its sleeps end.\n runtime.closing.abort();\n const natives = [...runtime.natives];\n runtime.natives.clear();\n await Promise.all(\n natives.map(async (close) => {\n try {\n const outcome = await closeWithin(\n close,\n runtime.clock,\n NATIVE_CLOSE_TIMEOUT_MS,\n );\n if (outcome === 'timeout') {\n runtime.log.warn('native client close timed out', {\n timeoutMs: NATIVE_CLOSE_TIMEOUT_MS,\n });\n }\n } catch (error) {\n runtime.log.warn('native client close failed', { code: errorCode(error) });\n }\n }),\n );\n await runtime.pool.close();\n }\n\n #bind(runtime: RootRuntime, layers: readonly ScopeOptions[], isRoot: boolean): void {\n const effective = () => mergeScopes([runtime.envLayer, ...layers]);\n let engine: OperationEngine | undefined;\n let monitor: Monitor | undefined;\n const getEngine = () => (engine ??= createEngine(runtime, effective));\n const wallets = walletCache(runtime, () => containerOf(this));\n bindContainer(this, {\n runtime,\n layers,\n isRoot,\n effective,\n signerDeadline: () => ({\n clock: runtime.clock,\n timeoutMs: withLifecycleDefaults(effective().lifecycle).signTimeoutMs,\n }),\n engine: getEngine,\n monitor: () =>\n (monitor ??= new Monitor({\n engine: getEngine(),\n stores: runtime.stores,\n events: runtime.events,\n clock: runtime.clock,\n log: runtime.log.child('monitor'),\n namespace: runtime.namespace,\n lifecycle: () => withLifecycleDefaults(effective().lifecycle),\n resolveRead: (record) => readTarget(this, record),\n resolveTarget: (record) => operationTarget(this, runtime, record, wallets),\n })),\n });\n }\n}\n"]}
1
+ {"version":3,"file":"container.js","sourceRoot":"","sources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type Blockchain } from '../blockchain/handle';\nimport { internalsOf, type HandleInternals } from '../blockchain/internal';\nimport { readEnvChains } from '../config/env';\nimport { assertNoCycle, isPlainObject, mergeScopes } from '../config/merge';\nimport { resolveSelection } from '../config/resolve';\nimport type {\n AioOptions,\n EffectiveOptions,\n HandleConfig,\n HandleOptions,\n ResolvedSelection,\n ScopeOptions,\n} from '../config/types';\nimport type { ChainDriver } from '../driver/types';\nimport { ConfigError } from '../errors/error';\nimport { EventBus } from '../events/bus';\nimport { createLogger } from '../events/logger';\nimport type { AioEvent, AioEventName } from '../events/types';\nimport {\n OperationEngine,\n errorCode,\n withLifecycleDefaults,\n type OperationTarget,\n type ReadTarget,\n} from '../lifecycle/engine';\nimport { Monitor, type RecoveryReport, type WorkerOptions } from '../lifecycle/monitor';\nimport { loadObservations } from '../lifecycle/observations';\nimport { toView, type OperationView } from '../lifecycle/views';\nimport type { ChainId } from '../model/ids';\nimport { SequenceCoordinator } from '../ordering/sequence';\nimport {\n applyPlugin,\n cloneCatalogs,\n createCatalogs,\n type Catalogs,\n type Plugin,\n} from '../registry/plugin';\nimport { SigningOrchestrator } from '../signing/orchestrator';\nimport { resolveWallet, type ResolvedWallet } from '../signing/wallet';\nimport { formatGuard } from '../store/format';\nimport { createMemoryStores } from '../store/memory';\nimport type { OperationRecord, OperationState, Stores } from '../store/types';\nimport { randomId } from '../util/bytes';\nimport { systemClock, type Clock } from '../util/clock';\nimport { builtinPlugins } from './builtins';\nimport {\n bindContainer,\n closedError,\n containerOf,\n type ContainerInternals,\n type RootRuntime,\n} from './internals';\nimport { DriverPool, type PooledDriver } from './pool';\n\nconst NAMESPACE = /^[A-Za-z0-9._-]{1,64}$/;\n\n/**\n * The signal a worker loop, pass or recovery runs under: the caller's, if any, and the\n * root's `closing`, which `close()` aborts. A closed container starts no new work: it\n * stops claiming Operations from a shared store (holding each for a lease) and no longer\n * keeps the process alive.\n */\nfunction workerSignal(\n runtime: RootRuntime,\n signal: AbortSignal | undefined,\n): AbortSignal {\n if (runtime.closed) throw closedError();\n return signal\n ? AbortSignal.any([signal, runtime.closing.signal])\n : runtime.closing.signal;\n}\n\n/** How long `close()` waits for one native client's `close` before moving on. */\nexport const NATIVE_CLOSE_TIMEOUT_MS = 5_000;\n\n/** Runs `close`, but gives up waiting after `ms` of `clock` time (the close keeps running). */\nasync function closeWithin(\n close: () => unknown,\n clock: Clock,\n ms: number,\n): Promise<'closed' | 'timeout'> {\n const timer = new AbortController();\n try {\n return await Promise.race([\n Promise.resolve()\n .then(close)\n .then(() => 'closed' as const),\n clock.sleep(ms, timer.signal).then(() => 'timeout' as const),\n ]);\n } finally {\n timer.abort();\n }\n}\n\ninterface ScopeInit {\n readonly parent: CryptoAio;\n readonly overrides: ScopeOptions;\n}\n\n/**\n * Set by `scope()` for the one synchronous constructor call it makes, so a child container\n * needs no constructor parameter in the public API.\n */\nlet pendingScope: ScopeInit | undefined;\n\n/**\n * Deep-clones plain objects/arrays into a frozen copy so a later mutation of the caller's\n * own input can never reach a layer already captured by a container. Class instances\n * (Signer, Secret, ...) are referenced, not cloned — they're already immutable.\n */\nfunction cloneFrozen<T>(value: T, ancestors: Set<object> = new Set()): T {\n if (!Array.isArray(value) && !isPlainObject(value)) return value;\n assertNoCycle(value, ancestors);\n ancestors.add(value);\n try {\n if (Array.isArray(value)) {\n return Object.freeze(\n value.map((item: unknown) => cloneFrozen(item, ancestors)),\n ) as T;\n }\n const out: Record<string, unknown> = {};\n for (const [key, v] of Object.entries(value)) out[key] = cloneFrozen(v, ancestors);\n return Object.freeze(out) as T;\n } finally {\n ancestors.delete(value);\n }\n}\n\n/** `chains`/`providers`/`wallets`/`signers`/`hooks`/`lifecycle` are all cloned and\n * deep-frozen at construction, so mutating the caller's options object afterwards never\n * affects handles already built from this layer. For `signers`, only the map OBJECT is\n * cloned (a fresh, frozen copy so adding/replacing a key on the caller's own map can't reach\n * an existing layer) — the `Signer` values it holds are opaque and always taken by reference,\n * never cloned or frozen, even a plain-object signer (`Signer` is an interface), so it keeps\n * its identity and its own mutable state. */\nfunction scopePart(options: ScopeOptions): ScopeOptions {\n const { chains, providers, signers, wallets, hooks, lifecycle } = options;\n return {\n ...(chains ? { chains: cloneFrozen(chains) } : {}),\n ...(providers ? { providers: cloneFrozen(providers) } : {}),\n ...(signers ? { signers: Object.freeze({ ...signers }) } : {}),\n ...(wallets ? { wallets: cloneFrozen(wallets) } : {}),\n ...(hooks ? { hooks: cloneFrozen(hooks) } : {}),\n ...(lifecycle ? { lifecycle: cloneFrozen(lifecycle) } : {}),\n };\n}\n\nconst checkedStores = new WeakMap<RootRuntime, Stores>();\n\n/**\n * The stores as the engine, the workers and `aio.operations` use them: Operation records\n * pass the format guard, so none is ever read in a format this version does not know.\n */\nfunction storesOf(runtime: RootRuntime): Stores {\n let stores = checkedStores.get(runtime);\n if (!stores) {\n stores = {\n ...runtime.stores,\n operations: formatGuard(runtime.stores.operations, runtime.log.child('store')),\n };\n checkedStores.set(runtime, stores);\n }\n return stores;\n}\n\nfunction createEngine(\n runtime: RootRuntime,\n effective: () => EffectiveOptions,\n): OperationEngine {\n const lifecycle = () => withLifecycleDefaults(effective().lifecycle);\n const { leaseMs, leaseWaitMs } = lifecycle();\n const log = runtime.log.child('lifecycle');\n return new OperationEngine({\n namespace: runtime.namespace,\n stores: storesOf(runtime),\n events: runtime.events,\n clock: runtime.clock,\n log,\n orchestrator: new SigningOrchestrator({\n schemes: () => runtime.catalogs.schemes,\n events: runtime.events,\n clock: runtime.clock,\n hooks: () => effective().hooks,\n }),\n sequences: new SequenceCoordinator({\n locks: runtime.stores.locks,\n sequences: runtime.stores.sequences,\n clock: runtime.clock,\n owner: runtime.owner,\n leaseMs,\n acquireTimeoutMs: leaseWaitMs,\n // The code only: a store's error message may carry detail that logs must not.\n onReleaseError: (error) =>\n log.warn('lease release failed', { code: errorCode(error) }),\n }),\n lifecycle,\n });\n}\n\n/**\n * The signer-free read target of a stored Operation, for every check,\n * worker pass and recovery read: its chain, network and library over its own named\n * providers first, then the current defaults when those no longer resolve (inline configs\n * are recorded by hash only and cannot be rebuilt). No wallet or signer is selected, not\n * even a chain default one, so a rotated signer, a removed wallet or a hung custody\n * backend never stops monitoring.\n */\nasync function readTarget(\n container: CryptoAio,\n record: OperationRecord,\n): Promise<ReadTarget> {\n const internals = containerOf(container);\n const { runtime } = internals;\n const { chain, network, library } = record.context;\n const effective = internals.effective();\n const { wallet: _wallet, signer: _signer, ...defaults } = effective.chains[chain] ?? {};\n const signerFree = { ...effective, chains: { ...effective.chains, [chain]: defaults } };\n const select = (provider?: readonly string[]) =>\n resolveSelection({\n handle: { chain, network, library, ...(provider ? { provider } : {}) },\n effective: signerFree,\n catalogs: runtime.catalogs,\n log: runtime.log,\n });\n const named = record.context.providers.filter((name) => !name.startsWith('inline:'));\n let selection: ResolvedSelection;\n try {\n selection = select(named.length > 0 ? named : undefined);\n } catch (error) {\n // Only a config that no longer resolves (e.g. a renamed provider) falls back.\n if (!(error instanceof ConfigError)) throw error;\n selection = select();\n }\n if (runtime.closed) throw closedError();\n return { selection, pooled: await runtime.pool.get(selection) };\n}\n\n/**\n * The wallets the monitor resolved for its writes, cached per container (one public-key\n * read per wallet selection, not one per pass) and bounded by `lifecycle.signTimeoutMs`. A\n * failed resolution is not kept. The cache is dropped when the config changes: a container's\n * layers are frozen, so only a plugin (`use()`, new catalogs and env layer) changes it.\n */\nfunction walletCache(\n runtime: RootRuntime,\n internals: () => ContainerInternals,\n): (selection: ResolvedSelection, driver: ChainDriver) => Promise<ResolvedWallet> {\n let catalogs: Catalogs = runtime.catalogs;\n const wallets = new Map<string, Promise<ResolvedWallet>>();\n return (selection, driver) => {\n if (runtime.catalogs !== catalogs) {\n catalogs = runtime.catalogs;\n wallets.clear();\n }\n const key = selection.configHash;\n const cached = wallets.get(key);\n if (cached) return cached;\n const { effective, signerDeadline } = internals();\n const resolving = resolveWallet(\n selection,\n driver,\n effective().signers,\n catalogs.schemes,\n signerDeadline(),\n ).catch((error: unknown) => {\n if (wallets.get(key) === resolving) wallets.delete(key);\n throw error;\n });\n wallets.set(key, resolving);\n return resolving;\n };\n}\n\n/**\n * The wallet-bound target of a stored Operation, resolved lazily and only for the\n * writes that need one: the all-rejected verdict, nonce reconciliation and recovery's\n * resend. None of them signs, and their address lease is keyed on the Operation itself.\n * Its frozen context (chain, network, library, wallet, signer) is rebuilt against the\n * container's current config with its own named providers first; when that no longer\n * resolves (a renamed provider, a rotated signer), the wallet alone over the current\n * defaults, with neither the recorded signer nor the providers: the wallet's current\n * signer, public key or address then stands for it (a watch-only wallet is enough). The\n * engine checks the resolved wallet still owns the Operation before using it.\n */\nasync function operationTarget(\n container: CryptoAio,\n runtime: RootRuntime,\n record: OperationRecord,\n wallets: (selection: ResolvedSelection, driver: ChainDriver) => Promise<ResolvedWallet>,\n): Promise<OperationTarget> {\n const { chain, network, library, wallet, signer, providers } = record.context;\n const base = { chain, network, library, wallet } as HandleConfig<ChainId>;\n const named = providers.filter((name) => !name.startsWith('inline:'));\n let handle: Blockchain<ChainId>;\n try {\n handle = container.blockchain({\n ...base,\n ...(signer !== undefined ? { signer } : {}),\n ...(named.length > 0 ? { provider: named } : {}),\n });\n } catch (error) {\n if (!(error instanceof ConfigError)) throw error;\n handle = container.blockchain(base);\n }\n const internals = internalsOf(handle);\n const pooled = await internals.pooled();\n return {\n selection: internals.selection,\n pooled,\n wallet: await wallets(internals.selection, pooled.driver),\n assets: runtime.assets,\n };\n}\n\nexport interface OperationsFilter {\n readonly states?: readonly OperationState[];\n readonly chain?: string;\n readonly network?: string;\n readonly limit?: number;\n}\n\nexport interface OperationsApi {\n get(id: string): Promise<OperationView | null>;\n /** In creation order. */\n list(filter?: OperationsFilter): Promise<OperationView[]>;\n /** Startup recovery for this namespace (see RecoveryReport); it never signs. */\n recover(options?: { readonly signal?: AbortSignal }): Promise<RecoveryReport>;\n}\n\nexport interface MonitorApi {\n /** Runs worker passes until `signal` aborts; any number of workers may run. */\n start(options?: WorkerOptions): Promise<void>;\n /** One worker pass; resolves to the number of Operations it claimed. */\n runOnce(options?: WorkerOptions): Promise<number>;\n}\n\n/**\n * Dependency container: stores, signers, wallets, hooks, plugins and a shared driver pool.\n * Separate `new CryptoAio()` instances are fully isolated (use one per tenant).\n */\nexport class CryptoAio {\n readonly namespace: string;\n\n constructor(options: AioOptions = {}) {\n const scope = pendingScope;\n pendingScope = undefined;\n if (scope) {\n const parent = containerOf(scope.parent);\n this.namespace = parent.runtime.namespace;\n this.#bind(parent.runtime, [...parent.layers, scopePart(scope.overrides)], false);\n return;\n }\n const namespace = options.namespace ?? 'default';\n if (!NAMESPACE.test(namespace))\n throw new ConfigError(\n 'CONFIG_INVALID',\n 'invalid namespace: use 1 to 64 letters, digits, dots, underscores or hyphens',\n );\n const clock = options.clock ?? systemClock;\n const log = options.logger ?? createLogger();\n const catalogs = createCatalogs();\n for (const plugin of [...builtinPlugins(), ...(options.plugins ?? [])])\n applyPlugin(catalogs, plugin);\n for (const asset of options.assets ?? []) {\n catalogs.chains.network(asset.chain, asset.network);\n catalogs.assets.register(asset);\n }\n const env = options.env === false ? {} : (options.env ?? process.env);\n const events = new EventBus(clock, log);\n // eslint-disable-next-line prefer-const -- closures below read it after assignment\n let runtime: RootRuntime;\n const pool = new DriverPool({\n catalogs: () => runtime.catalogs,\n clock,\n events,\n log,\n transport: () => runtime.transport,\n });\n runtime = {\n namespace,\n catalogs,\n envLayer: {\n chains: readEnvChains(\n env,\n catalogs.chains.list().map((c) => c.id),\n options.profile,\n ),\n },\n env,\n ...(options.profile !== undefined ? { profile: options.profile } : {}),\n clock,\n log,\n events,\n stores: {\n ...createMemoryStores(clock),\n ...(Object.fromEntries(\n Object.entries(options.stores ?? {}).filter(([, store]) => store !== undefined),\n ) as Partial<Stores>),\n },\n pool,\n assets: new AssetService(() => runtime.catalogs),\n transport: options.transport ?? {},\n owner: randomId('aio'),\n closed: false,\n closing: new AbortController(),\n natives: new Set(),\n };\n this.namespace = namespace;\n this.#bind(runtime, [scopePart(options)], true);\n }\n\n /**\n * Child container: inherits config, pool, stores and namespace; overrides merge on top.\n * Not a tenant boundary — a scope shares its root's pool and stores. Use a separate\n * `new CryptoAio({ namespace })` when isolation between tenants is required.\n */\n scope(overrides: ScopeOptions): CryptoAio {\n pendingScope = { parent: this, overrides };\n try {\n return new CryptoAio();\n } finally {\n pendingScope = undefined;\n }\n }\n\n blockchain<C extends ChainId>(config: HandleConfig<C>): Blockchain<C> {\n const internals = containerOf(this);\n const { runtime } = internals;\n const selection = resolveSelection({\n handle: config as HandleOptions,\n effective: internals.effective(),\n catalogs: runtime.catalogs,\n log: runtime.log,\n });\n let pooled: Promise<PooledDriver> | undefined;\n let wallet: Promise<ResolvedWallet> | undefined;\n const handle: HandleInternals = {\n container: this,\n selection,\n nativeClients: new Map(),\n assertOpen: () => {\n if (runtime.closed) throw closedError();\n },\n registerNative: (native) => {\n if (runtime.closed) throw closedError();\n if (native.close) runtime.natives.add(() => native.close?.());\n },\n // A closed root refuses work even through a pooled driver this handle holds.\n pooled: () => {\n if (runtime.closed) return Promise.reject(closedError());\n pooled ??= runtime.pool.get(selection).catch((error: unknown) => {\n pooled = undefined;\n throw error;\n });\n return pooled;\n },\n wallet: () => {\n if (runtime.closed) return Promise.reject(closedError());\n wallet ??= handle\n .pooled()\n .then(({ driver }) =>\n resolveWallet(\n selection,\n driver,\n internals.effective().signers,\n runtime.catalogs.schemes,\n internals.signerDeadline(),\n ),\n )\n .catch((error: unknown) => {\n wallet = undefined;\n throw error;\n });\n return wallet;\n },\n };\n return createBlockchain<C>(handle);\n }\n\n /** Registers a plugin on this root container (copy-on-write catalogs). */\n use(plugin: Plugin): this {\n const internals = containerOf(this);\n if (!internals.isRoot)\n throw new ConfigError(\n 'CONFIG_INVALID',\n 'plugins can only be added to a root container',\n );\n const { runtime } = internals;\n const next = cloneCatalogs(runtime.catalogs);\n applyPlugin(next, plugin);\n runtime.catalogs = next;\n runtime.envLayer = {\n chains: readEnvChains(\n runtime.env,\n next.chains.list().map((c) => c.id),\n runtime.profile,\n ),\n };\n return this;\n }\n\n on<E extends AioEventName>(type: E, handler: (event: AioEvent<E>) => void): () => void {\n return containerOf(this).runtime.events.on(type, handler);\n }\n\n onAny(handler: (event: AioEvent) => void): () => void {\n return containerOf(this).runtime.events.onAny(handler);\n }\n\n /** Stored Operations of this namespace, as views, and startup recovery. */\n get operations(): OperationsApi {\n const internals = containerOf(this);\n const store = storesOf(internals.runtime).operations;\n const namespace = internals.runtime.namespace;\n const view = async (record: OperationRecord) =>\n toView(record, await loadObservations(store, record));\n return {\n get: async (id) => {\n const record = await store.get(namespace, id);\n return record ? view(record) : null;\n },\n list: async (filter = {}) =>\n Promise.all(\n (\n await store.list({\n namespace,\n ...(filter.states ? { states: filter.states } : {}),\n ...(filter.chain ? { chain: filter.chain } : {}),\n ...(filter.network ? { network: filter.network } : {}),\n ...(filter.limit !== undefined ? { limit: filter.limit } : {}),\n })\n ).map(view),\n ),\n recover: async (options = {}) =>\n internals.monitor().recover({\n ...options,\n signal: workerSignal(internals.runtime, options.signal),\n }),\n };\n }\n\n /** Background workers that check due Operations without anyone waiting on them. */\n get monitor(): MonitorApi {\n const internals = containerOf(this);\n return {\n start: async (options = {}) =>\n internals.monitor().start({\n ...options,\n signal: workerSignal(internals.runtime, options.signal),\n }),\n runOnce: async (options = {}) =>\n internals.monitor().runOnce({\n workerId: options.workerId ?? internals.runtime.owner,\n ...(options.batch !== undefined ? { batch: options.batch } : {}),\n signal: workerSignal(internals.runtime, options.signal),\n }),\n };\n }\n\n /**\n * Closes the root container: runs the `close` of every native client that\n * `crypto-aio/native` handed out (a failing one is logged by code and skipped), then\n * closes the pooled drivers. Its handles and `native()` then fail with\n * `INVALID_TRANSITION`. A scope's `close()` does nothing; scopes share their root's pool.\n */\n async close(): Promise<void> {\n const internals = containerOf(this);\n if (!internals.isRoot) return;\n const { runtime } = internals;\n runtime.closed = true;\n // Every worker loop, pass and recovery stops at its next check, and its sleeps end.\n runtime.closing.abort();\n const natives = [...runtime.natives];\n runtime.natives.clear();\n await Promise.all(\n natives.map(async (close) => {\n try {\n const outcome = await closeWithin(\n close,\n runtime.clock,\n NATIVE_CLOSE_TIMEOUT_MS,\n );\n if (outcome === 'timeout') {\n runtime.log.warn('native client close timed out', {\n timeoutMs: NATIVE_CLOSE_TIMEOUT_MS,\n });\n }\n } catch (error) {\n runtime.log.warn('native client close failed', { code: errorCode(error) });\n }\n }),\n );\n await runtime.pool.close();\n }\n\n #bind(runtime: RootRuntime, layers: readonly ScopeOptions[], isRoot: boolean): void {\n const effective = () => mergeScopes([runtime.envLayer, ...layers]);\n let engine: OperationEngine | undefined;\n let monitor: Monitor | undefined;\n const getEngine = () => (engine ??= createEngine(runtime, effective));\n const wallets = walletCache(runtime, () => containerOf(this));\n bindContainer(this, {\n runtime,\n layers,\n isRoot,\n effective,\n signerDeadline: () => ({\n clock: runtime.clock,\n timeoutMs: withLifecycleDefaults(effective().lifecycle).signTimeoutMs,\n }),\n engine: getEngine,\n monitor: () =>\n (monitor ??= new Monitor({\n engine: getEngine(),\n stores: storesOf(runtime),\n events: runtime.events,\n clock: runtime.clock,\n log: runtime.log.child('monitor'),\n namespace: runtime.namespace,\n lifecycle: () => withLifecycleDefaults(effective().lifecycle),\n resolveRead: (record) => readTarget(this, record),\n resolveTarget: (record) => operationTarget(this, runtime, record, wallets),\n })),\n });\n }\n}\n"]}
@@ -7,7 +7,7 @@ import type { ChainInfo, NetworkInfo } from '../model/chain';
7
7
  import type { FeeEstimateDraft, FeeOverride, FeeSpeed } from '../model/fee';
8
8
  import type { DriverIntent } from '../model/intent';
9
9
  import type { OrderingData, OrderingKind } from '../model/ordering';
10
- import type { AttemptRef, Decoding, RawTx, SignedTx, TransferSource, UnsignedTx } from '../model/transaction';
10
+ import type { AttemptRef, Decoding, RawTx, SignedTx, TransferSource, TxFailure, UnsignedTx } from '../model/transaction';
11
11
  import type { KeyRef, SignatureBundle } from '../signing/types';
12
12
  import type { Transport } from '../transport/types';
13
13
  import type { Clock } from '../util/clock';
@@ -31,6 +31,14 @@ export interface BuildContext {
31
31
  readonly ordering?: OrderingData;
32
32
  /** Inputs held by other live Operations of this wallet (`inputs` ordering). */
33
33
  readonly excludeInputs?: readonly string[];
34
+ /**
35
+ * The decimals the core scaled the intent's amounts with: the asset's registered
36
+ * metadata, or what the chain gave. Drivers work in base units. One whose transaction
37
+ * signs the decimals (Solana's `transferChecked`) reads them from the chain and must
38
+ * refuse a mismatch with this value (`ASSET_RESOLUTION`): the amounts were then scaled
39
+ * wrong. Absent where no transfer is built (a replacement or a cancel).
40
+ */
41
+ readonly decimals?: number;
34
42
  readonly signal?: AbortSignal;
35
43
  }
36
44
  export type FundsCheck = {
@@ -70,6 +78,11 @@ export interface DriverTxObservation {
70
78
  * (`TxStatus.reason`).
71
79
  */
72
80
  readonly reason?: string;
81
+ /**
82
+ * With `success: false`, what failed (`TxFailure`). Absent is `'reverted'`; a driver sets
83
+ * `'unevidenced'` when the transaction executed but shows no transfer to the recipient.
84
+ */
85
+ readonly failure?: TxFailure;
73
86
  }
74
87
  export interface DriverTransfer {
75
88
  /** Deterministic within the transaction, e.g. `native`, `log:3`, `vout:1`, `ix:0.2`. */
@@ -181,6 +194,8 @@ export interface ProofSource {
181
194
  * proven.
182
195
  */
183
196
  readonly reason?: string;
197
+ /** With `success: false`, what failed, as `DriverTxObservation.failure`. */
198
+ readonly failure?: TxFailure;
184
199
  }>;
185
200
  /** Whether the ordering slot (nonce/seqno/an input) is consumed by ANY transaction at `level`. */
186
201
  slotConsumed(ordering: OrderingData, from: string, level: FinalityLevel): Promise<boolean>;
@@ -210,6 +225,13 @@ export interface ReplacementPolicy {
210
225
  * (a repeat cancel bumps a stuck one).
211
226
  */
212
227
  buildCancel?(previous: UnsignedTx, ctx: BuildContext, fee?: FeeSpeed | FeeOverride): Promise<UnsignedTx>;
228
+ /**
229
+ * Orders two transactions of one slot by the price a node compares when one replaces
230
+ * the other: negative when `a` pays less, positive when it pays more, `0` when neither
231
+ * does. A repeat cancel bumps from the highest earlier cancel by this order; without it,
232
+ * the core compares their total charges, which a gas limit can skew.
233
+ */
234
+ comparePrice?(a: UnsignedTx, b: UnsignedTx): number;
213
235
  }
214
236
  export interface ScanFilter {
215
237
  readonly addresses?: readonly string[];
@@ -263,6 +285,7 @@ export interface DisposableNativeClient {
263
285
  * | `blocks.transactions` | `monitor` | `safe` | none | retryable `PROVIDER_INCONSISTENT` when the block at `block.height` no longer has `block.hash` |
264
286
  * | `history.list` | `read` (indexer transport when configured) | `safe` | none | propagate |
265
287
  * | `createNativeClient` | no I/O | – | – | a fresh SDK instance on every call, never the pooled one |
288
+ * | `signingSchemes` (optional) | no I/O | – | – | `ConfigError('CONFIG_INVALID')` for wallet options it refuses |
266
289
  *
267
290
  * Further rules:
268
291
  * - On a proof path (`proofs.*`), only a definitive negative proof may
@@ -300,6 +323,16 @@ export interface ChainDriver {
300
323
  /** Two-level, capability-gated family API: `ext.<family>.<method>(...) → Promise`. */
301
324
  readonly ext?: Readonly<Record<string, Readonly<Record<string, (...args: never[]) => Promise<unknown>>>>>;
302
325
  limits?(wallet: WalletOptions): DriverLimits;
326
+ /**
327
+ * The signature schemes a wallet with these options signs with, when its options narrow
328
+ * the chain's `schemes` (a Bitcoin `p2tr` wallet signs with `secp256k1-schnorr` only). No
329
+ * I/O; it throws `CONFIG_INVALID` for options the driver refuses. When the core resolves
330
+ * a wallet that has a signer, it refuses (`CONFIG_INVALID`) one that does not declare each
331
+ * of them, before reading any key: the transfer would otherwise be built, reserved and
332
+ * fail only at signing. Without this method, a signer needs one of the chain's schemes.
333
+ * A watch-only wallet is not checked.
334
+ */
335
+ signingSchemes?(wallet: WalletOptions): readonly string[];
303
336
  /**
304
337
  * A fresh, caller-owned SDK client for `crypto-aio/native`: a new SDK instance on every
305
338
  * call, never the pooled one.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/driver/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CodesOf } from '../errors/codes';\nimport type { Logger } from '../events/logger';\nimport type { AddressFormatter, NormalizedAddress } from '../model/address';\nimport type { AssetMetadata, AssetRef, TokenRef } from '../model/asset';\nimport type { Capability } from '../model/capability';\nimport type { ChainInfo, NetworkInfo } from '../model/chain';\nimport type { FeeEstimateDraft, FeeOverride, FeeSpeed } from '../model/fee';\nimport type { DriverIntent } from '../model/intent';\nimport type { OrderingData, OrderingKind } from '../model/ordering';\nimport type {\n AttemptRef,\n Decoding,\n RawTx,\n SignedTx,\n TransferSource,\n UnsignedTx,\n} from '../model/transaction';\nimport type { KeyRef, SignatureBundle } from '../signing/types';\nimport type { Transport } from '../transport/types';\nimport type { Clock } from '../util/clock';\n\n/**\n * Family-specific wallet settings (e.g. `utxo.addressType`, TON wallet identity). The `hd`\n * key is reserved and core-built: the core sets it to the wallet's `WalletHdOptions` when\n * the wallet has an `xpub`, and a user's or caller's `hd` never reaches a driver, since a\n * driver trusts `hd` to validate change addresses.\n */\nexport type WalletOptions = Readonly<Record<string, unknown>>;\n\nexport interface WalletKey {\n readonly scheme: string;\n readonly publicKey: Uint8Array;\n readonly keyRef?: KeyRef;\n}\n\nexport interface BuildContext {\n readonly from: string;\n readonly keys: readonly WalletKey[];\n readonly wallet: WalletOptions;\n /** Allocated by the core for `nonce` and `seqno` ordering. */\n readonly ordering?: OrderingData;\n /** Inputs held by other live Operations of this wallet (`inputs` ordering). */\n readonly excludeInputs?: readonly string[];\n readonly signal?: AbortSignal;\n}\n\nexport type FundsCheck =\n | { readonly ok: true }\n | {\n readonly ok: false;\n readonly asset: AssetRef;\n readonly required: bigint;\n readonly available: bigint;\n };\n\n/**\n * `refused`: state-dependent (may become valid, or may already be included) — observed only.\n * `rejected`: permanently invalid by construction (malformed, bad signature, wrong chain).\n */\nexport type BroadcastResult =\n | { readonly kind: 'accepted' }\n | { readonly kind: 'already-known' }\n | { readonly kind: 'refused'; readonly code: CodesOf<'chain'>; readonly reason: string }\n | { readonly kind: 'rejected'; readonly reason: string };\n\nexport interface DriverTxObservation {\n readonly seen: 'none' | 'mempool' | 'block';\n readonly txHash?: string;\n readonly blockHeight?: bigint;\n readonly blockHash?: string;\n /** For included transactions: false when execution failed or reverted. */\n readonly success?: boolean;\n /**\n * With `success: false`, why, as a short fixed text: no addresses, amounts or node\n * text, which can carry either. The monitor records it on the observation\n * (`TxStatus.reason`).\n */\n readonly reason?: string;\n}\n\nexport interface DriverTransfer {\n /** Deterministic within the transaction, e.g. `native`, `log:3`, `vout:1`, `ix:0.2`. */\n readonly locator: string;\n readonly from: readonly string[];\n readonly to: string;\n readonly asset: AssetRef;\n readonly amount: bigint;\n readonly source: TransferSource;\n readonly memo?: string;\n}\n\nexport interface DriverTransaction {\n readonly id: string;\n readonly observation: DriverTxObservation;\n readonly fee?: readonly { readonly asset: AssetRef; readonly amount: bigint }[];\n readonly transfers: readonly DriverTransfer[];\n readonly decoding: Decoding;\n readonly raw?: RawTx;\n readonly timestamp?: number;\n readonly details: Readonly<Record<string, unknown>>;\n}\n\nexport interface DriverBlock {\n readonly height: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp?: number;\n readonly transactionIds?: readonly string[];\n}\n\nexport interface AddressCodec {\n validate(address: string): boolean;\n /**\n * Throws `ValidationError('INVALID_ADDRESS')`. The returned `variant` is part of the\n * intent hash: it must hold only JSON scalars (strings, finite numbers, booleans, `null`)\n * and should contain only semantic fields that change what the transfer does (for example\n * TON's `bounceable`), never encoding-only choices, so two spellings of one recipient\n * with the same meaning hash the same.\n */\n normalize(address: string): NormalizedAddress;\n fromPublicKey(publicKey: Uint8Array, wallet?: WalletOptions): NormalizedAddress;\n readonly format?: AddressFormatter;\n}\n\nexport interface ChainReader {\n getBalance(address: string, asset: AssetRef): Promise<bigint>;\n getBlockHeight(): Promise<bigint>;\n /** Highest block satisfying the network's finality policy. */\n getFinalizedHeight(): Promise<bigint>;\n getBlock(ref: bigint | string): Promise<DriverBlock | null>;\n getTransaction(id: string): Promise<DriverTransaction | null>;\n /**\n * Current view of an Attempt (uses `purpose: 'monitor'` reads). `ordering` and `from` are\n * `undefined` for a transaction the library does not manage (a status lookup by id).\n */\n observe(\n ref: AttemptRef,\n ordering: OrderingData | undefined,\n from: string | undefined,\n ): Promise<DriverTxObservation>;\n getTokenMetadata?(ref: TokenRef): Promise<AssetMetadata>;\n /** Canonicalizes a token contract (e.g. EIP-55); identity for asset ids. */\n normalizeTokenRef?(ref: TokenRef): TokenRef;\n}\n\nexport interface TxBuilder {\n estimateFee(intent: DriverIntent, ctx: BuildContext): Promise<FeeEstimateDraft>;\n checkFunds(\n intent: DriverIntent,\n fee: FeeEstimateDraft,\n ctx: BuildContext,\n ): Promise<FundsCheck>;\n build(\n intent: DriverIntent,\n fee: FeeEstimateDraft,\n ctx: BuildContext,\n ): Promise<UnsignedTx>;\n assemble(\n unsigned: UnsignedTx,\n signatures: readonly SignatureBundle[],\n ): Promise<SignedTx>;\n /**\n * The signatures a payload signed elsewhere carries for `unsigned`'s requests,\n * e.g. a PSBT a cold signer returned. No I/O. Throws `ValidationError('INVALID_INTENT')`\n * when `signed` is not the prepared transaction; one it does not tell apart still fails\n * the core's check with `SIGNATURE_MISMATCH`. Only signature bytes are taken from it: the\n * core verifies each one against its stored request, as for any bundle. A request\n * without a signature in `signed` is left out (a partial set).\n */\n signaturesFrom?(unsigned: UnsignedTx, signed: RawTx): readonly SignatureBundle[];\n}\n\nexport interface Broadcaster {\n /**\n * Throws (ambiguous) on transport failure; returns a classified result otherwise.\n * `signed.ref.id` is empty for bare broadcasts (`Blockchain.broadcast`); never rely on it.\n */\n broadcast(\n signed: SignedTx,\n options?: { readonly fanout?: number; readonly signal?: AbortSignal },\n ): Promise<BroadcastResult>;\n}\n\nexport type FinalityLevel = 'latest' | 'finalized';\n\n/**\n * Finalized-state checks behind `proven` verdicts; implementations use quorum reads.\n * Only a definitive negative proof answers \"no\". Every other RPC error (state or\n * history not available, pruned data, indexing in progress, a non-definitive error) throws\n * a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, which decides nothing.\n */\nexport interface ProofSource {\n finalizedHead(): Promise<{\n readonly height: bigint;\n readonly hash: string;\n readonly timestamp?: number;\n }>;\n includedFinal(\n ref: AttemptRef,\n ordering: OrderingData,\n from: string,\n ): Promise<\n | { readonly included: false }\n | {\n readonly included: true;\n readonly success: boolean;\n readonly blockHeight: bigint;\n readonly blockHash: string;\n readonly txHash: string;\n /**\n * With `success: false`, a short fixed text, never node text. It is recorded as\n * proven.\n */\n readonly reason?: string;\n }\n >;\n /** Whether the ordering slot (nonce/seqno/an input) is consumed by ANY transaction at `level`. */\n slotConsumed(\n ordering: OrderingData,\n from: string,\n level: FinalityLevel,\n ): Promise<boolean>;\n /** Whether expiry has passed per finalized state (expiry/seqno models; false otherwise). */\n expired(ordering: OrderingData): Promise<boolean>;\n /**\n * The hash of the block at `height` on the chain at `level`, or `null` when there is\n * none yet (above the head, or above the finalized height for `'finalized'`). Confirms\n * the monitor's orphan decisions and the scanner's rollback and TOO_DEEP verdicts.\n */\n blockHash(height: bigint, level: FinalityLevel): Promise<string | null>;\n}\n\nexport interface SequenceSource {\n /** Next nonce/seqno including pending transactions. */\n pending(address: string): Promise<bigint>;\n /** Next nonce/seqno per the latest block. */\n latest(address: string): Promise<bigint>;\n}\n\nexport interface ReplacementPolicy {\n readonly replace: boolean;\n readonly cancel: boolean;\n buildReplacement?(\n previous: UnsignedTx,\n fee: FeeSpeed | FeeOverride,\n ctx: BuildContext,\n ): Promise<UnsignedTx>;\n /**\n * A transaction for `previous`'s slot that does not execute the transfer (e.g. a\n * self-transfer). Without `fee` it pays the network's minimum bump over `previous`; with\n * one, that fee, refused (FEE_TOO_LOW) below the bump. `previous` may itself be a cancel\n * (a repeat cancel bumps a stuck one).\n */\n buildCancel?(\n previous: UnsignedTx,\n ctx: BuildContext,\n fee?: FeeSpeed | FeeOverride,\n ): Promise<UnsignedTx>;\n}\n\nexport interface ScanFilter {\n readonly addresses?: readonly string[];\n readonly assets?: readonly AssetRef[];\n}\n\nexport interface BlockSource {\n header(height: bigint): Promise<DriverBlock | null>;\n transactions(\n block: DriverBlock,\n filter?: ScanFilter,\n ): Promise<readonly DriverTransaction[]>;\n}\n\nexport interface AddressHistorySource {\n list(\n address: string,\n options: { readonly cursor?: string; readonly limit: number },\n ): Promise<{ readonly items: readonly DriverTransaction[]; readonly next?: string }>;\n}\n\nexport interface DriverLimits {\n readonly maxOutputs: number;\n}\n\n/**\n * A native SDK client for `crypto-aio/native` and how to release it. `close` frees\n * what the client holds (sockets, timers, workers); the root container's `close()` runs it\n * once, before closing its pooled drivers.\n */\nexport interface DisposableNativeClient {\n readonly client: unknown;\n close?(): void | Promise<void>;\n}\n\n/**\n * The driver port: every method's contract, as the core relies on it. Purpose, retry\n * class and quorum are the `CallOptions` a driver passes to its `Transport` (defaults:\n * purpose `read`, retry `safe`, no quorum). A `monitor` or `proof` read only goes to\n * endpoints that are not lagging.\n *\n * | Method | Purpose | Retry | Quorum | Returns / throws |\n * | --- | --- | --- | --- | --- |\n * | `reader.getBalance`, `getBlock`, `getTransaction` | `read` | `safe` | none | `null` when not found; provider errors propagate |\n * | `reader.getTokenMetadata` | `read` | `safe` | none (a driver may use a quorum) | A token's own unusable metadata (no contract, a reverting or malformed `decimals`/`symbol`) throws `ValidationError('ASSET_RESOLUTION')`, which the core caches per container (only a non-retryable `ASSET_RESOLUTION` is cached); every other failure, e.g. a transient provider failure (propagated retryable) or any other provider error, is not cached and the next lookup queries again. Stricter than this minimum, the EVM driver reads `decimals()` and `symbol()` under `quorum: 'proof'`: the metadata is cached for the container's life, and one endpoint's wrong `decimals` would mis-scale every amount; endpoints that disagree throw retryable `PROVIDER_INCONSISTENT`, which is not cached |\n * | `reader.getBlockHeight`, `getFinalizedHeight` | `monitor` | `safe` | none | propagate; they feed the stale-view guards and confirmation depths |\n * | `reader.observe(ref, ordering, from)` | `monitor` | `safe` | none | `{ seen: 'none' }` when not visible; `ordering` and `from` are `undefined` for a transaction the library does not manage |\n * | `sequence.pending`, `sequence.latest` | `monitor` | `safe` | none | propagate |\n * | `proofs.*` (`finalizedHead`, `includedFinal`, `slotConsumed`, `expired`, `blockHash`) | `proof` | `safe` | `'proof'` | endpoints that disagree throw retryable `PROVIDER_INCONSISTENT`, and the core then decides nothing. Only a definitive negative proof answers \"no\"; every other RPC error throws retryable `PROVIDER_UNAVAILABLE`, which decides nothing (see below). Only `slotConsumed(…, 'latest')` may be a single `monitor` read: the core records it as observed evidence |\n * | `broadcaster.broadcast` | `broadcast` | `ambiguous-on-failure` | none (passes `fanout` and `signal` through) | classifies a definitive `RPC_ERROR` into a `BroadcastResult`; rethrows an ambiguous one (`error.ambiguous`) and every other failure unclassified |\n * | `builder.estimateFee`, `checkFunds`, `build` | `read` | `safe` | none | `ValidationError` / `UnsupportedCapabilityError` for an intent it cannot build |\n * | `builder.assemble` | no I/O | – | – | `SigningError('SIGNING_FAILED')` when a signature is missing |\n * | `builder.signaturesFrom` (optional) | no I/O | – | – | `ValidationError('INVALID_INTENT')` when the signed payload is not the prepared transaction |\n * | `replacement.buildReplacement`, `buildCancel` | `read` | `safe` | none | `ChainError('FEE_TOO_LOW')` below the network's bump; `buildCancel` honours a given `fee` and never substitutes its own |\n * | `blocks.header` | `monitor` | `safe` | none | `null` while the height is not visible |\n * | `blocks.transactions` | `monitor` | `safe` | none | retryable `PROVIDER_INCONSISTENT` when the block at `block.height` no longer has `block.hash` |\n * | `history.list` | `read` (indexer transport when configured) | `safe` | none | propagate |\n * | `createNativeClient` | no I/O | – | – | a fresh SDK instance on every call, never the pooled one |\n *\n * Further rules:\n * - On a proof path (`proofs.*`), only a definitive negative proof may\n * answer \"no\" (`included: false`, a slot not consumed, a `null` block hash). Every other\n * RPC error, including state or history not available, pruned data, an index still being\n * built (\"transaction indexing is in progress\"), or an endpoint's non-definitive error,\n * must surface as a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, which decides\n * nothing: the core looks again later and never takes it for an answer.\n * - `BlockSource` heights are dense: every height up to the head has one block, and\n * `header(h)` is `null` only while `h` is not visible, never for a skipped slot.\n * - A provider must serve headers at least about 2 × `reorgWindow` below the head. A new\n * cursor loads `reorgWindow` blocks below its start, and a rollback refills its window\n * below the common ancestor.\n * - `ScanFilter.addresses`: when non-empty, return at least every transaction with a transfer\n * from or to one of them; empty (`[]`) or absent means no filter. `ScanFilter.assets` is a\n * hint only: a driver may narrow by it or ignore it, and the core does not filter again.\n * - `fee.details.requestedFee` is reserved. On replacements the core records the requested\n * fee spec there, so a driver never sets or reads it.\n * - `DriverContext` has no asset resolver and `DriverIntent` carries no decimals. Amounts\n * reach drivers in base units only; a driver that needs a token's decimals (Solana's\n * `transferChecked`) reads them from the chain itself.\n */\nexport interface ChainDriver {\n readonly ordering: OrderingKind;\n readonly capabilities: ReadonlySet<Capability>;\n readonly address: AddressCodec;\n readonly reader: ChainReader;\n readonly builder: TxBuilder;\n readonly broadcaster: Broadcaster;\n readonly proofs: ProofSource;\n readonly sequence?: SequenceSource;\n readonly replacement?: ReplacementPolicy;\n readonly blocks?: BlockSource;\n readonly history?: AddressHistorySource;\n /** Two-level, capability-gated family API: `ext.<family>.<method>(...) → Promise`. */\n readonly ext?: Readonly<\n Record<string, Readonly<Record<string, (...args: never[]) => Promise<unknown>>>>\n >;\n limits?(wallet: WalletOptions): DriverLimits;\n /**\n * A fresh, caller-owned SDK client for `crypto-aio/native`: a new SDK instance on every\n * call, never the pooled one.\n */\n createNativeClient?(): DisposableNativeClient;\n close?(): Promise<void>;\n}\n\n/**\n * A factory's `create()` must call `transport.setProbes(...)` exactly once, before any\n * other traffic, on every `Transport` it receives here — including `indexer`, when present.\n * `setProbes` resets health/identity state, so calling it again later, or skipping it on one\n * of the two transports, leaves that transport's health checks silently unconfigured.\n *\n * There is no asset resolver here, and `DriverIntent` carries no decimals: drivers work\n * in base units only.\n */\nexport interface DriverContext {\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly library: string;\n readonly transport: Transport;\n readonly indexer?: Transport;\n readonly clock: Clock;\n readonly log: Logger;\n readonly options: Readonly<Record<string, unknown>>;\n}\n\nexport interface DriverFactory {\n create(ctx: DriverContext): Promise<ChainDriver>;\n}\n\nexport interface PeerDependency {\n readonly name: string;\n readonly range: string;\n}\n\n/** Static metadata (no SDK import) plus a lazy `load()` that `require()`s the driver module. */\nexport interface AdapterManifest {\n readonly family: string;\n readonly library: string;\n readonly chains: readonly string[];\n readonly capabilities: readonly Capability[];\n readonly indexerCapabilities?: readonly Capability[];\n readonly requiresIndexer?: boolean;\n readonly peerDependencies: readonly PeerDependency[];\n load(): Promise<DriverFactory>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/driver/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CodesOf } from '../errors/codes';\nimport type { Logger } from '../events/logger';\nimport type { AddressFormatter, NormalizedAddress } from '../model/address';\nimport type { AssetMetadata, AssetRef, TokenRef } from '../model/asset';\nimport type { Capability } from '../model/capability';\nimport type { ChainInfo, NetworkInfo } from '../model/chain';\nimport type { FeeEstimateDraft, FeeOverride, FeeSpeed } from '../model/fee';\nimport type { DriverIntent } from '../model/intent';\nimport type { OrderingData, OrderingKind } from '../model/ordering';\nimport type {\n AttemptRef,\n Decoding,\n RawTx,\n SignedTx,\n TransferSource,\n TxFailure,\n UnsignedTx,\n} from '../model/transaction';\nimport type { KeyRef, SignatureBundle } from '../signing/types';\nimport type { Transport } from '../transport/types';\nimport type { Clock } from '../util/clock';\n\n/**\n * Family-specific wallet settings (e.g. `utxo.addressType`, TON wallet identity). The `hd`\n * key is reserved and core-built: the core sets it to the wallet's `WalletHdOptions` when\n * the wallet has an `xpub`, and a user's or caller's `hd` never reaches a driver, since a\n * driver trusts `hd` to validate change addresses.\n */\nexport type WalletOptions = Readonly<Record<string, unknown>>;\n\nexport interface WalletKey {\n readonly scheme: string;\n readonly publicKey: Uint8Array;\n readonly keyRef?: KeyRef;\n}\n\nexport interface BuildContext {\n readonly from: string;\n readonly keys: readonly WalletKey[];\n readonly wallet: WalletOptions;\n /** Allocated by the core for `nonce` and `seqno` ordering. */\n readonly ordering?: OrderingData;\n /** Inputs held by other live Operations of this wallet (`inputs` ordering). */\n readonly excludeInputs?: readonly string[];\n /**\n * The decimals the core scaled the intent's amounts with: the asset's registered\n * metadata, or what the chain gave. Drivers work in base units. One whose transaction\n * signs the decimals (Solana's `transferChecked`) reads them from the chain and must\n * refuse a mismatch with this value (`ASSET_RESOLUTION`): the amounts were then scaled\n * wrong. Absent where no transfer is built (a replacement or a cancel).\n */\n readonly decimals?: number;\n readonly signal?: AbortSignal;\n}\n\nexport type FundsCheck =\n | { readonly ok: true }\n | {\n readonly ok: false;\n readonly asset: AssetRef;\n readonly required: bigint;\n readonly available: bigint;\n };\n\n/**\n * `refused`: state-dependent (may become valid, or may already be included) — observed only.\n * `rejected`: permanently invalid by construction (malformed, bad signature, wrong chain).\n */\nexport type BroadcastResult =\n | { readonly kind: 'accepted' }\n | { readonly kind: 'already-known' }\n | { readonly kind: 'refused'; readonly code: CodesOf<'chain'>; readonly reason: string }\n | { readonly kind: 'rejected'; readonly reason: string };\n\nexport interface DriverTxObservation {\n readonly seen: 'none' | 'mempool' | 'block';\n readonly txHash?: string;\n readonly blockHeight?: bigint;\n readonly blockHash?: string;\n /** For included transactions: false when execution failed or reverted. */\n readonly success?: boolean;\n /**\n * With `success: false`, why, as a short fixed text: no addresses, amounts or node\n * text, which can carry either. The monitor records it on the observation\n * (`TxStatus.reason`).\n */\n readonly reason?: string;\n /**\n * With `success: false`, what failed (`TxFailure`). Absent is `'reverted'`; a driver sets\n * `'unevidenced'` when the transaction executed but shows no transfer to the recipient.\n */\n readonly failure?: TxFailure;\n}\n\nexport interface DriverTransfer {\n /** Deterministic within the transaction, e.g. `native`, `log:3`, `vout:1`, `ix:0.2`. */\n readonly locator: string;\n readonly from: readonly string[];\n readonly to: string;\n readonly asset: AssetRef;\n readonly amount: bigint;\n readonly source: TransferSource;\n readonly memo?: string;\n}\n\nexport interface DriverTransaction {\n readonly id: string;\n readonly observation: DriverTxObservation;\n readonly fee?: readonly { readonly asset: AssetRef; readonly amount: bigint }[];\n readonly transfers: readonly DriverTransfer[];\n readonly decoding: Decoding;\n readonly raw?: RawTx;\n readonly timestamp?: number;\n readonly details: Readonly<Record<string, unknown>>;\n}\n\nexport interface DriverBlock {\n readonly height: bigint;\n readonly hash: string;\n readonly parentHash: string;\n readonly timestamp?: number;\n readonly transactionIds?: readonly string[];\n}\n\nexport interface AddressCodec {\n validate(address: string): boolean;\n /**\n * Throws `ValidationError('INVALID_ADDRESS')`. The returned `variant` is part of the\n * intent hash: it must hold only JSON scalars (strings, finite numbers, booleans, `null`)\n * and should contain only semantic fields that change what the transfer does (for example\n * TON's `bounceable`), never encoding-only choices, so two spellings of one recipient\n * with the same meaning hash the same.\n */\n normalize(address: string): NormalizedAddress;\n fromPublicKey(publicKey: Uint8Array, wallet?: WalletOptions): NormalizedAddress;\n readonly format?: AddressFormatter;\n}\n\nexport interface ChainReader {\n getBalance(address: string, asset: AssetRef): Promise<bigint>;\n getBlockHeight(): Promise<bigint>;\n /** Highest block satisfying the network's finality policy. */\n getFinalizedHeight(): Promise<bigint>;\n getBlock(ref: bigint | string): Promise<DriverBlock | null>;\n getTransaction(id: string): Promise<DriverTransaction | null>;\n /**\n * Current view of an Attempt (uses `purpose: 'monitor'` reads). `ordering` and `from` are\n * `undefined` for a transaction the library does not manage (a status lookup by id).\n */\n observe(\n ref: AttemptRef,\n ordering: OrderingData | undefined,\n from: string | undefined,\n ): Promise<DriverTxObservation>;\n getTokenMetadata?(ref: TokenRef): Promise<AssetMetadata>;\n /** Canonicalizes a token contract (e.g. EIP-55); identity for asset ids. */\n normalizeTokenRef?(ref: TokenRef): TokenRef;\n}\n\nexport interface TxBuilder {\n estimateFee(intent: DriverIntent, ctx: BuildContext): Promise<FeeEstimateDraft>;\n checkFunds(\n intent: DriverIntent,\n fee: FeeEstimateDraft,\n ctx: BuildContext,\n ): Promise<FundsCheck>;\n build(\n intent: DriverIntent,\n fee: FeeEstimateDraft,\n ctx: BuildContext,\n ): Promise<UnsignedTx>;\n assemble(\n unsigned: UnsignedTx,\n signatures: readonly SignatureBundle[],\n ): Promise<SignedTx>;\n /**\n * The signatures a payload signed elsewhere carries for `unsigned`'s requests,\n * e.g. a PSBT a cold signer returned. No I/O. Throws `ValidationError('INVALID_INTENT')`\n * when `signed` is not the prepared transaction; one it does not tell apart still fails\n * the core's check with `SIGNATURE_MISMATCH`. Only signature bytes are taken from it: the\n * core verifies each one against its stored request, as for any bundle. A request\n * without a signature in `signed` is left out (a partial set).\n */\n signaturesFrom?(unsigned: UnsignedTx, signed: RawTx): readonly SignatureBundle[];\n}\n\nexport interface Broadcaster {\n /**\n * Throws (ambiguous) on transport failure; returns a classified result otherwise.\n * `signed.ref.id` is empty for bare broadcasts (`Blockchain.broadcast`); never rely on it.\n */\n broadcast(\n signed: SignedTx,\n options?: { readonly fanout?: number; readonly signal?: AbortSignal },\n ): Promise<BroadcastResult>;\n}\n\nexport type FinalityLevel = 'latest' | 'finalized';\n\n/**\n * Finalized-state checks behind `proven` verdicts; implementations use quorum reads.\n * Only a definitive negative proof answers \"no\". Every other RPC error (state or\n * history not available, pruned data, indexing in progress, a non-definitive error) throws\n * a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, which decides nothing.\n */\nexport interface ProofSource {\n finalizedHead(): Promise<{\n readonly height: bigint;\n readonly hash: string;\n readonly timestamp?: number;\n }>;\n includedFinal(\n ref: AttemptRef,\n ordering: OrderingData,\n from: string,\n ): Promise<\n | { readonly included: false }\n | {\n readonly included: true;\n readonly success: boolean;\n readonly blockHeight: bigint;\n readonly blockHash: string;\n readonly txHash: string;\n /**\n * With `success: false`, a short fixed text, never node text. It is recorded as\n * proven.\n */\n readonly reason?: string;\n /** With `success: false`, what failed, as `DriverTxObservation.failure`. */\n readonly failure?: TxFailure;\n }\n >;\n /** Whether the ordering slot (nonce/seqno/an input) is consumed by ANY transaction at `level`. */\n slotConsumed(\n ordering: OrderingData,\n from: string,\n level: FinalityLevel,\n ): Promise<boolean>;\n /** Whether expiry has passed per finalized state (expiry/seqno models; false otherwise). */\n expired(ordering: OrderingData): Promise<boolean>;\n /**\n * The hash of the block at `height` on the chain at `level`, or `null` when there is\n * none yet (above the head, or above the finalized height for `'finalized'`). Confirms\n * the monitor's orphan decisions and the scanner's rollback and TOO_DEEP verdicts.\n */\n blockHash(height: bigint, level: FinalityLevel): Promise<string | null>;\n}\n\nexport interface SequenceSource {\n /** Next nonce/seqno including pending transactions. */\n pending(address: string): Promise<bigint>;\n /** Next nonce/seqno per the latest block. */\n latest(address: string): Promise<bigint>;\n}\n\nexport interface ReplacementPolicy {\n readonly replace: boolean;\n readonly cancel: boolean;\n buildReplacement?(\n previous: UnsignedTx,\n fee: FeeSpeed | FeeOverride,\n ctx: BuildContext,\n ): Promise<UnsignedTx>;\n /**\n * A transaction for `previous`'s slot that does not execute the transfer (e.g. a\n * self-transfer). Without `fee` it pays the network's minimum bump over `previous`; with\n * one, that fee, refused (FEE_TOO_LOW) below the bump. `previous` may itself be a cancel\n * (a repeat cancel bumps a stuck one).\n */\n buildCancel?(\n previous: UnsignedTx,\n ctx: BuildContext,\n fee?: FeeSpeed | FeeOverride,\n ): Promise<UnsignedTx>;\n /**\n * Orders two transactions of one slot by the price a node compares when one replaces\n * the other: negative when `a` pays less, positive when it pays more, `0` when neither\n * does. A repeat cancel bumps from the highest earlier cancel by this order; without it,\n * the core compares their total charges, which a gas limit can skew.\n */\n comparePrice?(a: UnsignedTx, b: UnsignedTx): number;\n}\n\nexport interface ScanFilter {\n readonly addresses?: readonly string[];\n readonly assets?: readonly AssetRef[];\n}\n\nexport interface BlockSource {\n header(height: bigint): Promise<DriverBlock | null>;\n transactions(\n block: DriverBlock,\n filter?: ScanFilter,\n ): Promise<readonly DriverTransaction[]>;\n}\n\nexport interface AddressHistorySource {\n list(\n address: string,\n options: { readonly cursor?: string; readonly limit: number },\n ): Promise<{ readonly items: readonly DriverTransaction[]; readonly next?: string }>;\n}\n\nexport interface DriverLimits {\n readonly maxOutputs: number;\n}\n\n/**\n * A native SDK client for `crypto-aio/native` and how to release it. `close` frees\n * what the client holds (sockets, timers, workers); the root container's `close()` runs it\n * once, before closing its pooled drivers.\n */\nexport interface DisposableNativeClient {\n readonly client: unknown;\n close?(): void | Promise<void>;\n}\n\n/**\n * The driver port: every method's contract, as the core relies on it. Purpose, retry\n * class and quorum are the `CallOptions` a driver passes to its `Transport` (defaults:\n * purpose `read`, retry `safe`, no quorum). A `monitor` or `proof` read only goes to\n * endpoints that are not lagging.\n *\n * | Method | Purpose | Retry | Quorum | Returns / throws |\n * | --- | --- | --- | --- | --- |\n * | `reader.getBalance`, `getBlock`, `getTransaction` | `read` | `safe` | none | `null` when not found; provider errors propagate |\n * | `reader.getTokenMetadata` | `read` | `safe` | none (a driver may use a quorum) | A token's own unusable metadata (no contract, a reverting or malformed `decimals`/`symbol`) throws `ValidationError('ASSET_RESOLUTION')`, which the core caches per container (only a non-retryable `ASSET_RESOLUTION` is cached); every other failure, e.g. a transient provider failure (propagated retryable) or any other provider error, is not cached and the next lookup queries again. Stricter than this minimum, the EVM driver reads `decimals()` and `symbol()` under `quorum: 'proof'`: the metadata is cached for the container's life, and one endpoint's wrong `decimals` would mis-scale every amount; endpoints that disagree throw retryable `PROVIDER_INCONSISTENT`, which is not cached |\n * | `reader.getBlockHeight`, `getFinalizedHeight` | `monitor` | `safe` | none | propagate; they feed the stale-view guards and confirmation depths |\n * | `reader.observe(ref, ordering, from)` | `monitor` | `safe` | none | `{ seen: 'none' }` when not visible; `ordering` and `from` are `undefined` for a transaction the library does not manage |\n * | `sequence.pending`, `sequence.latest` | `monitor` | `safe` | none | propagate |\n * | `proofs.*` (`finalizedHead`, `includedFinal`, `slotConsumed`, `expired`, `blockHash`) | `proof` | `safe` | `'proof'` | endpoints that disagree throw retryable `PROVIDER_INCONSISTENT`, and the core then decides nothing. Only a definitive negative proof answers \"no\"; every other RPC error throws retryable `PROVIDER_UNAVAILABLE`, which decides nothing (see below). Only `slotConsumed(…, 'latest')` may be a single `monitor` read: the core records it as observed evidence |\n * | `broadcaster.broadcast` | `broadcast` | `ambiguous-on-failure` | none (passes `fanout` and `signal` through) | classifies a definitive `RPC_ERROR` into a `BroadcastResult`; rethrows an ambiguous one (`error.ambiguous`) and every other failure unclassified |\n * | `builder.estimateFee`, `checkFunds`, `build` | `read` | `safe` | none | `ValidationError` / `UnsupportedCapabilityError` for an intent it cannot build |\n * | `builder.assemble` | no I/O | – | – | `SigningError('SIGNING_FAILED')` when a signature is missing |\n * | `builder.signaturesFrom` (optional) | no I/O | – | – | `ValidationError('INVALID_INTENT')` when the signed payload is not the prepared transaction |\n * | `replacement.buildReplacement`, `buildCancel` | `read` | `safe` | none | `ChainError('FEE_TOO_LOW')` below the network's bump; `buildCancel` honours a given `fee` and never substitutes its own |\n * | `blocks.header` | `monitor` | `safe` | none | `null` while the height is not visible |\n * | `blocks.transactions` | `monitor` | `safe` | none | retryable `PROVIDER_INCONSISTENT` when the block at `block.height` no longer has `block.hash` |\n * | `history.list` | `read` (indexer transport when configured) | `safe` | none | propagate |\n * | `createNativeClient` | no I/O | – | – | a fresh SDK instance on every call, never the pooled one |\n * | `signingSchemes` (optional) | no I/O | – | – | `ConfigError('CONFIG_INVALID')` for wallet options it refuses |\n *\n * Further rules:\n * - On a proof path (`proofs.*`), only a definitive negative proof may\n * answer \"no\" (`included: false`, a slot not consumed, a `null` block hash). Every other\n * RPC error, including state or history not available, pruned data, an index still being\n * built (\"transaction indexing is in progress\"), or an endpoint's non-definitive error,\n * must surface as a retryable `ProviderError('PROVIDER_UNAVAILABLE')`, which decides\n * nothing: the core looks again later and never takes it for an answer.\n * - `BlockSource` heights are dense: every height up to the head has one block, and\n * `header(h)` is `null` only while `h` is not visible, never for a skipped slot.\n * - A provider must serve headers at least about 2 × `reorgWindow` below the head. A new\n * cursor loads `reorgWindow` blocks below its start, and a rollback refills its window\n * below the common ancestor.\n * - `ScanFilter.addresses`: when non-empty, return at least every transaction with a transfer\n * from or to one of them; empty (`[]`) or absent means no filter. `ScanFilter.assets` is a\n * hint only: a driver may narrow by it or ignore it, and the core does not filter again.\n * - `fee.details.requestedFee` is reserved. On replacements the core records the requested\n * fee spec there, so a driver never sets or reads it.\n * - `DriverContext` has no asset resolver and `DriverIntent` carries no decimals. Amounts\n * reach drivers in base units only; a driver that needs a token's decimals (Solana's\n * `transferChecked`) reads them from the chain itself.\n */\nexport interface ChainDriver {\n readonly ordering: OrderingKind;\n readonly capabilities: ReadonlySet<Capability>;\n readonly address: AddressCodec;\n readonly reader: ChainReader;\n readonly builder: TxBuilder;\n readonly broadcaster: Broadcaster;\n readonly proofs: ProofSource;\n readonly sequence?: SequenceSource;\n readonly replacement?: ReplacementPolicy;\n readonly blocks?: BlockSource;\n readonly history?: AddressHistorySource;\n /** Two-level, capability-gated family API: `ext.<family>.<method>(...) → Promise`. */\n readonly ext?: Readonly<\n Record<string, Readonly<Record<string, (...args: never[]) => Promise<unknown>>>>\n >;\n limits?(wallet: WalletOptions): DriverLimits;\n /**\n * The signature schemes a wallet with these options signs with, when its options narrow\n * the chain's `schemes` (a Bitcoin `p2tr` wallet signs with `secp256k1-schnorr` only). No\n * I/O; it throws `CONFIG_INVALID` for options the driver refuses. When the core resolves\n * a wallet that has a signer, it refuses (`CONFIG_INVALID`) one that does not declare each\n * of them, before reading any key: the transfer would otherwise be built, reserved and\n * fail only at signing. Without this method, a signer needs one of the chain's schemes.\n * A watch-only wallet is not checked.\n */\n signingSchemes?(wallet: WalletOptions): readonly string[];\n /**\n * A fresh, caller-owned SDK client for `crypto-aio/native`: a new SDK instance on every\n * call, never the pooled one.\n */\n createNativeClient?(): DisposableNativeClient;\n close?(): Promise<void>;\n}\n\n/**\n * A factory's `create()` must call `transport.setProbes(...)` exactly once, before any\n * other traffic, on every `Transport` it receives here — including `indexer`, when present.\n * `setProbes` resets health/identity state, so calling it again later, or skipping it on one\n * of the two transports, leaves that transport's health checks silently unconfigured.\n *\n * There is no asset resolver here, and `DriverIntent` carries no decimals: drivers work\n * in base units only.\n */\nexport interface DriverContext {\n readonly chain: ChainInfo;\n readonly network: NetworkInfo;\n readonly library: string;\n readonly transport: Transport;\n readonly indexer?: Transport;\n readonly clock: Clock;\n readonly log: Logger;\n readonly options: Readonly<Record<string, unknown>>;\n}\n\nexport interface DriverFactory {\n create(ctx: DriverContext): Promise<ChainDriver>;\n}\n\nexport interface PeerDependency {\n readonly name: string;\n readonly range: string;\n}\n\n/** Static metadata (no SDK import) plus a lazy `load()` that `require()`s the driver module. */\nexport interface AdapterManifest {\n readonly family: string;\n readonly library: string;\n readonly chains: readonly string[];\n readonly capabilities: readonly Capability[];\n readonly indexerCapabilities?: readonly Capability[];\n readonly requiresIndexer?: boolean;\n readonly peerDependencies: readonly PeerDependency[];\n load(): Promise<DriverFactory>;\n}\n"]}
@@ -81,6 +81,11 @@ export declare const ERROR_CODES: {
81
81
  readonly category: "chain";
82
82
  readonly retryable: false;
83
83
  };
84
+ /** Included and executed, but no transfer to the recipient shows: value may have moved. */
85
+ readonly TX_UNEVIDENCED: {
86
+ readonly category: "chain";
87
+ readonly retryable: false;
88
+ };
84
89
  readonly TX_EXPIRED: {
85
90
  readonly category: "chain";
86
91
  readonly retryable: false;
@@ -142,6 +147,11 @@ export declare const ERROR_CODES: {
142
147
  readonly category: "state";
143
148
  readonly retryable: false;
144
149
  };
150
+ /** A stored Operation's record format is newer than this version reads. */
151
+ readonly RECORD_FORMAT_UNSUPPORTED: {
152
+ readonly category: "state";
153
+ readonly retryable: false;
154
+ };
145
155
  readonly TIMEOUT: {
146
156
  readonly category: "timeout";
147
157
  readonly retryable: true;