@@ -77,7 +77,8 @@ const computeShellyDeposits = (
77
77
const computeConwayDeposits = (
78
78
certificates : Cardano . Certificate [ ] ,
79
79
rewardAccounts : Cardano . RewardAccount [ ] ,
80
- dRepKeyHash ?: Crypto . Ed25519KeyHashHex
80
+ dRepKeyHash ?: Crypto . Ed25519KeyHashHex ,
81
+ proposalProcedures ?: Cardano . ProposalProcedure [ ]
81
82
) : { deposit : Cardano . Lovelace ; reclaimDeposit : Cardano . Lovelace } => {
82
83
let deposit = 0n ;
83
84
let reclaimDeposit = 0n ;
@@ -108,6 +109,8 @@ const computeConwayDeposits = (
108
109
}
109
110
}
110
111
112
+ if ( proposalProcedures ) for ( const proposal of proposalProcedures ) deposit += proposal . deposit ;
113
+
111
114
return {
112
115
deposit,
113
116
reclaimDeposit
@@ -119,17 +122,19 @@ const getTxDeposits = (
119
122
{ stakeKeyDeposit, poolDeposit } : Pick < Cardano . ProtocolParameters , 'stakeKeyDeposit' | 'poolDeposit' > ,
120
123
certificates : Cardano . Certificate [ ] ,
121
124
rewardAccounts : Cardano . RewardAccount [ ] = [ ] ,
122
- dRepKeyHash ?: Crypto . Ed25519KeyHashHex
125
+ dRepKeyHash ?: Crypto . Ed25519KeyHashHex ,
126
+ proposalProcedures ?: Cardano . ProposalProcedure [ ]
123
127
) : { deposit : Cardano . Lovelace ; reclaimDeposit : Cardano . Lovelace } => {
124
- if ( certificates . length === 0 ) return { deposit : 0n , reclaimDeposit : 0n } ;
128
+ if ( certificates . length === 0 && ( ! proposalProcedures || proposalProcedures . length === 0 ) )
129
+ return { deposit : 0n , reclaimDeposit : 0n } ;
125
130
126
131
const depositParams = {
127
132
poolDeposit : poolDeposit ? BigInt ( poolDeposit ) : 0n ,
128
133
stakeKeyDeposit : BigInt ( stakeKeyDeposit )
129
134
} ;
130
135
131
136
const shelleyDeposits = computeShellyDeposits ( depositParams , certificates , rewardAccounts ) ;
132
- const conwayDeposits = computeConwayDeposits ( certificates , rewardAccounts , dRepKeyHash ) ;
137
+ const conwayDeposits = computeConwayDeposits ( certificates , rewardAccounts , dRepKeyHash , proposalProcedures ) ;
133
138
134
139
return {
135
140
deposit : shelleyDeposits . deposit + conwayDeposits . deposit ,
@@ -150,19 +155,24 @@ const getTxDeposits = (
150
155
* On the other hand, the transaction summary/display could receive a transaction from a dApp,
151
156
* and can have mixed certificates (foreign and ours), so we need the list of reward accounts and drepKeyHash
152
157
* to be able to distinguish the deposits that are going to our rewardAccounts from the ones that could
153
- * potentially go to a different reward accounts that we dont control (same with reclaims).
158
+ * potentially go to a different reward accounts that we don't control (same with reclaims).
154
159
*/
155
160
export const computeImplicitCoin = (
156
161
{ stakeKeyDeposit, poolDeposit } : Pick < Cardano . ProtocolParameters , 'stakeKeyDeposit' | 'poolDeposit' > ,
157
- { certificates, withdrawals } : Pick < HydratedTxBody , 'certificates' | 'withdrawals' > ,
162
+ {
163
+ certificates,
164
+ proposalProcedures,
165
+ withdrawals
166
+ } : Pick < HydratedTxBody , 'certificates' | 'proposalProcedures' | 'withdrawals' > ,
158
167
rewardAccounts ?: Cardano . RewardAccount [ ] ,
159
168
dRepKeyHash ?: Crypto . Ed25519KeyHashHex
160
169
) : ImplicitCoin => {
161
170
const { deposit, reclaimDeposit } = getTxDeposits (
162
171
{ poolDeposit, stakeKeyDeposit } ,
163
172
certificates ?? [ ] ,
164
173
rewardAccounts ,
165
- dRepKeyHash
174
+ dRepKeyHash ,
175
+ proposalProcedures
166
176
) ;
167
177
168
178
const withdrawalsTotal = ( withdrawals && BigIntMath . sum ( withdrawals . map ( ( { quantity } ) => quantity ) ) ) || 0n ;
0 commit comments