Skip to content

Commit a10a8d5

Browse files
committed
feat: merge voter to sdk
1 parent 4135147 commit a10a8d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2072
-406
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm-lock.yaml

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": true,
4+
"tabWidth": 2,
5+
"singleQuote": true,
6+
"printWidth": 100,
7+
"trailingComma": "none"
8+
}

package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
2-
"name": "maci",
3-
"version": "1.0.0",
4-
"private": true,
5-
"scripts": {
6-
"build": "pnpm -r build",
7-
"test": "pnpm -r test",
8-
"lint": "pnpm -r lint",
9-
"compile": "pnpm -r compile",
10-
"deploy": "pnpm -r deploy"
11-
},
12-
"devDependencies": {
13-
"@changesets/changelog-github": "^0.4.8",
14-
"@changesets/cli": "^2.26.1",
15-
"typescript": "^5.3.3",
16-
"prettier": "^3.2.5",
17-
"eslint": "^8.57.0",
18-
"@types/node": "^20.11.19",
19-
"hardhat": "^2.19.5",
20-
"ts-node": "^10.9.2"
21-
}
2+
"name": "maci",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"build": "pnpm -r build",
7+
"test": "pnpm -r test",
8+
"lint": "pnpm -r lint",
9+
"compile": "pnpm -r compile",
10+
"deploy": "pnpm -r deploy"
11+
},
12+
"devDependencies": {
13+
"@changesets/changelog-github": "^0.4.8",
14+
"@changesets/cli": "^2.26.1",
15+
"typescript": "^5.3.3",
16+
"prettier": "^3.2.5",
17+
"eslint": "^8.57.0",
18+
"@types/node": "^20.11.19",
19+
"hardhat": "^2.19.5",
20+
"ts-node": "^10.9.2"
21+
}
2222
}

packages/sdk/package.json

