@dorafactory/maci-sdk 0.0.7 → 0.0.9
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 +27 -7
- package/dist/index.js +751 -187
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +748 -187
- package/dist/index.mjs.map +1 -1
- package/dist/libs/circom/tree.d.ts +20 -20
- package/dist/libs/contract/ts/AMaci.client.d.ts +1 -1
- package/dist/libs/contract/ts/Maci.client.d.ts +21 -47
- package/dist/libs/contract/ts/Maci.types.d.ts +40 -31
- package/dist/libs/contract/ts/OracleMaci.client.d.ts +52 -52
- package/dist/libs/contract/ts/OracleMaci.types.d.ts +17 -7
- package/dist/libs/contract/ts/Registry.client.d.ts +2 -2
- package/dist/libs/contract/types.d.ts +2 -2
- package/dist/libs/errors/types.d.ts +1 -0
- package/dist/libs/http/http.d.ts +1 -1
- package/dist/libs/index.d.ts +3 -0
- package/dist/libs/indexer/indexer.d.ts +11 -2
- package/dist/libs/maci/index.d.ts +1 -0
- package/dist/libs/maci/maci.d.ts +64 -5
- package/dist/libs/oracle-certificate/oracle-certificate.d.ts +1 -21
- package/dist/libs/oracle-certificate/types.d.ts +12 -0
- package/dist/libs/query/event.d.ts +7 -0
- package/dist/libs/query/index.d.ts +1 -0
- package/dist/maci.d.ts +7 -5
- package/dist/types/index.d.ts +22 -0
- package/package.json +1 -1
- package/src/libs/const.ts +3 -2
- package/src/libs/contract/contract.ts +2 -6
- package/src/libs/contract/ts/AMaci.client.ts +868 -874
- package/src/libs/contract/ts/AMaci.types.ts +216 -216
- package/src/libs/contract/ts/Maci.client.ts +748 -888
- package/src/libs/contract/ts/Maci.types.ts +229 -224
- package/src/libs/contract/ts/OracleMaci.client.ts +623 -348
- package/src/libs/contract/ts/OracleMaci.types.ts +191 -138
- package/src/libs/contract/ts/Registry.client.ts +438 -446
- package/src/libs/contract/ts/Registry.types.ts +97 -97
- package/src/libs/contract/types.ts +6 -2
- package/src/libs/contract/utils.ts +9 -0
- package/src/libs/errors/types.ts +1 -0
- package/src/libs/http/http.ts +3 -7
- package/src/libs/index.ts +3 -0
- package/src/libs/indexer/indexer.ts +18 -0
- package/src/libs/maci/index.ts +1 -0
- package/src/libs/maci/maci.ts +302 -10
- package/src/libs/oracle-certificate/oracle-certificate.ts +19 -73
- package/src/libs/oracle-certificate/types.ts +15 -1
- package/src/libs/query/event.ts +78 -0
- package/src/libs/query/index.ts +1 -0
- package/src/maci.ts +27 -5
- package/src/types/index.ts +28 -0
package/README.md
CHANGED
|
@@ -23,11 +23,13 @@ const client = new MaciClient({
|
|
|
23
23
|
### Query Functions
|
|
24
24
|
|
|
25
25
|
#### Query Account Balance
|
|
26
|
+
|
|
26
27
|
```typescript
|
|
27
28
|
const balance = await client.balanceOf('dora1...');
|
|
28
29
|
```
|
|
29
30
|
|
|
30
31
|
#### Query Round Information
|
|
32
|
+
|
|
31
33
|
```typescript
|
|
32
34
|
// Query round by ID
|
|
33
35
|
const round = await client.getRoundById('dora1...');
|
|
@@ -39,13 +41,22 @@ const rounds = await client.getRounds('first', 10);
|
|
|
39
41
|
const roundsByStatus = await client.getRoundsByStatus('Created', 'first', 10);
|
|
40
42
|
|
|
41
43
|
// Query rounds by circuit name
|
|
42
|
-
const roundsByCircuit = await client.getRoundsByCircuitName(
|
|
44
|
+
const roundsByCircuit = await client.getRoundsByCircuitName(
|
|
45
|
+
'amaci-qv',
|
|
46
|
+
'first',
|
|
47
|
+
10
|
|
48
|
+
);
|
|
43
49
|
|
|
44
50
|
// Query rounds by operator address
|
|
45
|
-
const roundsByOperator = await client.getRoundsByOperator(
|
|
51
|
+
const roundsByOperator = await client.getRoundsByOperator(
|
|
52
|
+
'dora1...',
|
|
53
|
+
'first',
|
|
54
|
+
10
|
|
55
|
+
);
|
|
46
56
|
```
|
|
47
57
|
|
|
48
58
|
#### Query Operator Information
|
|
59
|
+
|
|
49
60
|
```typescript
|
|
50
61
|
// Query operator by address
|
|
51
62
|
const operator = await client.getOperatorByAddress('dora1...');
|
|
@@ -55,6 +66,7 @@ const operators = await client.getOperators('first', 10);
|
|
|
55
66
|
```
|
|
56
67
|
|
|
57
68
|
#### Query Circuit Information
|
|
69
|
+
|
|
58
70
|
```typescript
|
|
59
71
|
// Query circuit by name
|
|
60
72
|
const circuit = await client.getCircuitByName('amaci-qv');
|
|
@@ -64,6 +76,7 @@ const circuits = await client.getCircuits();
|
|
|
64
76
|
```
|
|
65
77
|
|
|
66
78
|
#### Query Transaction Information
|
|
79
|
+
|
|
67
80
|
```typescript
|
|
68
81
|
// Query transaction by hash
|
|
69
82
|
const transaction = await client.getTransactionByHash('HASH...');
|
|
@@ -72,10 +85,15 @@ const transaction = await client.getTransactionByHash('HASH...');
|
|
|
72
85
|
const transactions = await client.getTransactions('first', 10);
|
|
73
86
|
|
|
74
87
|
// Query transactions by contract address
|
|
75
|
-
const txByContract = await client.getTransactionsByContractAddress(
|
|
88
|
+
const txByContract = await client.getTransactionsByContractAddress(
|
|
89
|
+
'dora1...',
|
|
90
|
+
'first',
|
|
91
|
+
10
|
|
92
|
+
);
|
|
76
93
|
```
|
|
77
94
|
|
|
78
95
|
#### Query Proof Information
|
|
96
|
+
|
|
79
97
|
```typescript
|
|
80
98
|
const proof = await client.getProofByContractAddress('dora1...');
|
|
81
99
|
```
|
|
@@ -83,6 +101,7 @@ const proof = await client.getProofByContractAddress('dora1...');
|
|
|
83
101
|
### Contract Interactions
|
|
84
102
|
|
|
85
103
|
#### Create New Oracle Maci Round
|
|
104
|
+
|
|
86
105
|
```typescript
|
|
87
106
|
const wallet = await DirectSecp256k1Wallet.fromKey(
|
|
88
107
|
Buffer.from(privateKey, 'hex'),
|
|
@@ -110,7 +129,8 @@ const newRound = await client.createOracleMaciRound({
|
|
|
110
129
|
});
|
|
111
130
|
```
|
|
112
131
|
|
|
113
|
-
**Note:**
|
|
132
|
+
**Note:**
|
|
133
|
+
|
|
114
134
|
- The `operatorPubkey` is the public key of the operator. It is the compressed public key of the operator's private key.
|
|
115
135
|
- The `whitelistEcosystem` is the ecosystem of the whitelist (e.g. 'cosmoshub'). Only wallet addresses that have staked tokens in the specified ecosystem before the snapshot block height will be eligible to become voters.
|
|
116
136
|
- The `whitelistSnapshotHeight` is the snapshot block height for checking voter eligibility. The minimum valid height is 23,342,001. If set to "0", the round will evaluate the voter's stake at the time of signup.
|
|
@@ -123,6 +143,6 @@ const newRound = await client.createOracleMaciRound({
|
|
|
123
143
|
|
|
124
144
|
For example, if a voter stakes 100000000 tokens and the slope value is 2500000, the voter will be assigned 40 voice credits.
|
|
125
145
|
|
|
126
|
-
> The 1,000,000 reference value here is the precision of cosmoshub, which is 6 bits, and doravota, which is 18 bits, so when you want to pick doravota's staker as a whitelist and ask them to pledge 1DORA to convert 1vote, you need to set the scope to 1000000000000000000 (10
|
|
127
|
-
>
|
|
128
|
-
> One detail, here the slope is calculated by rounding down.
|
|
146
|
+
> The 1,000,000 reference value here is the precision of cosmoshub, which is 6 bits, and doravota, which is 18 bits, so when you want to pick doravota's staker as a whitelist and ask them to pledge 1DORA to convert 1vote, you need to set the scope to 1000000000000000000 (10\*\*18). Note that currently only cosmoshub and doravota are supported as ecosystem options.
|
|
147
|
+
>
|
|
148
|
+
> One detail, here the slope is calculated by rounding down.
|