MCPcopy Create free account
hub / github.com/B3Pay/B3Wallet / load

Function load

scripts/load-wasm.system.ts:75–107  ·  view source on GitHub ↗
(appId: string, reload: boolean)

Source from the content-addressed store, hash-verified

73}
74
75export const load = async (appId: string, reload: boolean) => {
76 const version = await readVersion(appId)
77
78 if (!version) {
79 console.error("Version for wasm cannot be read.")
80 return
81 }
82
83 console.log(`Loading ${appId} wasmModule v${version} in SystemCanister.`)
84
85 const { wasmModule, wasm_hash, wasm_size } = await loadWasmFile(appId)
86 console.log("Wasm size:", wasm_size, "hash:", hashToHex(wasm_hash))
87
88 if (reload) {
89 try {
90 await callSystemMethod("remove_release", wasm_hash)
91 } catch (e) {
92 console.error("Error removing release:", appId, version)
93 }
94 }
95
96 const release = await addRelease(appId, version, wasm_hash, wasm_size)
97
98 console.log("Release added:", release)
99
100 await loadWasmChunk(wasm_hash, wasmModule)
101
102 console.log("Wasm loaded.")
103
104 const app = await callSystemMethod("get_app", appId)
105
106 console.log("App:", app)
107}
108
109const loader = async (appId: AvailableAppIds, reload: boolean) => {
110 const app = await callSystemMethod("get_app", appId)

Callers 1

loaderFunction · 0.70

Calls 5

readVersionFunction · 0.90
loadWasmFileFunction · 0.90
hashToHexFunction · 0.90
addReleaseFunction · 0.85
loadWasmChunkFunction · 0.70

Tested by

no test coverage detected