@dorafactory/maci-sdk 0.0.4 → 0.0.5
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 +22 -7
- package/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -8
- package/dist/index.mjs.map +1 -1
- package/dist/libs/contract/contract.d.ts +4 -2
- package/dist/libs/contract/types.d.ts +2 -4
- package/dist/maci.d.ts +3 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/libs/contract/contract.ts +8 -4
- package/src/libs/contract/types.ts +4 -4
- package/src/maci.ts +11 -0
- package/src/types/index.ts +4 -0
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ const proof = await client.getProofByContractAddress('dora1...');
|
|
|
82
82
|
|
|
83
83
|
### Contract Interactions
|
|
84
84
|
|
|
85
|
-
#### Create New
|
|
85
|
+
#### Create New Oracle Maci Round
|
|
86
86
|
```typescript
|
|
87
87
|
const wallet = await DirectSecp256k1Wallet.fromKey(
|
|
88
88
|
Buffer.from(privateKey, 'hex'),
|
|
@@ -93,14 +93,13 @@ const newRound = await client.createOracleMaciRound({
|
|
|
93
93
|
signer: wallet,
|
|
94
94
|
operatorPubkey: '0e752c...',
|
|
95
95
|
startVoting: new Date(),
|
|
96
|
-
endVoting: new Date(new Date().getTime() +
|
|
97
|
-
title: '
|
|
98
|
-
description: '
|
|
99
|
-
link: '
|
|
96
|
+
endVoting: new Date(new Date().getTime() + 10 * 60 * 1000),
|
|
97
|
+
title: 'Just for fun',
|
|
98
|
+
description: 'some description',
|
|
99
|
+
link: 'https://www.dorafactory.org',
|
|
100
100
|
maxVoter: '5',
|
|
101
101
|
maxOption: '5',
|
|
102
102
|
circuitType: MaciCircuitType.IP1V,
|
|
103
|
-
whitelistBackendPubkey: 'AoYo...',
|
|
104
103
|
whitelistEcosystem: 'cosmoshub',
|
|
105
104
|
whitelistSnapshotHeight: '0',
|
|
106
105
|
whitelistVotingPowerArgs: {
|
|
@@ -108,6 +107,22 @@ const newRound = await client.createOracleMaciRound({
|
|
|
108
107
|
slope: '1000000',
|
|
109
108
|
threshold: '1000000',
|
|
110
109
|
},
|
|
111
|
-
feegrantOperator: 'dora1...',
|
|
112
110
|
});
|
|
113
111
|
```
|
|
112
|
+
|
|
113
|
+
**Note:**
|
|
114
|
+
- The `operatorPubkey` is the public key of the operator. It is the compressed public key of the operator's private key.
|
|
115
|
+
- 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
|
+
- 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.
|
|
117
|
+
- The `whitelistVotingPowerArgs` configures how voting power is calculated:
|
|
118
|
+
- `mode`: Can be either 'slope' or 'threshold'
|
|
119
|
+
- 'slope' mode: Calculates voice credits based on each voter's stake amount using the formula: voice credits = staked tokens / slope value
|
|
120
|
+
- 'threshold' mode: Equally assigns 1 voice credit to voters whose stake exceeds the specified threshold
|
|
121
|
+
- `slope`: The slope value for calculating voice credits in slope mode (e.g. 1000000)
|
|
122
|
+
- `threshold`: The minimum stake threshold in threshold mode (e.g. 1000000)
|
|
123
|
+
|
|
124
|
+
For example, if a voter stakes 100000000 tokens and the slope value is 2500000, the voter will be assigned 40 voice credits.
|
|
125
|
+
|
|
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**18). Note that currently only cosmoshub and doravota are supported as ecosystem options.
|
|
127
|
+
>
|
|
128
|
+
> One detail, here the slope is calculated by rounding down.
|
package/dist/index.js
CHANGED
|
@@ -3708,12 +3708,16 @@ var Contract = class {
|
|
|
3708
3708
|
rpcEndpoint,
|
|
3709
3709
|
registryAddress,
|
|
3710
3710
|
maciCodeId,
|
|
3711
|
-
oracleCodeId
|
|
3711
|
+
oracleCodeId,
|
|
3712
|
+
feegrantOperator,
|
|
3713
|
+
whitelistBackendPubkey
|
|
3712
3714
|
}) {
|
|
3713
3715
|
this.rpcEndpoint = rpcEndpoint;
|
|
3714
3716
|
this.registryAddress = registryAddress;
|
|
3715
3717
|
this.maciCodeId = maciCodeId;
|
|
3716
3718
|
this.oracleCodeId = oracleCodeId;
|
|
3719
|
+
this.feegrantOperator = feegrantOperator;
|
|
3720
|
+
this.whitelistBackendPubkey = whitelistBackendPubkey;
|
|
3717
3721
|
}
|
|
3718
3722
|
async createAMaciRound({
|
|
3719
3723
|
signer,
|
|
@@ -3845,11 +3849,9 @@ var Contract = class {
|
|
|
3845
3849
|
maxVoter,
|
|
3846
3850
|
maxOption,
|
|
3847
3851
|
circuitType,
|
|
3848
|
-
whitelistBackendPubkey,
|
|
3849
3852
|
whitelistEcosystem,
|
|
3850
3853
|
whitelistSnapshotHeight,
|
|
3851
|
-
whitelistVotingPowerArgs
|
|
3852
|
-
feegrantOperator
|
|
3854
|
+
whitelistVotingPowerArgs
|
|
3853
3855
|
}) {
|
|
3854
3856
|
const start_time = (startVoting.getTime() * 1e6).toString();
|
|
3855
3857
|
const end_time = (endVoting.getTime() * 1e6).toString();
|
|
@@ -3890,14 +3892,14 @@ var Contract = class {
|
|
|
3890
3892
|
plonk_process_vkey: plonkProcessVkey,
|
|
3891
3893
|
plonk_tally_vkey: plonkTallyVkey,
|
|
3892
3894
|
max_vote_options: maxOption,
|
|
3893
|
-
whitelist_backend_pubkey: whitelistBackendPubkey,
|
|
3895
|
+
whitelist_backend_pubkey: this.whitelistBackendPubkey,
|
|
3894
3896
|
whitelist_ecosystem: whitelistEcosystem,
|
|
3895
3897
|
whitelist_snapshot_height: whitelistSnapshotHeight,
|
|
3896
3898
|
whitelist_voting_power_args: whitelistVotingPowerArgs,
|
|
3897
3899
|
circuit_type: maciVoteType,
|
|
3898
3900
|
certification_system: maciCertSystem,
|
|
3899
3901
|
qtr_lib: QTR_LIB,
|
|
3900
|
-
feegrant_operator: feegrantOperator
|
|
3902
|
+
feegrant_operator: this.feegrantOperator
|
|
3901
3903
|
},
|
|
3902
3904
|
"[Oracle MACI]" + title,
|
|
3903
3905
|
"auto"
|
|
@@ -3974,7 +3976,9 @@ var MaciClient2 = class {
|
|
|
3974
3976
|
maciCodeId,
|
|
3975
3977
|
oracleCodeId,
|
|
3976
3978
|
customFetch,
|
|
3977
|
-
defaultOptions
|
|
3979
|
+
defaultOptions,
|
|
3980
|
+
feegrantOperator,
|
|
3981
|
+
whitelistBackendPubkey
|
|
3978
3982
|
}) {
|
|
3979
3983
|
const defaultParams = getDefaultParams(network);
|
|
3980
3984
|
this.rpcEndpoint = rpcEndpoint || defaultParams.rpcEndpoint;
|
|
@@ -3983,6 +3987,8 @@ var MaciClient2 = class {
|
|
|
3983
3987
|
this.registryAddress = registryAddress || defaultParams.registryAddress;
|
|
3984
3988
|
this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
|
|
3985
3989
|
this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
|
|
3990
|
+
this.feegrantOperator = feegrantOperator || defaultParams.oracleFeegrantOperator;
|
|
3991
|
+
this.whitelistBackendPubkey = whitelistBackendPubkey || defaultParams.oracleWhitelistBackendPubkey;
|
|
3986
3992
|
this.http = new Http(
|
|
3987
3993
|
this.apiEndpoint,
|
|
3988
3994
|
this.restEndpoint,
|
|
@@ -3999,7 +4005,9 @@ var MaciClient2 = class {
|
|
|
3999
4005
|
rpcEndpoint: this.rpcEndpoint,
|
|
4000
4006
|
registryAddress: this.registryAddress,
|
|
4001
4007
|
maciCodeId: this.maciCodeId,
|
|
4002
|
-
oracleCodeId: this.oracleCodeId
|
|
4008
|
+
oracleCodeId: this.oracleCodeId,
|
|
4009
|
+
feegrantOperator: this.feegrantOperator,
|
|
4010
|
+
whitelistBackendPubkey: this.whitelistBackendPubkey
|
|
4003
4011
|
});
|
|
4004
4012
|
}
|
|
4005
4013
|
async oracleMaciClient({
|