@cheqd/sdk 3.0.2-develop.1 → 3.0.2-develop.3

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.
Files changed (56) hide show
  1. package/package.json +9 -3
  2. package/.github/ISSUE_TEMPLATE/bug-report.yml +0 -74
  3. package/.github/ISSUE_TEMPLATE/config.yml +0 -14
  4. package/.github/ISSUE_TEMPLATE/feature-request.yaml +0 -27
  5. package/.github/dependabot.yml +0 -43
  6. package/.github/linters/.commitlint.rules.cjs +0 -37
  7. package/.github/linters/.eslintrc.json +0 -18
  8. package/.github/linters/.markdown-lint.yml +0 -139
  9. package/.github/linters/mlc_config.json +0 -13
  10. package/.github/workflows/build.yml +0 -26
  11. package/.github/workflows/cleanup-actions.yml +0 -45
  12. package/.github/workflows/cleanup-cache-automatic.yml +0 -24
  13. package/.github/workflows/cleanup-cache-manual.yml +0 -21
  14. package/.github/workflows/codeql.yml +0 -40
  15. package/.github/workflows/dispatch.yml +0 -30
  16. package/.github/workflows/lint.yml +0 -51
  17. package/.github/workflows/pull-request.yml +0 -48
  18. package/.github/workflows/release.yml +0 -42
  19. package/.github/workflows/test.yml +0 -66
  20. package/.releaserc.json +0 -61
  21. package/CHANGELOG.md +0 -320
  22. package/CODE_OF_CONDUCT.md +0 -81
  23. package/NOTICE.md +0 -10
  24. package/SECURITY.md +0 -12
  25. package/docker/Dockerfile +0 -55
  26. package/docker/entrypoint.sh +0 -58
  27. package/docker/localnet/build-latest.env +0 -7
  28. package/docker/localnet/container-env/observer-0.env +0 -13
  29. package/docker/localnet/container-env/seed-0.env +0 -17
  30. package/docker/localnet/container-env/validator-0.env +0 -13
  31. package/docker/localnet/container-env/validator-1.env +0 -13
  32. package/docker/localnet/container-env/validator-2.env +0 -13
  33. package/docker/localnet/container-env/validator-3.env +0 -13
  34. package/docker/localnet/docker-compose.yml +0 -281
  35. package/docker/localnet/gen-network-config.sh +0 -259
  36. package/docker/localnet/import-keys.sh +0 -31
  37. package/jest.config.cjs +0 -20
  38. package/src/index.ts +0 -192
  39. package/src/modules/_.ts +0 -61
  40. package/src/modules/did.ts +0 -601
  41. package/src/modules/resource.ts +0 -247
  42. package/src/querier.ts +0 -36
  43. package/src/registry.ts +0 -13
  44. package/src/signer.ts +0 -297
  45. package/src/types.ts +0 -110
  46. package/src/utils.ts +0 -246
  47. package/tests/index.test.ts +0 -155
  48. package/tests/modules/did.test.ts +0 -985
  49. package/tests/modules/resource.test.ts +0 -991
  50. package/tests/signer.test.ts +0 -202
  51. package/tests/testutils.test.ts +0 -29
  52. package/tests/utils.test.ts +0 -77
  53. package/tsconfig.cjs.json +0 -8
  54. package/tsconfig.esm.json +0 -8
  55. package/tsconfig.json +0 -84
  56. package/tsconfig.types.json +0 -10
