UNPKG

@arkiv-network/sdk

Version:

TypeScript client library for Arkiv's blockchains interactions

40 lines • 1.69 kB
//#region src/entity/expiry.d.ts /** * The brand. Module-private and never exported, so the only way to obtain an {@link Expiry} is to * build one with {@link ExpirationTime} — a hand-written `{ minLifetime, expiresAt }` literal will * not typecheck, and neither will a bare number of seconds. */ declare const validated: unique symbol; /** * How long an entity should live. * * This is the pair the ABI carries, and the engine resolves it as * `max(expiresAt, currentBlock + minLifetime)` — whichever is later. Build one with * {@link ExpirationTime}; there is no other way to make one. * * Which slot a value lands in also decides which rules govern it. `minLifetime` is a duration, so * it must come to a whole number of blocks. `expiresAt` is a block height, which is a whole number * by construction, so a wall-clock date rounds into it rather than being rejected. */ type Expiry = { /** Lifetime floor in blocks, counted from the block the transaction lands in. `0n` if unset. */ readonly minLifetime: bigint; /** * Absolute deadline: a block height, or a `Date` still to be placed against the current block. * `0n` if unset. */ readonly expiresAt: bigint | Date; readonly [validated]: true; }; /** * An expiry that is nothing but a duration — what the `ExpirationTime.from*` helpers return. * * Distinguished from a full {@link Expiry} by its `expiresAt` being the literal `0n`, which is what * keeps `atBlock(x, { atLeast: atBlock(y) })` from compiling: a deadline is not a floor. */ type Lifetime = Expiry & { readonly expiresAt: 0n; }; //#endregion export { Lifetime as n, Expiry as t }; //# sourceMappingURL=expiry-B48I-yTA.d.cts.map