ic-mops 0.11.0 → 0.12.1
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/commands/sources.js +6 -0
- package/declarations/main/index.d.ts +37 -3
- package/declarations/main/index.js +16 -21
- package/package.json +1 -1
package/commands/sources.js
CHANGED
|
@@ -112,6 +112,7 @@ export async function sources({verbose} = {}) {
|
|
|
112
112
|
let pkgDir;
|
|
113
113
|
if (pkg.path) {
|
|
114
114
|
pkgDir = path.relative(process.cwd(), path.resolve(pkg.path));
|
|
115
|
+
pkgDir = pkgDir.replaceAll('{MOPS_ENV}', process.env.MOPS_ENV || 'local');
|
|
115
116
|
}
|
|
116
117
|
else if (pkg.repo) {
|
|
117
118
|
pkgDir = path.relative(process.cwd(), formatGithubDir(name, pkg.repo));
|
|
@@ -130,6 +131,11 @@ export async function sources({verbose} = {}) {
|
|
|
130
131
|
pkgBaseDir = path.join(pkgDir, 'src');
|
|
131
132
|
}
|
|
132
133
|
|
|
134
|
+
// use pkgDir if baseDir doesn't exist for local packages
|
|
135
|
+
if (pkg.path && !fs.existsSync(pkgBaseDir)) {
|
|
136
|
+
pkgBaseDir = pkgDir;
|
|
137
|
+
}
|
|
138
|
+
|
|
133
139
|
return `--package ${name} ${pkgBaseDir}`;
|
|
134
140
|
});
|
|
135
141
|
}
|
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
ActorSubclass,
|
|
3
|
+
HttpAgentOptions,
|
|
4
|
+
ActorConfig,
|
|
5
|
+
Agent,
|
|
6
|
+
} from "@dfinity/agent";
|
|
7
|
+
import type { Principal } from "@dfinity/principal";
|
|
8
|
+
import type { IDL } from "@dfinity/candid";
|
|
3
9
|
|
|
4
10
|
import { _SERVICE } from './main.did';
|
|
5
11
|
|
|
12
|
+
export declare const idlFactory: IDL.InterfaceFactory;
|
|
13
|
+
export declare const canisterId: string;
|
|
14
|
+
|
|
6
15
|
export declare interface CreateActorOptions {
|
|
16
|
+
/**
|
|
17
|
+
* @see {@link Agent}
|
|
18
|
+
*/
|
|
19
|
+
agent?: Agent;
|
|
20
|
+
/**
|
|
21
|
+
* @see {@link HttpAgentOptions}
|
|
22
|
+
*/
|
|
7
23
|
agentOptions?: HttpAgentOptions;
|
|
24
|
+
/**
|
|
25
|
+
* @see {@link ActorConfig}
|
|
26
|
+
*/
|
|
8
27
|
actorOptions?: ActorConfig;
|
|
9
28
|
}
|
|
10
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister.
|
|
32
|
+
* @constructs {@link ActorSubClass}
|
|
33
|
+
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to
|
|
34
|
+
* @param {CreateActorOptions} options - see {@link CreateActorOptions}
|
|
35
|
+
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions
|
|
36
|
+
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent
|
|
37
|
+
* @see {@link HttpAgentOptions}
|
|
38
|
+
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor
|
|
39
|
+
* @see {@link ActorConfig}
|
|
40
|
+
*/
|
|
11
41
|
export declare const createActor: (
|
|
12
42
|
canisterId: string | Principal,
|
|
13
|
-
options
|
|
43
|
+
options?: CreateActorOptions
|
|
14
44
|
) => ActorSubclass<_SERVICE>;
|
|
15
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Intialized Actor using default settings, ready to talk to a canister using its candid interface
|
|
48
|
+
* @constructs {@link ActorSubClass}
|
|
49
|
+
*/
|
|
16
50
|
export declare const main: ActorSubclass<_SERVICE>;
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { Actor, HttpAgent } from "@dfinity/agent";
|
|
2
2
|
|
|
3
3
|
// Imports and re-exports candid interface
|
|
4
|
-
import { idlFactory } from
|
|
5
|
-
export { idlFactory } from
|
|
4
|
+
import { idlFactory } from "./main.did.js";
|
|
5
|
+
export { idlFactory } from "./main.did.js";
|
|
6
|
+
|
|
6
7
|
// CANISTER_ID is replaced by webpack based on node environment
|
|
7
8
|
export const canisterId = process.env.MAIN_CANISTER_ID;
|
|
8
9
|
|
|
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("./main.did.js")._SERVICE>}
|
|
15
|
-
*/
|
|
16
10
|
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
11
|
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
21
|
-
|
|
12
|
+
|
|
13
|
+
if (options.agent && options.agentOptions) {
|
|
14
|
+
console.warn(
|
|
15
|
+
"Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent."
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
22
19
|
// Fetch root key for certificate validation during development
|
|
23
20
|
if (process.env.DFX_NETWORK !== "ic") {
|
|
24
|
-
agent.fetchRootKey().catch(err => {
|
|
25
|
-
console.warn(
|
|
21
|
+
agent.fetchRootKey().catch((err) => {
|
|
22
|
+
console.warn(
|
|
23
|
+
"Unable to fetch root key. Check to ensure that your local replica is running"
|
|
24
|
+
);
|
|
26
25
|
console.error(err);
|
|
27
26
|
});
|
|
28
27
|
}
|
|
@@ -31,12 +30,8 @@ See https://internetcomputer.org/docs/current/developer-docs/updates/release-not
|
|
|
31
30
|
return Actor.createActor(idlFactory, {
|
|
32
31
|
agent,
|
|
33
32
|
canisterId,
|
|
34
|
-
...
|
|
33
|
+
...options.actorOptions,
|
|
35
34
|
});
|
|
36
35
|
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* A ready-to-use agent for the main canister
|
|
40
|
-
* @type {import("@dfinity/agent").ActorSubclass<import("./main.did.js")._SERVICE>}
|
|
41
|
-
*/
|
|
36
|
+
|
|
42
37
|
export const main = createActor(canisterId);
|