Skip to content

Commit

Permalink
use stableJson everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Dec 8, 2023
1 parent 9ca450c commit aa9b51f
Show file tree
Hide file tree
Showing 24 changed files with 61 additions and 27 deletions.
9 changes: 7 additions & 2 deletions examples/audio_recorder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Record,
Result,
StableBTreeMap,
stableJson,
text,
update,
Variant,
Expand Down Expand Up @@ -40,8 +41,12 @@ const AudioRecorderError = Variant({
});
type AudioRecorderError = typeof AudioRecorderError.tsType;

let users = StableBTreeMap<Principal, User>(Principal, User, 0);
let recordings = StableBTreeMap<Principal, Recording>(Principal, Recording, 1);
let users = StableBTreeMap<Principal, User>(stableJson, stableJson, 0);
let recordings = StableBTreeMap<Principal, Recording>(
stableJson,
stableJson,
1
);

export default Canister({
createUser: update([text], User, (username) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/ethereum_json_rpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
query,
Some,
StableBTreeMap,
stableJson,
text,
update
} from 'azle';
Expand All @@ -16,7 +17,7 @@ import {
managementCanister
} from 'azle/canisters/management';

let stableStorage = StableBTreeMap<text, text>(text, text, 0);
let stableStorage = StableBTreeMap<text, text>(stableJson, stableJson, 0);

export default Canister({
init: init([text], (ethereumUrl) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/func_types/canisters/func_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
query,
Record,
StableBTreeMap,
stableJson,
update,
Variant,
Vec,
Expand Down Expand Up @@ -47,7 +48,7 @@ const NullFunc = Func(
'query'
);

let stableStorage = StableBTreeMap<text, StableFunc>(text, StableFunc, 0);
let stableStorage = StableBTreeMap<text, StableFunc>(stableJson, stableJson, 0);

export default Canister({
init: init([], () => {
Expand Down
3 changes: 2 additions & 1 deletion examples/motoko_examples/http_counter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Record,
Some,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Expand Down Expand Up @@ -60,7 +61,7 @@ const HttpRequest = Record({
certificate_version: Opt(nat16)
});

let stableStorage = StableBTreeMap<text, nat>(text, nat, 0);
let stableStorage = StableBTreeMap<text, nat>(stableJson, stableJson, 0);

export default Canister({
init: init([], () => {
Expand Down
3 changes: 2 additions & 1 deletion examples/motoko_examples/persistent-storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
postUpgrade,
query,
StableBTreeMap,
stableJson,
text,
update
} from 'azle';

let stableStorage = StableBTreeMap<text, nat>(text, nat, 0);
let stableStorage = StableBTreeMap<text, nat>(stableJson, stableJson, 0);
let redeployed = false;

export default Canister({
Expand Down
3 changes: 2 additions & 1 deletion examples/pre_and_post_upgrade/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
query,
Record,
StableBTreeMap,
stableJson,
text,
update,
Vec,
Expand All @@ -19,7 +20,7 @@ const Entry = Record({
});
type Entry = typeof Entry;

let stableStorage = StableBTreeMap<text, Vec<Entry>>(text, Vec(Entry), 0);
let stableStorage = StableBTreeMap<text, Vec<Entry>>(stableJson, stableJson, 0);

let entries: {
[key: string]: nat64;
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister1/stable_map_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';

let stableMap0 = StableBTreeMap<nat8, text>(nat8, text, 0);
let stableMap0 = StableBTreeMap<nat8, text>(stableJson, stableJson, 0);

export const stableMap0Methods = {
stableMap0ContainsKey: query([nat8], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister1/stable_map_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';

let stableMap1 = StableBTreeMap<nat16, blob>(nat16, blob, 1);
let stableMap1 = StableBTreeMap<nat16, blob>(stableJson, stableJson, 1);

export const stableMap1Methods = {
stableMap1ContainsKey: query([nat16], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister1/stable_map_2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';

let stableMap2 = StableBTreeMap<nat32, nat>(nat32, nat, 2);
let stableMap2 = StableBTreeMap<nat32, nat>(stableJson, stableJson, 2);

export const stableMap2Methods = {
stableMap2ContainsKey: query([nat32], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister1/stable_map_3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';
import { Reaction } from '../types';

let stableMap3 = StableBTreeMap<Reaction, int>(Reaction, int, 3);
let stableMap3 = StableBTreeMap<Reaction, int>(stableJson, stableJson, 3);

export const stableMap3Methods = {
stableMap3ContainsKey: query([Reaction], bool, (key) => {
Expand Down
7 changes: 6 additions & 1 deletion examples/stable_structures/src/canister1/stable_map_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';
import { User } from '../types';

export let stableMap4 = StableBTreeMap<User, float32>(User, float32, 4);
export let stableMap4 = StableBTreeMap<User, float32>(
stableJson,
stableJson,
4
);

export const stableMap4Methods = {
stableMap4ContainsKey: query([User], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister2/stable_map_5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
query,
update,
StableBTreeMap,
stableJson,
Vec,
text,
Tuple
} from 'azle';

let stableMap5 = StableBTreeMap<Opt<text>, float64>(Opt(text), float64, 5);
let stableMap5 = StableBTreeMap<Opt<text>, float64>(stableJson, stableJson, 5);

export const stableMap5Methods = {
stableMap5ContainsKey: query([Opt(text)], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister2/stable_map_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {
query,
update,
StableBTreeMap,
stableJson,
Vec,
Tuple
} from 'azle';

let stableMap6 = StableBTreeMap<Vec<nat64>, bool>(Vec(nat64), bool, 6);
let stableMap6 = StableBTreeMap<Vec<nat64>, bool>(stableJson, stableJson, 6);

export const stableMap6Methods = {
stableMap6ContainsKey: query([Vec(nat64)], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister2/stable_map_7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';

let stableMap7 = StableBTreeMap<Null, Null>(Null, Null, 7);
let stableMap7 = StableBTreeMap<Null, Null>(stableJson, stableJson, 7);

export const stableMap7Methods = {
stableMap7ContainsKey: query([Null], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister2/stable_map_8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import {
query,
update,
StableBTreeMap,
stableJson,
Vec,
Tuple
} from 'azle';

let stableMap8 = StableBTreeMap<bool, Null>(bool, Null, 8);
let stableMap8 = StableBTreeMap<bool, Null>(stableJson, stableJson, 8);

export const stableMap8Methods = {
stableMap8ContainsKey: query([bool], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister2/stable_map_9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
query,
update,
StableBTreeMap,
stableJson,
Vec,
text,
Tuple
} from 'azle';

let stableMap9 = StableBTreeMap<float64, Vec<text>>(float64, Vec(text), 9);
let stableMap9 = StableBTreeMap<float64, Vec<text>>(stableJson, stableJson, 9);

export const stableMap9Methods = {
stableMap9ContainsKey: query([float64], bool, (key) => {
Expand Down
7 changes: 6 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';

let stableMap10 = StableBTreeMap<float32, Opt<bool>>(float32, Opt(bool), 10);
let stableMap10 = StableBTreeMap<float32, Opt<bool>>(
stableJson,
stableJson,
10
);

export const stableMap10Methods = {
stableMap10ContainsKey: query([float32], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';
import { User } from '../types';

let stableMap11 = StableBTreeMap<nat, User>(nat, User, 11);
let stableMap11 = StableBTreeMap<nat, User>(stableJson, stableJson, 11);

export const stableMap11Methods = {
stableMap11ContainsKey: query([nat], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
Tuple,
update,
Vec
} from 'azle';
import { Reaction } from '../types';

let stableMap12 = StableBTreeMap<blob, Reaction>(blob, Reaction, 12);
let stableMap12 = StableBTreeMap<blob, Reaction>(stableJson, stableJson, 12);

export const stableMap12Methods = {
stableMap12ContainsKey: query([blob], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_13.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import {
Principal,
query,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';

let stableMap13 = StableBTreeMap<text, Principal>(text, Principal, 13);
let stableMap13 = StableBTreeMap<text, Principal>(stableJson, stableJson, 13);

export const stableMap13Methods = {
stableMap13ContainsKey: query([text], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_14.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';
import { Callback } from '../types';

let stableMap14 = StableBTreeMap<text, Callback>(text, Callback, 14);
let stableMap14 = StableBTreeMap<text, Callback>(stableJson, stableJson, 14);

export const stableMap14Methods = {
stableMap14ContainsKey: query([text], bool, (key) => {
Expand Down
3 changes: 2 additions & 1 deletion examples/stable_structures/src/canister3/stable_map_15.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';
import { Callback } from '../types';

let stableMap15 = StableBTreeMap<Callback, text>(Callback, text, 15);
let stableMap15 = StableBTreeMap<Callback, text>(stableJson, stableJson, 15);

export const stableMap15Methods = {
stableMap15ContainsKey: query([Callback], bool, (key) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/stable_structures/src/canister3/stable_map_16.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
query,
Some,
StableBTreeMap,
StableJson,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';

let stableMap16 = StableBTreeMap<text, {}>(text, StableJson(), 16);
let stableMap16 = StableBTreeMap<text, {}>(stableJson, stableJson, 16);

export const stableMap16Methods = {
stableMap16ContainsKey: query([text], bool, (key) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/stable_structures/src/canister3/stable_map_17.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
Opt,
query,
StableBTreeMap,
StableJson,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';

let stableMap17 = StableBTreeMap<{}, text>(StableJson(), text, 17);
let stableMap17 = StableBTreeMap<{}, text>(stableJson, stableJson, 17);

export const stableMap17Methods = {
stableMap17ContainsKey: query([text], bool, (key) => {
Expand Down

0 comments on commit aa9b51f

Please sign in to comment.