Skip to content

Commit

Permalink
♻️ Correct agent call method name
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Oct 11, 2024
1 parent 545410b commit 14f8781
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
5 changes: 3 additions & 2 deletions packages/agent_dart_base/lib/agent/actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ ActorMethod _createActorMethod(Actor actor, String methodName, Func func) {
final ecid = effectiveCanisterId != null
? Principal.from(effectiveCanisterId)
: cid;
// final { requestId, response } =
final result = await agent!.call(
final callSync = actor.metadata.config?.callSync ?? newOptions.callSync;

final result = await agent!.callRequest(
cid,
CallOptions(
methodName: methodName,
Expand Down
2 changes: 1 addition & 1 deletion packages/agent_dart_base/lib/agent/agent/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ abstract class Agent {
Identity? identity,
);

Future<SubmitResponse> call(
Future<SubmitResponse> callRequest(
Principal canisterId,
CallOptions fields,
Identity? identity,
Expand Down
2 changes: 1 addition & 1 deletion packages/agent_dart_base/lib/agent/agent/http/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class HttpAgent implements Agent {
}

@override
Future<SubmitResponse> call(
Future<CallResponseBody> callRequest(
Principal canisterId,
CallOptions fields,
Identity? identity,
Expand Down
8 changes: 4 additions & 4 deletions packages/agent_dart_base/lib/agent/agent/proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class ProxyStubAgent {
final void Function(ProxyMessage msg) _frontend;
final Agent _agent;

void onmessage(ProxyMessage msg) {
void onMessage(ProxyMessage msg) {
switch (msg.type) {
case ProxyMessageKind.getPrincipal:
_agent.getPrincipal().then((response) {
Expand All @@ -305,7 +305,7 @@ class ProxyStubAgent {
});
break;
case ProxyMessageKind.call:
_agent.call(msg.args?[0], msg.args?[1], msg.args?[2]).then((response) {
_agent.callRequest(msg.args?[0], msg.args?[1], msg.args?[2]).then((response) {
_frontend(
ProxyMessageCallResponse.fromJson({
'id': msg.id,
Expand Down Expand Up @@ -356,7 +356,7 @@ class ProxyAgent implements Agent {
@override
BinaryBlob? rootKey;

void onmessage(ProxyMessage msg) {
void onMessage(ProxyMessage msg) {
final id = msg.id;

final maybePromise = _pendingCalls[id];
Expand Down Expand Up @@ -417,7 +417,7 @@ class ProxyAgent implements Agent {
}

@override
Future<SubmitResponse> call(
Future<SubmitResponse> callRequest(
Principal canisterId,
CallOptions fields,
Identity? identity,
Expand Down
15 changes: 6 additions & 9 deletions packages/agent_dart_base/test/agent/http/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ void httpTest() {
});
});

// ignore: unused_local_variable
final res = await agent.call(
final res = await agent.callRequest(
canisterId,
CallOptions(arg: arg, methodName: methodName),
null,
);

// print((res as CallResponseBody).toJson());
print(res.toJson());

final mockPartialRequest = {
'request_type': SubmitRequestType.call,
Expand All @@ -64,16 +62,15 @@ void httpTest() {
};

final mockPartialsRequestId = requestIdOf(mockPartialRequest);

final expectedRequest = {
'content': mockPartialRequest,
};

final expectedRequestId =
requestIdOf(expectedRequest['content'] as Map<String, dynamic>);

final expectedRequestId = requestIdOf(
expectedRequest['content'] as Map<String, dynamic>,
);
expect(expectedRequestId, mockPartialsRequestId);
});
});

group('description 2 ', () {});
}

0 comments on commit 14f8781

Please sign in to comment.