@lucid-evolution/provider 0.1.97 → 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.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,53 @@
1
- import { Provider, ProtocolParameters, Address, Credential, UTxO, Unit, OutRef, RewardAddress, Delegation, DatumHash, Datum, TxHash, Transaction, EvalRedeemer, UnixTime, Lovelace, Assets, OutputData } from '@lucid-evolution/core-types';
1
+ import { Provider, ProtocolParameters, Address, Credential, UTxO, Unit, OutRef, RewardAddress, RewardAccountState, Delegation, DatumHash, Datum, TxHash, TransactionStatusOptions, TransactionStatus, Transaction, EvalRedeemer, PolicyId, UnixTime, Lovelace, Assets, OutputData } from '@lucid-evolution/core-types';
2
2
  import * as effect_Cause from 'effect/Cause';
3
3
  import * as effect_Types from 'effect/Types';
4
4
 
5
+ type ProviderTransportProtocol = "kupo" | "ogmios";
6
+ type ProviderErrorKind = "http" | "timeout" | "transport" | "decode" | "json_rpc" | "aborted" | "unknown";
7
+ type KupmiosErrorOptions = {
8
+ /** Optional only for compatibility with the former `{ cause }` constructor. */
9
+ protocol?: ProviderTransportProtocol;
10
+ /** Optional only for compatibility with the former `{ cause }` constructor. */
11
+ operation?: string;
12
+ cause?: unknown;
13
+ kind?: ProviderErrorKind;
14
+ status?: number;
15
+ retryable?: boolean;
16
+ retryAfterMs?: number;
17
+ message?: string;
18
+ };
19
+ declare class KupmiosError extends Error {
20
+ readonly _tag: string;
21
+ readonly provider: "Kupmios";
22
+ readonly protocol?: ProviderTransportProtocol;
23
+ readonly operation: string;
24
+ readonly kind: ProviderErrorKind;
25
+ readonly status?: number;
26
+ readonly retryable: boolean;
27
+ readonly retryAfterMs?: number;
28
+ readonly cause?: unknown;
29
+ constructor(options: KupmiosErrorOptions);
30
+ }
31
+ type OgmiosJsonRpcErrorOptions = {
32
+ code: number;
33
+ message: string;
34
+ data?: unknown;
35
+ method?: string;
36
+ id: number | null;
37
+ operation?: string;
38
+ status?: number;
39
+ retryAfterMs?: number;
40
+ cause?: unknown;
41
+ };
42
+ declare class OgmiosJsonRpcError extends KupmiosError {
43
+ readonly _tag = "OgmiosJsonRpcError";
44
+ readonly code: number;
45
+ readonly data?: unknown;
46
+ readonly method?: string;
47
+ readonly id: number | null;
48
+ constructor(options: OgmiosJsonRpcErrorOptions);
49
+ }
50
+
5
51
  declare class Blockfrost implements Provider {
6
52
  url: string;
7
53
  projectId: string;
@@ -12,22 +58,16 @@ declare class Blockfrost implements Provider {
12
58
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
13
59
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
14
60
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
61
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
15
62
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
16
63
  getDatum(datumHash: DatumHash): Promise<Datum>;
17
64
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
65
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
18
66
  submitTx(tx: Transaction): Promise<TxHash>;
19
67
  private blockfrostUtxosToUtxos;
20
68
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
21
69
  }
22
70
 
23
- declare const KupmiosError_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 & {
24
- readonly _tag: "KupmiosError";
25
- } & Readonly<A>;
26
- declare class KupmiosError extends KupmiosError_base<{
27
- cause?: unknown;
28
- }> {
29
- get message(): string;
30
- }
31
71
  /**
32
72
  * Provides support for interacting with both Kupo and Ogmios APIs.
33
73
  *
@@ -70,10 +110,13 @@ declare class Kupmios implements Provider {
70
110
  getTreasury(): Promise<bigint>;
71
111
  getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
72
112
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
113
+ getUtxosWithPolicy(addressOrCredential: Address | Credential, policyId: PolicyId): Promise<UTxO[]>;
73
114
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
74
115
  getUtxosByOutRef(outRefs: Array<OutRef>): Promise<UTxO[]>;
116
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
75
117
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
76
118
  getDatum(datumHash: DatumHash): Promise<Datum>;
119
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
77
120
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
78
121
  submitTx(cbor: Transaction): Promise<TxHash>;
79
122
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
@@ -81,6 +124,8 @@ declare class Kupmios implements Provider {
81
124
 
82
125
  /** Concatentation of txHash + outputIndex */
83
126
  type FlatOutRef = string;
127
+ declare const EMULATOR_PROVIDER_BRAND: unique symbol;
128
+ declare const isEmulatorProvider: (provider: Provider | undefined) => provider is Emulator;
84
129
  type EmulatorAccount = {
85
130
  seedPhrase: string;
86
131
  address: Address;
@@ -91,6 +136,7 @@ type EmulatorAccount = {
91
136
  declare function generateEmulatorAccountFromPrivateKey(assets: Assets): EmulatorAccount;
92
137
  declare function generateEmulatorAccount(assets: Assets): EmulatorAccount;
93
138
  declare class Emulator implements Provider {
139
+ readonly [EMULATOR_PROVIDER_BRAND] = true;
94
140
  ledger: Record<FlatOutRef, {
95
141
  utxo: UTxO;
96
142
  spent: boolean;
@@ -113,8 +159,16 @@ declare class Emulator implements Provider {
113
159
  protocolParameters: ProtocolParameters;
114
160
  datumTable: Record<DatumHash, Datum>;
115
161
  treasury: Lovelace;
162
+ transactionHistory: Record<TxHash, {
163
+ status: "pending";
164
+ } | {
165
+ status: "confirmed";
166
+ blockHeight: number;
167
+ slot: number;
168
+ }>;
116
169
  constructor(accounts: EmulatorAccount[], protocolParameters?: ProtocolParameters, treasury?: Lovelace);
117
170
  now(): UnixTime;
171
+ private confirmPendingTransactions;
118
172
  awaitSlot(length?: number): void;
119
173
  awaitBlock(height?: number): void;
120
174
  getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
@@ -124,8 +178,10 @@ declare class Emulator implements Provider {
124
178
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
125
179
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
126
180
  getUtxoByUnit(unit: string): Promise<UTxO>;
181
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
127
182
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
128
183
  awaitTx(txHash: string): Promise<boolean>;
184
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
129
185
  /**
130
186
  * Emulates the behaviour of the reward distribution at epoch boundaries.
131
187
  * Stake keys need to be registered and delegated like on a real chain in order to receive rewards.
@@ -154,9 +210,11 @@ declare class Maestro implements Provider {
154
210
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
155
211
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
156
212
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
213
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
157
214
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
158
215
  getDatum(datumHash: DatumHash): Promise<Datum>;
159
216
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
217
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
160
218
  submitTx(tx: Transaction): Promise<TxHash>;
161
219
  private commonHeaders;
162
220
  private requireAmountsAsStrings;
@@ -211,11 +269,13 @@ declare class Koios implements Provider {
211
269
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
212
270
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
213
271
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
272
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
214
273
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
215
274
  getDatum(datumHash: DatumHash): Promise<Datum>;
216
275
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
276
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
217
277
  submitTx(tx: Transaction): Promise<TxHash>;
218
278
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
219
279
  }
220
280
 
221
- export { Blockfrost, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, Maestro, type MaestroConfig, type MaestroSupportedNetworks, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey };
281
+ export { Blockfrost, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, Maestro, type MaestroConfig, type MaestroSupportedNetworks, OgmiosJsonRpcError, type OgmiosJsonRpcErrorOptions, type ProviderErrorKind, type ProviderTransportProtocol, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey, isEmulatorProvider };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,53 @@
1
- import { Provider, ProtocolParameters, Address, Credential, UTxO, Unit, OutRef, RewardAddress, Delegation, DatumHash, Datum, TxHash, Transaction, EvalRedeemer, UnixTime, Lovelace, Assets, OutputData } from '@lucid-evolution/core-types';
1
+ import { Provider, ProtocolParameters, Address, Credential, UTxO, Unit, OutRef, RewardAddress, RewardAccountState, Delegation, DatumHash, Datum, TxHash, TransactionStatusOptions, TransactionStatus, Transaction, EvalRedeemer, PolicyId, UnixTime, Lovelace, Assets, OutputData } from '@lucid-evolution/core-types';
2
2
  import * as effect_Cause from 'effect/Cause';
3
3
  import * as effect_Types from 'effect/Types';
4
4
 
5
+ type ProviderTransportProtocol = "kupo" | "ogmios";
6
+ type ProviderErrorKind = "http" | "timeout" | "transport" | "decode" | "json_rpc" | "aborted" | "unknown";
7
+ type KupmiosErrorOptions = {
8
+ /** Optional only for compatibility with the former `{ cause }` constructor. */
9
+ protocol?: ProviderTransportProtocol;
10
+ /** Optional only for compatibility with the former `{ cause }` constructor. */
11
+ operation?: string;
12
+ cause?: unknown;
13
+ kind?: ProviderErrorKind;
14
+ status?: number;
15
+ retryable?: boolean;
16
+ retryAfterMs?: number;
17
+ message?: string;
18
+ };
19
+ declare class KupmiosError extends Error {
20
+ readonly _tag: string;
21
+ readonly provider: "Kupmios";
22
+ readonly protocol?: ProviderTransportProtocol;
23
+ readonly operation: string;
24
+ readonly kind: ProviderErrorKind;
25
+ readonly status?: number;
26
+ readonly retryable: boolean;
27
+ readonly retryAfterMs?: number;
28
+ readonly cause?: unknown;
29
+ constructor(options: KupmiosErrorOptions);
30
+ }
31
+ type OgmiosJsonRpcErrorOptions = {
32
+ code: number;
33
+ message: string;
34
+ data?: unknown;
35
+ method?: string;
36
+ id: number | null;
37
+ operation?: string;
38
+ status?: number;
39
+ retryAfterMs?: number;
40
+ cause?: unknown;
41
+ };
42
+ declare class OgmiosJsonRpcError extends KupmiosError {
43
+ readonly _tag = "OgmiosJsonRpcError";
44
+ readonly code: number;
45
+ readonly data?: unknown;
46
+ readonly method?: string;
47
+ readonly id: number | null;
48
+ constructor(options: OgmiosJsonRpcErrorOptions);
49
+ }
50
+
5
51
  declare class Blockfrost implements Provider {
6
52
  url: string;
7
53
  projectId: string;
@@ -12,22 +58,16 @@ declare class Blockfrost implements Provider {
12
58
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
13
59
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
14
60
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
61
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
15
62
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
16
63
  getDatum(datumHash: DatumHash): Promise<Datum>;
17
64
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
65
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
18
66
  submitTx(tx: Transaction): Promise<TxHash>;
19
67
  private blockfrostUtxosToUtxos;
20
68
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
21
69
  }
22
70
 
23
- declare const KupmiosError_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 & {
24
- readonly _tag: "KupmiosError";
25
- } & Readonly<A>;
26
- declare class KupmiosError extends KupmiosError_base<{
27
- cause?: unknown;
28
- }> {
29
- get message(): string;
30
- }
31
71
  /**
32
72
  * Provides support for interacting with both Kupo and Ogmios APIs.
33
73
  *
@@ -70,10 +110,13 @@ declare class Kupmios implements Provider {
70
110
  getTreasury(): Promise<bigint>;
71
111
  getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
72
112
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
113
+ getUtxosWithPolicy(addressOrCredential: Address | Credential, policyId: PolicyId): Promise<UTxO[]>;
73
114
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
74
115
  getUtxosByOutRef(outRefs: Array<OutRef>): Promise<UTxO[]>;
116
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
75
117
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
76
118
  getDatum(datumHash: DatumHash): Promise<Datum>;
119
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
77
120
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
78
121
  submitTx(cbor: Transaction): Promise<TxHash>;
79
122
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
@@ -81,6 +124,8 @@ declare class Kupmios implements Provider {
81
124
 
82
125
  /** Concatentation of txHash + outputIndex */
83
126
  type FlatOutRef = string;
127
+ declare const EMULATOR_PROVIDER_BRAND: unique symbol;
128
+ declare const isEmulatorProvider: (provider: Provider | undefined) => provider is Emulator;
84
129
  type EmulatorAccount = {
85
130
  seedPhrase: string;
86
131
  address: Address;
@@ -91,6 +136,7 @@ type EmulatorAccount = {
91
136
  declare function generateEmulatorAccountFromPrivateKey(assets: Assets): EmulatorAccount;
92
137
  declare function generateEmulatorAccount(assets: Assets): EmulatorAccount;
93
138
  declare class Emulator implements Provider {
139
+ readonly [EMULATOR_PROVIDER_BRAND] = true;
94
140
  ledger: Record<FlatOutRef, {
95
141
  utxo: UTxO;
96
142
  spent: boolean;
@@ -113,8 +159,16 @@ declare class Emulator implements Provider {
113
159
  protocolParameters: ProtocolParameters;
114
160
  datumTable: Record<DatumHash, Datum>;
115
161
  treasury: Lovelace;
162
+ transactionHistory: Record<TxHash, {
163
+ status: "pending";
164
+ } | {
165
+ status: "confirmed";
166
+ blockHeight: number;
167
+ slot: number;
168
+ }>;
116
169
  constructor(accounts: EmulatorAccount[], protocolParameters?: ProtocolParameters, treasury?: Lovelace);
117
170
  now(): UnixTime;
171
+ private confirmPendingTransactions;
118
172
  awaitSlot(length?: number): void;
119
173
  awaitBlock(height?: number): void;
120
174
  getUtxos(addressOrCredential: Address | Credential): Promise<UTxO[]>;
@@ -124,8 +178,10 @@ declare class Emulator implements Provider {
124
178
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
125
179
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
126
180
  getUtxoByUnit(unit: string): Promise<UTxO>;
181
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
127
182
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
128
183
  awaitTx(txHash: string): Promise<boolean>;
184
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
129
185
  /**
130
186
  * Emulates the behaviour of the reward distribution at epoch boundaries.
131
187
  * Stake keys need to be registered and delegated like on a real chain in order to receive rewards.
@@ -154,9 +210,11 @@ declare class Maestro implements Provider {
154
210
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
155
211
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
156
212
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
213
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
157
214
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
158
215
  getDatum(datumHash: DatumHash): Promise<Datum>;
159
216
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
217
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
160
218
  submitTx(tx: Transaction): Promise<TxHash>;
161
219
  private commonHeaders;
162
220
  private requireAmountsAsStrings;
@@ -211,11 +269,13 @@ declare class Koios implements Provider {
211
269
  getUtxosWithUnit(addressOrCredential: Address | Credential, unit: Unit): Promise<UTxO[]>;
212
270
  getUtxoByUnit(unit: Unit): Promise<UTxO>;
213
271
  getUtxosByOutRef(outRefs: OutRef[]): Promise<UTxO[]>;
272
+ getRewardAccount(rewardAddress: RewardAddress): Promise<RewardAccountState>;
214
273
  getDelegation(rewardAddress: RewardAddress): Promise<Delegation>;
215
274
  getDatum(datumHash: DatumHash): Promise<Datum>;
216
275
  awaitTx(txHash: TxHash, checkInterval?: number): Promise<boolean>;
276
+ getTransactionStatus(txHash: TxHash, options?: TransactionStatusOptions): Promise<TransactionStatus>;
217
277
  submitTx(tx: Transaction): Promise<TxHash>;
218
278
  evaluateTx(tx: Transaction, additionalUTxOs?: UTxO[]): Promise<EvalRedeemer[]>;
219
279
  }
220
280
 
221
- export { Blockfrost, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, Maestro, type MaestroConfig, type MaestroSupportedNetworks, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey };
281
+ export { Blockfrost, Emulator, type EmulatorAccount, Koios, KoiosError, Kupmios, KupmiosError, type KupmiosErrorOptions, Maestro, type MaestroConfig, type MaestroSupportedNetworks, OgmiosJsonRpcError, type OgmiosJsonRpcErrorOptions, type ProviderErrorKind, type ProviderTransportProtocol, generateEmulatorAccount, generateEmulatorAccountFromPrivateKey, isEmulatorProvider };