-
Notifications
You must be signed in to change notification settings - Fork 55
/
types.ts
109 lines (100 loc) · 3.01 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { Cardano } from '../..';
export type ProtocolParametersRequiredByWallet = Required<
Pick<
Cardano.ProtocolParametersAlonzo,
| 'coinsPerUtxoWord'
| 'maxTxSize'
| 'maxValueSize'
| 'stakeKeyDeposit'
| 'maxCollateralInputs'
| 'minFeeCoefficient'
| 'minFeeConstant'
| 'minPoolCost'
| 'poolDeposit'
| 'protocolVersion'
>
>;
export type AssetSupply = {
circulating: Cardano.Lovelace;
max: Cardano.Lovelace;
total: Cardano.Lovelace;
};
export type StakeSummary = {
active: Cardano.Lovelace;
live: Cardano.Lovelace;
};
export type StakePoolStats = {
qty: {
active: number;
retired: number;
retiring: number;
};
};
export type NetworkInfo = {
currentEpoch: {
number: Cardano.Epoch;
start: {
/** Local date */
date: Date;
};
end: {
/** Local date */
date: Date;
};
};
lovelaceSupply: AssetSupply;
stake: StakeSummary;
};
export interface EpochRange {
/**
* Inclusive
*/
lowerBound?: Cardano.Epoch;
/**
* Inclusive
*/
upperBound?: Cardano.Epoch;
}
export interface RewardHistoryProps {
stakeAddresses: Cardano.RewardAccount[];
epochs?: EpochRange;
}
export interface EpochRewards {
epoch: Cardano.Epoch;
rewards: Cardano.Lovelace;
}
export interface WalletProvider {
ledgerTip: () => Promise<Cardano.Tip>;
networkInfo: () => Promise<NetworkInfo>;
// TODO: move stakePoolStats out to other provider type, since it's not required for wallet operation
stakePoolStats?: () => Promise<StakePoolStats>;
/**
* @param signedTransaction signed and serialized cbor
* @throws {Cardano.TxSubmissionError} (see Cardano.TxSubmissionErrors)
*/
submitTx: (signedTransaction: Uint8Array) => Promise<void>;
// TODO: split utxoDelegationAndRewards this into 2 or 3 functions
utxoDelegationAndRewards: (
addresses: Cardano.Address[],
rewardAccount?: Cardano.RewardAccount
) => Promise<{ utxo: Cardano.Utxo[]; delegationAndRewards?: Cardano.DelegationsAndRewards }>;
/**
* TODO: add an optional 'since: Slot' argument for querying transactions and utxos.
* When doing so we need to also consider how best we can use the volatile block range of the chain
* to minimise over-fetching and assist the application in handling rollback scenarios.
*/
queryTransactionsByAddresses: (addresses: Cardano.Address[]) => Promise<Cardano.TxAlonzo[]>;
queryTransactionsByHashes: (hashes: Cardano.TransactionId[]) => Promise<Cardano.TxAlonzo[]>;
/**
* @returns an array of blocks, same length and in the same order as `hashes` argument.
*/
queryBlocksByHashes: (hashes: Cardano.BlockId[]) => Promise<Cardano.Block[]>;
currentWalletProtocolParameters: () => Promise<ProtocolParametersRequiredByWallet>;
genesisParameters: () => Promise<Cardano.CompactGenesis>;
/**
* Query rewards history for provided stake addresses.
*
* @returns Rewards quantity for every epoch that had any rewards in ascending order.
*/
rewardsHistory: (props: RewardHistoryProps) => Promise<EpochRewards[]>;
}