signAuthorization method
Signs an EIP-7702 authorization.
Implementation
@override
Future<Uint8List> signAuthorization(Authorization authorization) async {
// EIP-7702 authorization signing
// MAGIC || chainId || address || nonce
final magic = Uint8List.fromList([0x05]);
final chainIdBytes = BytesUtils.bigIntToBytes(
BigInt.from(authorization.chainId),
length: 32);
final addressBytes = HexUtils.decode(authorization.address);
final nonceBytes =
BytesUtils.bigIntToBytes(authorization.nonce, length: 32);
final message =
BytesUtils.concat([magic, chainIdBytes, addressBytes, nonceBytes]);
final hash = Keccak256.hash(message);
return Secp256k1.sign(hash, privateKey);
}