Skip to content

Commit

Permalink
lowercase principal type removed
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Sep 29, 2023
1 parent aedb2e2 commit 4721cd1
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 82 deletions.
27 changes: 13 additions & 14 deletions examples/audio_recorder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ic,
nat64,
Opt,
principal,
Principal,
query,
Record,
Expand All @@ -17,27 +16,27 @@ import {
} from 'azle';

const User = Record({
id: principal,
id: Principal,
createdAt: nat64,
recordingIds: Vec(principal),
recordingIds: Vec(Principal),
username: text
});

const Recording = Record({
id: principal,
id: Principal,
audio: blob,
createdAt: nat64,
name: text,
userId: principal
userId: Principal
});

const AudioRecorderError = Variant({
RecordingDoesNotExist: principal,
UserDoesNotExist: principal
RecordingDoesNotExist: Principal,
UserDoesNotExist: Principal
});

let users = StableBTreeMap(principal, User, 0);
let recordings = StableBTreeMap(principal, Recording, 1);
let users = StableBTreeMap(Principal, User, 0);
let recordings = StableBTreeMap(Principal, Recording, 1);

export default Canister({
createUser: update([text], User, (username) => {
Expand All @@ -56,10 +55,10 @@ export default Canister({
readUsers: query([], Vec(User), () => {
return users.values();
}),
readUserById: query([principal], Opt(User), (id) => {
readUserById: query([Principal], Opt(User), (id) => {
return users.get(id);
}),
deleteUser: update([principal], Result(User, AudioRecorderError), (id) => {
deleteUser: update([Principal], Result(User, AudioRecorderError), (id) => {
const userOpt = users.get(id);

if (userOpt.length === 0) {
Expand All @@ -83,7 +82,7 @@ export default Canister({
};
}),
createRecording: update(
[blob, text, principal],
[blob, text, Principal],
Result(Recording, AudioRecorderError),
(audio, name, userId) => {
const userOpt = users.get(userId);
Expand Down Expand Up @@ -124,11 +123,11 @@ export default Canister({
readRecordings: query([], Vec(Recording), () => {
return recordings.values();
}),
readRecordingById: query([principal], Opt(Recording), (id) => {
readRecordingById: query([Principal], Opt(Recording), (id) => {
return recordings.get(id);
}),
deleteRecording: update(
[principal],
[Principal],
Result(Recording, AudioRecorderError),
(id) => {
const recordingOpt = recordings.get(id);
Expand Down
6 changes: 3 additions & 3 deletions examples/call_raw/src/call_raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
ic,
nat,
nat64,
principal,
Principal,
Result,
text,
update
} from 'azle';

export default Canister({
executeCallRaw: update(
[principal, text, text, nat64],
[Principal, text, text, nat64],
Result(text, text),
async (canisterId, method, candidArgs, payment) => {
const result = await ic.callRaw(
Expand All @@ -25,7 +25,7 @@ export default Canister({
}
),
executeCallRaw128: update(
[principal, text, text, nat],
[Principal, text, text, nat],
Result(text, text),
async (canisterId, method, candidArgs, payment) => {
const result = await ic.callRaw128(
Expand Down
8 changes: 4 additions & 4 deletions examples/ic_api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
update,
bool,
text,
principal,
Principal,
Void
} from 'azle';

Expand Down Expand Up @@ -70,7 +70,7 @@ export default Canister({
}
),
// returns the principal of the identity that called this function
caller: query([], principal, () => {
caller: query([], Principal, () => {
return ic.caller();
}),
// returns the amount of cycles available in the canister
Expand Down Expand Up @@ -98,7 +98,7 @@ export default Canister({
return ic.dataCertificate();
}),
// returns this canister's id
id: query([], principal, () => {
id: query([], Principal, () => {
return ic.id();
}),
// Returns the number of instructions that the canister executed since the last
Expand All @@ -107,7 +107,7 @@ export default Canister({
return ic.instructionCounter();
}),
// determines whether the given principal is a controller of the canister
isController: query([principal], bool, (principal) => {
isController: query([Principal], bool, (principal) => {
return ic.isController(principal);
}),
performanceCounter: query([], nat64, () => {
Expand Down
5 changes: 2 additions & 3 deletions examples/init/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
None,
Null,
Opt,
principal,
Principal,
query,
Record,
Expand All @@ -28,7 +27,7 @@ let owner: Opt<Principal> = None;

export default Canister({
init: init(
[User, Reaction, principal],
[User, Reaction, Principal],
(initUser, initReaction, initOwner) => {
user = Some(initUser);
reaction = Some(initReaction);
Expand All @@ -41,7 +40,7 @@ export default Canister({
getReaction: query([], Opt(Reaction), () => {
return reaction;
}),
getOwner: query([], Opt(principal), () => {
getOwner: query([], Opt(Principal), () => {
return owner;
})
});
3 changes: 1 addition & 2 deletions examples/ledger_canister/src/ledger_canister/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
nat64,
None,
Opt,
principal,
Principal,
query,
Some,
Expand Down Expand Up @@ -101,7 +100,7 @@ export default Canister({
getArchives: update([], Archives, async () => {
return await ic.call(icpCanister.archives, {});
}),
getAddressFromPrincipal: query([principal], text, (principal) => {
getAddressFromPrincipal: query([Principal], text, (principal) => {
return hexAddressFromPrincipal(principal, 0);
})
});
6 changes: 3 additions & 3 deletions examples/list_of_lists/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
nat8,
Null,
Opt,
principal,
Principal,
query,
Record,
reserved,
Expand Down Expand Up @@ -113,8 +113,8 @@ export default Canister({
}
),
listOfPrincipal: query(
[Vec(Vec(Vec(principal)))],
Vec(Vec(Vec(principal))),
[Vec(Vec(Vec(Principal)))],
Vec(Vec(Vec(Principal))),
(param) => {
return param;
}
Expand Down
19 changes: 9 additions & 10 deletions examples/management_canister/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
ic,
nat,
None,
principal,
Principal,
query,
Some,
Expand Down Expand Up @@ -43,7 +42,7 @@ export default Canister({

return createCanisterResult;
}),
executeUpdateSettings: update([principal], bool, async (canisterId) => {
executeUpdateSettings: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.update_settings, {
args: [
{
Expand All @@ -61,7 +60,7 @@ export default Canister({
return true;
}),
executeInstallCode: update(
[principal, blob],
[Principal, blob],
bool,
async (canisterId, wasmModule) => {
await ic.call(managementCanister.install_code, {
Expand All @@ -81,7 +80,7 @@ export default Canister({
return true;
}
),
executeUninstallCode: update([principal], bool, async (canisterId) => {
executeUninstallCode: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.uninstall_code, {
args: [
{
Expand All @@ -92,7 +91,7 @@ export default Canister({

return true;
}),
executeStartCanister: update([principal], bool, async (canisterId) => {
executeStartCanister: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.start_canister, {
args: [
{
Expand All @@ -103,7 +102,7 @@ export default Canister({

return true;
}),
executeStopCanister: update([principal], bool, async (canisterId) => {
executeStopCanister: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.stop_canister, {
args: [
{
Expand All @@ -127,7 +126,7 @@ export default Canister({
});
}
),
executeDeleteCanister: update([principal], bool, async (canisterId) => {
executeDeleteCanister: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.delete_canister, {
args: [
{
Expand All @@ -138,7 +137,7 @@ export default Canister({

return true;
}),
executeDepositCycles: update([principal], bool, async (canisterId) => {
executeDepositCycles: update([Principal], bool, async (canisterId) => {
await ic.call(managementCanister.deposit_cycles, {
args: [
{
Expand Down Expand Up @@ -173,7 +172,7 @@ export default Canister({
),
// TODO we should test this like we test depositCycles
provisionalTopUpCanister: update(
[principal, nat],
[Principal, nat],
bool,
async (canisterId, amount) => {
await ic.call(managementCanister.provisional_top_up_canister, {
Expand All @@ -188,7 +187,7 @@ export default Canister({
return true;
}
),
getCreatedCanisterId: query([], principal, () => {
getCreatedCanisterId: query([], Principal, () => {
return state.createdCanisterId;
})
});
15 changes: 7 additions & 8 deletions examples/motoko_examples/whoami/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ic,
init,
postUpgrade,
principal,
Principal,
query,
update
Expand All @@ -13,35 +12,35 @@ import {
let install: Principal = Principal.fromText('aaaaa-aa');
let someone: Principal = Principal.fromText('aaaaa-aa');

const whoami = update([], principal, () => {
const whoami = update([], Principal, () => {
return ic.caller();
});

export default Canister({
// Manually save the calling principal and argument for later access.
init: init([principal], (somebody) => {
init: init([Principal], (somebody) => {
install = ic.caller();
someone = somebody;
}),
// Manually re-save these variables after new deploys.
postUpgrade: postUpgrade([principal], (somebody) => {
postUpgrade: postUpgrade([Principal], (somebody) => {
install = ic.caller();
someone = somebody;
}),
// Return the principal identifier of the wallet canister that installed this
// canister.
installer: query([], principal, () => {
installer: query([], Principal, () => {
return install;
}),
// Return the principal identifier that was provided as an installation
// argument to this canister.
argument: query([], principal, () => {
argument: query([], Principal, () => {
return someone;
}),
// Return the principal identifier of the caller of this method.
whoami,
// Return the principal identifier of this canister.
id: update([], principal, async () => {
id: update([], Principal, async () => {
// TODO This is not an ideal solution but will work for now
const self = Canister({
whoami
Expand All @@ -53,7 +52,7 @@ export default Canister({
// This is much quicker than `id()` above because it isn't making a cross-
// canister call to itself. Additionally, it can now be a `Query` which means it
// doesn't have to go through consensus.
idQuick: query([], principal, () => {
idQuick: query([], Principal, () => {
return ic.id();
})
});
5 changes: 2 additions & 3 deletions examples/primitive_types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
nat64,
nat8,
Null,
principal,
Principal,
query,
reserved,
Expand Down Expand Up @@ -135,10 +134,10 @@ export default Canister({
console.log(typeof bool);
return bool;
}),
getPrincipal: query([], principal, () => {
getPrincipal: query([], Principal, () => {
return Principal.fromText('rrkah-fqaaa-aaaaa-aaaaq-cai');
}),
printPrincipal: query([principal], principal, (principal) => {
printPrincipal: query([Principal], Principal, (principal) => {
console.log(typeof principal);
return principal;
}),
Expand Down
Loading

0 comments on commit 4721cd1

Please sign in to comment.