Skip to content

Commit

Permalink
fix signing payloads > 256 bytes (#419)
Browse files Browse the repository at this point in the history
* fix signing payloads > 256 bytes

* fmt
  • Loading branch information
clangenb authored Feb 3, 2024
1 parent 03a1a63 commit ded9a84
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/polkadart/lib/extrinsic/signing_payload.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:typed_data';

import 'package:convert/convert.dart';
import 'package:polkadart/polkadart.dart';
import 'package:polkadart/extrinsic/signed_extensions/signed_extensions_abstract.dart';
import 'package:polkadart/scale_codec.dart';
import 'package:polkadart/substrate/era.dart';
Expand Down Expand Up @@ -88,7 +89,12 @@ class SigningPayload {
final String addExtra = additionalExtras.join();
final String payload = method + extra + addExtra;

return Uint8List.fromList(hex.decode(payload));
final payloadEncoded = Uint8List.fromList(hex.decode(payload));

// See rust code: https://github.com/paritytech/polkadot-sdk/blob/e349fc9ef8354eea1bafc1040c20d6fe3189e1ec/substrate/primitives/runtime/src/generic/unchecked_extrinsic.rs#L253
return payloadEncoded.length > 256
? Blake2bHasher(32).hash(payloadEncoded)
: payloadEncoded;
}

bool _usesChargeAssetTxPayment(dynamic registry) {
Expand Down

0 comments on commit ded9a84

Please sign in to comment.