@dfinity/sns 3.0.0 → 3.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.
- package/README.md +24 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,7 +33,15 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils @dfinity/
|
|
|
33
33
|
The `explorative` approach has the advantage to simplify the code but, implies more costs as it queries the `root` canister for the list of canister IDs of the Sns project upon initialization.
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
|
-
|
|
36
|
+
import { createAgent } from "@dfinity/utils";
|
|
37
|
+
import { initSnsWrapper } from "@dfinity/sns";
|
|
38
|
+
|
|
39
|
+
const agent = await createAgent({
|
|
40
|
+
identity,
|
|
41
|
+
host: HOST,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const snsWrapper = await initSnsWrapper({
|
|
37
45
|
rootOptions: {
|
|
38
46
|
canisterId: rootCanisterId,
|
|
39
47
|
},
|
|
@@ -41,10 +49,10 @@ const snsWrapper: SnsWrapper = await initSnsWrapper({
|
|
|
41
49
|
certified,
|
|
42
50
|
});
|
|
43
51
|
|
|
44
|
-
const { metadata
|
|
45
|
-
const [
|
|
52
|
+
const { metadata, swapState } = wrapper;
|
|
53
|
+
const [data, token] = await metadata({});
|
|
46
54
|
|
|
47
|
-
console.log("
|
|
55
|
+
console.log("Sns:", data, token, swapState);
|
|
48
56
|
```
|
|
49
57
|
|
|
50
58
|
### Descriptive way
|
|
@@ -52,13 +60,22 @@ console.log("Summary data:", metadata, token);
|
|
|
52
60
|
The descriptive approach limits the scope of the features but, is more verbose.
|
|
53
61
|
|
|
54
62
|
```ts
|
|
55
|
-
|
|
63
|
+
import { createAgent } from "@dfinity/utils";
|
|
64
|
+
import { SnsGovernanceCanister } from "@dfinity/sns";
|
|
65
|
+
|
|
66
|
+
const agent = await createAgent({
|
|
67
|
+
identity,
|
|
68
|
+
host: HOST,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const { metadata } = SnsGovernanceCanister.create({
|
|
56
72
|
agent,
|
|
57
73
|
canisterId: rootCanisterId,
|
|
58
74
|
});
|
|
59
|
-
const metadata = await governanceMetadata({ certified: true });
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
const data = await metadata({ certified: true });
|
|
77
|
+
|
|
78
|
+
console.log("Summary data:", data);
|
|
62
79
|
```
|
|
63
80
|
|
|
64
81
|
## Features
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfinity/sns",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "A library for interfacing with a Service Nervous System (SNS) project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/cjs/index.cjs.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@dfinity/agent": "^1.0.1",
|
|
40
40
|
"@dfinity/candid": "^1.0.1",
|
|
41
|
-
"@dfinity/ledger-icrc": "^2.
|
|
41
|
+
"@dfinity/ledger-icrc": "^2.2.0",
|
|
42
42
|
"@dfinity/principal": "^1.0.1",
|
|
43
43
|
"@dfinity/utils": "^2.1.2"
|
|
44
44
|
},
|