Skip to content

Commit 3f63322

Browse files
authored
chore(cheqd): switch to @cheqd/sdk-esm (#2616)
Signed-off-by: DaevMithran <[email protected]>
1 parent e441cc1 commit 3f63322

6 files changed

Lines changed: 125 additions & 49 deletions

File tree

docker-compose.arm.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,28 @@ services:
3131
"
3232
3333
cheqd-ledger:
34-
image: ghcr.io/cheqd/cheqd-node:4.1.7
34+
image: ghcr.io/cheqd/cheqd-node:4.2.0
3535
platform: linux/amd64
3636
ports:
3737
- '26657:26657'
3838
command: >
3939
/bin/bash -c '
40+
mock-price-feed &
4041
cheqd-noded init "validator-node" --chain-id "testnet" --home "/tmp/.single-node" &&
4142
(echo "12345678") | cheqd-noded keys add validator --keyring-backend test --home "/tmp/.single-node" &&
4243
cheqd-noded genesis add-genesis-account $(cheqd-noded keys show validator -a --keyring-backend test --home "/tmp/.single-node") 100000000000000000ncheq --home "/tmp/.single-node" &&
4344
cheqd-noded genesis gentx validator 5000000000000000ncheq --chain-id testnet --keyring-backend test --home "/tmp/.single-node" &&
4445
cheqd-noded genesis collect-gentxs --home "/tmp/.single-node" &&
4546
sed -i 's/"stake"/"ncheq"/' "/tmp/.single-node/config/genesis.json" &&
47+
sed -i "s/\"vote_extensions_enable_height\"[[:space:]]*:[[:space:]]*\"0\"/\"vote_extensions_enable_height\": \"1\"/g" "/tmp/.single-node/config/genesis.json" &&
48+
sed -i "/\"fee_params\"/,/\"burn_factor\"/ s/\"ncheq\"/\"usd\"/g" "/tmp/.single-node/config/genesis.json" &&
49+
sed -i "/\"create_did\":/,/\"update_did\":/ { s/\"min_amount\": \"50000000000\"/\"min_amount\": \"2000000000000000000\"/g; s/\"max_amount\": \"100000000000\"/\"max_amount\": \"2000000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
50+
sed -i "/\"update_did\":/,/\"deactivate_did\":/ { s/\"min_amount\": \"25000000000\"/\"min_amount\": \"1000000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
51+
sed -i "/\"deactivate_did\":/,/\"burn_factor\":/ { s/\"min_amount\": \"10000000000\"/\"min_amount\": \"400000000000000000\"/g; s/\"max_amount\": \"20000000000\"/\"max_amount\": \"400000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
52+
sed -i "/\"image\":/,/\"json\":/ { s/\"min_amount\": \"20000000000\"/\"min_amount\": \"100000000000000000\"/g; s/\"max_amount\": \"30000000000\"/\"max_amount\": \"100000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
53+
sed -i "/\"json\":/,/\"default\":/ { s/\"min_amount\": \"3500000000\"/\"min_amount\": \"400000000000000000\"/g; s/\"max_amount\": \"60000000000\"/\"max_amount\": \"400000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
54+
sed -i "/\"default\":/,/\"burn_factor\":/ { s/\"min_amount\": \"6000000000\"/\"min_amount\": \"200000000000000000\"/g; s/\"max_amount\": \"20000000000\"/\"max_amount\": \"200000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
55+
sed -i "s/\"burn_factor\": \"0.500000000000000000\"/\"burn_factor\": \"0.990000000000000000\"/g" "/tmp/.single-node/config/genesis.json" &&
4656
sed -i "s/minimum-gas-prices = \"\"/minimum-gas-prices = \"50ncheq\"/g" "/tmp/.single-node/config/app.toml" &&
4757
sed -i "s/enable = false/enable = true/g" "/tmp/.single-node/config/app.toml" &&
4858
sed -i "s|laddr = \"tcp://127.0.0.1:26657\"|laddr = \"tcp://0.0.0.0:26657\"|g" "/tmp/.single-node/config/config.toml" &&
@@ -52,7 +62,13 @@ services:
5262
sed -i "s/timeout_precommit = \"1s\"/timeout_precommit = \"500ms\"/g" "/tmp/.single-node/config/config.toml" &&
5363
sed -i "s/timeout_commit = \"5s\"/timeout_commit = \"500ms\"/g" "/tmp/.single-node/config/config.toml" &&
5464
sed -i "s/log_level = \"info\"/log_level = \"debug\"/g" "/tmp/.single-node/config/config.toml" &&
55-
cheqd-noded start --home "/tmp/.single-node" &
65+
wget -O /tmp/.single-node/config/price-feeder.toml https://raw.githubusercontent.com/cheqd/cheqd-node/refs/tags/v4.2.0/pricefeeder/price-feeder.toml &&
66+
sed -i "s|rest = \"https://api.mexc.com/\"|rest = \"http://localhost:8080\"|g" "/tmp/.single-node/config/price-feeder.toml" &&
67+
sed -i "s|websocket = \"wbs-api.mexc.com\"|websocket = \"localhost:8080\"|g" "/tmp/.single-node/config/price-feeder.toml" &&
68+
sed -i "s|config_path = \"\"|config_path = \"/tmp/.single-node/config/price-feeder.toml\"|g" "/tmp/.single-node/config/app.toml" &&
69+
sed -i "s|log_level = \"\"|log_level = \"info\"|g" "/tmp/.single-node/config/app.toml" &&
70+
sed -i "s|enable = \"\"|enable = \"true\"|g" "/tmp/.single-node/config/app.toml" &&
71+
cheqd-noded start --home "/tmp/.single-node" --pricefeeder.enable=true --pricefeeder.config_path="/tmp/.single-node/config/price-feeder.toml" &
5672
RUN_TESTNET_PID=$! &&
5773
sleep 10 &&
5874
(echo "sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright"; echo "12345678";) | cheqd-noded keys add base --recover --keyring-backend test --home "/tmp/.single-node" &&

docker-compose.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,29 @@ services:
3030
"
3131
3232
cheqd-ledger:
33-
image: ghcr.io/cheqd/cheqd-node:4.1.7
33+
image: ghcr.io/cheqd/cheqd-node:4.2.0
3434
container_name: cheqd-validator
3535
platform: linux/amd64
3636
ports:
3737
- '26657:26657'
3838
command: >
3939
/bin/bash -c '
40+
mock-price-feed &
4041
cheqd-noded init "validator-node" --chain-id "testnet" --home "/tmp/.single-node" &&
4142
(echo "12345678") | cheqd-noded keys add validator --keyring-backend test --home "/tmp/.single-node" &&
4243
cheqd-noded genesis add-genesis-account $(cheqd-noded keys show validator -a --keyring-backend test --home "/tmp/.single-node") 100000000000000000ncheq --home "/tmp/.single-node" &&
4344
cheqd-noded genesis gentx validator 5000000000000000ncheq --chain-id testnet --keyring-backend test --home "/tmp/.single-node" &&
4445
cheqd-noded genesis collect-gentxs --home "/tmp/.single-node" &&
4546
sed -i 's/"stake"/"ncheq"/' "/tmp/.single-node/config/genesis.json" &&
47+
sed -i "s/\"vote_extensions_enable_height\"[[:space:]]*:[[:space:]]*\"0\"/\"vote_extensions_enable_height\": \"1\"/g" "/tmp/.single-node/config/genesis.json" &&
48+
sed -i "/\"fee_params\"/,/\"burn_factor\"/ s/\"ncheq\"/\"usd\"/g" "/tmp/.single-node/config/genesis.json" &&
49+
sed -i "/\"create_did\":/,/\"update_did\":/ { s/\"min_amount\": \"50000000000\"/\"min_amount\": \"2000000000000000000\"/g; s/\"max_amount\": \"100000000000\"/\"max_amount\": \"2000000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
50+
sed -i "/\"update_did\":/,/\"deactivate_did\":/ { s/\"min_amount\": \"25000000000\"/\"min_amount\": \"1000000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
51+
sed -i "/\"deactivate_did\":/,/\"burn_factor\":/ { s/\"min_amount\": \"10000000000\"/\"min_amount\": \"400000000000000000\"/g; s/\"max_amount\": \"20000000000\"/\"max_amount\": \"400000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
52+
sed -i "/\"image\":/,/\"json\":/ { s/\"min_amount\": \"20000000000\"/\"min_amount\": \"100000000000000000\"/g; s/\"max_amount\": \"30000000000\"/\"max_amount\": \"100000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
53+
sed -i "/\"json\":/,/\"default\":/ { s/\"min_amount\": \"3500000000\"/\"min_amount\": \"400000000000000000\"/g; s/\"max_amount\": \"60000000000\"/\"max_amount\": \"400000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
54+
sed -i "/\"default\":/,/\"burn_factor\":/ { s/\"min_amount\": \"6000000000\"/\"min_amount\": \"200000000000000000\"/g; s/\"max_amount\": \"20000000000\"/\"max_amount\": \"200000000000000000\"/g }" "/tmp/.single-node/config/genesis.json" &&
55+
sed -i "s/\"burn_factor\": \"0.500000000000000000\"/\"burn_factor\": \"0.990000000000000000\"/g" "/tmp/.single-node/config/genesis.json" &&
4656
sed -i "s/minimum-gas-prices = \"\"/minimum-gas-prices = \"50ncheq\"/g" "/tmp/.single-node/config/app.toml" &&
4757
sed -i "s/enable = false/enable = true/g" "/tmp/.single-node/config/app.toml" &&
4858
sed -i "s|laddr = \"tcp://127.0.0.1:26657\"|laddr = \"tcp://0.0.0.0:26657\"|g" "/tmp/.single-node/config/config.toml" &&
@@ -52,7 +62,13 @@ services:
5262
sed -i "s/timeout_precommit = \"1s\"/timeout_precommit = \"500ms\"/g" "/tmp/.single-node/config/config.toml" &&
5363
sed -i "s/timeout_commit = \"5s\"/timeout_commit = \"500ms\"/g" "/tmp/.single-node/config/config.toml" &&
5464
sed -i "s/log_level = \"info\"/log_level = \"debug\"/g" "/tmp/.single-node/config/config.toml" &&
55-
cheqd-noded start --home "/tmp/.single-node" &
65+
wget -O /tmp/.single-node/config/price-feeder.toml https://raw.githubusercontent.com/cheqd/cheqd-node/refs/tags/v4.2.0/pricefeeder/price-feeder.toml &&
66+
sed -i "s|rest = \"https://api.mexc.com/\"|rest = \"http://localhost:8080\"|g" "/tmp/.single-node/config/price-feeder.toml" &&
67+
sed -i "s|websocket = \"wbs-api.mexc.com\"|websocket = \"localhost:8080\"|g" "/tmp/.single-node/config/price-feeder.toml" &&
68+
sed -i "s|config_path = \"\"|config_path = \"/tmp/.single-node/config/price-feeder.toml\"|g" "/tmp/.single-node/config/app.toml" &&
69+
sed -i "s|log_level = \"\"|log_level = \"info\"|g" "/tmp/.single-node/config/app.toml" &&
70+
sed -i "s|enable = \"\"|enable = \"true\"|g" "/tmp/.single-node/config/app.toml" &&
71+
cheqd-noded start --home "/tmp/.single-node" --pricefeeder.enable=true --pricefeeder.config_path="/tmp/.single-node/config/price-feeder.toml" &
5672
RUN_TESTNET_PID=$! &&
5773
sleep 10 &&
5874
(echo "sketch mountain erode window enact net enrich smoke claim kangaroo another visual write meat latin bacon pulp similar forum guilt father state erase bright"; echo "12345678";) | cheqd-noded keys add base --recover --keyring-backend test --home "/tmp/.single-node" &&

packages/cheqd/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"prepublishOnly": "pnpm run build"
3030
},
3131
"dependencies": {
32-
"@cheqd/sdk": "npm:@cheqd/sdk-esm@~5.3.7",
32+
"@cheqd/sdk": "npm:@cheqd/sdk-esm@~5.4.8",
3333
"@cheqd/ts-proto": "^4.2.0",
3434
"@cosmjs/crypto": "^0.36.2",
3535
"@cosmjs/proto-signing": "^0.36.2",

packages/cheqd/src/dids/CheqdDidRegistrar.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
CheqdNetwork,
33
createDidVerificationMethod,
44
type DIDDocument,
5+
type DidFeeOptions,
56
type DidStdFee,
67
MethodSpecificIdAlgo,
78
VerificationMethods,
@@ -614,7 +615,13 @@ export class CheqdDidRegistrar implements DidRegistrar {
614615
didDocumentInstance.verificationMethod,
615616
didRecord.keys
616617
)
617-
const response = await cheqdLedgerService.createResource(did, resourcePayload, signInputs)
618+
const response = await cheqdLedgerService.createResource(
619+
did,
620+
resourcePayload,
621+
signInputs,
622+
resource.fee,
623+
resource.feeOptions
624+
)
618625
if (response.code !== 0) {
619626
throw new Error(`${response.rawLog}`)
620627
}
@@ -687,6 +694,7 @@ export interface CheqdDidCreateWithoutDidDocumentOptions extends DidCreateOption
687694
options: {
688695
network: `${CheqdNetwork}`
689696
fee?: DidStdFee
697+
feeOptions?: DidFeeOptions
690698
versionId?: string
691699
methodSpecificIdAlgo?: `${MethodSpecificIdAlgo}`
692700
} & XOR<{ createKey: KmsCreateKeyOptionsOkpEd25519 }, { keyId: string }>
@@ -703,6 +711,7 @@ export interface CheqdDidCreateFromDidDocumentOptions extends DidCreateOptions {
703711
*/
704712
keys: DidDocumentKey[]
705713
fee?: DidStdFee
714+
feeOptions?: DidFeeOptions
706715
versionId?: string
707716
}
708717
}
@@ -722,6 +731,7 @@ export interface CheqdDidUpdateOptions extends DidUpdateOptions {
722731
keys?: DidDocumentKey[]
723732

724733
fee?: DidStdFee
734+
feeOptions?: DidFeeOptions
725735
versionId?: string
726736
} & XOR<{ createKey?: KmsCreateKeyOptionsOkpEd25519 }, { keyId?: string }>
727737
}
@@ -731,6 +741,7 @@ export interface CheqdDidDeactivateOptions extends DidCreateOptions {
731741
did: string
732742
options: {
733743
fee?: DidStdFee
744+
feeOptions?: DidFeeOptions
734745
versionId?: string
735746
}
736747
}
@@ -740,4 +751,6 @@ export interface CheqdCreateResourceOptions extends Pick<MsgCreateResourcePayloa
740751
collectionId?: MsgCreateResourcePayload['collectionId']
741752
version?: MsgCreateResourcePayload['version']
742753
alsoKnownAs?: MsgCreateResourcePayload['alsoKnownAs']
754+
fee?: DidStdFee
755+
feeOptions?: DidFeeOptions
743756
}

