Skip to content

Commit

Permalink
🐛 Fix encoder with deps and format files (#77)
Browse files Browse the repository at this point in the history
Resolves #76
  • Loading branch information
AlexV525 authored May 22, 2024
1 parent 130fb26 commit f50971d
Show file tree
Hide file tree
Showing 24 changed files with 110 additions and 108 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ that can be found in the LICENSE file. -->

# Changelog

## 1.0.0-dev.23

- Fix encoder with deps and format files.

## 1.0.0-dev.22

- Correct invalid plugin references by marking FFI plugins.
Expand Down
8 changes: 4 additions & 4 deletions lib/agent/actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ActorCallError extends AgentFetchError {
'Call failed:',
' Canister: ${canisterId.toText()}',
' Method: $methodName ($type)',
...(props.entries).map((n) => " '${n.key}': ${jsonEncode(props[n])}"),
...props.entries.map((n) => " '${n.key}': ${jsonEncode(props[n])}"),
].join('\n');
throw e;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ class CallConfig {
'agent': agent,
'pollingStrategyFactory': pollingStrategyFactory,
'canisterId': canisterId,
'effectiveCanisterId': effectiveCanisterId
'effectiveCanisterId': effectiveCanisterId,
};
}
}
Expand Down Expand Up @@ -149,7 +149,7 @@ class ActorConfig extends CallConfig {
return {
...super.toJson(),
'callTransform': callTransform,
'queryTransform': queryTransform
'queryTransform': queryTransform,
};
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ class Actor {
dynamic result;
if (func != null) {
result = await func.call([
{'amount': [], 'settings': []}
{'amount': [], 'settings': []},
]);
}
final canisterId = Principal.from(result['canister_id']);
Expand Down
1 change: 0 additions & 1 deletion lib/agent/agent.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// Sub folders
export './agent/index.dart';
export './canisters/index.dart';
export './crypto/index.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/agent/agent/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ abstract class Agent {
Future<Map> status();

/// Send a query call to a canister. See
/// {@link https://sdk.dfinity.org/docs/interface-spec/#http-query | the interface spec}.
/// [the interface spec](https://sdk.dfinity.org/docs/interface-spec/#http-query).
/// @param canisterId The Principal of the Canister to send the query to. Sending a query to
/// the management canister is not supported (as it has no meaning from an agent).
/// @param options Options to use to create and send the query.
Expand Down
12 changes: 6 additions & 6 deletions lib/agent/agent/http/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ typedef HttpAgentRequestTransformFnCall = Future<HttpAgentRequest?> Function(

class HttpResponseBody extends ResponseBody {
const HttpResponseBody({
bool? ok,
int? status,
String? statusText,
super.ok,
super.status,
super.statusText,
this.body,
this.arrayBuffer,
}) : super(ok: ok, status: status, statusText: statusText);
});

factory HttpResponseBody.fromJson(Map<String, dynamic> map) {
return HttpResponseBody(
Expand All @@ -240,7 +240,7 @@ class HttpResponseBody extends ResponseBody {
'status': status,
'statusText': statusText,
'body': body,
'arrayBuffer': arrayBuffer
'arrayBuffer': arrayBuffer,
};
}
}
Expand Down Expand Up @@ -320,7 +320,7 @@ class QueryResponseWithStatus extends QueryResponse {
'arg': reply?.arg,
},
'rejected_code': rejectCode,
'rejected_message': rejectMessage
'rejected_message': rejectMessage,
};
}
}
2 changes: 1 addition & 1 deletion lib/agent/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class AnonymousIdentity implements Identity {
Future<Map<String, dynamic>> transformRequest(HttpAgentRequest request) {
return Future.value({
...request.toJson(),
'body': {'content': request.body.toJson()}
'body': {'content': request.body.toJson()},
});
}
}
10 changes: 5 additions & 5 deletions lib/agent/canisters/management_idl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ Service managementIDL() {
[
IDL.Record(
{'amount': IDL.Opt(IDL.Nat), 'settings': IDL.Opt(canisterSettings)},
)
),
],
[
IDL.Record({'canister_id': canisterId})
IDL.Record({'canister_id': canisterId}),
],
[],
),
'create_canister': IDL.Func(
[],
[
IDL.Record({'canister_id': canisterId})
IDL.Record({'canister_id': canisterId}),
],
[],
),
Expand All @@ -32,7 +32,7 @@ Service managementIDL() {
'mode': IDL.Variant({
'install': IDL.Null,
'reinstall': IDL.Null,
'upgrade': IDL.Null
'upgrade': IDL.Null,
}),
'canister_id': canisterId,
'wasm_module': wasmModule,
Expand All @@ -46,7 +46,7 @@ Service managementIDL() {
[
IDL.Record(
{'canister_id': canisterId, 'new_controller': IDL.Principal},
)
),
],
[],
[],
Expand Down
2 changes: 1 addition & 1 deletion lib/agent/certificate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Cert {
return {
'tree': tree,
'signature': signature,
'delegation': delegation?.toJson() ?? {}
'delegation': delegation?.toJson() ?? {},
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/agent/crypto/keystore/function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ Future<EncryptMessageResponse> encryptMessage({
return EncryptMessageResponse(
content: '$encryptedMessage?iv=$ivBase64',
tags: [
['p', theirPublicKey.toRaw().toHex()]
['p', theirPublicKey.toRaw().toHex()],
],
kind: 4,
createdAt: (DateTime.now().millisecondsSinceEpoch / 1000).floor(),
Expand Down Expand Up @@ -441,7 +441,7 @@ class EncryptMessageResponse {
'tags': tags,
'kind': kind,
'created_at': createdAt,
'pubkey': pubKey
'pubkey': pubKey,
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/agent/crypto/keystore/key_derivator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _PBDKDF2KeyDerivator extends KeyDerivator {
'c': iterations,
'dklen': dklen,
'prf': 'hmac-sha256',
'salt': salt.toHex()
'salt': salt.toHex(),
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/agent/polling/strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ PollStrategy defaultStrategy() {
return chain([
conditionalDelay(once(), 1000),
backoff(1000, 1.2),
timeout(5 * 60 * 1000)
timeout(5 * 60 * 1000),
]);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/archiver/encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SigningBlockEncoder extends ZipEncoder {
messages: [message],
signatures: [signature],
publicKeys: [publicKey],
)
),
],
);

Expand Down Expand Up @@ -159,9 +159,9 @@ class SingingBlockZipFileEncoder extends ZipFileEncoder {
}

@override
void close() {
Future<void> close() async {
_encoder.writeBlock(_output);
_encoder.endEncode();
_output.close();
await _output.close();
}
}
2 changes: 1 addition & 1 deletion lib/auth_client/auth_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class AuthClient {
'sessionPublicKey': key != null
? (key as SignIdentity).getPublicKey().toDer().toHex()
: null,
'canisterId': options?.canisterId
'canisterId': options?.canisterId,
},
);
return AuthPayload(identityProviderUrl.toString(), scheme);
Expand Down
7 changes: 3 additions & 4 deletions lib/authentication/authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class CreateUrlOptions {
final PublicKey publicKey;

/// The scope of the delegation. This must contain at least one key and
/// a maximum of four. This is validated in
/// {@link createAuthenticationRequestUrl} but also will be validated as part
/// of the identity provider.
/// a maximum of four. This is validated in [createAuthenticationRequestUrl]
/// but also will be validated as part of the identity provider.
final List<dynamic> scope;

/// The URI to redirect to, after authentication. By default,
Expand Down Expand Up @@ -66,7 +65,7 @@ Uri createAuthenticationRequestUrl(CreateUrlOptions options) {
.map((p) => p.toString())
.join(' '),
),
const MapEntry('state', '')
const MapEntry('state', ''),
]);

return url;
Expand Down
2 changes: 1 addition & 1 deletion lib/bridge/wasm_interop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ const _importExportKindMap = {
'function': ImportExportKind.function,
'global': ImportExportKind.global,
'memory': ImportExportKind.memory,
'table': ImportExportKind.table
'table': ImportExportKind.table,
};

@JS()
Expand Down
12 changes: 6 additions & 6 deletions lib/candid/idl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ class VecClass<T> extends ConstructType<List<T>> {
final len = lebEncode(x.length);
return u8aConcat([
len,
...x.map((dynamic d) => tryToJson(_type, d) ?? _type.encodeValue(d))
...x.map((dynamic d) => tryToJson(_type, d) ?? _type.encodeValue(d)),
]);
}

Expand Down Expand Up @@ -816,7 +816,7 @@ class OptClass<T> extends ConstructType<List> {
final val = x[0];
return u8aConcat([
Uint8List.fromList([1]),
tryToJson(_type, val) ?? _type.encodeValue(val)
tryToJson(_type, val) ?? _type.encodeValue(val),
]);
}

Expand Down Expand Up @@ -931,7 +931,7 @@ class RecordClass extends ConstructType<Map> {
final fields = _fields.map(
(entry) => u8aConcat([
lebEncode(idlLabelToId(entry.key)),
entry.value.encodeType(typeTable)
entry.value.encodeType(typeTable),
]),
);
typeTable.add(this, u8aConcat([opCode, len, u8aConcat(fields.toList())]));
Expand Down Expand Up @@ -1051,7 +1051,7 @@ class TupleClass<T extends List> extends ConstructType<List> {
final fields = _fields.map(
(entry) => u8aConcat([
lebEncode(idlLabelToId(entry.key)),
entry.value.encodeType(typeTable)
entry.value.encodeType(typeTable),
]),
);
typeTable.add(this, u8aConcat([opCode, len, u8aConcat(fields.toList())]));
Expand Down Expand Up @@ -1171,7 +1171,7 @@ class VariantClass extends ConstructType<Map<String, dynamic>> {
final fields = _fields.map(
(entry) => u8aConcat([
lebEncode(idlLabelToId(entry.key)),
entry.value.encodeType(typeTable)
entry.value.encodeType(typeTable),
]),
);
typeTable.add(this, u8aConcat([opCode, len, ...fields]));
Expand Down Expand Up @@ -1353,7 +1353,7 @@ class PrincipalClass extends PrimitiveType<PrincipalId> {
return u8aConcat([
Uint8List.fromList([1]),
len,
buf
buf,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/identity/der.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final oidP256 = Uint8List.fromList([
0x03,
0x01,
0x07,
]
],
]);

/// Wraps the given [payload] in a DER encoding tagged with the given encoded
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/bech32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ const List<String> charset = [
'u',
'a',
'7',
'l'
'l',
];
// @formatter:on

Expand All @@ -306,7 +306,7 @@ const List<int> generator = [
0x26508e6d,
0x1ea119fa,
0x3d4233dd,
0x2a1462b3
0x2a1462b3,
];
// @formatter:on

Expand Down
8 changes: 4 additions & 4 deletions lib/wallet/ledger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class SendArgs {
'memo': memo,
'from_subaccount': fromSubAccount != null ? [fromSubAccount] : [],
'created_at_time': createdAtTime != null ? [createdAtTime!.toJson()] : [],
'amount': amount.toJson()
'amount': amount.toJson(),
}..removeWhere((key, value) => value == null);
}
}
Expand Down Expand Up @@ -363,7 +363,7 @@ class TransferArgs {
'memo': memo,
'from_subaccount': fromSubAccount != null ? [fromSubAccount] : [],
'created_at_time': createdAtTime != null ? [createdAtTime!.toJson()] : [],
'amount': amount.toJson()
'amount': amount.toJson(),
}..removeWhere((key, value) => value == null);
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ class TransferError {
'BadFee': badFee,
'TxDuplicate': txDuplicate,
'InsufficientFunds': insufficientFunds,
'TxCreatedInFuture': txCreatedInFuture
'TxCreatedInFuture': txCreatedInFuture,
}..removeWhere((key, value) => value == null || value == false);
if (res['TxCreatedInFuture'] != null && res['TxCreatedInFuture'] == true) {
res.update('TxCreatedInFuture', (value) => null);
Expand Down Expand Up @@ -597,7 +597,7 @@ class Ledger {
? null
: {
'timestamp_nanos':
sendOpts?.createAtTime?.millisecondsSinceEpoch.toBn()
sendOpts?.createAtTime?.millisecondsSinceEpoch.toBn(),
},
};
final res = await ledgerInstance.agent.actor!.getFunc(
Expand Down
Loading

0 comments on commit f50971d

Please sign in to comment.