@@ -175,6 +175,46 @@ export type Certificate =
175
175
| UnRegisterDelegateRepresentativeCertificate
176
176
| UpdateDelegateRepresentativeCertificate ;
177
177
178
+ export const StakeRegistrationCertificateTypes = [
179
+ CertificateType . StakeRegistration ,
180
+ CertificateType . Registration ,
181
+ CertificateType . VoteRegistrationDelegation ,
182
+ CertificateType . StakeRegistrationDelegation ,
183
+ CertificateType . StakeVoteRegistrationDelegation
184
+ ] as const ;
185
+
186
+ export type StakeRegistrationCertificateTypes = typeof StakeRegistrationCertificateTypes [ number ] ;
187
+
188
+ export type StakeDelegationCertificateUnion =
189
+ | StakeDelegationCertificate
190
+ | StakeVoteDelegationCertificate
191
+ | StakeRegistrationDelegationCertificate
192
+ | StakeVoteRegistrationDelegationCertificate ;
193
+
194
+ export const StakeDelegationCertificateTypes = [
195
+ CertificateType . StakeDelegation ,
196
+ CertificateType . StakeVoteDelegation ,
197
+ CertificateType . StakeRegistrationDelegation ,
198
+ CertificateType . StakeVoteRegistrationDelegation
199
+ ] as const ;
200
+
201
+ export type StakeDelegationCertificateTypes = typeof StakeDelegationCertificateTypes [ number ] ;
202
+
203
+ export type RegAndDeregCertificateUnion =
204
+ | StakeAddressCertificate
205
+ | NewStakeAddressCertificate
206
+ | VoteRegistrationDelegationCertificate
207
+ | StakeRegistrationDelegationCertificate
208
+ | StakeVoteRegistrationDelegationCertificate ;
209
+
210
+ export const RegAndDeregCertificateTypes = [
211
+ ...StakeRegistrationCertificateTypes ,
212
+ CertificateType . Unregistration ,
213
+ CertificateType . StakeDeregistration
214
+ ] as const ;
215
+
216
+ export type RegAndDeregCertificateTypes = typeof RegAndDeregCertificateTypes [ number ] ;
217
+
178
218
/**
179
219
* Creates a stake key registration certificate from a given reward account.
180
220
*
@@ -215,3 +255,12 @@ export const createDelegationCert = (rewardAccount: RewardAccount, poolId: PoolI
215
255
type : CredentialType . KeyHash
216
256
}
217
257
} ) ;
258
+
259
+ /** Filters certificates, returning only stake key register/deregister certificates */
260
+ export const stakeKeyCertificates = ( certificates ?: Certificate [ ] ) =>
261
+ certificates ?. filter ( ( certificate ) : certificate is RegAndDeregCertificateUnion =>
262
+ RegAndDeregCertificateTypes . includes ( certificate . __typename as RegAndDeregCertificateTypes )
263
+ ) || [ ] ;
264
+
265
+ export const includesAnyCertificate = ( haystack : Certificate [ ] , needle : readonly CertificateType [ ] ) =>
266
+ haystack . some ( ( { __typename } ) => needle . includes ( __typename ) ) || false ;
0 commit comments