Skip to content

Commit a2007e6

Browse files
frnanduclaude
andcommitted
fix: dart format (match CI environment without pub get)
Reformatted files that only appeared correctly formatted locally because a stale .dart_tool pub cache let flutter_lints resolve; CI's format.yml has no `dart pub get` step, so package:flutter_lints never resolves and the formatter falls back to different defaults. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 675b3a8 commit a2007e6

403 files changed

Lines changed: 18738 additions & 16546 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/bc_ur/lib/bytewords.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ const String BYTEWORDS =
77

88
List<int>? _wordArray;
99

10-
enum Style {
11-
standard,
12-
uri,
13-
minimal,
14-
}
10+
enum Style { standard, uri, minimal }
1511

1612
int decodeWord(String word, int wordLen) {
1713
if (word.length != wordLen) {
@@ -38,7 +34,8 @@ int decodeWord(String word, int wordLen) {
3834
// If the coordinates generated by the first and last letters are out of bounds,
3935
// or the lookup table contains -1 at the coordinates, then the word is not valid.
4036
int x = word[0].toLowerCase().codeUnitAt(0) - 'a'.codeUnitAt(0);
41-
int y = word[wordLen == 4 ? 3 : 1].toLowerCase().codeUnitAt(0) -
37+
int y =
38+
word[wordLen == 4 ? 3 : 1].toLowerCase().codeUnitAt(0) -
4239
'a'.codeUnitAt(0);
4340
if (x < 0 || x >= dim || y < 0 || y >= dim) {
4441
throw ArgumentError('Invalid Bytewords.');

packages/bc_ur/lib/cashu_animated_qr_example.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,25 @@ void multiPartExample() {
113113
if (i % 2 == 0 || decoder.isComplete()) {
114114
// Show progress every 2 parts
115115
print(
116-
' Scanned part ${i + 1}/${parts.length} - ${(progress * 100).toStringAsFixed(1)}% complete');
116+
' Scanned part ${i + 1}/${parts.length} - ${(progress * 100).toStringAsFixed(1)}% complete',
117+
);
117118
}
118119
if (decoder.isComplete()) break;
119120
}
120121

121122
// Decode the complete token
122123
if (decoder.isComplete()) {
123-
final decodedToken =
124-
CashuTokenUrEncoder.decodeFromMultiPartDecoder(decoder);
124+
final decodedToken = CashuTokenUrEncoder.decodeFromMultiPartDecoder(
125+
decoder,
126+
);
125127
if (decodedToken != null) {
126128
print('\nSuccessfully decoded complete token:');
127129
print(' Mint: ${decodedToken.mintUrl}');
128130
print(' Total proofs: ${decodedToken.proofs.length}');
129-
final totalAmount =
130-
decodedToken.proofs.fold(0, (sum, p) => sum + p.amount);
131+
final totalAmount = decodedToken.proofs.fold(
132+
0,
133+
(sum, p) => sum + p.amount,
134+
);
131135
print(' Total amount: $totalAmount ${decodedToken.unit}');
132136
print(' Memo: ${decodedToken.memo}');
133137
}

packages/bc_ur/lib/cashu_token_ur_encoder.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ class CashuTokenUrEncoder {
1919
/// Use this for tokens that can fit in a single QR code.
2020
///
2121
/// Returns a UR-formatted string like: "ur:bytes/..."
22-
static String encodeSinglePart({
23-
required CashuToken token,
24-
}) {
22+
static String encodeSinglePart({required CashuToken token}) {
2523
try {
2624
final json = token.toV4Json();
2725
final myCbor = CborValue(json);

packages/bc_ur/lib/cbor_lite.dart

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import 'dart:typed_data';
22

3-
enum Flag {
4-
none,
5-
requireMinimalEncoding,
6-
}
3+
enum Flag { none, requireMinimalEncoding }
74

85
class CBORTag {
96
static const int majorUnsignedInteger = 0;
@@ -75,23 +72,27 @@ class CBOREncoder {
7572
if (length >= 5 && length <= 8) {
7673
encodeTagAndAdditional(tag, CBORTag.minorLength8);
7774
_buffer.add(
78-
Uint8List(8)..buffer.asByteData().setUint64(0, value, Endian.big));
75+
Uint8List(8)..buffer.asByteData().setUint64(0, value, Endian.big),
76+
);
7977
} else if (length == 3 || length == 4) {
8078
encodeTagAndAdditional(tag, CBORTag.minorLength4);
8179
_buffer.add(
82-
Uint8List(4)..buffer.asByteData().setUint32(0, value, Endian.big));
80+
Uint8List(4)..buffer.asByteData().setUint32(0, value, Endian.big),
81+
);
8382
} else if (length == 2) {
8483
encodeTagAndAdditional(tag, CBORTag.minorLength2);
8584
_buffer.add(
86-
Uint8List(2)..buffer.asByteData().setUint16(0, value, Endian.big));
85+
Uint8List(2)..buffer.asByteData().setUint16(0, value, Endian.big),
86+
);
8787
} else if (length == 1) {
8888
encodeTagAndAdditional(tag, CBORTag.minorLength1);
8989
_buffer.addByte(value);
9090
} else if (length == 0) {
9191
encodeTagAndAdditional(tag, value);
9292
} else {
9393
throw Exception(
94-
"Unsupported byte length of $length for value in encodeTagAndValue()");
94+
"Unsupported byte length of $length for value in encodeTagAndValue()",
95+
);
9596
}
9697

9798
return 1 + length;
@@ -111,7 +112,9 @@ class CBOREncoder {
111112

112113
int encodeBool(bool value) {
113114
return encodeTagAndValue(
114-
CBORTag.majorSimple, value ? CBORTag.minorTrue : CBORTag.minorFalse);
115+
CBORTag.majorSimple,
116+
value ? CBORTag.minorTrue : CBORTag.minorFalse,
117+
);
115118
}
116119

117120
int encodeBytes(Uint8List value) {
@@ -122,12 +125,16 @@ class CBOREncoder {
122125

123126
int encodeEncodedBytesPrefix(int value) {
124127
return encodeTagAndValue(
125-
CBORTag.majorSemantic, CBORTag.minorCborEncodedData);
128+
CBORTag.majorSemantic,
129+
CBORTag.minorCborEncodedData,
130+
);
126131
}
127132

128133
int encodeEncodedBytes(Uint8List value) {
129-
int length =
130-
encodeTagAndValue(CBORTag.majorSemantic, CBORTag.minorCborEncodedData);
134+
int length = encodeTagAndValue(
135+
CBORTag.majorSemantic,
136+
CBORTag.minorCborEncodedData,
137+
);
131138
return length + encodeBytes(value);
132139
}
133140

@@ -197,8 +204,11 @@ class CBORDecoder {
197204
throw Exception("Not enough input");
198205
}
199206

200-
ByteData byteData =
201-
ByteData.sublistView(_buffer, _position, _position + bytesToRead);
207+
ByteData byteData = ByteData.sublistView(
208+
_buffer,
209+
_position,
210+
_position + bytesToRead,
211+
);
202212
_position += bytesToRead;
203213

204214
switch (bytesToRead) {
@@ -271,8 +281,11 @@ class CBORDecoder {
271281
throw Exception("Not enough input");
272282
}
273283

274-
Uint8List value =
275-
Uint8List.sublistView(_buffer, _position, _position + byteLength);
284+
Uint8List value = Uint8List.sublistView(
285+
_buffer,
286+
_position,
287+
_position + byteLength,
288+
);
276289
_position += byteLength;
277290
return (value, sizeLength + byteLength);
278291
}
@@ -312,8 +325,11 @@ class CBORDecoder {
312325
throw Exception("Not enough input");
313326
}
314327

315-
Uint8List utf8Bytes =
316-
Uint8List.sublistView(_buffer, _position, _position + byteLength);
328+
Uint8List utf8Bytes = Uint8List.sublistView(
329+
_buffer,
330+
_position,
331+
_position + byteLength,
332+
);
317333
_position += byteLength;
318334
String value = String.fromCharCodes(utf8Bytes);
319335
return (value, sizeLength + byteLength);

packages/bc_ur/lib/constants.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
const int MAX_UINT32 = 0xFFFFFFFF;
2-
final BigInt MAX_UINT64 =
3-
BigInt.parse('18446744073709551615'); // 0xFFFFFFFFFFFFFFFF
2+
final BigInt MAX_UINT64 = BigInt.parse(
3+
'18446744073709551615',
4+
); // 0xFFFFFFFFFFFFFFFF

packages/bc_ur/lib/fountain_decoder.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ class FountainDecoder {
121121
}
122122

123123
void reduceBy(FountainDecoderPart p) {
124-
var reducedParts =
125-
mixedParts.values.map((value) => reducePartByPart(value, p)).toList();
124+
var reducedParts = mixedParts.values
125+
.map((value) => reducePartByPart(value, p))
126+
.toList();
126127

127128
var newMixed = <Set<int>, FountainDecoderPart>{};
128129
for (var reducedPart in reducedParts) {
@@ -137,7 +138,9 @@ class FountainDecoder {
137138
}
138139

139140
FountainDecoderPart reducePartByPart(
140-
FountainDecoderPart a, FountainDecoderPart b) {
141+
FountainDecoderPart a,
142+
FountainDecoderPart b,
143+
) {
141144
if (isStrictSubset(b.indexes, a.indexes)) {
142145
var newIndexes = a.indexes.difference(b.indexes);
143146
var newData = xorWith(Uint8List.fromList(a.data), b.data);
@@ -199,8 +202,9 @@ class FountainDecoder {
199202

200203
bool validatePart(FountainEncoderPart p) {
201204
if (expectedPartIndexes == null) {
202-
expectedPartIndexes =
203-
Set<int>.from(List<int>.generate(p.seqLen, (i) => i));
205+
expectedPartIndexes = Set<int>.from(
206+
List<int>.generate(p.seqLen, (i) => i),
207+
);
204208
expectedMessageLen = p.messageLen;
205209
expectedChecksum = p.checksum;
206210
expectedFragmentLen = p.data.length;

packages/bc_ur/lib/fountain_encoder.dart

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ class FountainEncoderPart {
1818
final Uint8List data;
1919

2020
FountainEncoderPart(
21-
this.seqNum, this.seqLen, this.messageLen, this.checksum, this.data);
21+
this.seqNum,
22+
this.seqLen,
23+
this.messageLen,
24+
this.checksum,
25+
this.data,
26+
);
2227

2328
static FountainEncoderPart fromCbor(Uint8List cborBuf) {
2429
var decoder = CBORDecoder(cborBuf);
@@ -59,31 +64,46 @@ class FountainEncoder {
5964
final List<Uint8List> fragments;
6065
int seqNum;
6166

62-
FountainEncoder(Uint8List message, int maxFragmentLen,
63-
{int firstSeqNum = 0, int minFragmentLen = 10})
64-
: messageLen = message.length,
65-
checksum = crc32Int(message),
66-
fragmentLen = findNominalFragmentLength(
67-
message.length, minFragmentLen, maxFragmentLen),
68-
fragments = partitionMessage(
69-
message,
70-
findNominalFragmentLength(
71-
message.length, minFragmentLen, maxFragmentLen)),
72-
seqNum = firstSeqNum {
67+
FountainEncoder(
68+
Uint8List message,
69+
int maxFragmentLen, {
70+
int firstSeqNum = 0,
71+
int minFragmentLen = 10,
72+
}) : messageLen = message.length,
73+
checksum = crc32Int(message),
74+
fragmentLen = findNominalFragmentLength(
75+
message.length,
76+
minFragmentLen,
77+
maxFragmentLen,
78+
),
79+
fragments = partitionMessage(
80+
message,
81+
findNominalFragmentLength(
82+
message.length,
83+
minFragmentLen,
84+
maxFragmentLen,
85+
),
86+
),
87+
seqNum = firstSeqNum {
7388
assert(message.length <= MAX_UINT32);
7489
}
7590

7691
static int findNominalFragmentLength(
77-
int messageLen, int minFragmentLen, int maxFragmentLen) {
92+
int messageLen,
93+
int minFragmentLen,
94+
int maxFragmentLen,
95+
) {
7896
assert(messageLen > 0);
7997
assert(minFragmentLen > 0);
8098
assert(maxFragmentLen >= minFragmentLen);
8199
int maxFragmentCount = messageLen ~/ minFragmentLen;
82100
int fragmentLen = messageLen;
83101

84-
for (int fragmentCount = 1;
85-
fragmentCount <= maxFragmentCount;
86-
fragmentCount++) {
102+
for (
103+
int fragmentCount = 1;
104+
fragmentCount <= maxFragmentCount;
105+
fragmentCount++
106+
) {
87107
fragmentLen = (messageLen / fragmentCount).ceil();
88108
if (fragmentLen <= maxFragmentLen) {
89109
break;

packages/bc_ur/lib/fountain_utils.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ Set<int> chooseFragments(int seqNum, int seqLen, int checksum) {
3232
if (seqNum <= seqLen) {
3333
return {seqNum - 1};
3434
} else {
35-
Uint8List seed =
36-
Uint8List.fromList(intToBytes(seqNum) + intToBytes(checksum));
35+
Uint8List seed = Uint8List.fromList(
36+
intToBytes(seqNum) + intToBytes(checksum),
37+
);
3738
Xoshiro256 rng = Xoshiro256.fromBytes(seed);
3839
int degree = chooseDegree(seqLen, rng);
3940
List<int> indexes = List<int>.generate(seqLen, (i) => i);

packages/bc_ur/lib/random_sampler.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class RandomSampler {
55
final List<double> _aliases;
66

77
RandomSampler._(List<double> probs, List<double> _aliases)
8-
: _probs = probs,
9-
_aliases = _aliases {}
8+
: _probs = probs,
9+
_aliases = _aliases {}
1010

1111
factory RandomSampler(List<double> probs) {
1212
assert(probs.every((p) => p > 0), "All probabilities must be positive");

packages/bc_ur/lib/ur_encoder.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ class UREncoder {
66
final UR ur;
77
final FountainEncoder fountainEncoder;
88

9-
UREncoder(this.ur, int maxFragmentLen,
10-
{int firstSeqNum = 0, int minFragmentLen = 10})
11-
: fountainEncoder = FountainEncoder(ur.cbor, maxFragmentLen,
12-
firstSeqNum: firstSeqNum, minFragmentLen: minFragmentLen);
9+
UREncoder(
10+
this.ur,
11+
int maxFragmentLen, {
12+
int firstSeqNum = 0,
13+
int minFragmentLen = 10,
14+
}) : fountainEncoder = FountainEncoder(
15+
ur.cbor,
16+
maxFragmentLen,
17+
firstSeqNum: firstSeqNum,
18+
minFragmentLen: minFragmentLen,
19+
);
1320

1421
static String encode(UR ur) {
1522
String body = Bytewords.encodeStyle(Bytewords.Style.minimal, ur.cbor);

0 commit comments

Comments
 (0)