decodeAddres static method
AdaGenericAddrDecoderResult
decodeAddres(
- String address, {
- ADAAddressType? addrType,
- ADANetwork? network,
Decode an ADA address string.
address: The address to decode.
addrType: The expected address type. If provided, the decoded address type
must match this.
network: The network type.
Returns a AdaGenericAddrDecoderResult object containing the decoded address.
Implementation
static AdaGenericAddrDecoderResult decodeAddres(
String address, {
ADAAddressType? addrType,
ADANetwork? network,
}) {
final decodeAddr = AdaGenericAddrDecoder().decode(address);
if (network != null && decodeAddr.network != network) {
throw ADAPluginException(
'Incorrect address network. ',
details: {'expected': network.name, 'network': decodeAddr.network.name},
);
}
if (addrType != null) {
if (decodeAddr.type.header != addrType.header) {
throw ADAPluginException(
'Incorrect address type. ',
details: {'expected': addrType.name, 'type': decodeAddr.type},
);
}
}
return decodeAddr;
}