setValidityExpiration method

void setValidityExpiration({
  1. BigInt? minEpoch,
  2. BigInt? maxEpoch,
  3. BigInt? minTimestamp,
  4. BigInt? maxTimestamp,
  5. required String chain,
  6. required int nonce,
  7. BigInt? proposerEpoch,
  8. List<int>? allowedProposers,
})

Restricts validity to a chain, time window and optionally a validator set. Timestamp bounds are milliseconds since the Unix epoch.

Implementation

void setValidityExpiration({
  BigInt? minEpoch,
  BigInt? maxEpoch,
  BigInt? minTimestamp,
  BigInt? maxTimestamp,
  required String chain,
  required int nonce,
  BigInt? proposerEpoch,
  List<int>? allowedProposers,
}) {
  if ((proposerEpoch == null) != (allowedProposers == null)) {
    throw ArgumentError(
      'proposerEpoch and allowedProposers must be provided together',
    );
  }
  if (allowedProposers != null) {
    SuiBcs.validateAllowedProposers(allowedProposers);
  }
  _blockData.expiration = TransactionExpiration(
    validity: {
      'minEpoch': minEpoch?.toString(),
      'maxEpoch': maxEpoch?.toString(),
      'minTimestamp': minTimestamp?.toString(),
      'maxTimestamp': maxTimestamp?.toString(),
      'chain': chain,
      'nonce': nonce,
      'allowedProposers': allowedProposers == null
          ? null
          : {
              'epoch': proposerEpoch.toString(),
              'proposers': List<int>.of(allowedProposers),
            },
    },
  );
}