@dorafactory/maci-sdk 0.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 +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4157 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4123 -0
- package/dist/index.mjs.map +1 -0
- package/dist/libs/const.d.ts +117 -0
- package/dist/libs/contract/config.d.ts +29 -0
- package/dist/libs/contract/contract.d.ts +37 -0
- package/dist/libs/contract/index.d.ts +1 -0
- package/dist/libs/contract/ts/AMaci.client.d.ts +216 -0
- package/dist/libs/contract/ts/AMaci.types.d.ts +203 -0
- package/dist/libs/contract/ts/Maci.client.d.ts +206 -0
- package/dist/libs/contract/ts/Maci.types.d.ts +217 -0
- package/dist/libs/contract/ts/OracleMaci.client.d.ts +206 -0
- package/dist/libs/contract/ts/OracleMaci.types.d.ts +253 -0
- package/dist/libs/contract/ts/Registry.client.d.ts +128 -0
- package/dist/libs/contract/ts/Registry.types.d.ts +110 -0
- package/dist/libs/contract/types.d.ts +50 -0
- package/dist/libs/contract/utils.d.ts +67 -0
- package/dist/libs/contract/vars.d.ts +65 -0
- package/dist/libs/errors/index.d.ts +28 -0
- package/dist/libs/errors/types.d.ts +14 -0
- package/dist/libs/http/http.d.ts +16 -0
- package/dist/libs/http/index.d.ts +1 -0
- package/dist/libs/index.d.ts +4 -0
- package/dist/libs/indexer/index.d.ts +1 -0
- package/dist/libs/indexer/indexer.d.ts +133 -0
- package/dist/libs/indexer/types.d.ts +7 -0
- package/dist/libs/query/account.d.ts +7 -0
- package/dist/libs/query/circuit.d.ts +8 -0
- package/dist/libs/query/index.d.ts +6 -0
- package/dist/libs/query/operator.d.ts +9 -0
- package/dist/libs/query/proof.d.ts +7 -0
- package/dist/libs/query/round.d.ts +11 -0
- package/dist/libs/query/transaction.d.ts +9 -0
- package/dist/maci.d.ts +151 -0
- package/dist/types/index.d.ts +254 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +154 -0
- package/src/index.ts +11 -0
- package/src/libs/const.ts +196 -0
- package/src/libs/contract/config.ts +117 -0
- package/src/libs/contract/contract.ts +330 -0
- package/src/libs/contract/index.ts +1 -0
- package/src/libs/contract/ts/AMaci.client.ts +893 -0
- package/src/libs/contract/ts/AMaci.types.ts +252 -0
- package/src/libs/contract/ts/Maci.client.ts +906 -0
- package/src/libs/contract/ts/Maci.types.ts +263 -0
- package/src/libs/contract/ts/OracleMaci.client.ts +561 -0
- package/src/libs/contract/ts/OracleMaci.types.ts +254 -0
- package/src/libs/contract/ts/Registry.client.ts +466 -0
- package/src/libs/contract/ts/Registry.types.ts +127 -0
- package/src/libs/contract/types.ts +57 -0
- package/src/libs/contract/utils.ts +175 -0
- package/src/libs/contract/vars.ts +420 -0
- package/src/libs/errors/index.ts +122 -0
- package/src/libs/errors/types.ts +14 -0
- package/src/libs/http/http.ts +152 -0
- package/src/libs/http/index.ts +1 -0
- package/src/libs/index.ts +4 -0
- package/src/libs/indexer/index.ts +1 -0
- package/src/libs/indexer/indexer.ts +240 -0
- package/src/libs/indexer/types.ts +8 -0
- package/src/libs/query/account.ts +39 -0
- package/src/libs/query/circuit.ts +99 -0
- package/src/libs/query/index.ts +6 -0
- package/src/libs/query/operator.ts +263 -0
- package/src/libs/query/proof.ts +76 -0
- package/src/libs/query/round.ts +533 -0
- package/src/libs/query/transaction.ts +204 -0
- package/src/maci.ts +313 -0
- package/src/types/index.ts +301 -0
- package/src/utils/index.ts +44 -0
package/package.json
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dorafactory/maci-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SDK for interacting with maci",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"maci",
|
|
7
|
+
"blockchain"
|
|
8
|
+
],
|
|
9
|
+
"author": "team@dorafactory.org",
|
|
10
|
+
"homepage": "https://github.com/dorafactory/maci-sdk",
|
|
11
|
+
"bugs": "https://github.com/dorafactory/maci-sdk/issues",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/dorafactory/maci-sdk.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"source": "./src/index.ts",
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"require": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./types": "./src/types/index.ts",
|
|
33
|
+
"./client": "./src/indexer.ts",
|
|
34
|
+
"./const": "./src/libs/const.ts"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"src"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@cosmjs/amino": "^0.32.1",
|
|
42
|
+
"@cosmjs/cosmwasm-stargate": "^0.32.1",
|
|
43
|
+
"@cosmjs/crypto": "^0.32.1",
|
|
44
|
+
"@cosmjs/launchpad": "^0.27.1",
|
|
45
|
+
"@cosmjs/proto-signing": "^0.32.1",
|
|
46
|
+
"@cosmjs/stargate": "^0.32.1",
|
|
47
|
+
"@injectivelabs/sdk-ts": "^1.14.33",
|
|
48
|
+
"assert": "^2.1.0",
|
|
49
|
+
"bech32": "1.1.4",
|
|
50
|
+
"superstruct": "^1.0.3",
|
|
51
|
+
"ts-retry-promise": "^0.7.1",
|
|
52
|
+
"tweetnacl": "^1.0.3",
|
|
53
|
+
"colorts": "^0.1.63",
|
|
54
|
+
"husky": "^8.0.3",
|
|
55
|
+
"keccak256": "^1.0.6",
|
|
56
|
+
"process": "^0.11.10",
|
|
57
|
+
"gql.tada": "^1.7.0",
|
|
58
|
+
"graphql": "^16.8.1",
|
|
59
|
+
"tmp": "^0.2.1",
|
|
60
|
+
"valibot": "0.36.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@commitlint/cli": "^18.0.0",
|
|
64
|
+
"@commitlint/config-conventional": "^18.0.0",
|
|
65
|
+
"@commitlint/prompt-cli": "^18.0.0",
|
|
66
|
+
"@types/node": "^20.8.7",
|
|
67
|
+
"@types/tmp": "^0.2.5",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
69
|
+
"@typescript-eslint/parser": "^6.8.0",
|
|
70
|
+
"dotenv": "^16.3.1",
|
|
71
|
+
"eslint": "^8.52.0",
|
|
72
|
+
"eslint-config-prettier": "^8.8.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
74
|
+
"lint-staged": "^15.0.2",
|
|
75
|
+
"prettier": "^2.8.8",
|
|
76
|
+
"ts-node": "^10.9.1",
|
|
77
|
+
"tsconfig-paths": "^4.2.0",
|
|
78
|
+
"tsup": "^7.1.0",
|
|
79
|
+
"typedoc": "^0.25.2",
|
|
80
|
+
"typescript": "^5.2.2"
|
|
81
|
+
},
|
|
82
|
+
"lint-staged": {
|
|
83
|
+
"**/*.ts": [
|
|
84
|
+
"pnpm run format:fix",
|
|
85
|
+
"pnpm run lint:fix"
|
|
86
|
+
],
|
|
87
|
+
"**/*.json|md": [
|
|
88
|
+
"pnpm run format:fix"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"commitlint": {
|
|
92
|
+
"extends": [
|
|
93
|
+
"@commitlint/config-conventional"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"prettier": {
|
|
97
|
+
"trailingComma": "es5",
|
|
98
|
+
"tabWidth": 2,
|
|
99
|
+
"semi": true,
|
|
100
|
+
"singleQuote": true,
|
|
101
|
+
"useTabs": false,
|
|
102
|
+
"quoteProps": "as-needed",
|
|
103
|
+
"bracketSpacing": true,
|
|
104
|
+
"arrowParens": "always",
|
|
105
|
+
"endOfLine": "lf"
|
|
106
|
+
},
|
|
107
|
+
"eslintConfig": {
|
|
108
|
+
"root": true,
|
|
109
|
+
"env": {
|
|
110
|
+
"browser": true,
|
|
111
|
+
"node": true,
|
|
112
|
+
"es2022": true
|
|
113
|
+
},
|
|
114
|
+
"extends": [
|
|
115
|
+
"eslint:recommended",
|
|
116
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
117
|
+
"plugin:prettier/recommended"
|
|
118
|
+
],
|
|
119
|
+
"plugins": [
|
|
120
|
+
"@typescript-eslint",
|
|
121
|
+
"prettier"
|
|
122
|
+
],
|
|
123
|
+
"parser": "@typescript-eslint/parser",
|
|
124
|
+
"rules": {
|
|
125
|
+
"prettier/prettier": "warn",
|
|
126
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
127
|
+
"no-unused-vars": "off",
|
|
128
|
+
"@typescript-eslint/no-unused-vars": [
|
|
129
|
+
"error",
|
|
130
|
+
{
|
|
131
|
+
"argsIgnorePattern": "^_",
|
|
132
|
+
"varsIgnorePattern": "^_",
|
|
133
|
+
"caughtErrorsIgnorePattern": "^_"
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
"scripts": {
|
|
139
|
+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
140
|
+
"build": "npm run build:types && npm run build:tsup",
|
|
141
|
+
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
|
|
142
|
+
"build:types": "tsc --build",
|
|
143
|
+
"watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
|
|
144
|
+
"watch:types": "tsc --watch",
|
|
145
|
+
"watch": "pnpm run clean & pnpm run watch:types & pnpm run watch:tsup",
|
|
146
|
+
"test": "pnpm test:typecheck && pnpm test:unit",
|
|
147
|
+
"format:fix": "prettier --ignore-path 'dist/* docs/*' --write '**/*.{ts,json,md}'",
|
|
148
|
+
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
|
|
149
|
+
"commit": "commit",
|
|
150
|
+
"doc": "typedoc --out docs src/index.ts",
|
|
151
|
+
"chalk": "^5.0.1",
|
|
152
|
+
"prettier": "^2.8.4"
|
|
153
|
+
}
|
|
154
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './libs';
|
|
2
|
+
export type * from './types';
|
|
3
|
+
export * from './libs/const';
|
|
4
|
+
export { MaciClient } from './maci';
|
|
5
|
+
export { Http } from './libs/http';
|
|
6
|
+
export { Round } from './libs/query';
|
|
7
|
+
export { Account } from './libs/query';
|
|
8
|
+
export { Circuit } from './libs/query';
|
|
9
|
+
export { Operator } from './libs/query';
|
|
10
|
+
export { Proof } from './libs/query';
|
|
11
|
+
export { Transaction } from './libs/query';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { CircuitType } from '../types';
|
|
2
|
+
|
|
3
|
+
export const circuits: Record<string, CircuitType> = {
|
|
4
|
+
'maci-1p1v': {
|
|
5
|
+
maciType: 'MACI',
|
|
6
|
+
circuitType: '1p1v',
|
|
7
|
+
displayName: 'MACI-1p1v',
|
|
8
|
+
repoUrl:
|
|
9
|
+
'https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/maci',
|
|
10
|
+
zipUrl:
|
|
11
|
+
'https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip',
|
|
12
|
+
},
|
|
13
|
+
'maci-qv': {
|
|
14
|
+
maciType: 'MACI',
|
|
15
|
+
circuitType: 'QV',
|
|
16
|
+
displayName: 'MACI-QV',
|
|
17
|
+
repoUrl:
|
|
18
|
+
'https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/maci',
|
|
19
|
+
zipUrl:
|
|
20
|
+
'https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip',
|
|
21
|
+
},
|
|
22
|
+
'amaci-1p1v': {
|
|
23
|
+
maciType: 'aMACI',
|
|
24
|
+
circuitType: '1p1v',
|
|
25
|
+
displayName: 'aMACI-1p1v',
|
|
26
|
+
repoUrl:
|
|
27
|
+
'https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/amaci',
|
|
28
|
+
zipUrl:
|
|
29
|
+
'https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip',
|
|
30
|
+
},
|
|
31
|
+
'amaci-qv': {
|
|
32
|
+
maciType: 'aMACI',
|
|
33
|
+
circuitType: 'QV',
|
|
34
|
+
displayName: 'aMACI-QV',
|
|
35
|
+
repoUrl:
|
|
36
|
+
'https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/amaci',
|
|
37
|
+
zipUrl:
|
|
38
|
+
'https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const validator_operator_set = {
|
|
43
|
+
doravaloper12yk434ut3un4wx0rult2aww89rsrel8nhmp387: {
|
|
44
|
+
operator_address: '',
|
|
45
|
+
account_address: 'dora12yk434ut3un4wx0rult2aww89rsrel8nydy83p',
|
|
46
|
+
allocation: '22571615985356796592128',
|
|
47
|
+
allocation_dora: 22571.615985356795,
|
|
48
|
+
moniker: '𝐥𝐞𝐬𝐧𝐢𝐤 | 𝐔𝐓𝐒𝐀',
|
|
49
|
+
program_voting_power: 0.06432895760166438,
|
|
50
|
+
tokens: '200731587709257889972292',
|
|
51
|
+
},
|
|
52
|
+
doravaloper15frh0nn3v4yp3vv6sk4pn6jg9l8rt82f7uqfk5: {
|
|
53
|
+
operator_address: '',
|
|
54
|
+
account_address: 'dora15frh0nn3v4yp3vv6sk4pn6jg9l8rt82fd29lqt',
|
|
55
|
+
allocation: '33745159209325474873344',
|
|
56
|
+
allocation_dora: 33745.15920932547,
|
|
57
|
+
moniker: 'NomadValidator',
|
|
58
|
+
program_voting_power: 0.09617348254756773,
|
|
59
|
+
tokens: '300099000000000000000000',
|
|
60
|
+
},
|
|
61
|
+
doravaloper1ddewp74vd2w8jhth2p0uazmc8ajgtcuf3ntqgn: {
|
|
62
|
+
operator_address: '',
|
|
63
|
+
account_address: 'dora1ddewp74vd2w8jhth2p0uazmc8ajgtcufz9wk7v',
|
|
64
|
+
allocation: '40789397021635754590208',
|
|
65
|
+
allocation_dora: 40789.397021635756,
|
|
66
|
+
moniker: 'polkachu.com',
|
|
67
|
+
program_voting_power: 0.11624951413777938,
|
|
68
|
+
tokens: '362744095556470434789338',
|
|
69
|
+
},
|
|
70
|
+
doravaloper1gh8j89jtc2vx6d3y4ehllcdlvluwa49w6xmjsm: {
|
|
71
|
+
operator_address: '',
|
|
72
|
+
account_address: 'dora1gh8j89jtc2vx6d3y4ehllcdlvluwa49wfs7yxy',
|
|
73
|
+
allocation: '33743029941764137943040',
|
|
74
|
+
allocation_dora: 33743.029941764136,
|
|
75
|
+
moniker: 'ITRocket',
|
|
76
|
+
program_voting_power: 0.09616741414897524,
|
|
77
|
+
tokens: '300080064215405665352721',
|
|
78
|
+
},
|
|
79
|
+
doravaloper1j8ru7p8zctup6grfwuga6ndrjj7v88wzn407x7: {
|
|
80
|
+
operator_address: '',
|
|
81
|
+
account_address: 'dora1j8ru7p8zctup6grfwuga6ndrjj7v88wzqr2gsp',
|
|
82
|
+
allocation: '22646525272055477174272',
|
|
83
|
+
allocation_dora: 22646.525272055478,
|
|
84
|
+
moniker: 'StakeUs',
|
|
85
|
+
program_voting_power: 0.06454244857772638,
|
|
86
|
+
tokens: '201397763319500000000000',
|
|
87
|
+
},
|
|
88
|
+
doravaloper1l5zz0kkjt2n7nllsrymy96mc2v2gehda0zc85s: {
|
|
89
|
+
operator_address: '',
|
|
90
|
+
account_address: 'dora1l5zz0kkjt2n7nllsrymy96mc2v2gehdau5a3z0',
|
|
91
|
+
allocation: '22622846742220005965824',
|
|
92
|
+
allocation_dora: 22622.846742220005,
|
|
93
|
+
moniker: 'BlackNodes',
|
|
94
|
+
program_voting_power: 0.06447496492290769,
|
|
95
|
+
tokens: '201187187838702364379121',
|
|
96
|
+
},
|
|
97
|
+
doravaloper1m9v3txhhtadjxpv09gwjhhs344qsxgfscwxjkg: {
|
|
98
|
+
operator_address: '',
|
|
99
|
+
account_address: 'dora1m9v3txhhtadjxpv09gwjhhs344qsxgfstcryqh',
|
|
100
|
+
allocation: '22549006983854435598336',
|
|
101
|
+
allocation_dora: 22549.006983854437,
|
|
102
|
+
moniker: '👋 79anvi 🍀',
|
|
103
|
+
program_voting_power: 0.06426452209558432,
|
|
104
|
+
tokens: '200530523648490887200824',
|
|
105
|
+
},
|
|
106
|
+
doravaloper1tu8006g60t62zwgwf5knkaujv0uzhp2a6wh94h: {
|
|
107
|
+
operator_address: '',
|
|
108
|
+
account_address: 'dora1tu8006g60t62zwgwf5knkaujv0uzhp2afcjnrg',
|
|
109
|
+
allocation: '39369183740744815345664',
|
|
110
|
+
allocation_dora: 39369.18374074482,
|
|
111
|
+
moniker: 'Citadel.one',
|
|
112
|
+
program_voting_power: 0.11220191559671686,
|
|
113
|
+
tokens: '350114000000000000000000',
|
|
114
|
+
},
|
|
115
|
+
doravaloper1x5z0tkafrgyeuqkrwfjr933vghjxchqnqlhcdw: {
|
|
116
|
+
operator_address: '',
|
|
117
|
+
account_address: 'dora1x5z0tkafrgyeuqkrwfjr933vghjxchqnnfjwm3',
|
|
118
|
+
allocation: '22611521290904268701696',
|
|
119
|
+
allocation_dora: 22611.521290904268,
|
|
120
|
+
moniker: '1ce',
|
|
121
|
+
program_voting_power: 0.064442687460896,
|
|
122
|
+
tokens: '201086469492900000000000',
|
|
123
|
+
},
|
|
124
|
+
doravaloper1z6kfew2nhuh02szc2hdecw4fqey2d32auucvux: {
|
|
125
|
+
operator_address: '',
|
|
126
|
+
account_address: 'dora1z6kfew2nhuh02szc2hdecw4fqey2d32a02a62e',
|
|
127
|
+
allocation: '45246951843662957379584',
|
|
128
|
+
allocation_dora: 45246.95184366296,
|
|
129
|
+
moniker: 'Nodes.Guru',
|
|
130
|
+
program_voting_power: 0.12895351616135226,
|
|
131
|
+
tokens: '402385566389000000000006',
|
|
132
|
+
},
|
|
133
|
+
doravaloper1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v: {
|
|
134
|
+
operator_address: '',
|
|
135
|
+
account_address: 'dora1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v',
|
|
136
|
+
allocation: '44982761968475888943104',
|
|
137
|
+
allocation_dora: 44982.76196847589,
|
|
138
|
+
moniker: 'ZKV',
|
|
139
|
+
program_voting_power: 0.12820057674882976,
|
|
140
|
+
tokens: '400036100000000000000000',
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export interface NetworkConfig {
|
|
145
|
+
network: string;
|
|
146
|
+
chainId: string;
|
|
147
|
+
rpcEndpoint: string;
|
|
148
|
+
restEndpoint: string;
|
|
149
|
+
apiEndpoint: string;
|
|
150
|
+
certificateApiEndpoint: string;
|
|
151
|
+
registryAddress: string;
|
|
152
|
+
maciCodeId: number;
|
|
153
|
+
oracleCodeId: number;
|
|
154
|
+
oracleWhitelistBackendPubkey: string;
|
|
155
|
+
oracleFeegrantOperator: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function getDefaultParams(
|
|
159
|
+
network: 'mainnet' | 'testnet' = 'mainnet'
|
|
160
|
+
): NetworkConfig {
|
|
161
|
+
switch (network) {
|
|
162
|
+
case 'mainnet':
|
|
163
|
+
return {
|
|
164
|
+
network: 'mainnet',
|
|
165
|
+
chainId: 'vota-ash',
|
|
166
|
+
rpcEndpoint: 'https://vota-rpc.dorafactory.org',
|
|
167
|
+
restEndpoint: 'https://vota-rest.dorafactory.org',
|
|
168
|
+
apiEndpoint: 'https://vota-api.dorafactory.org',
|
|
169
|
+
certificateApiEndpoint: 'https://vota-certificate-api.dorafactory.org',
|
|
170
|
+
registryAddress:
|
|
171
|
+
'dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4',
|
|
172
|
+
maciCodeId: 106,
|
|
173
|
+
oracleCodeId: 111,
|
|
174
|
+
oracleWhitelistBackendPubkey:
|
|
175
|
+
'A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q',
|
|
176
|
+
oracleFeegrantOperator: 'dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8',
|
|
177
|
+
};
|
|
178
|
+
case 'testnet':
|
|
179
|
+
return {
|
|
180
|
+
network: 'testnet',
|
|
181
|
+
chainId: 'vota-testnet',
|
|
182
|
+
rpcEndpoint: 'https://vota-testnet-rpc.dorafactory.org',
|
|
183
|
+
restEndpoint: 'https://vota-testnet-rest.dorafactory.org',
|
|
184
|
+
apiEndpoint: 'https://vota-testnet-api.dorafactory.org',
|
|
185
|
+
certificateApiEndpoint:
|
|
186
|
+
'https://vota-testnet-certificate-api.dorafactory.org',
|
|
187
|
+
registryAddress:
|
|
188
|
+
'dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd',
|
|
189
|
+
maciCodeId: 107,
|
|
190
|
+
oracleCodeId: 110,
|
|
191
|
+
oracleWhitelistBackendPubkey:
|
|
192
|
+
'AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ',
|
|
193
|
+
oracleFeegrantOperator: 'dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78',
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Secp256k1HdWallet } from '@cosmjs/launchpad';
|
|
2
|
+
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
3
|
+
import {
|
|
4
|
+
GasPrice,
|
|
5
|
+
SigningStargateClient,
|
|
6
|
+
SigningStargateClientOptions,
|
|
7
|
+
} from '@cosmjs/stargate';
|
|
8
|
+
import {
|
|
9
|
+
SigningCosmWasmClient,
|
|
10
|
+
SigningCosmWasmClientOptions,
|
|
11
|
+
} from '@cosmjs/cosmwasm-stargate';
|
|
12
|
+
import { MaciClient } from './ts/Maci.client';
|
|
13
|
+
import { AMaciClient } from './ts/AMaci.client';
|
|
14
|
+
import { RegistryClient } from './ts/Registry.client';
|
|
15
|
+
import { OracleMaciClient } from './ts/OracleMaci.client';
|
|
16
|
+
|
|
17
|
+
const defaultSigningClientOptions: SigningStargateClientOptions = {
|
|
18
|
+
broadcastPollIntervalMs: 8_000,
|
|
19
|
+
broadcastTimeoutMs: 64_000,
|
|
20
|
+
gasPrice: GasPrice.fromString('100000000000peaka'),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export async function createMaciClientBy({
|
|
24
|
+
rpcEndpoint,
|
|
25
|
+
wallet,
|
|
26
|
+
contractAddress,
|
|
27
|
+
}: {
|
|
28
|
+
rpcEndpoint: string;
|
|
29
|
+
wallet: OfflineSigner;
|
|
30
|
+
contractAddress: string;
|
|
31
|
+
}) {
|
|
32
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
33
|
+
rpcEndpoint,
|
|
34
|
+
wallet
|
|
35
|
+
);
|
|
36
|
+
const [{ address }] = await wallet.getAccounts();
|
|
37
|
+
return new MaciClient(signingCosmWasmClient, address, contractAddress);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function createAMaciClientBy({
|
|
41
|
+
rpcEndpoint,
|
|
42
|
+
wallet,
|
|
43
|
+
contractAddress,
|
|
44
|
+
}: {
|
|
45
|
+
rpcEndpoint: string;
|
|
46
|
+
wallet: OfflineSigner;
|
|
47
|
+
contractAddress: string;
|
|
48
|
+
}) {
|
|
49
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
50
|
+
rpcEndpoint,
|
|
51
|
+
wallet
|
|
52
|
+
);
|
|
53
|
+
const [{ address }] = await wallet.getAccounts();
|
|
54
|
+
return new AMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function createRegistryClientBy({
|
|
58
|
+
rpcEndpoint,
|
|
59
|
+
wallet,
|
|
60
|
+
contractAddress,
|
|
61
|
+
}: {
|
|
62
|
+
rpcEndpoint: string;
|
|
63
|
+
wallet: OfflineSigner;
|
|
64
|
+
contractAddress: string;
|
|
65
|
+
}) {
|
|
66
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
67
|
+
rpcEndpoint,
|
|
68
|
+
wallet
|
|
69
|
+
);
|
|
70
|
+
const [{ address }] = await wallet.getAccounts();
|
|
71
|
+
return new RegistryClient(signingCosmWasmClient, address, contractAddress);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function createOracleMaciClientBy({
|
|
75
|
+
rpcEndpoint,
|
|
76
|
+
wallet,
|
|
77
|
+
contractAddress,
|
|
78
|
+
}: {
|
|
79
|
+
rpcEndpoint: string;
|
|
80
|
+
wallet: OfflineSigner;
|
|
81
|
+
contractAddress: string;
|
|
82
|
+
}) {
|
|
83
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
84
|
+
rpcEndpoint,
|
|
85
|
+
wallet
|
|
86
|
+
);
|
|
87
|
+
const [{ address }] = await wallet.getAccounts();
|
|
88
|
+
return new OracleMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function createContractClientByWallet(
|
|
92
|
+
rpcEndpoint: string,
|
|
93
|
+
wallet: OfflineSigner
|
|
94
|
+
) {
|
|
95
|
+
const client = await SigningCosmWasmClient.connectWithSigner(
|
|
96
|
+
rpcEndpoint,
|
|
97
|
+
wallet,
|
|
98
|
+
{
|
|
99
|
+
...defaultSigningClientOptions,
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
return client;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function getSignerClientByWallet(
|
|
106
|
+
rpcEndpoint: string,
|
|
107
|
+
wallet: OfflineSigner
|
|
108
|
+
) {
|
|
109
|
+
const signingStargateClient = await SigningStargateClient.connectWithSigner(
|
|
110
|
+
rpcEndpoint,
|
|
111
|
+
wallet,
|
|
112
|
+
{
|
|
113
|
+
...defaultSigningClientOptions,
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
return signingStargateClient;
|
|
117
|
+
}
|