Comparing version 0.2.4 to 0.2.5
@@ -0,1 +1,3 @@ | ||
import { HttpAgent } from '@dfinity/agent'; | ||
import { agentCanister, AgentCanister } from './canister/agentCanister'; | ||
import { devCanister, DevCanister } from './canister/devCanister'; | ||
@@ -5,4 +7,2 @@ import { mockCanister, MockCanister, Mocks } from './canister/mockCanister'; | ||
import { Canister, Network, Replica } from './types'; | ||
import { HttpAgent } from '@dfinity/agent'; | ||
import { agentCanister, AgentCanister } from './canister/agentCanister'; | ||
declare const ic: import("./replica").AgentReplica; | ||
@@ -9,0 +9,0 @@ declare const local: import("./replica").AgentReplica; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpAgent = exports.mockCanister = exports.devCanister = exports.agentCanister = exports.replica = exports.local = exports.ic = void 0; | ||
const agent_1 = require("@dfinity/agent"); | ||
Object.defineProperty(exports, "HttpAgent", { enumerable: true, get: function () { return agent_1.HttpAgent; } }); | ||
const agentCanister_1 = require("./canister/agentCanister"); | ||
Object.defineProperty(exports, "agentCanister", { enumerable: true, get: function () { return agentCanister_1.agentCanister; } }); | ||
const devCanister_1 = require("./canister/devCanister"); | ||
@@ -10,6 +14,2 @@ Object.defineProperty(exports, "devCanister", { enumerable: true, get: function () { return devCanister_1.devCanister; } }); | ||
Object.defineProperty(exports, "replica", { enumerable: true, get: function () { return replica_1.replica; } }); | ||
const agent_1 = require("@dfinity/agent"); | ||
Object.defineProperty(exports, "HttpAgent", { enumerable: true, get: function () { return agent_1.HttpAgent; } }); | ||
const agentCanister_1 = require("./canister/agentCanister"); | ||
Object.defineProperty(exports, "agentCanister", { enumerable: true, get: function () { return agentCanister_1.agentCanister; } }); | ||
const ic = (0, replica_1.deferredReplica)('https://ic0.app'); | ||
@@ -16,0 +16,0 @@ exports.ic = ic; |
{ | ||
"name": "ic0", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "An easy-to-use JavaScript API for the Internet Computer.", | ||
@@ -5,0 +5,0 @@ "author": "DFINITY Foundation", |
@@ -61,4 +61,3 @@ | ||
```ts | ||
import { replica } from 'ic0'; | ||
import { HttpAgent } from '@dfinity/agent'; | ||
import { replica, HttpAgent } from 'ic0'; | ||
@@ -72,33 +71,2 @@ const ic = replica(new HttpAgent({ ... })); // Use a custom agent from `@dfinity/agent` | ||
## Dev Canisters | ||
A **dev canister** makes it possible to interact with canisters provided by a live-reload development environment | ||
such as the [Motoko Dev Server](https://github.com/dfinity/motoko-dev-server). | ||
### Basic usage: | ||
```ts | ||
import { devCanister } from 'ic0'; | ||
const backend = devCanister('backend'); // Canister alias specified in your `dfx.json` file | ||
console.log(await backend.call('getValue')); // Call the `getValue()` method on your `backend` canister | ||
``` | ||
### Advanced usage: | ||
This package makes it possible to seamlessly switch between a `devCanister` and `replicaCanister` depending on the environment. | ||
For example, you can use the `import.meta.env` property available in [Vite](https://vitejs.dev/): | ||
```ts | ||
import { devCanister, ic } from 'ic0'; | ||
const backend = import.meta.env.DEV | ||
? devCanister('backend') | ||
: ic('rrkah-fqaaa-aaaaa-aaaaq-cai'); // Deployed canister | ||
console.log(await backend.call('getValue')); // Call the `getValue()` method on the deployed canister when in production | ||
``` | ||
## Mock Canisters | ||
@@ -105,0 +73,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
47019
121