Skip to content

Commit

Permalink
feat: did and rename
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Dec 15, 2023
1 parent 42c258d commit 9a10932
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/declarations/satellite/satellite.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ export interface ListResults_1 {
items_length: bigint;
}
export type Memory = { Heap: null } | { Stable: null };
export interface MemorySize {
stable: bigint;
heap: bigint;
}
export type Permission =
| { Controllers: null }
| { Private: null }
Expand Down Expand Up @@ -218,6 +222,7 @@ export interface _SERVICE {
list_custom_domains: ActorMethod<[], Array<[string, CustomDomain]>>;
list_docs: ActorMethod<[string, ListParams], ListResults_1>;
list_rules: ActorMethod<[RulesType], Array<[string, Rule]>>;
memory_size: ActorMethod<[], MemorySize>;
set_config: ActorMethod<[Config], undefined>;
set_controllers: ActorMethod<[SetControllersArgs], Array<[Principal, Controller]>>;
set_custom_domain: ActorMethod<[string, [] | [string]], undefined>;
Expand Down
2 changes: 2 additions & 0 deletions src/declarations/satellite/satellite.factory.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const idlFactory = ({ IDL }) => {
mutable_permissions: IDL.Opt(IDL.Bool),
write: Permission
});
const MemorySize = IDL.Record({ stable: IDL.Nat64, heap: IDL.Nat64 });
const SetController = IDL.Record({
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
scope: ControllerScope,
Expand Down Expand Up @@ -227,6 +228,7 @@ export const idlFactory = ({ IDL }) => {
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
list_rules: IDL.Func([RulesType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
memory_size: IDL.Func([], [MemorySize], ['query']),
set_config: IDL.Func([Config], [], []),
set_controllers: IDL.Func(
[SetControllersArgs],
Expand Down
2 changes: 2 additions & 0 deletions src/declarations/satellite/satellite.factory.did.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const idlFactory = ({ IDL }) => {
mutable_permissions: IDL.Opt(IDL.Bool),
write: Permission
});
const MemorySize = IDL.Record({ stable: IDL.Nat64, heap: IDL.Nat64 });
const SetController = IDL.Record({
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
scope: ControllerScope,
Expand Down Expand Up @@ -227,6 +228,7 @@ export const idlFactory = ({ IDL }) => {
list_custom_domains: IDL.Func([], [IDL.Vec(IDL.Tuple(IDL.Text, CustomDomain))], ['query']),
list_docs: IDL.Func([IDL.Text, ListParams], [ListResults_1], ['query']),
list_rules: IDL.Func([RulesType], [IDL.Vec(IDL.Tuple(IDL.Text, Rule))], ['query']),
memory_size: IDL.Func([], [MemorySize], ['query']),
set_config: IDL.Func([Config], [], []),
set_controllers: IDL.Func(
[SetControllersArgs],
Expand Down
2 changes: 2 additions & 0 deletions src/satellite/satellite.did
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type ListResults_1 = record {
items_length : nat64;
};
type Memory = variant { Heap; Stable };
type MemorySize = record { stable : nat64; heap : nat64 };
type Permission = variant { Controllers; Private; Public; Managed };
type Rule = record {
memory : opt Memory;
Expand Down Expand Up @@ -189,6 +190,7 @@ service : () -> {
list_custom_domains : () -> (vec record { text; CustomDomain }) query;
list_docs : (text, ListParams) -> (ListResults_1) query;
list_rules : (RulesType) -> (vec record { text; Rule }) query;
memory_size : () -> (MemorySize) query;
set_config : (Config) -> ();
set_controllers : (SetControllersArgs) -> (
vec record { principal; Controller },
Expand Down
6 changes: 3 additions & 3 deletions src/satellite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use controllers::store::{
delete_controllers as delete_controllers_store, get_controllers,
set_controllers as set_controllers_store,
};
use core::arch::wasm32::memory_size;
use core::arch::wasm32::memory_size as wasm_memory_size;
use ic_cdk::api::call::arg_data;
use ic_cdk::api::stable::{stable_size, WASM_PAGE_SIZE_IN_BYTES};
use ic_cdk::api::{caller, trap};
Expand Down Expand Up @@ -512,9 +512,9 @@ fn version() -> String {
}

#[query(guard = "caller_is_admin_controller")]
fn memory() -> MemorySize {
fn memory_size() -> MemorySize {
MemorySize {
heap: memory_size(0) * WASM_PAGE_SIZE_IN_BYTES,
heap: wasm_memory_size(0) * WASM_PAGE_SIZE_IN_BYTES,
stable: stable_size() as usize * WASM_PAGE_SIZE_IN_BYTES,
}
}
Expand Down

0 comments on commit 9a10932

Please sign in to comment.