@@ -1,259 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Generates network configuration for an arbitrary amount of validators, observers, and seeds.
4
-
5
- set -euo pipefail
6
-
7
- # sed in macos requires extra argument
8
- if [[ "$OSTYPE" == "linux-gnu"* ]]; then
9
- SED_EXT=''
10
- elif [[ "$OSTYPE" == "darwin"* ]]; then
11
- SED_EXT='.orig'
12
- fi
13
-
14
- # Params
15
- CHAIN_ID=${1:-"cheqd"} # First parameter, default is "cheqd"
16
-
17
- VALIDATORS_COUNT=${2:-4} # Second parameter, default is 4
18
- SEEDS_COUNT=${3:-1} # Third parameter, default is 1
19
- OBSERVERS_COUNT=${4:-1} # Fourth parameter, default is 1
20
-
21
- function init_node() {
22
- NODE_HOME=$1
23
- NODE_MONIKER=$2
24
-
25
- echo "[${NODE_MONIKER}] Initializing"
26
-
27
- cheqd-noded init "${NODE_MONIKER}" --chain-id "${CHAIN_ID}" --home "${NODE_HOME}" 2> /dev/null
28
- cheqd-noded tendermint show-node-id --home "${NODE_HOME}" > "${NODE_HOME}/node_id.txt"
29
- cheqd-noded tendermint show-validator --home "${NODE_HOME}" > "${NODE_HOME}/node_val_pubkey.txt"
30
- }
31
-
32
- function configure_node() {
33
- NODE_HOME=$1
34
- NODE_MONIKER=$2
35
-
36
- echo "[${NODE_MONIKER}] Configuring app.toml and config.toml"
37
-
38
- APP_TOML="${NODE_HOME}/config/app.toml"
39
- CONFIG_TOML="${NODE_HOME}/config/config.toml"
40
-
41
- sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}"
42
- sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}"
43
-
44
- sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}"
45
- sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}"
46
-
47
- sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}"
48
- sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}"
49
- sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}"
50
- sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}"
51
- }
52
-
53
- function configure_genesis() {
54
- NODE_HOME=$1
55
- NODE_MONIKER=$2
56
-
57
- echo "[${NODE_MONIKER}] Configuring genesis"
58
-
59
- GENESIS="${NODE_HOME}/config/genesis.json"
60
- GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json"
61
-
62
- # Default denom
63
- sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}"
64
-
65
- # Short voting period
66
- sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}"
67
-
68
- # Test accounts
69
- BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96"
70
- # Mnemonic: sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright
71
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_1}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
72
- mv "${GENESIS_TMP}" "${GENESIS}"
73
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_1}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
74
- mv "${GENESIS_TMP}" "${GENESIS}"
75
-
76
- BASE_ACCOUNT_2="cheqd1l9sq0se0jd3vklyrrtjchx4ua47awug5vsyeeh"
77
- # Mnemonic: ugly dirt sorry girl prepare argue door man that manual glow scout bomb pigeon matter library transfer flower clown cat miss pluck drama dizzy
78
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_2}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
79
- mv "${GENESIS_TMP}" "${GENESIS}"
80
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_2}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
81
- mv "${GENESIS_TMP}" "${GENESIS}"
82
-
83
- BASE_ACCOUNT_3="cheqd14wymr6h8a0rvynwayytssy5rhn3evltcpxh0zh"
84
- # Mnemonic: fix wheel picnic about army scan table fence device trust alter erupt wear donkey wood slender gold reunion grant quiz absurd tragic reform attitude
85
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_3}'", "coins": [{"denom": "ncheq", "amount": "100"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
86
- mv "${GENESIS_TMP}" "${GENESIS}"
87
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_3}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
88
- mv "${GENESIS_TMP}" "${GENESIS}"
89
-
90
- BASE_ACCOUNT_4="cheqd1c8tq9wcfwtunkunng5pe442jlmwns9sgve42mf"
91
- # Mnemonic: horn slim pigeon winner capable piano soul find ignore crawl arrow genuine magnet nasty basic lamp scissors treat stick arm dress elbow trash naive
92
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_4}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
93
- mv "${GENESIS_TMP}" "${GENESIS}"
94
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_4}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
95
- mv "${GENESIS_TMP}" "${GENESIS}"
96
-
97
- BASE_ACCOUNT_5="cheqd1xnx6fe4fg4etlaxm0ty25j3ae5thhadraskplv"
98
- # Mnemonic: blue town hobby lens hawk deputy father tissue state choose another liquid license start push iron limb visa taste mother cause history tackle fiber
99
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_5}'", "coins": [{"denom": "ncheq", "amount": "100001000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
100
- mv "${GENESIS_TMP}" "${GENESIS}"
101
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_5}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
102
- mv "${GENESIS_TMP}" "${GENESIS}"
103
-
104
- BASE_ACCOUNT_6="cheqd1makysw7c788c7fzkfzn7al80wyfl4at6jtjyg4"
105
- # Mnemonic: gallery hospital vicious demand orient piano melody vanish remind pistol elephant bracket olive kitten caution apart capital protect junior endorse run drama tiny patrol
106
- jq '.app_state.bank.balances += [{"address": "'${BASE_ACCOUNT_6}'", "coins": [{"denom": "ncheq", "amount": "100"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
107
- mv "${GENESIS_TMP}" "${GENESIS}"
108
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.auth.v1beta1.BaseAccount","address": "'${BASE_ACCOUNT_6}'", "pub_key": null,"account_number": "0","sequence": "0"}]' "$GENESIS" > "$GENESIS_TMP" && \
109
- mv "${GENESIS_TMP}" "${GENESIS}"
110
-
111
- BASE_VESTING_ACCOUNT="cheqd1lkqddnapqvz2hujx2trpj7xj6c9hmuq7uhl0md"
112
- # Mnemonic: coach index fence broken very cricket someone casino dial truth fitness stay habit such three jump exotic spawn planet fragile walk enact angry great
113
- # shellcheck disable=SC2089
114
- BASE_VESTING_COIN="{\"denom\":\"ncheq\",\"amount\":\"10001000000000000\"}"
115
- jq '.app_state.bank.balances += [{"address": "'${BASE_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
116
- mv "${GENESIS_TMP}" "${GENESIS}"
117
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.BaseVestingAccount", "base_account": {"address": "'${BASE_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1672531199"}]' "$GENESIS" > "$GENESIS_TMP" && \
118
- mv "${GENESIS_TMP}" "${GENESIS}"
119
-
120
- CONTINUOUS_VESTING_ACCOUNT="cheqd1353p46macvn444rupg2jstmx3tmz657yt9gl4l"
121
- # Mnemonic: phone worry flame safe panther dirt picture pepper purchase tiny search theme issue genre orange merit stove spoil surface color garment mind chuckle image
122
- jq '.app_state.bank.balances += [{"address": "'${CONTINUOUS_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
123
- mv "${GENESIS_TMP}" "${GENESIS}"
124
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.ContinuousVestingAccount", "base_vesting_account": { "base_account": {"address": "'${CONTINUOUS_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1672531199"}, "start_time": "1630352459"}]' "$GENESIS" > "$GENESIS_TMP" && \
125
- mv "${GENESIS_TMP}" "${GENESIS}"
126
-
127
- DELAYED_VESTING_ACCOUNT="cheqd1njwu33lek5jt4kzlmljkp366ny4qpqusahpyrj"
128
- # Mnemonic: pilot text keen deal economy donkey use artist divide foster walk pink breeze proud dish brown icon shaft infant level labor lift will tomorrow
129
- jq '.app_state.bank.balances += [{"address": "'${DELAYED_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
130
- mv "${GENESIS_TMP}" "${GENESIS}"
131
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.DelayedVestingAccount", "base_vesting_account": { "base_account": {"address": "'${DELAYED_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1672531199"}}]' "$GENESIS" > "$GENESIS_TMP" && \
132
- mv "${GENESIS_TMP}" "${GENESIS}"
133
-
134
- PERIODIC_VESTING_ACCOUNT="cheqd1uyngr0l3xtyj07js9sdew9mk50tqeq8lghhcfr"
135
- # Mnemonic: want merge flame plate trouble moral submit wing whale sick meat lonely yellow lens enable oyster slight health vast weird radar mesh grab olive
136
- jq '.app_state.bank.balances += [{"address": "'${PERIODIC_VESTING_ACCOUNT}'", "coins": [{"denom": "ncheq", "amount": "5000000000000000"}] }]' "$GENESIS" > "$GENESIS_TMP" && \
137
- mv "${GENESIS_TMP}" "${GENESIS}"
138
- jq '.app_state.auth.accounts += [{"@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount", "base_vesting_account": { "base_account": {"address": "'${PERIODIC_VESTING_ACCOUNT}'","pub_key": null,"account_number": "0","sequence": "0"}, "original_vesting": ['"${BASE_VESTING_COIN}"'], "delegated_free": [], "delegated_vesting": [], "end_time": "1672531199"}, "start_time": "1672531179", "vesting_periods": [{"length": "20", "amount": ['"${BASE_VESTING_COIN}"']}]}]' "$GENESIS" > "$GENESIS_TMP" && \
139
- mv "${GENESIS_TMP}" "${GENESIS}"
140
- }
141
-
142
-
143
- NETWORK_CONFIG_DIR="network-config"
144
- rm -rf $NETWORK_CONFIG_DIR
145
- mkdir $NETWORK_CONFIG_DIR
146
-
147
-
148
- # Generating node configurations
149
- for ((i=0 ; i<VALIDATORS_COUNT ; i++))
150
- do
151
- NODE_MONIKER="validator-$i"
152
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
153
-
154
- init_node "${NODE_HOME}" "${NODE_MONIKER}"
155
- configure_node "${NODE_HOME}" "${NODE_MONIKER}"
156
- done
157
-
158
- for ((i=0 ; i<SEEDS_COUNT ; i++))
159
- do
160
- NODE_MONIKER="seed-$i"
161
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
162
-
163
- init_node "${NODE_HOME}" "${NODE_MONIKER}"
164
- configure_node "${NODE_HOME}" "${NODE_MONIKER}"
165
- done
166
-
167
- for ((i=0 ; i<OBSERVERS_COUNT ; i++))
168
- do
169
- NODE_MONIKER="observer-$i"
170
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
171
-
172
- init_node "${NODE_HOME}" "${NODE_MONIKER}"
173
- configure_node "${NODE_HOME}" "${NODE_MONIKER}"
174
- done
175
-
176
-
177
- # Generating genesis
178
- TMP_NODE_MONIKER="tmp"
179
- TMP_NODE_HOME="${NETWORK_CONFIG_DIR}/${TMP_NODE_MONIKER}"
180
- init_node "${TMP_NODE_HOME}" "${TMP_NODE_MONIKER}"
181
- configure_genesis "${TMP_NODE_HOME}" "${TMP_NODE_MONIKER}"
182
-
183
- mkdir "${TMP_NODE_HOME}/config/gentx"
184
-
185
-
186
- # Adding genesis validators
187
- for ((i=0 ; i<VALIDATORS_COUNT ; i++))
188
- do
189
- NODE_MONIKER="validator-$i"
190
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
191
-
192
- cp "${TMP_NODE_HOME}/config/genesis.json" "${NODE_HOME}/config/genesis.json"
193
-
194
- cheqd-noded keys add "operator-$i" --keyring-backend "test" --home "${NODE_HOME}"
195
- cheqd-noded add-genesis-account "operator-$i" 20000000000000000ncheq --keyring-backend "test" --home "${NODE_HOME}"
196
-
197
- NODE_ID=$(cheqd-noded tendermint show-node-id --home "${NODE_HOME}")
198
- NODE_VAL_PUBKEY=$(cheqd-noded tendermint show-validator --home "${NODE_HOME}")
199
- cheqd-noded gentx "operator-$i" 1000000000000000ncheq --chain-id "${CHAIN_ID}" --node-id "${NODE_ID}" \
200
- --pubkey "${NODE_VAL_PUBKEY}" --keyring-backend "test" --home "${NODE_HOME}"
201
-
202
- cp "${NODE_HOME}/config/genesis.json" "${TMP_NODE_HOME}/config/genesis.json"
203
- cp -R "${NODE_HOME}/config/gentx/." "${TMP_NODE_HOME}/config/gentx"
204
- done
205
-
206
-
207
- echo "Collecting gentxs"
208
- cheqd-noded collect-gentxs --home "${TMP_NODE_HOME}"
209
- cheqd-noded validate-genesis --home "${TMP_NODE_HOME}"
210
-
211
- # Distribute final genesis
212
- for ((i=0 ; i<VALIDATORS_COUNT ; i++))
213
- do
214
- NODE_MONIKER="validator-$i"
215
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
216
-
217
- cp "${TMP_NODE_HOME}/config/genesis.json" "${NODE_HOME}/config/genesis.json"
218
- done
219
-
220
- for ((i=0 ; i<SEEDS_COUNT ; i++))
221
- do
222
- NODE_MONIKER="seed-$i"
223
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
224
-
225
- cp "${TMP_NODE_HOME}/config/genesis.json" "${NODE_HOME}/config/genesis.json"
226
- done
227
-
228
- for ((i=0 ; i<OBSERVERS_COUNT ; i++))
229
- do
230
- NODE_MONIKER="observer-$i"
231
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
232
-
233
- cp "${TMP_NODE_HOME}/config/genesis.json" "${NODE_HOME}/config/genesis.json"
234
- done
235
-
236
- # Leave one copy of genesis in the root of network-config
237
- cp "${TMP_NODE_HOME}/config/genesis.json" "${NETWORK_CONFIG_DIR}/genesis.json"
238
-
239
- # Generate seeds.txt
240
- SEEDS_STR=""
241
-
242
- for ((i=0 ; i<SEEDS_COUNT ; i++))
243
- do
244
- NODE_MONIKER="seed-$i"
245
- NODE_P2P_PORT="26656"
246
- NODE_HOME="${NETWORK_CONFIG_DIR}/${NODE_MONIKER}"
247
-
248
- if ((i != 0))
249
- then
250
- SEEDS_STR="${SEEDS_STR},"
251
- fi
252
-
253
- SEEDS_STR="${SEEDS_STR}$(cat "${NODE_HOME}/node_id.txt")@${NODE_MONIKER}:${NODE_P2P_PORT}"
254
- done
255
-
256
- echo "${SEEDS_STR}" > "${NETWORK_CONFIG_DIR}/seeds.txt"
257
-
258
- # We don't need the tmp node anymore
259
- rm -rf "${TMP_NODE_HOME}"
@@ -1,31 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -euox pipefail
4
-
5
- KEYRING_BACKEND="test"
6
-
7
- function import_key() {
8
- ALIAS=${1}
9
- MNEMONIC=${2}
10
-
11
- echo "Importing key: ${ALIAS}"
12
-
13
- if cheqd-noded keys show "${ALIAS}" --keyring-backend ${KEYRING_BACKEND}
14
- then
15
- echo "Key ${ALIAS} already exists"
16
- return 0
17
- fi
18
-
19
- echo "${MNEMONIC}" | cheqd-noded keys add "${ALIAS}" --keyring-backend ${KEYRING_BACKEND} --recover
20
- }
21
-
22
- import_key "base_account_1" "sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright"
23
- import_key "base_account_2" "ugly dirt sorry girl prepare argue door man that manual glow scout bomb pigeon matter library transfer flower clown cat miss pluck drama dizzy"
24
- import_key "base_account_3" "fix wheel picnic about army scan table fence device trust alter erupt wear donkey wood slender gold reunion grant quiz absurd tragic reform attitude"
25
- import_key "base_account_4" "horn slim pigeon winner capable piano soul find ignore crawl arrow genuine magnet nasty basic lamp scissors treat stick arm dress elbow trash naive"
26
- import_key "base_account_5" "blue town hobby lens hawk deputy father tissue state choose another liquid license start push iron limb visa taste mother cause history tackle fiber"
27
- import_key "base_account_6" "gallery hospital vicious demand orient piano melody vanish remind pistol elephant bracket olive kitten caution apart capital protect junior endorse run drama tiny patrol"
28
- import_key "base_vesting_account" "coach index fence broken very cricket someone casino dial truth fitness stay habit such three jump exotic spawn planet fragile walk enact angry great"
29
- import_key "continuous_vesting_account" "phone worry flame safe panther dirt picture pepper purchase tiny search theme issue genre orange merit stove spoil surface color garment mind chuckle image"
30
- import_key "delayed_vesting_account" "pilot text keen deal economy donkey use artist divide foster walk pink breeze proud dish brown icon shaft infant level labor lift will tomorrow"
31
- import_key "periodic_vesting_account" "want merge flame plate trouble moral submit wing whale sick meat lonely yellow lens enable oyster slight health vast weird radar mesh grab olive"
package/jest.config.cjs DELETED
@@ -1,20 +0,0 @@
1
- /** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
2
- module.exports = {
3
- extensionsToTreatAsEsm: ['.ts'],
4
- moduleNameMapper: {
5
- '^(\\.{1,2}/.*)\\.js$': '$1',
6
- },
7
- transform: {
8
- // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
9
- // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
10
- '^.+\\.m?[tj]sx?$': [
11
- 'ts-jest',
12
- {
13
- useESM: true,
14
- },
15
- ],
16
- },
17
- testEnvironment: 'node',
18
- moduleDirectories: ['node_modules', 'src'],
19
- modulePathIgnorePatterns: ["tests/testutils.test.ts"],
20
- };
package/src/index.ts DELETED
@@ -1,192 +0,0 @@
1
- import {
2
- OfflineSigner,
3
- Registry
4
- } from '@cosmjs/proto-signing'
5
- import {
6
- DIDModule,
7
- MinimalImportableDIDModule,
8
- DidExtension
9
- } from './modules/did.js';
10
- import {
11
- MinimalImportableResourceModule,
12
- ResourceModule,
13
- ResourceExtension
14
- } from './modules/resource.js';
15
- import {
16
- AbstractCheqdSDKModule,
17
- applyMixins,
18
- instantiateCheqdSDKModule,
19
- instantiateCheqdSDKModuleRegistryTypes,
20
- instantiateCheqdSDKModuleQuerierExtensionSetup
21
- } from './modules/_.js';
22
- import { createDefaultCheqdRegistry } from './registry.js'
23
- import { CheqdSigningStargateClient } from './signer.js'
24
- import {
25
- CheqdNetwork,
26
- IContext,
27
- IModuleMethodMap
28
- } from './types.js';
29
- import {
30
- GasPrice,
31
- QueryClient
32
- } from '@cosmjs/stargate'
33
- import { CheqdQuerier } from './querier.js'
34
- import { Tendermint34Client } from '@cosmjs/tendermint-rpc'
35
-
36
- export interface ICheqdSDKOptions {
37
- modules: AbstractCheqdSDKModule[]
38
- querierExtensions?: Record<string, any>[]
39
- rpcUrl: string
40
- network?: CheqdNetwork
41
- gasPrice?: GasPrice
42
- authorizedMethods?: string[]
43
- readonly wallet: OfflineSigner
44
- }
45
-
46
- export type DefaultCheqdSDKModules = MinimalImportableDIDModule & MinimalImportableResourceModule
47
-
48
- export interface CheqdSDK extends DefaultCheqdSDKModules {}
49
-
50
- export class CheqdSDK {
51
- methods: IModuleMethodMap
52
- signer: CheqdSigningStargateClient
53
- querier: CheqdQuerier & DidExtension & ResourceExtension
54
- options: ICheqdSDKOptions
55
- private protectedMethods: string[] = ['constructor', 'build', 'loadModules', 'loadRegistry']
56
-
57
- constructor(options: ICheqdSDKOptions) {
58
- if (!options?.wallet) {
59
- throw new Error('No wallet provided')
60
- }
61
-
62
- this.options = {
63
- authorizedMethods: [],
64
- network: CheqdNetwork.Testnet,
65
- ...options
66
- }
67
-
68
- this.methods = {}
69
- this.signer = new CheqdSigningStargateClient(undefined, this.options.wallet, {})
70
- this.querier = <any> new QueryClient({} as unknown as Tendermint34Client)
71
- }
72
-
73
- async execute<P = any, R = any>(method: string, ...params: P[]): Promise<R> {
74
- if (!Object.keys(this.methods).includes(method)) {
75
- throw new Error(`Method ${method} is not authorized`)
76
- }
77
- return await this.methods[method](...params, { sdk: this } as IContext)
78
- }
79
-
80
- private async loadModules(modules: AbstractCheqdSDKModule[]): Promise<CheqdSDK> {
81
- this.options.modules = this.options.modules.map((module: any) => instantiateCheqdSDKModule(module, this.signer, this.querier, { sdk: this } as IContext) as unknown as AbstractCheqdSDKModule)
82
-
83
- const methods = applyMixins(this, modules)
84
- this.methods = { ...this.methods, ...filterUnauthorizedMethods(methods, this.options.authorizedMethods || [], this.protectedMethods) }
85
-
86
- for (const method of Object.keys(this.methods)) {
87
- // @ts-ignore
88
- this[method] = async (...params: any[]) => {
89
- return await this.execute(method, ...params)
90
- }
91
- }
92
-
93
- return this
94
- }
95
-
96
- private loadRegistry(): Registry {
97
- const registryTypes = this.options.modules.map((module: any) => instantiateCheqdSDKModuleRegistryTypes(module)).reduce((acc, types) => {
98
- return [...acc, ...types]
99
- })
100
- return createDefaultCheqdRegistry(registryTypes)
101
- }
102
-
103
- private async loadQuerierExtensions(): Promise<CheqdQuerier & DidExtension & ResourceExtension> {
104
- const querierExtensions = this.options.modules.map((module: any) => instantiateCheqdSDKModuleQuerierExtensionSetup(module))
105
- const querier = await CheqdQuerier.connectWithExtensions(this.options.rpcUrl, ...querierExtensions)
106
- return <CheqdQuerier & DidExtension & ResourceExtension>querier
107
- }
108
-
109
- async build(): Promise<CheqdSDK> {
110
- const registry = this.loadRegistry()
111
-
112
- this.querier = await this.loadQuerierExtensions()
113
- this.signer = await CheqdSigningStargateClient.connectWithSigner(
114
- this.options.rpcUrl,
115
- this.options.wallet,
116
- {
117
- registry,
118
- gasPrice: this.options?.gasPrice,
119
- }
120
- )
121
-
122
- return await this.loadModules(this.options.modules)
123
- }
124
- }
125
-
126
- export function filterUnauthorizedMethods(methods: IModuleMethodMap, authorizedMethods: string[], protectedMethods: string[]): IModuleMethodMap {
127
- let _methods = Object.keys(methods)
128
- if (authorizedMethods.length === 0)
129
- return _methods
130
- .filter(method => !protectedMethods.includes(method))
131
- .reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {})
132
-
133
- return _methods
134
- .filter(method => authorizedMethods.includes(method) && !protectedMethods.includes(method))
135
- .reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {})
136
- }
137
-
138
- export async function createCheqdSDK(options: ICheqdSDKOptions): Promise<CheqdSDK> {
139
- return await (new CheqdSDK(options)).build()
140
- }
141
-
142
- export { DIDModule, ResourceModule }
143
- export { AbstractCheqdSDKModule, applyMixins } from './modules/_.js'
144
- export {
145
- DidExtension,
146
- MinimalImportableDIDModule,
147
- MsgCreateDidDocEncodeObject,
148
- MsgCreateDidDocResponseEncodeObject,
149
- MsgUpdateDidDocEncodeObject,
150
- MsgUpdateDidDocResponseEncodeObject,
151
- MsgDeactivateDidDocEncodeObject,
152
- MsgDeactivateDidDocResponseEncodeObject,
153
- contexts,
154
- defaultDidExtensionKey,
155
- protobufLiterals as protobufLiteralsDid,
156
- typeUrlMsgCreateDidDoc,
157
- typeUrlMsgCreateDidDocResponse,
158
- typeUrlMsgUpdateDidDoc,
159
- typeUrlMsgUpdateDidDocResponse,
160
- typeUrlMsgDeactivateDidDoc,
161
- typeUrlMsgDeactivateDidDocResponse,
162
- setupDidExtension,
163
- isMsgCreateDidDocEncodeObject,
164
- isMsgUpdateDidDocEncodeObject,
165
- isMsgDeactivateDidDocEncodeObject,
166
- } from './modules/did.js'
167
- export {
168
- ResourceExtension,
169
- MinimalImportableResourceModule,
170
- defaultResourceExtensionKey,
171
- protobufLiterals as protobufLiteralsResource,
172
- typeUrlMsgCreateResource,
173
- typeUrlMsgCreateResourceResponse,
174
- setupResourceExtension,
175
- isMsgCreateResourceEncodeObject,
176
- } from './modules/resource.js'
177
- export * from './signer.js'
178
- export * from './querier.js'
179
- export * from './registry.js'
180
- export * from './types.js'
181
- export {
182
- TImportableEd25519Key,
183
- createKeyPairRaw,
184
- createKeyPairBase64,
185
- createKeyPairHex,
186
- createVerificationKeys,
187
- createDidVerificationMethod,
188
- createDidPayload,
189
- createSignInputsFromImportableEd25519Key,
190
- validateSpecCompliantPayload,
191
- isEqualKeyValuePair,
192
- } from './utils.js'
package/src/modules/_.ts DELETED
@@ -1,61 +0,0 @@
1
- import { GeneratedType } from "@cosmjs/proto-signing"
2
- import { QueryClient } from "@cosmjs/stargate"
3
- import { CheqdSigningStargateClient } from '../signer.js'
4
- import {
5
- IModuleMethodMap,
6
- QueryExtensionSetup
7
- } from '../types.js';
8
- import { CheqdQuerier } from "../querier.js";
9
-
10
- export abstract class AbstractCheqdSDKModule {
11
- _signer: CheqdSigningStargateClient
12
- methods: IModuleMethodMap = {}
13
- querier: CheqdQuerier
14
- readonly _protectedMethods: string[] = ['constructor', 'getRegistryTypes', 'getQuerierExtensionSetup']
15
- static readonly registryTypes: Iterable<[string, GeneratedType]> = []
16
- static readonly querierExtensionSetup: QueryExtensionSetup<any> = (base: QueryClient) => ({})
17
-
18
- constructor(signer: CheqdSigningStargateClient, querier: CheqdQuerier) {
19
- if (!signer) {
20
- throw new Error("signer is required")
21
- }
22
- if (!querier) {
23
- throw new Error("querier is required")
24
- }
25
- this._signer = signer
26
- this.querier = querier
27
- }
28
-
29
- abstract getRegistryTypes(): Iterable<[string, GeneratedType]>
30
- }
31
-
32
- type ProtectedMethods<T extends AbstractCheqdSDKModule, K extends keyof T> = T[K] extends string[] ? T[K][number] : T[K]
33
-
34
- export type MinimalImportableCheqdSDKModule<T extends AbstractCheqdSDKModule> = Omit<T, '_signer' | '_protectedMethods' | 'registryTypes' | 'querierExtensionSetup' | 'getRegistryTypes' | 'getQuerierExtensionSetup'>
35
-
36
- export function instantiateCheqdSDKModule<T extends new (...args: any[]) => T>(module: T, ...args: ConstructorParameters<T>): T {
37
- return new module(...args)
38
- }
39
-
40
- export function instantiateCheqdSDKModuleRegistryTypes(module: any): Iterable<[string, GeneratedType]> {
41
- return module.registryTypes ?? []
42
- }
43
-
44
- export function instantiateCheqdSDKModuleQuerierExtensionSetup(module: any): QueryExtensionSetup<any> {
45
- return module.querierExtensionSetup ?? {}
46
- }
47
-
48
- export function applyMixins(derivedCtor: any, constructors: any[]): IModuleMethodMap {
49
- let methods: IModuleMethodMap = {}
50
-
51
- constructors.forEach((baseCtor) => {
52
- Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
53
- const property = baseCtor.prototype[name]
54
- if (typeof property !== 'function' || derivedCtor.hasOwnProperty(name) || derivedCtor?.protectedMethods.includes(name) || baseCtor.prototype?._protectedMethods?.includes(name)) return
55
-
56
- methods = { ...methods, [name]: property }
57
- });
58
- });
59
-
60
- return methods
61
- }