-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
68 lines (60 loc) · 1.91 KB
/
index.html
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Flow Wasm example</title>
</head>
<body>
<div id="app"></div>
<script src="./dist/wasm_exec.js"></script>
<script src="https://unpkg.com/@isomorphic-git/lightning-fs"></script>
<script src="https://unpkg.com/isomorphic-git"></script>
<script type="module">
import {
FclGateway,
FlowWasm,
LightningFileSystem,
WindowPrompter,
} from "./dist/flow-wasm.mjs";
import http from "https://unpkg.com/isomorphic-git@beta/http/web/index.js";
const fs = new LightningFS("fs");
const dir = "/flow-nft-scaffold-4";
try {
await fs.promises.stat(dir);
} catch (rootDirNotFoundError) {
// Stat throws an error if directory doesn't exist
await git.clone({
fs,
http,
dir,
url: "https://github.com/onflowser/flow-nft-scaffold",
corsProxy: "https://cors.isomorphic-git.org",
ref: "main",
singleBranch: true,
depth: 10,
});
}
window.mainnet = new FclGateway("mainnet");
const goRuntime = new Go();
const wasmModule = await WebAssembly.instantiateStreaming(
fetch("./dist/flow.wasm"),
goRuntime.importObject,
);
const flowWasm = new FlowWasm({
global: window,
flowWasm: wasmModule,
fileSystem: new LightningFileSystem(fs, dir),
prompter: new WindowPrompter(),
gateways: {
mainnet: new FclGateway("mainnet"),
previewnet: new FclGateway("previewnet"),
testnet: new FclGateway("testnet"),
},
});
window.flowWasm = flowWasm;
await flowWasm.run(goRuntime);
</script>
</body>
</html>