ic-mops 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/RELEASE.md +198 -0
- package/bundle/cli.tgz +0 -0
- package/check-requirements.ts +3 -8
- package/cli.ts +94 -11
- package/commands/bench/bench-canister.mo +17 -6
- package/commands/bench.ts +13 -16
- package/commands/build.ts +5 -6
- package/commands/check.ts +121 -0
- package/commands/format.ts +3 -18
- package/commands/lint.ts +92 -0
- package/commands/sync.ts +2 -8
- package/commands/test/test.ts +10 -20
- package/commands/toolchain/index.ts +21 -8
- package/commands/toolchain/lintoko.ts +54 -0
- package/commands/toolchain/toolchain-utils.ts +2 -0
- package/commands/watch/error-checker.ts +8 -2
- package/commands/watch/warning-checker.ts +8 -2
- package/constants.ts +23 -0
- package/dist/check-requirements.js +3 -8
- package/dist/cli.js +73 -11
- package/dist/commands/bench/bench-canister.mo +17 -6
- package/dist/commands/bench.js +7 -15
- package/dist/commands/build.js +5 -6
- package/dist/commands/check.d.ts +6 -0
- package/dist/commands/check.js +82 -0
- package/dist/commands/format.js +3 -16
- package/dist/commands/lint.d.ts +7 -0
- package/dist/commands/lint.js +69 -0
- package/dist/commands/sync.js +2 -7
- package/dist/commands/test/test.js +10 -18
- package/dist/commands/toolchain/index.d.ts +2 -2
- package/dist/commands/toolchain/index.js +18 -7
- package/dist/commands/toolchain/lintoko.d.ts +8 -0
- package/dist/commands/toolchain/lintoko.js +36 -0
- package/dist/commands/toolchain/toolchain-utils.d.ts +1 -0
- package/dist/commands/toolchain/toolchain-utils.js +1 -0
- package/dist/commands/watch/error-checker.js +8 -2
- package/dist/commands/watch/warning-checker.js +8 -2
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +21 -0
- package/dist/environments/nodejs/cli.js +6 -1
- package/dist/error.d.ts +1 -1
- package/dist/helpers/autofix-motoko.d.ts +26 -0
- package/dist/helpers/autofix-motoko.js +150 -0
- package/dist/helpers/get-moc-version.d.ts +2 -0
- package/dist/helpers/get-moc-version.js +10 -1
- package/dist/mops.d.ts +1 -0
- package/dist/mops.js +12 -1
- package/dist/package.json +3 -2
- package/dist/tests/build-no-dfx.test.d.ts +1 -0
- package/dist/tests/build-no-dfx.test.js +9 -0
- package/dist/tests/build.test.d.ts +1 -0
- package/dist/tests/build.test.js +18 -0
- package/dist/tests/check-candid.test.d.ts +1 -0
- package/dist/tests/check-candid.test.js +20 -0
- package/dist/tests/check-fix.test.d.ts +1 -0
- package/dist/tests/check-fix.test.js +89 -0
- package/dist/tests/check.test.d.ts +1 -0
- package/dist/tests/check.test.js +37 -0
- package/dist/tests/cli.test.js +4 -57
- package/dist/tests/helpers.d.ts +22 -0
- package/dist/tests/helpers.js +43 -0
- package/dist/tests/lint.test.d.ts +1 -0
- package/dist/tests/lint.test.js +15 -0
- package/dist/tests/moc-args.test.d.ts +1 -0
- package/dist/tests/moc-args.test.js +17 -0
- package/dist/tests/toolchain.test.d.ts +1 -0
- package/dist/tests/toolchain.test.js +11 -0
- package/dist/types.d.ts +8 -1
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/environments/nodejs/cli.ts +7 -1
- package/error.ts +1 -1
- package/helpers/autofix-motoko.ts +240 -0
- package/helpers/get-moc-version.ts +12 -1
- package/mops.ts +15 -1
- package/package.json +3 -2
- package/tests/__snapshots__/build-no-dfx.test.ts.snap +11 -0
- package/tests/__snapshots__/build.test.ts.snap +77 -0
- package/tests/__snapshots__/check-candid.test.ts.snap +73 -0
- package/tests/__snapshots__/check-fix.test.ts.snap +261 -0
- package/tests/__snapshots__/check.test.ts.snap +81 -0
- package/tests/__snapshots__/lint.test.ts.snap +78 -0
- package/tests/build/no-dfx/mops.toml +5 -0
- package/tests/build/no-dfx/src/Main.mo +5 -0
- package/tests/build-no-dfx.test.ts +10 -0
- package/tests/build.test.ts +24 -0
- package/tests/check/error/Error.mo +7 -0
- package/tests/check/error/mops.toml +2 -0
- package/tests/check/fix/M0223.mo +11 -0
- package/tests/check/fix/M0236.mo +11 -0
- package/tests/check/fix/M0237.mo +11 -0
- package/tests/check/fix/Ok.mo +7 -0
- package/tests/check/fix/edit-suggestions.mo +143 -0
- package/tests/check/fix/mops.toml +5 -0
- package/tests/check/fix/overlapping.mo +10 -0
- package/tests/check/fix/transitive-lib.mo +9 -0
- package/tests/check/fix/transitive-main.mo +9 -0
- package/tests/check/moc-args/Warning.mo +5 -0
- package/tests/check/moc-args/mops.toml +2 -0
- package/tests/check/success/Ok.mo +5 -0
- package/tests/check/success/Warning.mo +5 -0
- package/tests/check/success/mops.toml +2 -0
- package/tests/check-candid.test.ts +22 -0
- package/tests/check-fix.test.ts +134 -0
- package/tests/check.test.ts +51 -0
- package/tests/cli.test.ts +4 -74
- package/tests/helpers.ts +58 -0
- package/tests/lint/lints/no-bool-switch.toml +9 -0
- package/tests/lint/mops.toml +4 -0
- package/tests/lint/src/NoBoolSwitch.mo +8 -0
- package/tests/lint/src/Ok.mo +5 -0
- package/tests/lint.test.ts +17 -0
- package/tests/moc-args.test.ts +19 -0
- package/tests/toolchain/mock +2 -0
- package/tests/toolchain/mops.toml +2 -0
- package/tests/toolchain.test.ts +12 -0
- package/types.ts +8 -1
- package/wasm/Cargo.lock +101 -54
- package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/.DS_Store +0 -0
- package/bundle/bench/bench-canister.mo +0 -121
- package/bundle/bench/user-bench.mo +0 -10
- package/bundle/bin/moc-wrapper.sh +0 -40
- package/bundle/bin/mops.js +0 -3
- package/bundle/cli.js +0 -2144
- package/bundle/declarations/bench/bench.did +0 -30
- package/bundle/declarations/bench/bench.did.d.ts +0 -33
- package/bundle/declarations/bench/bench.did.js +0 -30
- package/bundle/declarations/bench/index.d.ts +0 -50
- package/bundle/declarations/bench/index.js +0 -40
- package/bundle/declarations/main/index.d.ts +0 -50
- package/bundle/declarations/main/index.js +0 -40
- package/bundle/declarations/main/main.did +0 -428
- package/bundle/declarations/main/main.did.d.ts +0 -348
- package/bundle/declarations/main/main.did.js +0 -406
- package/bundle/declarations/storage/index.d.ts +0 -50
- package/bundle/declarations/storage/index.js +0 -30
- package/bundle/declarations/storage/storage.did +0 -46
- package/bundle/declarations/storage/storage.did.d.ts +0 -40
- package/bundle/declarations/storage/storage.did.js +0 -38
- package/bundle/package.json +0 -36
- package/bundle/templates/README.md +0 -13
- package/bundle/templates/licenses/Apache-2.0 +0 -202
- package/bundle/templates/licenses/Apache-2.0-NOTICE +0 -13
- package/bundle/templates/licenses/MIT +0 -21
- package/bundle/templates/mops-publish.yml +0 -17
- package/bundle/templates/mops-test.yml +0 -24
- package/bundle/templates/src/lib.mo +0 -15
- package/bundle/templates/test/lib.test.mo +0 -4
- package/bundle/wasm_bg.wasm +0 -0
- package/bundle/xhr-sync-worker.js +0 -59
- package/dist/wasm/pkg/bundler/package.json +0 -20
- package/dist/wasm/pkg/bundler/wasm.d.ts +0 -3
- package/dist/wasm/pkg/bundler/wasm.js +0 -5
- package/dist/wasm/pkg/bundler/wasm_bg.js +0 -93
- package/dist/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/bundler/wasm_bg.wasm.d.ts +0 -8
- package/tests/__snapshots__/cli.test.ts.snap +0 -202
- package/tests/build/success/.dfx/local/canister_ids.json +0 -17
- package/tests/build/success/.dfx/local/canisters/bar/bar.did +0 -3
- package/tests/build/success/.dfx/local/canisters/bar/bar.most +0 -4
- package/tests/build/success/.dfx/local/canisters/bar/bar.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/bar/constructor.did +0 -3
- package/tests/build/success/.dfx/local/canisters/bar/index.js +0 -42
- package/tests/build/success/.dfx/local/canisters/bar/init_args.txt +0 -1
- package/tests/build/success/.dfx/local/canisters/bar/service.did +0 -3
- package/tests/build/success/.dfx/local/canisters/bar/service.did.d.ts +0 -7
- package/tests/build/success/.dfx/local/canisters/bar/service.did.js +0 -4
- package/tests/build/success/.dfx/local/canisters/foo/constructor.did +0 -3
- package/tests/build/success/.dfx/local/canisters/foo/foo.did +0 -3
- package/tests/build/success/.dfx/local/canisters/foo/foo.most +0 -4
- package/tests/build/success/.dfx/local/canisters/foo/foo.wasm +0 -0
- package/tests/build/success/.dfx/local/canisters/foo/index.js +0 -42
- package/tests/build/success/.dfx/local/canisters/foo/init_args.txt +0 -1
- package/tests/build/success/.dfx/local/canisters/foo/service.did +0 -3
- package/tests/build/success/.dfx/local/canisters/foo/service.did.d.ts +0 -7
- package/tests/build/success/.dfx/local/canisters/foo/service.did.js +0 -4
- package/tests/build/success/.dfx/local/lsp/ucwa4-rx777-77774-qaada-cai.did +0 -3
- package/tests/build/success/.dfx/local/lsp/ulvla-h7777-77774-qaacq-cai.did +0 -3
- package/tests/build/success/.dfx/local/network-id +0 -4
- package/wasm/pkg/bundler/package.json +0 -20
- package/wasm/pkg/bundler/wasm.d.ts +0 -3
- package/wasm/pkg/bundler/wasm.js +0 -5
- package/wasm/pkg/bundler/wasm_bg.js +0 -93
- package/wasm/pkg/bundler/wasm_bg.wasm +0 -0
- package/wasm/pkg/bundler/wasm_bg.wasm.d.ts +0 -8
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
|
2
|
-
|
|
3
|
-
exports[`mops build error 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"exitCode": 0,
|
|
6
|
-
"stderr": "",
|
|
7
|
-
"stdout": "
|
|
8
|
-
> ic-mops@2.0.1 mops
|
|
9
|
-
> tsx ./environments/nodejs/cli build foo
|
|
10
|
-
|
|
11
|
-
build canister foo
|
|
12
|
-
|
|
13
|
-
✓ Built 1 canister successfully",
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
exports[`mops build error 2`] = `
|
|
18
|
-
{
|
|
19
|
-
"exitCode": 1,
|
|
20
|
-
"stderr": "Candid compatibility check failed for canister bar",
|
|
21
|
-
"stdout": "
|
|
22
|
-
> ic-mops@2.0.1 mops
|
|
23
|
-
> tsx ./environments/nodejs/cli build bar
|
|
24
|
-
|
|
25
|
-
build canister bar",
|
|
26
|
-
}
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
exports[`mops build error 3`] = `
|
|
30
|
-
{
|
|
31
|
-
"exitCode": 1,
|
|
32
|
-
"stderr": "Candid compatibility check failed for canister bar",
|
|
33
|
-
"stdout": "
|
|
34
|
-
> ic-mops@2.0.1 mops
|
|
35
|
-
> tsx ./environments/nodejs/cli build foo bar
|
|
36
|
-
|
|
37
|
-
build canister foo
|
|
38
|
-
build canister bar",
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
exports[`mops build success 1`] = `
|
|
43
|
-
{
|
|
44
|
-
"exitCode": 0,
|
|
45
|
-
"stderr": "",
|
|
46
|
-
"stdout": "
|
|
47
|
-
> ic-mops@2.0.1 mops
|
|
48
|
-
> tsx ./environments/nodejs/cli build
|
|
49
|
-
|
|
50
|
-
build canister foo
|
|
51
|
-
build canister bar
|
|
52
|
-
|
|
53
|
-
✓ Built 2 canisters successfully",
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
exports[`mops build success 2`] = `
|
|
58
|
-
{
|
|
59
|
-
"exitCode": 0,
|
|
60
|
-
"stderr": "",
|
|
61
|
-
"stdout": "
|
|
62
|
-
> ic-mops@2.0.1 mops
|
|
63
|
-
> tsx ./environments/nodejs/cli build foo
|
|
64
|
-
|
|
65
|
-
build canister foo
|
|
66
|
-
|
|
67
|
-
✓ Built 1 canister successfully",
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
|
|
71
|
-
exports[`mops build success 3`] = `
|
|
72
|
-
{
|
|
73
|
-
"exitCode": 0,
|
|
74
|
-
"stderr": "",
|
|
75
|
-
"stdout": "
|
|
76
|
-
> ic-mops@2.0.1 mops
|
|
77
|
-
> tsx ./environments/nodejs/cli build bar
|
|
78
|
-
|
|
79
|
-
build canister bar
|
|
80
|
-
|
|
81
|
-
✓ Built 1 canister successfully",
|
|
82
|
-
}
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
|
-
exports[`mops build success 4`] = `
|
|
86
|
-
{
|
|
87
|
-
"exitCode": 0,
|
|
88
|
-
"stderr": "",
|
|
89
|
-
"stdout": "
|
|
90
|
-
> ic-mops@2.0.1 mops
|
|
91
|
-
> tsx ./environments/nodejs/cli build foo bar
|
|
92
|
-
|
|
93
|
-
build canister foo
|
|
94
|
-
build canister bar
|
|
95
|
-
|
|
96
|
-
✓ Built 2 canisters successfully",
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
exports[`mops check-candid 1`] = `
|
|
101
|
-
{
|
|
102
|
-
"exitCode": 0,
|
|
103
|
-
"stderr": "",
|
|
104
|
-
"stdout": "
|
|
105
|
-
> ic-mops@2.0.1 mops
|
|
106
|
-
> tsx ./environments/nodejs/cli check-candid a.did a.did
|
|
107
|
-
|
|
108
|
-
✓ Candid compatibility check passed",
|
|
109
|
-
}
|
|
110
|
-
`;
|
|
111
|
-
|
|
112
|
-
exports[`mops check-candid 2`] = `
|
|
113
|
-
{
|
|
114
|
-
"exitCode": 0,
|
|
115
|
-
"stderr": "",
|
|
116
|
-
"stdout": "
|
|
117
|
-
> ic-mops@2.0.1 mops
|
|
118
|
-
> tsx ./environments/nodejs/cli check-candid b.did b.did
|
|
119
|
-
|
|
120
|
-
✓ Candid compatibility check passed",
|
|
121
|
-
}
|
|
122
|
-
`;
|
|
123
|
-
|
|
124
|
-
exports[`mops check-candid 3`] = `
|
|
125
|
-
{
|
|
126
|
-
"exitCode": 0,
|
|
127
|
-
"stderr": "",
|
|
128
|
-
"stdout": "
|
|
129
|
-
> ic-mops@2.0.1 mops
|
|
130
|
-
> tsx ./environments/nodejs/cli check-candid c.did c.did
|
|
131
|
-
|
|
132
|
-
✓ Candid compatibility check passed",
|
|
133
|
-
}
|
|
134
|
-
`;
|
|
135
|
-
|
|
136
|
-
exports[`mops check-candid 4`] = `
|
|
137
|
-
{
|
|
138
|
-
"exitCode": 0,
|
|
139
|
-
"stderr": "",
|
|
140
|
-
"stdout": "
|
|
141
|
-
> ic-mops@2.0.1 mops
|
|
142
|
-
> tsx ./environments/nodejs/cli check-candid a.did b.did
|
|
143
|
-
|
|
144
|
-
✓ Candid compatibility check passed",
|
|
145
|
-
}
|
|
146
|
-
`;
|
|
147
|
-
|
|
148
|
-
exports[`mops check-candid 5`] = `
|
|
149
|
-
{
|
|
150
|
-
"exitCode": 0,
|
|
151
|
-
"stderr": "",
|
|
152
|
-
"stdout": "
|
|
153
|
-
> ic-mops@2.0.1 mops
|
|
154
|
-
> tsx ./environments/nodejs/cli check-candid b.did a.did
|
|
155
|
-
|
|
156
|
-
✓ Candid compatibility check passed",
|
|
157
|
-
}
|
|
158
|
-
`;
|
|
159
|
-
|
|
160
|
-
exports[`mops check-candid 6`] = `
|
|
161
|
-
{
|
|
162
|
-
"exitCode": 1,
|
|
163
|
-
"stderr": "✖ Candid compatibility check failed",
|
|
164
|
-
"stdout": "
|
|
165
|
-
> ic-mops@2.0.1 mops
|
|
166
|
-
> tsx ./environments/nodejs/cli check-candid a.did c.did
|
|
167
|
-
",
|
|
168
|
-
}
|
|
169
|
-
`;
|
|
170
|
-
|
|
171
|
-
exports[`mops check-candid 7`] = `
|
|
172
|
-
{
|
|
173
|
-
"exitCode": 1,
|
|
174
|
-
"stderr": "✖ Candid compatibility check failed",
|
|
175
|
-
"stdout": "
|
|
176
|
-
> ic-mops@2.0.1 mops
|
|
177
|
-
> tsx ./environments/nodejs/cli check-candid c.did a.did
|
|
178
|
-
",
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
181
|
-
|
|
182
|
-
exports[`mops check-candid 8`] = `
|
|
183
|
-
{
|
|
184
|
-
"exitCode": 1,
|
|
185
|
-
"stderr": "✖ Candid compatibility check failed",
|
|
186
|
-
"stdout": "
|
|
187
|
-
> ic-mops@2.0.1 mops
|
|
188
|
-
> tsx ./environments/nodejs/cli check-candid b.did c.did
|
|
189
|
-
",
|
|
190
|
-
}
|
|
191
|
-
`;
|
|
192
|
-
|
|
193
|
-
exports[`mops check-candid 9`] = `
|
|
194
|
-
{
|
|
195
|
-
"exitCode": 1,
|
|
196
|
-
"stderr": "✖ Candid compatibility check failed",
|
|
197
|
-
"stdout": "
|
|
198
|
-
> ic-mops@2.0.1 mops
|
|
199
|
-
> tsx ./environments/nodejs/cli check-candid c.did b.did
|
|
200
|
-
",
|
|
201
|
-
}
|
|
202
|
-
`;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"__Candid_UI": {
|
|
3
|
-
"local": "ufxgi-4p777-77774-qaadq-cai"
|
|
4
|
-
},
|
|
5
|
-
"a": {
|
|
6
|
-
"local": "uzt4z-lp777-77774-qaabq-cai"
|
|
7
|
-
},
|
|
8
|
-
"b": {
|
|
9
|
-
"local": "umunu-kh777-77774-qaaca-cai"
|
|
10
|
-
},
|
|
11
|
-
"bar": {
|
|
12
|
-
"local": "ulvla-h7777-77774-qaacq-cai"
|
|
13
|
-
},
|
|
14
|
-
"foo": {
|
|
15
|
-
"local": "ucwa4-rx777-77774-qaada-cai"
|
|
16
|
-
}
|
|
17
|
-
}
|
|
Binary file
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
|
|
3
|
-
// Imports and re-exports candid interface
|
|
4
|
-
import { idlFactory } from './bar.did.js';
|
|
5
|
-
export { idlFactory } from './bar.did.js';
|
|
6
|
-
// CANISTER_ID is replaced by webpack based on node environment
|
|
7
|
-
export const canisterId = process.env.CANISTER_ID_BAR;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated since dfx 0.11.1
|
|
11
|
-
* Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface.
|
|
12
|
-
* @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent
|
|
13
|
-
* @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options]
|
|
14
|
-
* @return {import("@dfinity/agent").ActorSubclass<import("./bar.did.js")._SERVICE>}
|
|
15
|
-
*/
|
|
16
|
-
export const createActor = (canisterId, options = {}) => {
|
|
17
|
-
console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings.
|
|
18
|
-
|
|
19
|
-
See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`);
|
|
20
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
21
|
-
|
|
22
|
-
// Fetch root key for certificate validation during development
|
|
23
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
24
|
-
agent.fetchRootKey().catch(err => {
|
|
25
|
-
console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
|
|
26
|
-
console.error(err);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
31
|
-
return Actor.createActor(idlFactory, {
|
|
32
|
-
agent,
|
|
33
|
-
canisterId,
|
|
34
|
-
...(options ? options.actorOptions : {}),
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* A ready-to-use agent for the bar canister
|
|
40
|
-
* @type {import("@dfinity/agent").ActorSubclass<import("./bar.did.js")._SERVICE>}
|
|
41
|
-
*/
|
|
42
|
-
export const bar = createActor(canisterId);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
()
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Principal } from '@dfinity/principal';
|
|
2
|
-
import type { ActorMethod } from '@dfinity/agent';
|
|
3
|
-
import type { IDL } from '@dfinity/candid';
|
|
4
|
-
|
|
5
|
-
export interface _SERVICE { 'call' : ActorMethod<[], string> }
|
|
6
|
-
export declare const idlFactory: IDL.InterfaceFactory;
|
|
7
|
-
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
Binary file
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
|
-
|
|
3
|
-
// Imports and re-exports candid interface
|
|
4
|
-
import { idlFactory } from './foo.did.js';
|
|
5
|
-
export { idlFactory } from './foo.did.js';
|
|
6
|
-
// CANISTER_ID is replaced by webpack based on node environment
|
|
7
|
-
export const canisterId = process.env.CANISTER_ID_FOO;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated since dfx 0.11.1
|
|
11
|
-
* Do not import from `.dfx`, instead switch to using `dfx generate` to generate your JS interface.
|
|
12
|
-
* @param {string | import("@dfinity/principal").Principal} canisterId Canister ID of Agent
|
|
13
|
-
* @param {{agentOptions?: import("@dfinity/agent").HttpAgentOptions; actorOptions?: import("@dfinity/agent").ActorConfig} | { agent?: import("@dfinity/agent").Agent; actorOptions?: import("@dfinity/agent").ActorConfig }} [options]
|
|
14
|
-
* @return {import("@dfinity/agent").ActorSubclass<import("./foo.did.js")._SERVICE>}
|
|
15
|
-
*/
|
|
16
|
-
export const createActor = (canisterId, options = {}) => {
|
|
17
|
-
console.warn(`Deprecation warning: you are currently importing code from .dfx. Going forward, refactor to use the dfx generate command for JavaScript bindings.
|
|
18
|
-
|
|
19
|
-
See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`);
|
|
20
|
-
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
21
|
-
|
|
22
|
-
// Fetch root key for certificate validation during development
|
|
23
|
-
if (process.env.DFX_NETWORK !== "ic") {
|
|
24
|
-
agent.fetchRootKey().catch(err => {
|
|
25
|
-
console.warn("Unable to fetch root key. Check to ensure that your local replica is running");
|
|
26
|
-
console.error(err);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Creates an actor with using the candid interface and the HttpAgent
|
|
31
|
-
return Actor.createActor(idlFactory, {
|
|
32
|
-
agent,
|
|
33
|
-
canisterId,
|
|
34
|
-
...(options ? options.actorOptions : {}),
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* A ready-to-use agent for the foo canister
|
|
40
|
-
* @type {import("@dfinity/agent").ActorSubclass<import("./foo.did.js")._SERVICE>}
|
|
41
|
-
*/
|
|
42
|
-
export const foo = createActor(canisterId);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
()
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Principal } from '@dfinity/principal';
|
|
2
|
-
import type { ActorMethod } from '@dfinity/agent';
|
|
3
|
-
import type { IDL } from '@dfinity/candid';
|
|
4
|
-
|
|
5
|
-
export interface _SERVICE { 'call' : ActorMethod<[], string> }
|
|
6
|
-
export declare const idlFactory: IDL.InterfaceFactory;
|
|
7
|
-
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "wasm",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"collaborators": [
|
|
5
|
-
"Ryan Vandersmith <ryan.vandersmith@dfinity.org>"
|
|
6
|
-
],
|
|
7
|
-
"version": "0.1.0",
|
|
8
|
-
"files": [
|
|
9
|
-
"wasm_bg.wasm",
|
|
10
|
-
"wasm.js",
|
|
11
|
-
"wasm_bg.js",
|
|
12
|
-
"wasm.d.ts"
|
|
13
|
-
],
|
|
14
|
-
"main": "wasm.js",
|
|
15
|
-
"types": "wasm.d.ts",
|
|
16
|
-
"sideEffects": [
|
|
17
|
-
"./wasm.js",
|
|
18
|
-
"./snippets/*"
|
|
19
|
-
]
|
|
20
|
-
}
|
package/wasm/pkg/bundler/wasm.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let WASM_VECTOR_LEN = 0;
|
|
8
|
-
|
|
9
|
-
let cachedUint8ArrayMemory0 = null;
|
|
10
|
-
|
|
11
|
-
function getUint8ArrayMemory0() {
|
|
12
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
13
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
14
|
-
}
|
|
15
|
-
return cachedUint8ArrayMemory0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const cachedTextEncoder = new TextEncoder();
|
|
19
|
-
|
|
20
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
21
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
22
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
23
|
-
view.set(buf);
|
|
24
|
-
return {
|
|
25
|
-
read: arg.length,
|
|
26
|
-
written: buf.length
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
32
|
-
|
|
33
|
-
if (realloc === undefined) {
|
|
34
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
35
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
36
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
37
|
-
WASM_VECTOR_LEN = buf.length;
|
|
38
|
-
return ptr;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let len = arg.length;
|
|
42
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
43
|
-
|
|
44
|
-
const mem = getUint8ArrayMemory0();
|
|
45
|
-
|
|
46
|
-
let offset = 0;
|
|
47
|
-
|
|
48
|
-
for (; offset < len; offset++) {
|
|
49
|
-
const code = arg.charCodeAt(offset);
|
|
50
|
-
if (code > 0x7F) break;
|
|
51
|
-
mem[ptr + offset] = code;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (offset !== len) {
|
|
55
|
-
if (offset !== 0) {
|
|
56
|
-
arg = arg.slice(offset);
|
|
57
|
-
}
|
|
58
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
59
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
60
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
61
|
-
|
|
62
|
-
offset += ret.written;
|
|
63
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
WASM_VECTOR_LEN = offset;
|
|
67
|
-
return ptr;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* @param {string} new_interface
|
|
71
|
-
* @param {string} original_interface
|
|
72
|
-
* @returns {boolean}
|
|
73
|
-
*/
|
|
74
|
-
export function is_candid_compatible(new_interface, original_interface) {
|
|
75
|
-
const ptr0 = passStringToWasm0(new_interface, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
-
const len0 = WASM_VECTOR_LEN;
|
|
77
|
-
const ptr1 = passStringToWasm0(original_interface, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
-
const len1 = WASM_VECTOR_LEN;
|
|
79
|
-
const ret = wasm.is_candid_compatible(ptr0, len0, ptr1, len1);
|
|
80
|
-
return ret !== 0;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function __wbindgen_init_externref_table() {
|
|
84
|
-
const table = wasm.__wbindgen_externrefs;
|
|
85
|
-
const offset = table.grow(4);
|
|
86
|
-
table.set(0, undefined);
|
|
87
|
-
table.set(offset + 0, undefined);
|
|
88
|
-
table.set(offset + 1, null);
|
|
89
|
-
table.set(offset + 2, true);
|
|
90
|
-
table.set(offset + 3, false);
|
|
91
|
-
;
|
|
92
|
-
};
|
|
93
|
-
|
|
Binary file
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const is_candid_compatible: (a: number, b: number, c: number, d: number) => number;
|
|
5
|
-
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
6
|
-
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
7
|
-
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
8
|
-
export const __wbindgen_start: () => void;
|