@lucid-evolution/provider 0.2.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +523 -618
- package/dist/index.d.cts +48 -48
- package/dist/index.d.ts +48 -48
- package/dist/index.js +537 -622
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -82,6 +82,12 @@ interface KupmiosOptions {
|
|
|
82
82
|
readonly requestTimeoutMs?: number;
|
|
83
83
|
/** Overall transaction confirmation deadline in milliseconds. @default 160000 */
|
|
84
84
|
readonly awaitTxTimeoutMs?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The `fetch` this provider uses for its Kupo and Ogmios requests, in place
|
|
87
|
+
* of `globalThis.fetch`. It receives the provider's abort signal in
|
|
88
|
+
* `init.signal`, which fires on `requestTimeoutMs` and on a caller's abort.
|
|
89
|
+
*/
|
|
90
|
+
readonly fetchImpl?: typeof globalThis.fetch;
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
* Provides support for interacting with both Kupo and Ogmios APIs.
|
|
@@ -121,6 +127,7 @@ declare class Kupmios implements Provider {
|
|
|
121
127
|
private readonly options;
|
|
122
128
|
private readonly requestTimeoutMs;
|
|
123
129
|
private readonly awaitTxTimeoutMs;
|
|
130
|
+
private readonly httpLayer;
|
|
124
131
|
constructor(kupoUrl: string, ogmiosUrl: string, options?: KupmiosOptions);
|
|
125
132
|
getProtocolParameters(): Promise<ProtocolParameters>;
|
|
126
133
|
getTreasury(): Promise<bigint>;
|
|
@@ -138,8 +145,20 @@ declare class Kupmios implements Provider {
|
|
|
138
145
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
/**
|
|
148
|
+
/** Concatenation of txHash + outputIndex */
|
|
142
149
|
type FlatOutRef = string;
|
|
150
|
+
type LedgerEntry = {
|
|
151
|
+
utxo: UTxO;
|
|
152
|
+
spent: boolean;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
type TransactionHistory = Record<TxHash, {
|
|
156
|
+
status: "pending";
|
|
157
|
+
} | {
|
|
158
|
+
status: "confirmed";
|
|
159
|
+
blockHeight: number;
|
|
160
|
+
slot: number;
|
|
161
|
+
}>;
|
|
143
162
|
declare const EMULATOR_PROVIDER_BRAND: unique symbol;
|
|
144
163
|
declare const isEmulatorProvider: (provider: Provider | undefined) => provider is Emulator;
|
|
145
164
|
type EmulatorAccount = {
|
|
@@ -152,15 +171,16 @@ type EmulatorAccount = {
|
|
|
152
171
|
declare function generateEmulatorAccountFromPrivateKey(assets: Assets): EmulatorAccount;
|
|
153
172
|
declare function generateEmulatorAccount(assets: Assets): EmulatorAccount;
|
|
154
173
|
declare class Emulator implements Provider {
|
|
174
|
+
#private;
|
|
155
175
|
readonly [EMULATOR_PROVIDER_BRAND] = true;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
/**
|
|
177
|
+
* The confirmed UTxO set, keyed by txHash + outputIndex: a plain record
|
|
178
|
+
* that callers may read, edit, replace or snapshot freely. It is an own
|
|
179
|
+
* enumerable property, defined here so it keeps its place among the
|
|
180
|
+
* instance's keys.
|
|
181
|
+
*/
|
|
182
|
+
ledger: Record<FlatOutRef, LedgerEntry>;
|
|
183
|
+
mempool: Record<FlatOutRef, LedgerEntry>;
|
|
164
184
|
/**
|
|
165
185
|
* Only stake key registrations/delegations and rewards are tracked.
|
|
166
186
|
* Other certificates are not tracked.
|
|
@@ -175,16 +195,14 @@ declare class Emulator implements Provider {
|
|
|
175
195
|
protocolParameters: ProtocolParameters;
|
|
176
196
|
datumTable: Record<DatumHash, Datum>;
|
|
177
197
|
treasury: Lovelace;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} | {
|
|
181
|
-
status: "confirmed";
|
|
182
|
-
blockHeight: number;
|
|
183
|
-
slot: number;
|
|
184
|
-
}>;
|
|
198
|
+
/** Every transaction status, keyed by hash; a plain record, like `ledger`. */
|
|
199
|
+
transactionHistory: TransactionHistory;
|
|
185
200
|
constructor(accounts: EmulatorAccount[], protocolParameters?: ProtocolParameters, treasury?: Lovelace);
|
|
186
201
|
now(): UnixTime;
|
|
202
|
+
/** Confirms every pending transaction in `transactionHistory`. */
|
|
187
203
|
private confirmPendingTransactions;
|
|
204
|
+
/** Moves the mempool into the ledger and drops spent entries. */
|
|
205
|
+
private applyMempool;
|
|
188
206
|
awaitSlot(length?: number): void;
|
|
189
207
|
awaitBlock(height?: number): void;
|
|
190
208
|
getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
|
|
@@ -204,41 +222,23 @@ declare class Emulator implements Provider {
|
|
|
204
222
|
*/
|
|
205
223
|
distributeRewards(rewards: Lovelace): void;
|
|
206
224
|
submitTx(tx: Transaction): Promise<TxHash>;
|
|
225
|
+
/** Validates `tx` and applies it to the mempool; returns its hash. */
|
|
226
|
+
private applyTx;
|
|
227
|
+
/**
|
|
228
|
+
* The ledger's collateral rules for a transaction with redeemers: at least
|
|
229
|
+
* one and at most `maxCollateralInputs` collateral inputs, a balance (inputs
|
|
230
|
+
* minus the collateral return) of ADA only that covers
|
|
231
|
+
* `collateralPercentage` of the fee, a `total_collateral` field, when
|
|
232
|
+
* present, equal to that balance, and a collateral return holding at least
|
|
233
|
+
* its minimum ADA.
|
|
234
|
+
*/
|
|
235
|
+
private checkCollateral;
|
|
236
|
+
/** Hash of a reference script, computed once per distinct script. */
|
|
237
|
+
private scriptRefHash;
|
|
207
238
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
208
239
|
log(): void;
|
|
209
240
|
}
|
|
210
241
|
|
|
211
|
-
type MaestroSupportedNetworks = "Mainnet" | "Preprod" | "Preview";
|
|
212
|
-
interface MaestroConfig {
|
|
213
|
-
network: MaestroSupportedNetworks;
|
|
214
|
-
apiKey: string;
|
|
215
|
-
turboSubmit?: boolean;
|
|
216
|
-
}
|
|
217
|
-
declare class Maestro implements Provider {
|
|
218
|
-
url: string;
|
|
219
|
-
apiKey: string;
|
|
220
|
-
turboSubmit: boolean;
|
|
221
|
-
constructor({ network, apiKey, turboSubmit }: MaestroConfig);
|
|
222
|
-
getProtocolParameters(): Promise<ProtocolParameters>;
|
|
223
|
-
getTreasury(): Promise<bigint>;
|
|
224
|
-
private getUtxosInternal;
|
|
225
|
-
getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
|
|
226
|
-
getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
|
|
227
|
-
getUtxoByUnit(unit: Unit): Promise<UTxO>;
|
|
228
|
-
getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
|
|
229
|
-
getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
|
|
230
|
-
getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
|
|
231
|
-
getDatum(datumHash: DatumHash): Promise<Datum>;
|
|
232
|
-
awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
|
|
233
|
-
getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
|
|
234
|
-
submitTx(tx: Transaction): Promise<TxHash>;
|
|
235
|
-
private commonHeaders;
|
|
236
|
-
private requireAmountsAsStrings;
|
|
237
|
-
private maestroUtxoToUtxo;
|
|
238
|
-
private getAllPagesData;
|
|
239
|
-
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
242
|
declare const KoiosError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
|
|
243
243
|
readonly _tag: "KoiosError";
|
|
244
244
|
} & Readonly<A>;
|
|
@@ -294,4 +294,4 @@ declare class Koios implements Provider {
|
|
|
294
294
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
export { Blockfrost, type BlockfrostOptions, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, type KupmiosOptions,
|
|
297
|
+
export { Blockfrost, type BlockfrostOptions, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, type KupmiosOptions, OgmiosJsonRpcError, type OgmiosJsonRpcErrorOptions, type ProviderErrorKind, type ProviderTransportProtocol, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey, isEmulatorProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -82,6 +82,12 @@ interface KupmiosOptions {
|
|
|
82
82
|
readonly requestTimeoutMs?: number;
|
|
83
83
|
/** Overall transaction confirmation deadline in milliseconds. @default 160000 */
|
|
84
84
|
readonly awaitTxTimeoutMs?: number;
|
|
85
|
+
/**
|
|
86
|
+
* The `fetch` this provider uses for its Kupo and Ogmios requests, in place
|
|
87
|
+
* of `globalThis.fetch`. It receives the provider's abort signal in
|
|
88
|
+
* `init.signal`, which fires on `requestTimeoutMs` and on a caller's abort.
|
|
89
|
+
*/
|
|
90
|
+
readonly fetchImpl?: typeof globalThis.fetch;
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
* Provides support for interacting with both Kupo and Ogmios APIs.
|
|
@@ -121,6 +127,7 @@ declare class Kupmios implements Provider {
|
|
|
121
127
|
private readonly options;
|
|
122
128
|
private readonly requestTimeoutMs;
|
|
123
129
|
private readonly awaitTxTimeoutMs;
|
|
130
|
+
private readonly httpLayer;
|
|
124
131
|
constructor(kupoUrl: string, ogmiosUrl: string, options?: KupmiosOptions);
|
|
125
132
|
getProtocolParameters(): Promise<ProtocolParameters>;
|
|
126
133
|
getTreasury(): Promise<bigint>;
|
|
@@ -138,8 +145,20 @@ declare class Kupmios implements Provider {
|
|
|
138
145
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
/**
|
|
148
|
+
/** Concatenation of txHash + outputIndex */
|
|
142
149
|
type FlatOutRef = string;
|
|
150
|
+
type LedgerEntry = {
|
|
151
|
+
utxo: UTxO;
|
|
152
|
+
spent: boolean;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
type TransactionHistory = Record<TxHash, {
|
|
156
|
+
status: "pending";
|
|
157
|
+
} | {
|
|
158
|
+
status: "confirmed";
|
|
159
|
+
blockHeight: number;
|
|
160
|
+
slot: number;
|
|
161
|
+
}>;
|
|
143
162
|
declare const EMULATOR_PROVIDER_BRAND: unique symbol;
|
|
144
163
|
declare const isEmulatorProvider: (provider: Provider | undefined) => provider is Emulator;
|
|
145
164
|
type EmulatorAccount = {
|
|
@@ -152,15 +171,16 @@ type EmulatorAccount = {
|
|
|
152
171
|
declare function generateEmulatorAccountFromPrivateKey(assets: Assets): EmulatorAccount;
|
|
153
172
|
declare function generateEmulatorAccount(assets: Assets): EmulatorAccount;
|
|
154
173
|
declare class Emulator implements Provider {
|
|
174
|
+
#private;
|
|
155
175
|
readonly [EMULATOR_PROVIDER_BRAND] = true;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
/**
|
|
177
|
+
* The confirmed UTxO set, keyed by txHash + outputIndex: a plain record
|
|
178
|
+
* that callers may read, edit, replace or snapshot freely. It is an own
|
|
179
|
+
* enumerable property, defined here so it keeps its place among the
|
|
180
|
+
* instance's keys.
|
|
181
|
+
*/
|
|
182
|
+
ledger: Record<FlatOutRef, LedgerEntry>;
|
|
183
|
+
mempool: Record<FlatOutRef, LedgerEntry>;
|
|
164
184
|
/**
|
|
165
185
|
* Only stake key registrations/delegations and rewards are tracked.
|
|
166
186
|
* Other certificates are not tracked.
|
|
@@ -175,16 +195,14 @@ declare class Emulator implements Provider {
|
|
|
175
195
|
protocolParameters: ProtocolParameters;
|
|
176
196
|
datumTable: Record<DatumHash, Datum>;
|
|
177
197
|
treasury: Lovelace;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
} | {
|
|
181
|
-
status: "confirmed";
|
|
182
|
-
blockHeight: number;
|
|
183
|
-
slot: number;
|
|
184
|
-
}>;
|
|
198
|
+
/** Every transaction status, keyed by hash; a plain record, like `ledger`. */
|
|
199
|
+
transactionHistory: TransactionHistory;
|
|
185
200
|
constructor(accounts: EmulatorAccount[], protocolParameters?: ProtocolParameters, treasury?: Lovelace);
|
|
186
201
|
now(): UnixTime;
|
|
202
|
+
/** Confirms every pending transaction in `transactionHistory`. */
|
|
187
203
|
private confirmPendingTransactions;
|
|
204
|
+
/** Moves the mempool into the ledger and drops spent entries. */
|
|
205
|
+
private applyMempool;
|
|
188
206
|
awaitSlot(length?: number): void;
|
|
189
207
|
awaitBlock(height?: number): void;
|
|
190
208
|
getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
|
|
@@ -204,41 +222,23 @@ declare class Emulator implements Provider {
|
|
|
204
222
|
*/
|
|
205
223
|
distributeRewards(rewards: Lovelace): void;
|
|
206
224
|
submitTx(tx: Transaction): Promise<TxHash>;
|
|
225
|
+
/** Validates `tx` and applies it to the mempool; returns its hash. */
|
|
226
|
+
private applyTx;
|
|
227
|
+
/**
|
|
228
|
+
* The ledger's collateral rules for a transaction with redeemers: at least
|
|
229
|
+
* one and at most `maxCollateralInputs` collateral inputs, a balance (inputs
|
|
230
|
+
* minus the collateral return) of ADA only that covers
|
|
231
|
+
* `collateralPercentage` of the fee, a `total_collateral` field, when
|
|
232
|
+
* present, equal to that balance, and a collateral return holding at least
|
|
233
|
+
* its minimum ADA.
|
|
234
|
+
*/
|
|
235
|
+
private checkCollateral;
|
|
236
|
+
/** Hash of a reference script, computed once per distinct script. */
|
|
237
|
+
private scriptRefHash;
|
|
207
238
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
208
239
|
log(): void;
|
|
209
240
|
}
|
|
210
241
|
|
|
211
|
-
type MaestroSupportedNetworks = "Mainnet" | "Preprod" | "Preview";
|
|
212
|
-
interface MaestroConfig {
|
|
213
|
-
network: MaestroSupportedNetworks;
|
|
214
|
-
apiKey: string;
|
|
215
|
-
turboSubmit?: boolean;
|
|
216
|
-
}
|
|
217
|
-
declare class Maestro implements Provider {
|
|
218
|
-
url: string;
|
|
219
|
-
apiKey: string;
|
|
220
|
-
turboSubmit: boolean;
|
|
221
|
-
constructor({ network, apiKey, turboSubmit }: MaestroConfig);
|
|
222
|
-
getProtocolParameters(): Promise<ProtocolParameters>;
|
|
223
|
-
getTreasury(): Promise<bigint>;
|
|
224
|
-
private getUtxosInternal;
|
|
225
|
-
getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
|
|
226
|
-
getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
|
|
227
|
-
getUtxoByUnit(unit: Unit): Promise<UTxO>;
|
|
228
|
-
getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
|
|
229
|
-
getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
|
|
230
|
-
getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
|
|
231
|
-
getDatum(datumHash: DatumHash): Promise<Datum>;
|
|
232
|
-
awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
|
|
233
|
-
getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
|
|
234
|
-
submitTx(tx: Transaction): Promise<TxHash>;
|
|
235
|
-
private commonHeaders;
|
|
236
|
-
private requireAmountsAsStrings;
|
|
237
|
-
private maestroUtxoToUtxo;
|
|
238
|
-
private getAllPagesData;
|
|
239
|
-
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
242
|
declare const KoiosError_base: new <A extends Record<string, any> = {}>(args: effect_Types.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => effect_Cause.YieldableError & {
|
|
243
243
|
readonly _tag: "KoiosError";
|
|
244
244
|
} & Readonly<A>;
|
|
@@ -294,4 +294,4 @@ declare class Koios implements Provider {
|
|
|
294
294
|
evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
export { Blockfrost, type BlockfrostOptions, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, type KupmiosOptions,
|
|
297
|
+
export { Blockfrost, type BlockfrostOptions, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, type KupmiosOptions, OgmiosJsonRpcError, type OgmiosJsonRpcErrorOptions, type ProviderErrorKind, type ProviderTransportProtocol, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey, isEmulatorProvider };
|