@icp-sdk/core 1.0.0-beta.5 → 4.0.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.
Files changed (2) hide show
  1. package/README.md +27 -26
  2. package/package.json +9 -9
package/README.md CHANGED
@@ -4,9 +4,7 @@ The `@icp-sdk/core` package is a JavaScript and TypeScript library designed to i
4
4
 
5
5
  Do you want to know more about developing on the Internet Computer? Visit the [Developer Docs](https://internetcomputer.org/docs/home).
6
6
 
7
- Additional API Documentation can be found [here](https://js.icp.build/core/libs/core/api).
8
-
9
- **Note:** This package requires the `node16` (or later) module resolution strategy to function correctly.
7
+ > Still using `@dfinity/agent`? Migrate to [`@icp-sdk/core`](https://js.icp.build/core/latest/upgrading/v4)!
10
8
 
11
9
  ---
12
10
 
@@ -32,16 +30,6 @@ yarn add @icp-sdk/core
32
30
  pnpm add @icp-sdk/core
33
31
  ```
34
32
 
35
- ## Package Structure
36
-
37
- The `@icp-sdk/core` package re-exports modules from the following `@dfinity` packages:
38
-
39
- - [`@dfinity/agent`](../agent/README.md): Provides tools to interact with the Internet Computer, including creating actors and making calls.
40
- - [`@dfinity/candid`](../candid/README.md): Tools for working with Candid, the Internet Computer's interface definition language.
41
- - [`@dfinity/identity`](../identity/README.md): Identity management for signing and authentication.
42
- - [`@dfinity/identity-secp256k1`](../identity-secp256k1/README.md): Identity management using secp256k1 cryptography.
43
- - [`@dfinity/principal`](../principal/README.md): Utilities for working with principals on the Internet Computer.
44
-
45
33
  ## Import Paths
46
34
 
47
35
  The package provides the following import paths for accessing the re-exported modules:
@@ -60,31 +48,44 @@ Here is an example of how to use the `@icp-sdk/core` package:
60
48
  // Importing the HttpAgent from the agent module
61
49
  import { HttpAgent } from '@icp-sdk/core/agent';
62
50
 
51
+ // Importing the Identity utility
52
+ import { Ed25519KeyIdentity } from '@icp-sdk/core/identity';
53
+
54
+ // Importing the Candid utility
55
+ import { IDL } from '@icp-sdk/core/candid';
56
+
63
57
  // Importing the Principal utility
64
58
  import { Principal } from '@icp-sdk/core/principal';
65
59
 
66
- // Create an HttpAgent instance
67
- const agent = new HttpAgent({ host: 'https://ic0.app' });
60
+ // Create a new identity
61
+ const identity = Ed25519KeyIdentity.generate();
68
62
 
69
63
  // Create a Principal from a string
70
- const principal = Principal.fromText('aaaaa-aa');
64
+ const canisterId = Principal.fromText('uqqxf-5h777-77774-qaaaa-cai');
71
65
 
72
- // Log the Principal
73
- console.log(principal.toText());
66
+ // Create an HttpAgent instance
67
+ const agent = await HttpAgent.create({
68
+ host: 'https://icp-api.io',
69
+ identity,
70
+ });
71
+
72
+ // Call a canister
73
+ const response = await agent.call(canisterId, {
74
+ methodName: 'greet',
75
+ arg: IDL.encode([IDL.Text], ['world']),
76
+ });
77
+
78
+ console.log(response);
74
79
  ```
75
80
 
76
- For detailed usage and API documentation, refer to the respective documentation of the re-exported packages:
81
+ **Note:** If you are using TypeScript, this package requires the `node16` (or later) [`moduleResolution`](https://www.typescriptlang.org/tsconfig#moduleResolution) strategy to function correctly.
77
82
 
78
- - [@dfinity/agent Documentation](../agent/README.md)
79
- - [@dfinity/candid Documentation](../candid/README.md)
80
- - [@dfinity/identity Documentation](../identity/README.md)
81
- - [@dfinity/identity-secp256k1 Documentation](../identity-secp256k1/README.md)
82
- - [@dfinity/principal Documentation](../principal/README.md)
83
+ Additional API Documentation can be found [here](https://js.icp.build/core/latest/).
83
84
 
84
85
  ## Contributing
85
86
 
86
- Contributions are welcome! Please refer to the [repository](https://github.com/dfinity/agent-js) for guidelines on contributing to this project.
87
+ Contributions are welcome! Please refer to the [repository](https://github.com/dfinity/icp-js-core) for guidelines on contributing to this project.
87
88
 
88
89
  ## License
89
90
 
90
- This project is licensed under the Apache-2.0 License. See the [LICENSE](https://github.com/dfinity/agent-js/blob/main/LICENSE) file for details.
91
+ This project is licensed under the Apache-2.0 License. See the [LICENSE](https://github.com/dfinity/icp-js-core/blob/main/LICENSE) file for details.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@icp-sdk/core",
3
- "version": "1.0.0-beta.5",
3
+ "version": "4.0.1",
4
4
  "author": "DFINITY Stiftung <sdk@dfinity.org>",
5
5
  "license": "Apache-2.0",
6
6
  "description": "JavaScript and TypeScript library to interact with the Internet Computer",
7
- "homepage": "https://js.icp.build/core/libs/core",
7
+ "homepage": "https://js.icp.build/core/",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/dfinity/agent-js.git",
10
+ "url": "https://github.com/dfinity/icp-js-core.git",
11
11
  "directory": "packages/core"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/dfinity/agent-js/issues"
14
+ "url": "https://github.com/dfinity/icp-js-core/issues"
15
15
  },
16
16
  "keywords": [
17
17
  "internet computer",
@@ -33,11 +33,11 @@
33
33
  "sdk"
34
34
  ],
35
35
  "peerDependencies": {
36
- "@dfinity/agent": "^3.2.1",
37
- "@dfinity/candid": "^3.2.1",
38
- "@dfinity/identity": "^3.2.1",
39
- "@dfinity/identity-secp256k1": "^3.2.1",
40
- "@dfinity/principal": "^3.2.1"
36
+ "@dfinity/candid": "^3.2.3",
37
+ "@dfinity/agent": "^3.2.3",
38
+ "@dfinity/identity": "^3.2.3",
39
+ "@dfinity/identity-secp256k1": "^3.2.3",
40
+ "@dfinity/principal": "^3.2.3"
41
41
  },
42
42
  "exports": {
43
43
  ".": {