log of failing language server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Trace - 8:11:48 AM] Sending request 'initialize - (0)'. | |
Params: { | |
"processId": 35143, | |
"clientInfo": { | |
"name": "Visual Studio Code", | |
"version": "1.71.2" | |
}, | |
"locale": "en-us", | |
"rootPath": "/Users/a_user/code/test/ic", | |
"rootUri": "file:///Users/a_user/code/test/ic", | |
"capabilities": { | |
"workspace": { | |
"applyEdit": true, | |
"workspaceEdit": { | |
"documentChanges": true, | |
"resourceOperations": [ | |
"create", | |
"rename", | |
"delete" | |
], | |
"failureHandling": "textOnlyTransactional", | |
"normalizesLineEndings": true, | |
"changeAnnotationSupport": { | |
"groupsOnLabel": true | |
} | |
}, | |
"configuration": true, | |
"didChangeWatchedFiles": { | |
"dynamicRegistration": true, | |
"relativePatternSupport": true | |
}, | |
"symbol": { | |
"dynamicRegistration": true, | |
"symbolKind": { | |
"valueSet": [ | |
1, | |
2, | |
3, | |
4, | |
5, | |
6, | |
7, | |
8, | |
9, | |
10, | |
11, | |
12, | |
13, | |
14, | |
15, | |
16, | |
17, | |
18, | |
19, | |
20, | |
21, | |
22, | |
23, | |
24, | |
25, | |
26 | |
] | |
}, | |
"tagSupport": { | |
"valueSet": [ | |
1 | |
] | |
}, | |
"resolveSupport": { | |
"properties": [ | |
"location.range" | |
] | |
} | |
}, | |
"codeLens": { | |
"refreshSupport": true | |
}, | |
"executeCommand": { | |
"dynamicRegistration": true | |
}, | |
"didChangeConfiguration": { | |
"dynamicRegistration": true | |
}, | |
"workspaceFolders": true, | |
"semanticTokens": { | |
"refreshSupport": true | |
}, | |
"fileOperations": { | |
"dynamicRegistration": true, | |
"didCreate": true, | |
"didRename": true, | |
"didDelete": true, | |
"willCreate": true, | |
"willRename": true, | |
"willDelete": true | |
}, | |
"inlineValue": { | |
"refreshSupport": true | |
}, | |
"inlayHint": { | |
"refreshSupport": true | |
}, | |
"diagnostics": { | |
"refreshSupport": true | |
} | |
}, | |
"textDocument": { | |
"publishDiagnostics": { | |
"relatedInformation": true, | |
"versionSupport": false, | |
"tagSupport": { | |
"valueSet": [ | |
1, | |
2 | |
] | |
}, | |
"codeDescriptionSupport": true, | |
"dataSupport": true | |
}, | |
"synchronization": { | |
"dynamicRegistration": true, | |
"willSave": true, | |
"willSaveWaitUntil": true, | |
"didSave": true | |
}, | |
"completion": { | |
"dynamicRegistration": true, | |
"contextSupport": true, | |
"completionItem": { | |
"snippetSupport": true, | |
"commitCharactersSupport": true, | |
"documentationFormat": [ | |
"markdown", | |
"plaintext" | |
], | |
"deprecatedSupport": true, | |
"preselectSupport": true, | |
"tagSupport": { | |
"valueSet": [ | |
1 | |
] | |
}, | |
"insertReplaceSupport": true, | |
"resolveSupport": { | |
"properties": [ | |
"documentation", | |
"detail", | |
"additionalTextEdits" | |
] | |
}, | |
"insertTextModeSupport": { | |
"valueSet": [ | |
1, | |
2 | |
] | |
}, | |
"labelDetailsSupport": true | |
}, | |
"insertTextMode": 2, | |
"completionItemKind": { | |
"valueSet": [ | |
1, | |
2, | |
3, | |
4, | |
5, | |
6, | |
7, | |
8, | |
9, | |
10, | |
11, | |
12, | |
13, | |
14, | |
15, | |
16, | |
17, | |
18, | |
19, | |
20, | |
21, | |
22, | |
23, | |
24, | |
25 | |
] | |
}, | |
"completionList": { | |
"itemDefaults": [ | |
"commitCharacters", | |
"editRange", | |
"insertTextFormat", | |
"insertTextMode" | |
] | |
} | |
}, | |
"hover": { | |
"dynamicRegistration": true, | |
"contentFormat": [ | |
"markdown", | |
"plaintext" | |
] | |
}, | |
"signatureHelp": { | |
"dynamicRegistration": true, | |
"signatureInformation": { | |
"documentationFormat": [ | |
"markdown", | |
"plaintext" | |
], | |
"parameterInformation": { | |
"labelOffsetSupport": true | |
}, | |
"activeParameterSupport": true | |
}, | |
"contextSupport": true | |
}, | |
"definition": { | |
"dynamicRegistration": true, | |
"linkSupport": true | |
}, | |
"references": { | |
"dynamicRegistration": true | |
}, | |
"documentHighlight": { | |
"dynamicRegistration": true | |
}, | |
"documentSymbol": { | |
"dynamicRegistration": true, | |
"symbolKind": { | |
"valueSet": [ | |
1, | |
2, | |
3, | |
4, | |
5, | |
6, | |
7, | |
8, | |
9, | |
10, | |
11, | |
12, | |
13, | |
14, | |
15, | |
16, | |
17, | |
18, | |
19, | |
20, | |
21, | |
22, | |
23, | |
24, | |
25, | |
26 | |
] | |
}, | |
"hierarchicalDocumentSymbolSupport": true, | |
"tagSupport": { | |
"valueSet": [ | |
1 | |
] | |
}, | |
"labelSupport": true | |
}, | |
"codeAction": { | |
"dynamicRegistration": true, | |
"isPreferredSupport": true, | |
"disabledSupport": true, | |
"dataSupport": true, | |
"resolveSupport": { | |
"properties": [ | |
"edit" | |
] | |
}, | |
"codeActionLiteralSupport": { | |
"codeActionKind": { | |
"valueSet": [ | |
"", | |
"quickfix", | |
"refactor", | |
"refactor.extract", | |
"refactor.inline", | |
"refactor.rewrite", | |
"source", | |
"source.organizeImports" | |
] | |
} | |
}, | |
"honorsChangeAnnotations": false | |
}, | |
"codeLens": { | |
"dynamicRegistration": true | |
}, | |
"formatting": { | |
"dynamicRegistration": true | |
}, | |
"rangeFormatting": { | |
"dynamicRegistration": true | |
}, | |
"onTypeFormatting": { | |
"dynamicRegistration": true | |
}, | |
"rename": { | |
"dynamicRegistration": true, | |
"prepareSupport": true, | |
"prepareSupportDefaultBehavior": 1, | |
"honorsChangeAnnotations": true | |
}, | |
"documentLink": { | |
"dynamicRegistration": true, | |
"tooltipSupport": true | |
}, | |
"typeDefinition": { | |
"dynamicRegistration": true, | |
"linkSupport": true | |
}, | |
"implementation": { | |
"dynamicRegistration": true, | |
"linkSupport": true | |
}, | |
"colorProvider": { | |
"dynamicRegistration": true | |
}, | |
"foldingRange": { | |
"dynamicRegistration": true, | |
"rangeLimit": 5000, | |
"lineFoldingOnly": true, | |
"foldingRangeKind": { | |
"valueSet": [ | |
"comment", | |
"imports", | |
"region" | |
] | |
}, | |
"foldingRange": { | |
"collapsedText": false | |
} | |
}, | |
"declaration": { | |
"dynamicRegistration": true, | |
"linkSupport": true | |
}, | |
"selectionRange": { | |
"dynamicRegistration": true | |
}, | |
"callHierarchy": { | |
"dynamicRegistration": true | |
}, | |
"semanticTokens": { | |
"dynamicRegistration": true, | |
"tokenTypes": [ | |
"namespace", | |
"type", | |
"class", | |
"enum", | |
"interface", | |
"struct", | |
"typeParameter", | |
"parameter", | |
"variable", | |
"property", | |
"enumMember", | |
"event", | |
"function", | |
"method", | |
"macro", | |
"keyword", | |
"modifier", | |
"comment", | |
"string", | |
"number", | |
"regexp", | |
"operator", | |
"decorator" | |
], | |
"tokenModifiers": [ | |
"declaration", | |
"definition", | |
"readonly", | |
"static", | |
"deprecated", | |
"abstract", | |
"async", | |
"modification", | |
"documentation", | |
"defaultLibrary" | |
], | |
"formats": [ | |
"relative" | |
], | |
"requests": { | |
"range": true, | |
"full": { | |
"delta": true | |
} | |
}, | |
"multilineTokenSupport": false, | |
"overlappingTokenSupport": false, | |
"serverCancelSupport": true, | |
"augmentsSyntaxTokens": true | |
}, | |
"linkedEditingRange": { | |
"dynamicRegistration": true | |
}, | |
"typeHierarchy": { | |
"dynamicRegistration": true | |
}, | |
"inlineValue": { | |
"dynamicRegistration": true | |
}, | |
"inlayHint": { | |
"dynamicRegistration": true, | |
"resolveSupport": { | |
"properties": [ | |
"tooltip", | |
"textEdits", | |
"label.tooltip", | |
"label.location", | |
"label.command" | |
] | |
} | |
}, | |
"diagnostic": { | |
"dynamicRegistration": true, | |
"relatedDocumentSupport": false | |
} | |
}, | |
"window": { | |
"showMessage": { | |
"messageActionItem": { | |
"additionalPropertiesSupport": true | |
} | |
}, | |
"showDocument": { | |
"support": true | |
}, | |
"workDoneProgress": true | |
}, | |
"general": { | |
"staleRequestSupport": { | |
"cancel": true, | |
"retryOnContentModified": [ | |
"textDocument/semanticTokens/full", | |
"textDocument/semanticTokens/range", | |
"textDocument/semanticTokens/full/delta" | |
] | |
}, | |
"regularExpressions": { | |
"engine": "ECMAScript", | |
"version": "ES2020" | |
}, | |
"markdown": { | |
"parser": "marked", | |
"version": "1.1.0" | |
}, | |
"positionEncodings": [ | |
"utf-16" | |
] | |
}, | |
"notebookDocument": { | |
"synchronization": { | |
"dynamicRegistration": true, | |
"executionSummarySupport": true | |
} | |
} | |
}, | |
"trace": "verbose", | |
"workspaceFolders": [ | |
{ | |
"uri": "file:///Users/a_user/code/test/ic", | |
"name": "ic" | |
} | |
] | |
} | |
[Trace - 8:11:48 AM] Received response 'initialize - (0)' in 191ms. | |
Result: { | |
"capabilities": { | |
"textDocumentSync": { | |
"openClose": true, | |
"change": 2, | |
"willSave": false, | |
"willSaveWaitUntil": false, | |
"save": { | |
"includeText": true | |
} | |
}, | |
"hoverProvider": true, | |
"completionProvider": { | |
"resolveProvider": false, | |
"triggerCharacters": [ | |
"." | |
] | |
}, | |
"definitionProvider": true | |
} | |
} | |
[Trace - 8:11:48 AM] Sending notification 'initialized'. | |
Params: {} | |
[Trace - 8:11:48 AM] Sending notification 'textDocument/didOpen'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/data/data.mo", | |
"languageId": "motoko", | |
"version": 2, | |
"text": "import HashMap \"mo:base/HashMap\";\nimport Text \"mo:base/Text\";\nimport Iter \"mo:base/Iter\";\nimport Result \"mo:base/Result\";\nimport Error \"mo:base/Error\";\n\nimport Types \"../types/types\";\nimport DataTypes \"./data.types\";\n\nimport Filter \"./data.filter\";\n\nimport Utils \"../utils/utils\";\n\nimport WalletUtils \"../utils/wallet.utils\";\n\nimport DataStore \"./data.store\";\n\n\nactor class DataBucket(owner : Types.UserId) = this {\n\n type UserId = Types.UserId;\n\n type Data = DataTypes.Data;\n type PutData = DataTypes.PutData;\n type DelData = DataTypes.DelData;\n\n type DataFilter = Filter.DataFilter;\n\n private stable let user : Types.UserId = owner;\n\n private let walletUtils : WalletUtils.WalletUtils = WalletUtils.WalletUtils();\n\n private let store : DataStore.DataStore = DataStore.DataStore();\n\n // Preserve the application state on upgrades\n private stable var entries : [(Text, Data)] = [];\n\n /**\n * Data\n */\n\n public shared query ({caller}) func get(key : Text) : async (?Data) {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to get the data.\");\n };\n\n let entry : ?Data = store.get(key);\n return entry;\n };\n\n public shared query ({caller}) func list(filter : ?DataFilter) : async [(Text, Data)] {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to list the data.\");\n };\n\n let results : [(Text, Data)] = store.entries(filter);\n return results;\n };\n\n /// @deprecated Backwards compatibility - function will be removed few weeks after the dapp has been updated to avoid issue with caches\n public shared ({caller}) func set(key : Text, data : Data) : async () {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to set data.\");\n };\n\n store.putNoChecks(key, data);\n };\n\n public shared ({caller}) func put(key : Text, data : PutData) : async (Data) {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to set data.\");\n };\n\n let result : Result.Result<Data, Text> = store.put(key, data);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok resultData) {\n return resultData;\n };\n };\n };\n\n /// @deprecated Backwards compatibility - function will be removed few weeks after the dapp has been updated to avoid issue with caches\n public shared ({caller}) func del(key : Text) : async () {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to delete the data.\");\n };\n\n let entry : ?Data = store.delNoChecks(key);\n };\n\n public shared ({caller}) func delete(key : Text, data : DelData) : async () {\n if (Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"User does not have the permission to delete the data.\");\n };\n\n let result : Result.Result<?Data, Text> = store.del(key, data);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok resultData) {};\n };\n };\n\n /**\n * Canister mgmt\n */\n\n public shared ({caller}) func transferFreezingThresholdCycles() : async () {\n if (not Utils.isManager(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not a manager.\");\n };\n\n await walletUtils.transferFreezingThresholdCycles(caller);\n };\n\n public shared query ({caller}) func cyclesBalance() : async (Nat) {\n if (not Utils.isManager(caller) and Utils.isPrincipalNotEqual(caller, user)) {\n throw Error.reject(\"No permission to read the balance of the cycles.\");\n };\n\n return walletUtils.cyclesBalance();\n };\n\n system func preupgrade() {\n entries := Iter.toArray(store.preupgrade().entries());\n };\n\n system func postupgrade() {\n store.postupgrade(entries);\n entries := [];\n };\n\n};\n" | |
} | |
} | |
[Trace - 8:11:48 AM] Sending notification 'textDocument/didOpen'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/feed/post.types.mo", | |
"languageId": "motoko", | |
"version": 2, | |
"text": "import Text \"mo:base/Text\";\nimport Time \"mo:base/Time\";\nimport Blob \"mo:base/Blob\";\n\nimport IC \"../types/ic.types\";\n\nimport ProposalTypes \"./proposal.types\";\n\n\nmodule {\n\n type Proposal = ProposalTypes.Proposal;\n\n public type Post = Proposal and {\n created_at : Time.Time;\n updated_at : Time.Time;\n };\n\n};\n" | |
} | |
} | |
[Trace - 8:11:48 AM] Sending notification 'textDocument/didOpen'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo", | |
"languageId": "motoko", | |
"version": 101, | |
"text": "import Cycles \"mo:base/ExperimentalCycles\";\nimport Error \"mo:base/Error\";\nimport HashMap \"mo:base/HashMap\";\nimport Iter \"mo:base/Iter\";\nimport Option \"mo:base/Option\";\nimport Principal \"mo:base/Principal\";\nimport Text \"mo:base/Text\";\nimport Result \"mo:base/Result\";\nimport Array \"mo:base/Array\";\n\nimport Types \"../types/types\";\n\nimport CanisterUtils \"../utils/canister.utils\";\nimport WalletUtils \"../utils/wallet.utils\";\n\nimport BucketTypes \"./bucket.types\";\nimport BucketStore \"./bucket.store\";\n\nimport DataBucket \"../data/data\";\nimport StorageBucket \"../storage/storage\";\n\nimport Utils \"../utils/utils\";\n\nactor Manager {\n private type UserId = Types.UserId;\n\n private type DataBucket = DataBucket.DataBucket;\n private type StorageBucket = StorageBucket.StorageBucket;\n\n private type Bucket = BucketTypes.Bucket;\n private type BucketId = BucketTypes.BucketId;\n\n private let walletUtils : WalletUtils.WalletUtils = WalletUtils.WalletUtils();\n private let canisterUtils : CanisterUtils.CanisterUtils = CanisterUtils.CanisterUtils();\n\n let dataStore : BucketStore.BucketStore = BucketStore.BucketStore();\n let storagesStore : BucketStore.BucketStore = BucketStore.BucketStore();\n\n // Preserve the application state on upgrades\n private stable var data : [(Principal, BucketTypes.Bucket)] = [];\n private stable var storages : [(Principal, BucketTypes.Bucket)] = [];\n\n /**\n * Data\n */\n\n public shared ({caller}) func initData() : async (Bucket) {\n let x : [Nat8] = [1];\n let y = Array.append(x, [2]);\n return await initBucket(caller, dataStore, initNewDataBucket);\n };\n\n private func initNewDataBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : DataBucket = await DataBucket.DataBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getData() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = dataStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delData() : async (Bool) {\n return await delBucket(caller, dataStore);\n };\n\n /**\n * Storages\n */\n\n public shared ({caller}) func initStorage() : async (Bucket) {\n return await initBucket(caller, storagesStore, initNewStorageBucket);\n };\n\n private func initNewStorageBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : StorageBucket = await StorageBucket.StorageBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getStorage() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = storagesStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delStorage() : async (Bool) {\n return await delBucket(caller, storagesStore);\n };\n\n /**\n * Buckets\n */\n\n private func initBucket(\n caller : Principal,\n store : BucketStore.BucketStore,\n initNewBucket : (manager : Principal, user : UserId) -> async (Principal)\n ) : async (Bucket) {\n let self : Principal = Principal.fromActor(Manager);\n\n let result : Result.Result<Bucket, Text> = await store.init(self, caller, initNewBucket);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n return bucket;\n };\n };\n };\n\n private func delBucket(caller : Principal, store : BucketStore.BucketStore) : async (Bool) {\n let result : Result.Result<?Bucket, Text> = await store.deleteBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n let exists : Bool = Option.isSome(bucket);\n return exists;\n };\n };\n };\n\n /**\n * Utilities\n */\n\n // is a canister id known by the manager?\n public shared func knownBucket(bucketId : Text, store : Text) : async (Bool) {\n if (Text.equal(store, \"data\")) {\n return dataStore.exists(Principal.fromText(bucketId));\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.exists(Principal.fromText(bucketId));\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n /**\n * Admin: restricted for manager\n */\n\n public shared query ({caller}) func list(store : Text) : async [Bucket] {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n if (Text.equal(store, \"data\")) {\n return dataStore.entries();\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.entries();\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n public shared ({caller}) func installCode(canisterId : Principal, owner : Blob, wasmModule : Blob) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await canisterUtils.installCode(canisterId, owner, wasmModule);\n };\n\n public shared ({caller}) func transferCycles(canisterId : Principal, amount : Nat) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await walletUtils.transferCycles(canisterId, amount);\n };\n\n public shared query ({caller}) func cyclesBalance() : async (Nat) {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n return walletUtils.cyclesBalance();\n };\n\n /**\n * Stable memory for upgrade\n */\n\n system func preupgrade() {\n data := Iter.toArray(dataStore.preupgrade().entries());\n storages := Iter.toArray(storagesStore.preupgrade().entries());\n };\n\n system func postupgrade() {\n dataStore.postupgrade(data);\n data := [];\n\n storagesStore.postupgrade(storages);\n storages := [];\n };\n};\n" | |
} | |
} | |
[Trace - 8:11:48 AM] Sending notification 'workspace/didChangeConfiguration'. | |
Params: { | |
"settings": { | |
"motoko": { | |
"dfx": "dfx", | |
"legacyDfxSupport": true, | |
"maxNumberOfProblems": 1000, | |
"hideWarningRegex": "", | |
"trace": { | |
"server": "verbose" | |
}, | |
"canister": "", | |
"standaloneBinary": "mo-ide", | |
"standaloneArguments": "", | |
"formatter": "none" | |
} | |
} | |
} | |
[Trace - 8:11:48 AM] Received notification 'window/showMessage'. | |
Params: { | |
"type": 3, | |
"message": "Motoko LS initialized" | |
} | |
[Trace - 8:11:53 AM] Sending notification 'textDocument/didChange'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo", | |
"version": 102 | |
}, | |
"contentChanges": [ | |
{ | |
"range": { | |
"start": { | |
"line": 144, | |
"character": 0 | |
}, | |
"end": { | |
"line": 144, | |
"character": 0 | |
} | |
}, | |
"rangeLength": 0, | |
"text": "\n" | |
} | |
] | |
} | |
[Trace - 8:11:53 AM] Sending notification 'textDocument/didSave'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"text": "import Cycles \"mo:base/ExperimentalCycles\";\nimport Error \"mo:base/Error\";\nimport HashMap \"mo:base/HashMap\";\nimport Iter \"mo:base/Iter\";\nimport Option \"mo:base/Option\";\nimport Principal \"mo:base/Principal\";\nimport Text \"mo:base/Text\";\nimport Result \"mo:base/Result\";\nimport Array \"mo:base/Array\";\n\nimport Types \"../types/types\";\n\nimport CanisterUtils \"../utils/canister.utils\";\nimport WalletUtils \"../utils/wallet.utils\";\n\nimport BucketTypes \"./bucket.types\";\nimport BucketStore \"./bucket.store\";\n\nimport DataBucket \"../data/data\";\nimport StorageBucket \"../storage/storage\";\n\nimport Utils \"../utils/utils\";\n\nactor Manager {\n private type UserId = Types.UserId;\n\n private type DataBucket = DataBucket.DataBucket;\n private type StorageBucket = StorageBucket.StorageBucket;\n\n private type Bucket = BucketTypes.Bucket;\n private type BucketId = BucketTypes.BucketId;\n\n private let walletUtils : WalletUtils.WalletUtils = WalletUtils.WalletUtils();\n private let canisterUtils : CanisterUtils.CanisterUtils = CanisterUtils.CanisterUtils();\n\n let dataStore : BucketStore.BucketStore = BucketStore.BucketStore();\n let storagesStore : BucketStore.BucketStore = BucketStore.BucketStore();\n\n // Preserve the application state on upgrades\n private stable var data : [(Principal, BucketTypes.Bucket)] = [];\n private stable var storages : [(Principal, BucketTypes.Bucket)] = [];\n\n /**\n * Data\n */\n\n public shared ({caller}) func initData() : async (Bucket) {\n let x : [Nat8] = [1];\n let y = Array.append(x, [2]);\n return await initBucket(caller, dataStore, initNewDataBucket);\n };\n\n private func initNewDataBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : DataBucket = await DataBucket.DataBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getData() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = dataStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delData() : async (Bool) {\n return await delBucket(caller, dataStore);\n };\n\n /**\n * Storages\n */\n\n public shared ({caller}) func initStorage() : async (Bucket) {\n return await initBucket(caller, storagesStore, initNewStorageBucket);\n };\n\n private func initNewStorageBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : StorageBucket = await StorageBucket.StorageBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getStorage() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = storagesStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delStorage() : async (Bool) {\n return await delBucket(caller, storagesStore);\n };\n\n /**\n * Buckets\n */\n\n private func initBucket(\n caller : Principal,\n store : BucketStore.BucketStore,\n initNewBucket : (manager : Principal, user : UserId) -> async (Principal)\n ) : async (Bucket) {\n let self : Principal = Principal.fromActor(Manager);\n\n\n let result : Result.Result<Bucket, Text> = await store.init(self, caller, initNewBucket);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n return bucket;\n };\n };\n };\n\n private func delBucket(caller : Principal, store : BucketStore.BucketStore) : async (Bool) {\n let result : Result.Result<?Bucket, Text> = await store.deleteBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n let exists : Bool = Option.isSome(bucket);\n return exists;\n };\n };\n };\n\n /**\n * Utilities\n */\n\n // is a canister id known by the manager?\n public shared func knownBucket(bucketId : Text, store : Text) : async (Bool) {\n if (Text.equal(store, \"data\")) {\n return dataStore.exists(Principal.fromText(bucketId));\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.exists(Principal.fromText(bucketId));\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n /**\n * Admin: restricted for manager\n */\n\n public shared query ({caller}) func list(store : Text) : async [Bucket] {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n if (Text.equal(store, \"data\")) {\n return dataStore.entries();\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.entries();\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n public shared ({caller}) func installCode(canisterId : Principal, owner : Blob, wasmModule : Blob) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await canisterUtils.installCode(canisterId, owner, wasmModule);\n };\n\n public shared ({caller}) func transferCycles(canisterId : Principal, amount : Nat) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await walletUtils.transferCycles(canisterId, amount);\n };\n\n public shared query ({caller}) func cyclesBalance() : async (Nat) {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n return walletUtils.cyclesBalance();\n };\n\n /**\n * Stable memory for upgrade\n */\n\n system func preupgrade() {\n data := Iter.toArray(dataStore.preupgrade().entries());\n storages := Iter.toArray(storagesStore.preupgrade().entries());\n };\n\n system func postupgrade() {\n dataStore.postupgrade(data);\n data := [];\n\n storagesStore.postupgrade(storages);\n storages := [];\n };\n};\n" | |
} | |
[Trace - 8:11:54 AM] Sending notification 'workspace/didChangeWatchedFiles'. | |
Params: { | |
"changes": [ | |
{ | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo", | |
"type": 2 | |
} | |
] | |
} | |
[Trace - 8:12:06 AM] Sending request 'textDocument/hover - (1)'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"position": { | |
"line": 47, | |
"character": 24 | |
} | |
} | |
[Trace - 8:12:06 AM] Received response 'textDocument/hover - (1)' in 4ms. | |
No result returned. | |
[Trace - 8:12:07 AM] Sending request 'textDocument/hover - (2)'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"position": { | |
"line": 49, | |
"character": 30 | |
} | |
} | |
[Trace - 8:12:07 AM] Received response 'textDocument/hover - (2)' in 5ms. | |
No result returned. | |
[Trace - 8:12:08 AM] Sending request 'textDocument/hover - (3)'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"position": { | |
"line": 49, | |
"character": 30 | |
} | |
} | |
[Trace - 8:12:08 AM] Received response 'textDocument/hover - (3)' in 7ms. | |
No result returned. | |
[Trace - 8:12:08 AM] Sending request 'textDocument/hover - (4)'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"position": { | |
"line": 49, | |
"character": 30 | |
} | |
} | |
[Trace - 8:12:08 AM] Received response 'textDocument/hover - (4)' in 19ms. | |
No result returned. | |
[Trace - 8:12:10 AM] Sending notification 'textDocument/didChange'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo", | |
"version": 103 | |
}, | |
"contentChanges": [ | |
{ | |
"range": { | |
"start": { | |
"line": 45, | |
"character": 0 | |
}, | |
"end": { | |
"line": 45, | |
"character": 0 | |
} | |
}, | |
"rangeLength": 0, | |
"text": "\n" | |
} | |
] | |
} | |
[Trace - 8:12:11 AM] Sending notification 'textDocument/didSave'. | |
Params: { | |
"textDocument": { | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo" | |
}, | |
"text": "import Cycles \"mo:base/ExperimentalCycles\";\nimport Error \"mo:base/Error\";\nimport HashMap \"mo:base/HashMap\";\nimport Iter \"mo:base/Iter\";\nimport Option \"mo:base/Option\";\nimport Principal \"mo:base/Principal\";\nimport Text \"mo:base/Text\";\nimport Result \"mo:base/Result\";\nimport Array \"mo:base/Array\";\n\nimport Types \"../types/types\";\n\nimport CanisterUtils \"../utils/canister.utils\";\nimport WalletUtils \"../utils/wallet.utils\";\n\nimport BucketTypes \"./bucket.types\";\nimport BucketStore \"./bucket.store\";\n\nimport DataBucket \"../data/data\";\nimport StorageBucket \"../storage/storage\";\n\nimport Utils \"../utils/utils\";\n\nactor Manager {\n private type UserId = Types.UserId;\n\n private type DataBucket = DataBucket.DataBucket;\n private type StorageBucket = StorageBucket.StorageBucket;\n\n private type Bucket = BucketTypes.Bucket;\n private type BucketId = BucketTypes.BucketId;\n\n private let walletUtils : WalletUtils.WalletUtils = WalletUtils.WalletUtils();\n private let canisterUtils : CanisterUtils.CanisterUtils = CanisterUtils.CanisterUtils();\n\n let dataStore : BucketStore.BucketStore = BucketStore.BucketStore();\n let storagesStore : BucketStore.BucketStore = BucketStore.BucketStore();\n\n // Preserve the application state on upgrades\n private stable var data : [(Principal, BucketTypes.Bucket)] = [];\n private stable var storages : [(Principal, BucketTypes.Bucket)] = [];\n\n /**\n * Data\n */\n\n\n public shared ({caller}) func initData() : async (Bucket) {\n let x : [Nat8] = [1];\n let y = Array.append(x, [2]);\n return await initBucket(caller, dataStore, initNewDataBucket);\n };\n\n private func initNewDataBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : DataBucket = await DataBucket.DataBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getData() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = dataStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delData() : async (Bool) {\n return await delBucket(caller, dataStore);\n };\n\n /**\n * Storages\n */\n\n public shared ({caller}) func initStorage() : async (Bucket) {\n return await initBucket(caller, storagesStore, initNewStorageBucket);\n };\n\n private func initNewStorageBucket(manager : Principal, user : UserId) : async (Principal) {\n Cycles.add(1_000_000_000_000);\n let b : StorageBucket = await StorageBucket.StorageBucket(user);\n\n let canisterId : Principal = Principal.fromActor(b);\n\n await canisterUtils.updateSettings(canisterId, manager);\n\n return canisterId;\n };\n\n public shared query ({caller}) func getStorage() : async ?Bucket {\n let result : Result.Result<?Bucket, Text> = storagesStore.getBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n switch (bucket) {\n case (?bucket) {\n return ?bucket;\n };\n case null {\n // We do not throw a \"Not found error\" here.\n // For performance reason, in web app we first query if the bucket exists and then if not, we init it.\n return null;\n };\n };\n };\n };\n };\n\n public shared ({caller}) func delStorage() : async (Bool) {\n return await delBucket(caller, storagesStore);\n };\n\n /**\n * Buckets\n */\n\n private func initBucket(\n caller : Principal,\n store : BucketStore.BucketStore,\n initNewBucket : (manager : Principal, user : UserId) -> async (Principal)\n ) : async (Bucket) {\n let self : Principal = Principal.fromActor(Manager);\n\n\n let result : Result.Result<Bucket, Text> = await store.init(self, caller, initNewBucket);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n return bucket;\n };\n };\n };\n\n private func delBucket(caller : Principal, store : BucketStore.BucketStore) : async (Bool) {\n let result : Result.Result<?Bucket, Text> = await store.deleteBucket(caller);\n\n switch (result) {\n case (#err error) {\n throw Error.reject(error);\n };\n case (#ok bucket) {\n let exists : Bool = Option.isSome(bucket);\n return exists;\n };\n };\n };\n\n /**\n * Utilities\n */\n\n // is a canister id known by the manager?\n public shared func knownBucket(bucketId : Text, store : Text) : async (Bool) {\n if (Text.equal(store, \"data\")) {\n return dataStore.exists(Principal.fromText(bucketId));\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.exists(Principal.fromText(bucketId));\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n /**\n * Admin: restricted for manager\n */\n\n public shared query ({caller}) func list(store : Text) : async [Bucket] {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n if (Text.equal(store, \"data\")) {\n return dataStore.entries();\n };\n\n if (Text.equal(store, \"storage\")) {\n return storagesStore.entries();\n };\n\n throw Error.reject(\"Type of store not supported\");\n };\n\n public shared ({caller}) func installCode(canisterId : Principal, owner : Blob, wasmModule : Blob) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await canisterUtils.installCode(canisterId, owner, wasmModule);\n };\n\n public shared ({caller}) func transferCycles(canisterId : Principal, amount : Nat) : async () {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n await walletUtils.transferCycles(canisterId, amount);\n };\n\n public shared query ({caller}) func cyclesBalance() : async (Nat) {\n if (not Utils.isAdmin(caller)) {\n throw Error.reject(\"Unauthorized access. Caller is not an admin. \" # Principal.toText(caller));\n };\n\n return walletUtils.cyclesBalance();\n };\n\n /**\n * Stable memory for upgrade\n */\n\n system func preupgrade() {\n data := Iter.toArray(dataStore.preupgrade().entries());\n storages := Iter.toArray(storagesStore.preupgrade().entries());\n };\n\n system func postupgrade() {\n dataStore.postupgrade(data);\n data := [];\n\n storagesStore.postupgrade(storages);\n storages := [];\n };\n};\n" | |
} | |
[Trace - 8:12:11 AM] Sending notification 'workspace/didChangeWatchedFiles'. | |
Params: { | |
"changes": [ | |
{ | |
"uri": "file:///Users/a_user/code/test/ic/canisters/src/manager/manager.mo", | |
"type": 2 | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment