Skip to content

Commit

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

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

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

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

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

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

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

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

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

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

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

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

let entries: {
[key: string]: nat64;
Expand Down
2 changes: 1 addition & 1 deletion examples/robust_imports/src/azle_coverage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const Watermelon = Voavanga({
Seedless: Nutmeg
});

let soncoya = Soncoya(nectarine8, PreparedFruit, 0);
let soncoya = Soncoya<nectarine8, PreparedFruit>(0);

function gatherGrapes() {
const opt = soncoya.get(0);
Expand Down
2 changes: 1 addition & 1 deletion examples/robust_imports/src/type_alias_decls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export const returnFuncAlias = azle.query(
}
);

let stableMap = types.DeepStableBTreeMapAlias(azle.nat16, azle.text, 1);
let stableMap = types.DeepStableBTreeMapAlias<azle.nat16, azle.text>(1);

export const setStable = azle.update(
[azle.nat16, azle.text],
Expand Down
19 changes: 3 additions & 16 deletions examples/stable_b_tree_map_instruction_threshold/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
query,
Record,
StableBTreeMap,
stableJson,
text,
update,
Vec,
Expand All @@ -20,11 +19,7 @@ const SmallRecord = Record({
});
type SmallRecord = typeof SmallRecord.tsType;

let smallRecordMap = StableBTreeMap<string, SmallRecord>(
stableJson,
stableJson,
0
);
let smallRecordMap = StableBTreeMap<string, SmallRecord>(0);

const MediumRecord = Record({
id: text,
Expand All @@ -34,11 +29,7 @@ const MediumRecord = Record({
});
type MediumRecord = typeof MediumRecord.tsType;

let mediumRecordMap = StableBTreeMap<string, MediumRecord>(
stableJson,
stableJson,
1
);
let mediumRecordMap = StableBTreeMap<string, MediumRecord>(1);

const LargeRecord = Record({
id: text,
Expand All @@ -51,11 +42,7 @@ const LargeRecord = Record({
});
type LargeRecord = typeof LargeRecord.tsType;

let largeRecordMap = StableBTreeMap<string, LargeRecord>(
stableJson,
stableJson,
2
);
let largeRecordMap = StableBTreeMap<string, LargeRecord>(2);

export default Canister({
insertSmallRecord: update([nat32], Void, (numToInsert) => {
Expand Down
3 changes: 1 addition & 2 deletions examples/stable_structures/src/canister1/stable_map_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import {
Opt,
query,
StableBTreeMap,
stableJson,
text,
Tuple,
update,
Vec
} from 'azle';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

export const stableMap13Methods = {
stableMap13ContainsKey: query([text], bool, (key) => {
Expand Down
Loading

0 comments on commit 05aede4

Please sign in to comment.