Skip to content

Commit

Permalink
get rid of reply raw everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jul 12, 2024
1 parent 970d8e3 commit b3c27e5
Show file tree
Hide file tree
Showing 15 changed files with 2,358 additions and 107 deletions.
7 changes: 5 additions & 2 deletions examples/composite_queries/src/canister1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,12 @@ const CompQueryCanister = Canister({
);
const responseJson = await response.json();

ic.reply(responseJson, text);
ic.reply({ data: responseJson, type: text });
} else {
ic.reply(await ic.call(canister2.manualQuery), text);
ic.reply({
data: await ic.call(canister2.manualQuery),
type: text
});
}
},
{ manual: true }
Expand Down
5 changes: 4 additions & 1 deletion examples/composite_queries/src/canister2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export default Canister({
[],
Manual(text),
() => {
ic.reply('Hello from Canister 2 manual query', text);
ic.reply({
data: 'Hello from Canister 2 manual query',
type: text
});
},
{ manual: true }
),
Expand Down
66 changes: 35 additions & 31 deletions examples/manual_reply/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,58 +79,60 @@ export default Canister({
return;
}

ic.reply(message, text);
ic.reply({ data: message, type: text });
},
{ manual: true }
),
updateBlob: update(
[],
Manual(blob),
() => {
ic.reply(
new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]),
blob
);
ic.reply({
data: new Uint8Array([
83, 117, 114, 112, 114, 105, 115, 101, 33
]),
type: blob
});
},
{ manual: true }
),
updateFloat32: update(
[],
Manual(float32),
() => {
ic.reply(1245.678, float32);
ic.reply({ data: 1245.678, type: float32 });
},
{ manual: true }
),
updateInt8: update(
[],
Manual(int8),
() => {
ic.reply(-100, int8);
ic.reply({ data: -100, type: int8 });
},
{ manual: true }
),
updateNat: update(
[],
Manual(nat),
() => {
ic.reply(184467440737095516150n, nat);
ic.reply({ data: 184467440737095516150n, type: nat });
},
{ manual: true }
),
updateNull: update(
[],
Manual(Null),
() => {
ic.reply(null, Null);
ic.reply({ data: null, type: Null });
},
{ manual: true }
),
updateVoid: update(
[],
Manual(Void),
() => {
ic.reply(undefined, Void);
ic.reply({ data: undefined, type: Void });
},
{ manual: true }
),
Expand All @@ -154,23 +156,23 @@ export default Canister({
Gas: { Elemental: null }
}
};
ic.reply(element, Element);
ic.reply({ data: element, type: Element });
},
{ manual: true }
),
updateReserved: update(
[],
Manual(reserved),
() => {
ic.reply(undefined, reserved);
ic.reply({ data: undefined, type: reserved });
},
{ manual: true }
),
updateString: update(
[],
Manual(text),
() => {
ic.reply('hello', text);
ic.reply({ data: 'hello', type: text });
},
{ manual: true }
),
Expand All @@ -179,19 +181,19 @@ export default Canister({
Manual(Gas),
() => {
const gas = { Toxic: null };
ic.reply(gas, Gas);
ic.reply({ data: gas, type: Gas });
},
{ manual: true }
),
replyRaw: update(
[],
Manual(RawReply),
() => {
ic.replyRaw(
ic.candidEncode(
ic.reply({
raw: ic.candidEncode(
'(record { "int" = 42; "text" = "text"; "bool" = true; "myBlob" = blob "Surprise!"; "myVariant" = variant { Medium } })'
)
);
});
},
{ manual: true }
),
Expand All @@ -205,58 +207,60 @@ export default Canister({
return;
}

ic.reply(message, text);
ic.reply({ data: message, type: text });
},
{ manual: true }
),
queryBlob: query(
[],
Manual(blob),
() => {
ic.reply(
new Uint8Array([83, 117, 114, 112, 114, 105, 115, 101, 33]),
blob
);
ic.reply({
data: new Uint8Array([
83, 117, 114, 112, 114, 105, 115, 101, 33
]),
type: blob
});
},
{ manual: true }
),
queryFloat32: query(
[],
Manual(float32),
() => {
ic.reply(1245.678, float32);
ic.reply({ data: 1245.678, type: float32 });
},
{ manual: true }
),
queryInt8: query(
[],
Manual(int8),
() => {
ic.reply(-100, int8);
ic.reply({ data: -100, type: int8 });
},
{ manual: true }
),
queryNat: query(
[],
Manual(nat),
() => {
ic.reply(184_467_440_737_095_516_150n, nat);
ic.reply({ data: 184_467_440_737_095_516_150n, type: nat });
},
{ manual: true }
),
queryNull: query(
[],
Manual(Null),
() => {
ic.reply(null, Null);
ic.reply({ data: null, type: Null });
},
{ manual: true }
),
queryVoid: query(
[],
Manual(Void),
() => {
ic.reply(undefined, Void);
ic.reply({ data: undefined, type: Void });
},
{ manual: true }
),
Expand All @@ -280,23 +284,23 @@ export default Canister({
Gas: { Elemental: null }
}
};
ic.reply(element, Element);
ic.reply({ data: element, type: Element });
},
{ manual: true }
),
queryReserved: query(
[],
Manual(reserved),
() => {
ic.reply(undefined, reserved);
ic.reply({ data: undefined, type: reserved });
},
{ manual: true }
),
queryString: query(
[],
Manual(text),
() => {
ic.reply('hello', text);
ic.reply({ data: 'hello', type: text });
},
{ manual: true }
),
Expand All @@ -305,7 +309,7 @@ export default Canister({
Manual(Gas),
() => {
const gas = { Toxic: null };
ic.reply(gas, Gas);
ic.reply({ data: gas, type: Gas });
},
{ manual: true }
)
Expand Down
Loading

0 comments on commit b3c27e5

Please sign in to comment.