Lines changed: 99 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,101 @@
11
{
2-
"name": "@dorafactory/maci-sdk",
3-
"version": "0.1.3-pre.21",
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/tree/main/packages/sdk#readme",
11-
"bugs": "https://github.com/dorafactory/maci/issues",
12-
"repository": {
13-
"type": "git",
14-
"url": "https://github.com/dorafactory/maci.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-
"files": [
27-
"dist",
28-
"src"
29-
],
30-
"scripts": {
31-
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
32-
"build": "npm run build:types && npm run build:tsup",
33-
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
34-
"build:types": "tsc --build",
35-
"watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
36-
"watch:types": "tsc --watch",
37-
"watch": "pnpm run clean & pnpm run watch:types & pnpm run watch:tsup",
38-
"test": "pnpm test:typecheck && pnpm test:unit",
39-
"test:typecheck": "tsc -p ./test",
40-
"test:unit": "vitest run --test-timeout=60000",
41-
"test:watch": "vitest",
42-
"format:fix": "prettier --ignore-path 'dist/* docs/*' --write '**/*.{ts,json,md}'",
43-
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
44-
"commit": "commit",
45-
"doc": "typedoc --out docs src/index.ts"
46-
},
47-
"dependencies": {
48-
"@cosmjs/amino": "^0.32.1",
49-
"@cosmjs/cosmwasm-stargate": "^0.32.1",
50-
"@cosmjs/launchpad": "^0.27.1",
51-
"@cosmjs/proto-signing": "^0.32.1",
52-
"@cosmjs/stargate": "^0.32.1",
53-
"@zk-kit/baby-jubjub": "^1.0.3",
54-
"@zk-kit/eddsa-poseidon": "^1.1.0",
55-
"@zk-kit/poseidon-cipher": "^0.3.2",
56-
"assert": "^2.1.0",
57-
"bech32": "1.1.4",
58-
"cosmjs-types": "^0.9.0",
59-
"crypto-js": "^4.2.0",
60-
"ethers": "^6.13.4"
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/crypto-js": "^4.2.2",
67-
"@types/node": "^20.8.7",
68-
"@types/tmp": "^0.2.5",
69-
"@typescript-eslint/eslint-plugin": "^6.8.0",
70-
"@typescript-eslint/parser": "^6.8.0",
71-
"browserify-zlib": "^0.2.0",
72-
"buffer": "^6.0.3",
73-
"crypto-browserify": "^3.12.1",
74-
"dotenv": "^16.3.1",
75-
"esbuild": "^0.25.0",
76-
"eslint": "^8.52.0",
77-
"eslint-config-prettier": "^8.8.0",
78-
"eslint-plugin-prettier": "^5.0.1",
79-
"events": "^3.3.0",
80-
"events-browserify": "^0.0.1",
81-
"https-browserify": "^1.0.0",
82-
"lint-staged": "^15.0.2",
83-
"prettier": "^3.5.3",
84-
"process": "^0.11.10",
85-
"stream-browserify": "^3.0.0",
86-
"stream-http": "^3.2.0",
87-
"ts-node": "^10.9.1",
88-
"tsconfig-paths": "^4.2.0",
89-
"tsup": "^8.0.0",
90-
"typedoc": "^0.25.2",
91-
"typescript": "^5.2.2"
92-
},
93-
"lint-staged": {
94-
"**/*.ts": [
95-
"pnpm run format:fix",
96-
"pnpm run lint:fix"
97-
],
98-
"**/*.json|md": [
99-
"pnpm run format:fix"
100-
]
101-
},
102-
"commitlint": {
103-
"extends": [
104-
"@commitlint/config-conventional"
105-
]
106-
},
107-
"prettier": {
108-
"trailingComma": "es5",
109-
"tabWidth": 2,
110-
"semi": true,
111-
"singleQuote": true,
112-
"useTabs": false,
113-
"quoteProps": "as-needed",
114-
"bracketSpacing": true,
115-
"arrowParens": "always",
116-
"endOfLine": "lf"
117-
},
118-
"eslintConfig": {
119-
"root": true,
120-
"env": {
121-
"browser": true,
122-
"node": true,
123-
"es2022": true
124-
},
125-
"extends": [
126-
"eslint:recommended",
127-
"plugin:@typescript-eslint/eslint-recommended",
128-
"plugin:prettier/recommended"
129-
],
130-
"plugins": [
131-
"@typescript-eslint",
132-
"prettier"
133-
],
134-
"parser": "@typescript-eslint/parser",
135-
"rules": {
136-
"prettier/prettier": "warn",
137-
"@typescript-eslint/no-explicit-any": "off",
138-
"no-unused-vars": "off",
139-
"@typescript-eslint/no-unused-vars": [
140-
"error",
141-
{
142-
"argsIgnorePattern": "^_",
143-
"varsIgnorePattern": "^_",
144-
"caughtErrorsIgnorePattern": "^_"
145-
}
146-
]
147-
}
148-
}
2+
"name": "@dorafactory/maci-sdk",
3+
"version": "0.1.3-pre.21",
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/tree/main/packages/sdk#readme",
11+
"bugs": "https://github.com/dorafactory/maci/issues",
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/dorafactory/maci.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+
"files": [
27+
"dist",
28+
"src"
29+
],
30+
"scripts": {
31+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
32+
"build": "npm run build:types && npm run build:tsup",
33+
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
34+
"build:types": "tsc --build",
35+
"watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
36+
"watch:types": "tsc --watch",
37+
"watch": "pnpm run clean & pnpm run watch:types & pnpm run watch:tsup",
38+
"test": "pnpm test:typecheck && pnpm test:unit",
39+
"test:typecheck": "tsc -p ./test",
40+
"test:unit": "vitest run --test-timeout=60000",
41+
"test:watch": "vitest",
42+
"format:fix": "prettier --ignore-path 'dist/* docs/*' --write '**/*.{ts,json,md}'",
43+
"lint:fix": "eslint . --ignore-pattern dist --ext .ts --fix",
44+
"commit": "commit",
45+
"doc": "typedoc --out docs src/index.ts"
46+
},
47+
"dependencies": {
48+
"snarkjs": "0.7.5",
49+
"ffjavascript": "0.3.1",
50+
"@noble/curves": "^1.4.2",
51+
"@noble/hashes": "^1.4.0",
52+
"@scure/bip32": "^1.3.3",
53+
"@scure/bip39": "^1.3.0",
54+
"@zk-kit/baby-jubjub": "^1.0.3",
55+
"@zk-kit/eddsa-poseidon": "^1.1.0",
56+
"@zk-kit/poseidon-cipher": "^0.3.2",
57+
"@zk-kit/utils": "^1.4.1",
58+
"@cosmjs/amino": "^0.32.1",
59+
"@cosmjs/cosmwasm-stargate": "^0.32.1",
60+
"@cosmjs/launchpad": "^0.27.1",
61+
"@cosmjs/proto-signing": "^0.32.1",
62+
"@cosmjs/stargate": "^0.32.1",
63+
"assert": "^2.1.0",
64+
"bech32": "^2.0.0",
65+
"cosmjs-types": "^0.9.0",
66+
"crypto-js": "^4.2.0",
67+
"ethers": "^6.13.4"
68+
},
69+
"devDependencies": {
70+
"@commitlint/cli": "^18.0.0",
71+
"@commitlint/config-conventional": "^18.0.0",
72+
"@commitlint/prompt-cli": "^18.0.0",
73+
"@types/crypto-js": "^4.2.2",
74+
"@types/node": "^20.8.7",
75+
"@types/tmp": "^0.2.5",
76+
"@types/snarkjs": "^0.7.9",
77+
"@typescript-eslint/eslint-plugin": "^6.8.0",
78+
"@typescript-eslint/parser": "^6.8.0",
79+
"browserify-zlib": "^0.2.0",
80+
"buffer": "^6.0.3",
81+
"crypto-browserify": "^3.12.1",
82+
"dotenv": "^16.3.1",
83+
"esbuild": "^0.25.0",
84+
"eslint": "^8.52.0",
85+
"eslint-config-prettier": "^8.8.0",
86+
"eslint-plugin-prettier": "^5.0.1",
87+
"events": "^3.3.0",
88+
"events-browserify": "^0.0.1",
89+
"https-browserify": "^1.0.0",
90+
"lint-staged": "^15.0.2",
91+
"prettier": "^3.5.3",
92+
"process": "^0.11.10",
93+
"stream-browserify": "^3.0.0",
94+
"stream-http": "^3.2.0",
95+
"ts-node": "^10.9.1",
96+
"tsconfig-paths": "^4.2.0",
97+
"tsup": "^8.0.0",
98+
"typedoc": "^0.25.2",
99+
"typescript": "^5.2.2"
100+
}
149101
}

packages/sdk/scripts/query.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@ dotenv.config();
88
const defaultSigningClientOptions: SigningStargateClientOptions = {
99
broadcastPollIntervalMs: 8_000,
1010
broadcastTimeoutMs: 16_000,
11-
gasPrice: GasPrice.fromString('10000000000peaka'),
11+
gasPrice: GasPrice.fromString('10000000000peaka')
1212
};
1313

14-
async function createContractClientByWallet(
15-
rpcEndpoint: string,
16-
wallet: OfflineSigner
17-
) {
18-
const client = await SigningCosmWasmClient.connectWithSigner(
19-
rpcEndpoint,
20-
wallet,
21-
{
22-
...defaultSigningClientOptions,
23-
}
24-
);
14+
async function createContractClientByWallet(rpcEndpoint: string, wallet: OfflineSigner) {
15+
const client = await SigningCosmWasmClient.connectWithSigner(rpcEndpoint, wallet, {
16+
...defaultSigningClientOptions
17+
});
2518
return client;
2619
}
2720

@@ -34,24 +27,18 @@ async function main() {
3427
if (key.startsWith('0x')) {
3528
key = key.slice(2);
3629
}
37-
const wallet = await DirectSecp256k1Wallet.fromKey(
38-
Buffer.from(key, 'hex'),
39-
'dora'
40-
);
30+
const wallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(key, 'hex'), 'dora');
4131

42-
const client = await createContractClientByWallet(
43-
'https://vota-rpc.dorafactory.org',
44-
wallet
45-
);
32+
const client = await createContractClientByWallet('https://vota-rpc.dorafactory.org', wallet);
4633

4734
const [{ address }] = await wallet.getAccounts();
4835

4936
const data = await client.queryContractSmart(
5037
'dora14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcp4lsrrghu944740q633553',
5138
{
5239
get_pub_key: {
53-
address,
54-
},
40+
address
41+
}
5542
}
5643
);
5744

0 commit comments

Comments
 (0)