@icp-sdk/core 1.0.0-beta.5 → 4.0.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/README.md +25 -24
- package/package.json +7 -7
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
|
-
|
|
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,26 +48,39 @@ 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
|
|
67
|
-
const
|
|
60
|
+
// Create a new identity
|
|
61
|
+
const identity = Ed25519KeyIdentity.generate();
|
|
68
62
|
|
|
69
63
|
// Create a Principal from a string
|
|
70
|
-
const
|
|
64
|
+
const canisterId = Principal.fromText('uqqxf-5h777-77774-qaaaa-cai');
|
|
71
65
|
|
|
72
|
-
//
|
|
73
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@icp-sdk/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
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/
|
|
7
|
+
"homepage": "https://js.icp.build/core/",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/dfinity/agent-js.git",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"sdk"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@dfinity/agent": "^3.2.
|
|
37
|
-
"@dfinity/candid": "^3.2.
|
|
38
|
-
"@dfinity/identity": "^3.2.
|
|
39
|
-
"@dfinity/identity-secp256k1": "^3.2.
|
|
40
|
-
"@dfinity/principal": "^3.2.
|
|
36
|
+
"@dfinity/agent": "^3.2.2",
|
|
37
|
+
"@dfinity/candid": "^3.2.2",
|
|
38
|
+
"@dfinity/identity": "^3.2.2",
|
|
39
|
+
"@dfinity/identity-secp256k1": "^3.2.2",
|
|
40
|
+
"@dfinity/principal": "^3.2.2"
|
|
41
41
|
},
|
|
42
42
|
"exports": {
|
|
43
43
|
".": {
|