packages/cheqd/src/ledger/CheqdLedgerService.ts

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { AbstractCheqdSDKModule, CheqdSDK, DIDDocument, DidStdFee } from '@cheqd/sdk'
2-
import { CheqdNetwork, createCheqdSDK, DIDModule, FeemarketModule, ResourceModule } from '@cheqd/sdk'
1+
import type { AbstractCheqdSDKModule, CheqdSDK, DIDDocument, DidFeeOptions, DidStdFee } from '@cheqd/sdk'
2+
import { CheqdNetwork, createCheqdSDK, DIDModule, FeemarketModule, OracleModule, ResourceModule } from '@cheqd/sdk'
33
import type { QueryAllDidDocVersionsMetadataResponse, SignInfo } from '@cheqd/ts-proto/cheqd/did/v2'
44
import type {
55
Metadata,
@@ -101,6 +101,7 @@ export class CheqdLedgerService {
101101
FeemarketModule as unknown as AbstractCheqdSDKModule,
102102
DIDModule as unknown as AbstractCheqdSDKModule,
103103
ResourceModule as unknown as AbstractCheqdSDKModule,
104+
OracleModule as unknown as AbstractCheqdSDKModule,
104105
],
105106
rpcUrl: network.rpcUrl,
106107
wallet: await network.cosmosPayerWallet.catch((error) => {
@@ -122,30 +123,57 @@ export class CheqdLedgerService {
122123
didPayload: DIDDocument,
123124
signInputs: SignInfo[],
124125
versionId?: string | undefined,
125-
fee?: DidStdFee
126+
fee?: DidStdFee,
127+
feeOptions?: DidFeeOptions
126128
): Promise<DeliverTxResponse> {
127129
const sdk = await this.getSdk(didPayload.id)
128-
return sdk.createDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)
130+
return sdk.createDidDocTx(
131+
signInputs,
132+
didPayload,
133+
'',
134+
fee,
135+
undefined,
136+
versionId,
137+
feeOptions || { slippageBps: 1000 }
138+
)
129139
}
130140

131141
public async update(
132142
didPayload: DIDDocument,
133143
signInputs: SignInfo[],
134144
versionId?: string | undefined,
135-
fee?: DidStdFee
145+
fee?: DidStdFee,
146+
feeOptions?: DidFeeOptions
136147
): Promise<DeliverTxResponse> {
137148
const sdk = await this.getSdk(didPayload.id)
138-
return sdk.updateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)
149+
return sdk.updateDidDocTx(
150+
signInputs,
151+
didPayload,
152+
'',
153+
fee,
154+
undefined,
155+
versionId,
156+
feeOptions || { slippageBps: 1000 }
157+
)
139158
}
140159

141160
public async deactivate(
142161
didPayload: DIDDocument,
143162
signInputs: SignInfo[],
144163
versionId?: string | undefined,
145-
fee?: DidStdFee
164+
fee?: DidStdFee,
165+
feeOptions?: DidFeeOptions
146166
): Promise<DeliverTxResponse> {
147167
const sdk = await this.getSdk(didPayload.id)
148-
return sdk.deactivateDidDocTx(signInputs, didPayload, '', fee, undefined, versionId)
168+
return sdk.deactivateDidDocTx(
169+
signInputs,
170+
didPayload,
171+
'',
172+
fee,
173+
undefined,
174+
versionId,
175+
feeOptions || { slippageBps: 1000 }
176+
)
149177
}
150178

151179
public async resolve(did: string, version?: string) {
@@ -165,10 +193,18 @@ export class CheqdLedgerService {
165193
did: string,
166194
resourcePayload: Partial<MsgCreateResourcePayload>,
167195
signInputs: SignInfo[],
168-
fee?: DidStdFee
196+
fee?: DidStdFee,
197+
feeOptions?: DidFeeOptions
169198
): Promise<DeliverTxResponse> {
170199
const sdk = await this.getSdk(did)
171-
return sdk.createLinkedResourceTx(signInputs, resourcePayload, '', fee, undefined)
200+
return sdk.createLinkedResourceTx(
201+
signInputs,
202+
resourcePayload,
203+
'',
204+
fee,
205+
undefined,
206+
feeOptions || { slippageBps: 1000 }
207+
)
172208
}
173209

174210
public async resolveResource(did: string, collectionId: string, resourceId: string): Promise<ResourceWithMetadata> {

0 commit comments

Comments
 (0)