@mysten-incubation/hashi 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.mts CHANGED
@@ -20,6 +20,10 @@ interface HashiClientOptions<Name = "HashiClient"> {
20
20
  btcRpcUrl?: string;
21
21
  /** Override the Sui GraphQL endpoint URL (defaults to `https://fullnode.{network}.sui.io:443/graphql`). */
22
22
  graphqlUrl?: string;
23
+ /** Guardian origin URL (e.g. `https://hashi-guardian-devnet.mystenlabs.com`); the SDK appends `/info`. Takes precedence over the on-chain `guardian_url` config. */
24
+ guardianUrl?: string;
25
+ /** Custom guardian-info source. When set, the SDK calls this instead of fetching `/info` — useful for caching, tests, or bespoke transports. */
26
+ guardianInfoProvider?: GuardianInfoProvider;
23
27
  }
24
28
  /**
25
29
  * Frozen snapshot of every governance-controlled protocol parameter, returned
@@ -229,5 +233,62 @@ interface UtxoLookupResult {
229
233
  /** Amount in satoshis. */
230
234
  readonly amountSats: bigint;
231
235
  }
236
+ interface GuardianLimiterState {
237
+ /** Available tokens in satoshis at the snapshot instant. */
238
+ readonly numTokensAvailableSats: bigint;
239
+ /** Unix seconds when the bucket was last updated. */
240
+ readonly lastUpdatedAtSecs: bigint;
241
+ /** Next expected withdrawal sequence number. */
242
+ readonly nextSeq: bigint;
243
+ }
244
+ interface GuardianLimiterConfig {
245
+ /** Token refill rate in satoshis per second. */
246
+ readonly refillRateSatsPerSec: bigint;
247
+ /** Maximum bucket capacity in satoshis. */
248
+ readonly maxBucketCapacitySats: bigint;
249
+ }
250
+ /** Raw limiter state + config, as returned by the guardian `/info` endpoint. */
251
+ interface GuardianLimiterRaw {
252
+ readonly state: GuardianLimiterState;
253
+ readonly config: GuardianLimiterConfig;
254
+ }
255
+ /**
256
+ * Curated guardian identity + limiter, parsed from `GET {guardianUrl}/info`.
257
+ * `limiter` is `null` until the guardian is provisioned/activated.
258
+ */
259
+ interface RawGuardianInfo {
260
+ readonly limiter: GuardianLimiterRaw | null;
261
+ /** Guardian build git revision (untrusted, enclave-self-reported). */
262
+ readonly gitRevision: string;
263
+ /** Current committee epoch; `null` before the guardian is initialized. */
264
+ readonly committeeEpoch: bigint | null;
265
+ /** Guardian x-only 32-byte BTC pubkey (hex); `null` before provisioning. */
266
+ readonly btcPubkey: string | null;
267
+ /** Guardian ed25519 32-byte signing pubkey (hex). */
268
+ readonly signingPubKey: string;
269
+ /** `GuardianInfo` signing timestamp (ms since epoch); `null` if absent. */
270
+ readonly signedAtMs: bigint | null;
271
+ }
272
+ /** Pluggable source for {@link RawGuardianInfo}; see `HashiClientOptions.guardianInfoProvider`. */
273
+ type GuardianInfoProvider = () => Promise<RawGuardianInfo>;
274
+ /** Derived limiter view returned by `client.hashi.guardian.limiterStatus()`. */
275
+ interface GuardianLimiterSnapshot {
276
+ readonly state: GuardianLimiterState;
277
+ readonly config: GuardianLimiterConfig;
278
+ /** Projected available tokens (sats), accounting for refill since `lastUpdatedAtSecs`. */
279
+ readonly availableNowSats: bigint;
280
+ /** Bucket fill as a percentage in [0, 100]. */
281
+ readonly bucketFillPercent: number;
282
+ /** Unix seconds at which the bucket refills to full (assuming no withdrawals). `null` if already full or the refill rate is 0. */
283
+ readonly fullAtSecs: bigint | null;
284
+ }
285
+ /** Result of `client.hashi.guardian.canWithdraw(amountSats)`. */
286
+ interface GuardianWithdrawCheck {
287
+ readonly allowed: boolean;
288
+ /** Current available capacity in sats. */
289
+ readonly availableNowSats: bigint;
290
+ /** Seconds until `amountSats` is available; `0n` if available now; `null` if it exceeds max capacity (or the refill rate is 0). */
291
+ readonly estimatedWaitSecs: bigint | null;
292
+ }
232
293
  //#endregion
233
- export { BitcoinNetwork, CancelWithdrawalParams, DepositFees, DepositHistoryItem, DepositInfo, DepositParams, DepositStatus, GovernanceConfig, HashiClientOptions, HbtcBalance, NetworkConfig, SuiNetwork, TransactionHistoryItem, UtxoId, UtxoLookupResult, UtxoOutput, UtxoUsageResult, WaitOptions, WithdrawalFees, WithdrawalHistoryItem, WithdrawalInfo, WithdrawalParams, WithdrawalStatus };
294
+ export { BitcoinNetwork, CancelWithdrawalParams, DepositFees, DepositHistoryItem, DepositInfo, DepositParams, DepositStatus, GovernanceConfig, GuardianInfoProvider, GuardianLimiterConfig, GuardianLimiterRaw, GuardianLimiterSnapshot, GuardianLimiterState, GuardianWithdrawCheck, HashiClientOptions, HbtcBalance, NetworkConfig, RawGuardianInfo, SuiNetwork, TransactionHistoryItem, UtxoId, UtxoLookupResult, UtxoOutput, UtxoUsageResult, WaitOptions, WithdrawalFees, WithdrawalHistoryItem, WithdrawalInfo, WithdrawalParams, WithdrawalStatus };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten-incubation/hashi",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "TypeScript SDK for the Hashi Sui Move smart contracts",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Mysten Labs <build@mystenlabs.com>",