@cheqd/sdk 5.3.2-develop.2 → 5.3.3-develop.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 +310 -0
- package/build/cjs/index.d.ts +92 -1
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/index.js +75 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/modules/_.d.ts +61 -0
- package/build/cjs/modules/_.d.ts.map +1 -1
- package/build/cjs/modules/_.js +50 -0
- package/build/cjs/modules/_.js.map +1 -1
- package/build/cjs/modules/did.d.ts +278 -0
- package/build/cjs/modules/did.d.ts.map +1 -1
- package/build/cjs/modules/did.js +242 -0
- package/build/cjs/modules/did.js.map +1 -1
- package/build/cjs/modules/feeabstraction.d.ts +297 -2
- package/build/cjs/modules/feeabstraction.d.ts.map +1 -1
- package/build/cjs/modules/feeabstraction.js +235 -4
- package/build/cjs/modules/feeabstraction.js.map +1 -1
- package/build/cjs/modules/feemarket.d.ts +154 -21
- package/build/cjs/modules/feemarket.d.ts.map +1 -1
- package/build/cjs/modules/feemarket.js +133 -22
- package/build/cjs/modules/feemarket.js.map +1 -1
- package/build/cjs/modules/resource.d.ts +143 -0
- package/build/cjs/modules/resource.d.ts.map +1 -1
- package/build/cjs/modules/resource.js +131 -0
- package/build/cjs/modules/resource.js.map +1 -1
- package/build/cjs/querier.d.ts +50 -0
- package/build/cjs/querier.d.ts.map +1 -1
- package/build/cjs/querier.js +50 -0
- package/build/cjs/querier.js.map +1 -1
- package/build/cjs/registry.d.ts +14 -0
- package/build/cjs/registry.d.ts.map +1 -1
- package/build/cjs/registry.js +14 -0
- package/build/cjs/registry.js.map +1 -1
- package/build/cjs/signer.d.ts +172 -1
- package/build/cjs/signer.d.ts.map +1 -1
- package/build/cjs/signer.js +172 -1
- package/build/cjs/signer.js.map +1 -1
- package/build/cjs/types.d.ts +91 -0
- package/build/cjs/types.d.ts.map +1 -1
- package/build/cjs/types.js +17 -0
- package/build/cjs/types.js.map +1 -1
- package/build/cjs/utils.d.ts +188 -0
- package/build/cjs/utils.d.ts.map +1 -1
- package/build/cjs/utils.js +195 -0
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.d.ts +92 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +74 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/modules/_.d.ts +42 -0
- package/build/esm/modules/_.d.ts.map +1 -1
- package/build/esm/modules/_.js +32 -0
- package/build/esm/modules/_.js.map +1 -1
- package/build/esm/modules/did.d.ts +274 -0
- package/build/esm/modules/did.d.ts.map +1 -1
- package/build/esm/modules/did.js +242 -0
- package/build/esm/modules/did.js.map +1 -1
- package/build/esm/modules/feeabstraction.d.ts +277 -2
- package/build/esm/modules/feeabstraction.d.ts.map +1 -1
- package/build/esm/modules/feeabstraction.js +221 -2
- package/build/esm/modules/feeabstraction.js.map +1 -1
- package/build/esm/modules/feemarket.d.ts +152 -21
- package/build/esm/modules/feemarket.d.ts.map +1 -1
- package/build/esm/modules/feemarket.js +131 -21
- package/build/esm/modules/feemarket.js.map +1 -1
- package/build/esm/modules/resource.d.ts +142 -0
- package/build/esm/modules/resource.d.ts.map +1 -1
- package/build/esm/modules/resource.js +130 -0
- package/build/esm/modules/resource.js.map +1 -1
- package/build/esm/querier.d.ts +50 -0
- package/build/esm/querier.d.ts.map +1 -1
- package/build/esm/querier.js +50 -0
- package/build/esm/querier.js.map +1 -1
- package/build/esm/registry.d.ts +14 -0
- package/build/esm/registry.d.ts.map +1 -1
- package/build/esm/registry.js +14 -0
- package/build/esm/registry.js.map +1 -1
- package/build/esm/signer.d.ts +122 -0
- package/build/esm/signer.d.ts.map +1 -1
- package/build/esm/signer.js +122 -0
- package/build/esm/signer.js.map +1 -1
- package/build/esm/types.d.ts +92 -0
- package/build/esm/types.d.ts.map +1 -1
- package/build/esm/types.js +17 -0
- package/build/esm/types.js.map +1 -1
- package/build/esm/utils.d.ts +178 -0
- package/build/esm/utils.d.ts.map +1 -1
- package/build/esm/utils.js +171 -0
- package/build/esm/utils.js.map +1 -1
- package/build/types/index.d.ts +92 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/modules/_.d.ts +42 -0
- package/build/types/modules/_.d.ts.map +1 -1
- package/build/types/modules/did.d.ts +274 -0
- package/build/types/modules/did.d.ts.map +1 -1
- package/build/types/modules/feeabstraction.d.ts +277 -2
- package/build/types/modules/feeabstraction.d.ts.map +1 -1
- package/build/types/modules/feemarket.d.ts +152 -21
- package/build/types/modules/feemarket.d.ts.map +1 -1
- package/build/types/modules/resource.d.ts +142 -0
- package/build/types/modules/resource.d.ts.map +1 -1
- package/build/types/querier.d.ts +50 -0
- package/build/types/querier.d.ts.map +1 -1
- package/build/types/registry.d.ts +14 -0
- package/build/types/registry.d.ts.map +1 -1
- package/build/types/signer.d.ts +122 -0
- package/build/types/signer.d.ts.map +1 -1
- package/build/types/types.d.ts +92 -0
- package/build/types/types.d.ts.map +1 -1
- package/build/types/utils.d.ts +178 -0
- package/build/types/utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -7,16 +7,38 @@ import { fileTypeFromBuffer } from 'file-type';
|
|
|
7
7
|
import { toString } from 'uint8arrays/to-string';
|
|
8
8
|
import { assert } from '@cosmjs/utils';
|
|
9
9
|
import { isJSON } from '../utils.js';
|
|
10
|
+
/** Default extension key for resource-related query operations */
|
|
10
11
|
export const defaultResourceExtensionKey = 'resource';
|
|
12
|
+
/**
|
|
13
|
+
* Protobuf message type literals for resource operations.
|
|
14
|
+
* Used for consistent message type identification across the module.
|
|
15
|
+
*/
|
|
11
16
|
export const protobufLiterals = {
|
|
17
|
+
/** Create resource message type */
|
|
12
18
|
MsgCreateResource: 'MsgCreateResource',
|
|
19
|
+
/** Create resource response message type */
|
|
13
20
|
MsgCreateResourceResponse: 'MsgCreateResourceResponse',
|
|
14
21
|
};
|
|
22
|
+
/** Type URL for MsgCreateResource messages */
|
|
15
23
|
export const typeUrlMsgCreateResource = `/${protobufPackage}.${protobufLiterals.MsgCreateResource}`;
|
|
24
|
+
/** Type URL for MsgCreateResourceResponse messages */
|
|
16
25
|
export const typeUrlMsgCreateResourceResponse = `/${protobufPackage}.${protobufLiterals.MsgCreateResourceResponse}`;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard function to check if an object is a MsgCreateResourceEncodeObject.
|
|
28
|
+
*
|
|
29
|
+
* @param obj - EncodeObject to check
|
|
30
|
+
* @returns True if the object is a MsgCreateResourceEncodeObject
|
|
31
|
+
*/
|
|
17
32
|
export function isMsgCreateResourceEncodeObject(obj) {
|
|
18
33
|
return obj.typeUrl === typeUrlMsgCreateResource;
|
|
19
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets up the resource extension for the querier client.
|
|
37
|
+
* Creates and configures the resource-specific query methods.
|
|
38
|
+
*
|
|
39
|
+
* @param base - Base QueryClient to extend
|
|
40
|
+
* @returns Configured resource extension with query methods
|
|
41
|
+
*/
|
|
20
42
|
export const setupResourceExtension = (base) => {
|
|
21
43
|
const rpc = createProtobufRpcClient(base);
|
|
22
44
|
const queryService = new QueryClientImpl(rpc);
|
|
@@ -42,20 +64,40 @@ export const setupResourceExtension = (base) => {
|
|
|
42
64
|
},
|
|
43
65
|
};
|
|
44
66
|
};
|
|
67
|
+
/**
|
|
68
|
+
* Resource Module class providing comprehensive linked resource functionality.
|
|
69
|
+
* Handles creation, querying, and metadata management of resources linked to DID documents.
|
|
70
|
+
*/
|
|
45
71
|
export class ResourceModule extends AbstractCheqdSDKModule {
|
|
46
72
|
// @ts-expect-error underlying type `GeneratedType` is intentionally wider
|
|
47
73
|
static registryTypes = [
|
|
48
74
|
[typeUrlMsgCreateResource, MsgCreateResource],
|
|
49
75
|
[typeUrlMsgCreateResourceResponse, MsgCreateResourceResponse],
|
|
50
76
|
];
|
|
77
|
+
/** Base denomination for Cheqd network transactions */
|
|
51
78
|
static baseMinimalDenom = 'ncheq';
|
|
79
|
+
/**
|
|
80
|
+
* Standard fee amounts for different resource types.
|
|
81
|
+
* Fees vary based on resource content type and processing requirements.
|
|
82
|
+
*/
|
|
52
83
|
static fees = {
|
|
84
|
+
/** Default fee for creating image resources */
|
|
53
85
|
DefaultCreateResourceImageFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
86
|
+
/** Default fee for creating JSON resources */
|
|
54
87
|
DefaultCreateResourceJsonFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
88
|
+
/** Default fee for creating other types of resources */
|
|
55
89
|
DefaultCreateResourceDefaultFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
56
90
|
};
|
|
91
|
+
/** Querier extension setup function for resource operations */
|
|
57
92
|
static querierExtensionSetup = setupResourceExtension;
|
|
93
|
+
/** Querier instance with resource extension capabilities */
|
|
58
94
|
querier;
|
|
95
|
+
/**
|
|
96
|
+
* Constructs a new resource module instance.
|
|
97
|
+
*
|
|
98
|
+
* @param signer - Signing client for blockchain transactions
|
|
99
|
+
* @param querier - Querier client with resource extension for data retrieval
|
|
100
|
+
*/
|
|
59
101
|
constructor(signer, querier) {
|
|
60
102
|
super(signer, querier);
|
|
61
103
|
this.querier = querier;
|
|
@@ -66,12 +108,30 @@ export class ResourceModule extends AbstractCheqdSDKModule {
|
|
|
66
108
|
queryLinkedResources: this.queryLinkedResources.bind(this),
|
|
67
109
|
};
|
|
68
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the registry types for resource message encoding/decoding.
|
|
113
|
+
*
|
|
114
|
+
* @returns Iterable of [typeUrl, GeneratedType] pairs for the registry
|
|
115
|
+
*/
|
|
69
116
|
getRegistryTypes() {
|
|
70
117
|
return ResourceModule.registryTypes;
|
|
71
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Gets the querier extension setup for resource operations.
|
|
121
|
+
*
|
|
122
|
+
* @returns Query extension setup function for resource functionality
|
|
123
|
+
*/
|
|
72
124
|
getQuerierExtensionSetup() {
|
|
73
125
|
return ResourceModule.querierExtensionSetup;
|
|
74
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Signs a resource payload with provided signature inputs.
|
|
129
|
+
* Creates a complete signed resource message ready for blockchain submission.
|
|
130
|
+
*
|
|
131
|
+
* @param payload - Resource payload to sign
|
|
132
|
+
* @param signInputs - Signing inputs or pre-computed signatures
|
|
133
|
+
* @returns Promise resolving to the signed resource message
|
|
134
|
+
*/
|
|
75
135
|
static async signPayload(payload, signInputs) {
|
|
76
136
|
const signBytes = MsgCreateResourcePayload.encode(payload).finish();
|
|
77
137
|
let signatures;
|
|
@@ -86,6 +146,19 @@ export class ResourceModule extends AbstractCheqdSDKModule {
|
|
|
86
146
|
signatures,
|
|
87
147
|
};
|
|
88
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Creates a linked resource transaction on the blockchain.
|
|
151
|
+
* Handles automatic fee calculation based on resource content type and size.
|
|
152
|
+
*
|
|
153
|
+
* @param signInputs - Signing inputs or pre-computed signatures for the transaction
|
|
154
|
+
* @param resourcePayload - Resource payload containing data and metadata
|
|
155
|
+
* @param address - Address of the account submitting the transaction
|
|
156
|
+
* @param fee - Transaction fee configuration or 'auto' for automatic calculation
|
|
157
|
+
* @param memo - Optional transaction memo
|
|
158
|
+
* @param context - Optional SDK context for accessing clients
|
|
159
|
+
* @returns Promise resolving to the transaction response
|
|
160
|
+
* @throws Error if linked resource data is empty when automatic fee calculation is requested
|
|
161
|
+
*/
|
|
89
162
|
async createLinkedResourceTx(signInputs, resourcePayload, address, fee, memo, context) {
|
|
90
163
|
if (!this._signer) {
|
|
91
164
|
this._signer = context.sdk.signer;
|
|
@@ -116,29 +189,70 @@ export class ResourceModule extends AbstractCheqdSDKModule {
|
|
|
116
189
|
}
|
|
117
190
|
return this._signer.signAndBroadcast(address, [encObj], fee, memo);
|
|
118
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Queries a specific linked resource by collection and resource ID.
|
|
194
|
+
* Retrieves the complete resource data along with its metadata.
|
|
195
|
+
*
|
|
196
|
+
* @param collectionId - ID of the collection containing the resource
|
|
197
|
+
* @param resourceId - ID of the resource to query
|
|
198
|
+
* @param context - Optional SDK context for accessing clients
|
|
199
|
+
* @returns Promise resolving to the resource with metadata
|
|
200
|
+
*/
|
|
119
201
|
async queryLinkedResource(collectionId, resourceId, context) {
|
|
120
202
|
if (!this.querier) {
|
|
121
203
|
this.querier = context.sdk.querier;
|
|
122
204
|
}
|
|
123
205
|
return await this.querier[defaultResourceExtensionKey].resource(collectionId, resourceId);
|
|
124
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Queries metadata for a specific linked resource.
|
|
209
|
+
* Retrieves only the metadata without the resource content data.
|
|
210
|
+
*
|
|
211
|
+
* @param collectionId - ID of the collection containing the resource
|
|
212
|
+
* @param resourceId - ID of the resource to query metadata for
|
|
213
|
+
* @param context - Optional SDK context for accessing clients
|
|
214
|
+
* @returns Promise resolving to the resource metadata
|
|
215
|
+
*/
|
|
125
216
|
async queryLinkedResourceMetadata(collectionId, resourceId, context) {
|
|
126
217
|
if (!this.querier) {
|
|
127
218
|
this.querier = context.sdk.querier;
|
|
128
219
|
}
|
|
129
220
|
return await this.querier[defaultResourceExtensionKey].resourceMetadata(collectionId, resourceId);
|
|
130
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Queries all resources in a collection with pagination support.
|
|
224
|
+
* Retrieves a list of all resources belonging to a specific collection.
|
|
225
|
+
*
|
|
226
|
+
* @param collectionId - ID of the collection to query resources for
|
|
227
|
+
* @param context - Optional SDK context for accessing clients
|
|
228
|
+
* @returns Promise resolving to the collection resources response with pagination
|
|
229
|
+
*/
|
|
131
230
|
async queryLinkedResources(collectionId, context) {
|
|
132
231
|
if (!this.querier) {
|
|
133
232
|
this.querier = context.sdk.querier;
|
|
134
233
|
}
|
|
135
234
|
return await this.querier[defaultResourceExtensionKey].collectionResources(collectionId);
|
|
136
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Reads and determines the MIME type of resource content.
|
|
238
|
+
* Analyzes the content to identify the appropriate MIME type for fee calculation and validation.
|
|
239
|
+
*
|
|
240
|
+
* @param content - Resource content as byte array
|
|
241
|
+
* @returns Promise resolving to the detected MIME type string
|
|
242
|
+
*/
|
|
137
243
|
static async readMimeType(content) {
|
|
138
244
|
if (isJSON(toString(content, 'utf-8')))
|
|
139
245
|
return 'application/json';
|
|
140
246
|
return (await fileTypeFromBuffer(content))?.mime ?? 'application/octet-stream';
|
|
141
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Generates fee configuration for image resource creation transactions.
|
|
250
|
+
* Uses higher gas limits appropriate for image processing and storage.
|
|
251
|
+
*
|
|
252
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
253
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
254
|
+
* @returns Promise resolving to the fee configuration for image resources
|
|
255
|
+
*/
|
|
142
256
|
static async generateCreateResourceImageFees(feePayer, granter) {
|
|
143
257
|
return {
|
|
144
258
|
amount: [ResourceModule.fees.DefaultCreateResourceImageFee],
|
|
@@ -147,6 +261,14 @@ export class ResourceModule extends AbstractCheqdSDKModule {
|
|
|
147
261
|
granter: granter,
|
|
148
262
|
};
|
|
149
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Generates fee configuration for JSON resource creation transactions.
|
|
266
|
+
* Uses gas limits optimized for JSON data processing and validation.
|
|
267
|
+
*
|
|
268
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
269
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
270
|
+
* @returns Promise resolving to the fee configuration for JSON resources
|
|
271
|
+
*/
|
|
150
272
|
static async generateCreateResourceJsonFees(feePayer, granter) {
|
|
151
273
|
return {
|
|
152
274
|
amount: [ResourceModule.fees.DefaultCreateResourceJsonFee],
|
|
@@ -155,6 +277,14 @@ export class ResourceModule extends AbstractCheqdSDKModule {
|
|
|
155
277
|
granter: granter,
|
|
156
278
|
};
|
|
157
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Generates fee configuration for default resource creation transactions.
|
|
282
|
+
* Uses standard gas limits for generic resource types and binary data.
|
|
283
|
+
*
|
|
284
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
285
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
286
|
+
* @returns Promise resolving to the fee configuration for default resources
|
|
287
|
+
*/
|
|
158
288
|
static async generateCreateResourceDefaultFees(feePayer, granter) {
|
|
159
289
|
return {
|
|
160
290
|
amount: [ResourceModule.fees.DefaultCreateResourceDefaultFee],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../esm/src/modules/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAmC,MAAM,QAAQ,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,EAAuB,WAAW,EAAuB,MAAM,aAAa,CAAC;AACpF,OAAO,EAEN,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EAGf,eAAe,GACf,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAkC,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAmB,CAAC;AAE/D,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,iBAAiB,EAAE,mBAAmB;IACtC,yBAAyB,EAAE,2BAA2B;CAC7C,CAAC;AAEX,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,eAAe,IAAI,gBAAgB,CAAC,iBAAiB,EAAW,CAAC;AAC7G,MAAM,CAAC,MAAM,gCAAgC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QAChF,OAAO;YACN,MAAM,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,+BAA+B,CAAC;YAC7D,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,OAAO;SACH,CAAC;IAChB,CAAC"}
|
package/build/esm/querier.d.ts
CHANGED
|
@@ -1,12 +1,62 @@
|
|
|
1
1
|
import { QueryClient } from '@cosmjs/stargate';
|
|
2
2
|
import { CometClient, ConsensusParams } from '@cosmjs/tendermint-rpc';
|
|
3
3
|
import { QueryExtensionSetup, CheqdExtensions } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extended QueryClient specifically designed for the Cheqd blockchain network.
|
|
6
|
+
* Provides enhanced querying capabilities with support for custom extensions
|
|
7
|
+
* and consensus parameter retrieval.
|
|
8
|
+
*/
|
|
4
9
|
export declare class CheqdQuerier extends QueryClient {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new CheqdQuerier instance with the provided Comet client.
|
|
12
|
+
*
|
|
13
|
+
* @param cometClient - Comet client for blockchain communication
|
|
14
|
+
*/
|
|
5
15
|
constructor(cometClient: CometClient);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the consensus parameters from the blockchain network.
|
|
18
|
+
* This method creates a temporary connection to fetch the latest block results
|
|
19
|
+
* and extract consensus update information.
|
|
20
|
+
*
|
|
21
|
+
* @param url - RPC URL of the blockchain node
|
|
22
|
+
* @returns Promise resolving to consensus parameters or undefined if not available
|
|
23
|
+
*/
|
|
6
24
|
static getConsensusParameters(url: string): Promise<ConsensusParams | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new CheqdQuerier instance by establishing a connection to the specified RPC URL.
|
|
27
|
+
* This is the primary method for creating a querier instance for blockchain communication.
|
|
28
|
+
*
|
|
29
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
30
|
+
* @returns Promise resolving to a connected CheqdQuerier instance
|
|
31
|
+
*/
|
|
7
32
|
static connect(url: string): Promise<CheqdQuerier>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a CheqdQuerier instance from an existing Comet client.
|
|
35
|
+
* Useful when you already have an established client connection.
|
|
36
|
+
*
|
|
37
|
+
* @param client - Existing Comet client
|
|
38
|
+
* @returns Promise resolving to a CheqdQuerier instance using the provided client
|
|
39
|
+
*/
|
|
8
40
|
static fromClient(client: CometClient): Promise<CheqdQuerier>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a CheqdQuerier instance with a single query extension.
|
|
43
|
+
* Extensions provide specialized query capabilities for specific blockchain modules.
|
|
44
|
+
*
|
|
45
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
46
|
+
* @param extension - Query extension setup to add specialized query functionality
|
|
47
|
+
* @returns Promise resolving to a CheqdQuerier instance with the specified extension
|
|
48
|
+
*/
|
|
9
49
|
static connectWithExtension(url: string, extension: QueryExtensionSetup<CheqdExtensions>): Promise<CheqdQuerier & CheqdExtensions>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a CheqdQuerier instance with multiple query extensions.
|
|
52
|
+
* This method supports adding multiple specialized query capabilities for different
|
|
53
|
+
* blockchain modules in a single operation. For single extensions, it delegates
|
|
54
|
+
* to connectWithExtension for efficiency.
|
|
55
|
+
*
|
|
56
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
57
|
+
* @param extensions - Variable number of query extension setups to add functionality
|
|
58
|
+
* @returns Promise resolving to a CheqdQuerier instance with all specified extensions
|
|
59
|
+
*/
|
|
10
60
|
static connectWithExtensions(url: string, ...extensions: QueryExtensionSetup<CheqdExtensions>[]): Promise<CheqdQuerier & CheqdExtensions>;
|
|
11
61
|
}
|
|
12
62
|
//# sourceMappingURL=querier.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"querier.d.ts","sourceRoot":"","sources":["../../esm/src/querier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,qBAAa,YAAa,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"querier.d.ts","sourceRoot":"","sources":["../../esm/src/querier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAgB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC5C;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAIpC;;;;;;;OAOG;WACU,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IActF;;;;;;OAMG;WACU,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAKxD;;;;;;OAMG;WACU,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAInE;;;;;;;OAOG;WACU,oBAAoB,CAChC,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,mBAAmB,CAAC,eAAe,CAAC,GAC7C,OAAO,CAAC,YAAY,GAAG,eAAe,CAAC;IAK1C;;;;;;;;;OASG;WACU,qBAAqB,CACjC,GAAG,EAAE,MAAM,EACX,GAAG,UAAU,EAAE,mBAAmB,CAAC,eAAe,CAAC,EAAE,GACnD,OAAO,CAAC,YAAY,GAAG,eAAe,CAAC;CAY1C"}
|
package/build/esm/querier.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
import { QueryClient } from '@cosmjs/stargate';
|
|
2
2
|
import { connectComet } from '@cosmjs/tendermint-rpc';
|
|
3
|
+
/**
|
|
4
|
+
* Extended QueryClient specifically designed for the Cheqd blockchain network.
|
|
5
|
+
* Provides enhanced querying capabilities with support for custom extensions
|
|
6
|
+
* and consensus parameter retrieval.
|
|
7
|
+
*/
|
|
3
8
|
export class CheqdQuerier extends QueryClient {
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new CheqdQuerier instance with the provided Comet client.
|
|
11
|
+
*
|
|
12
|
+
* @param cometClient - Comet client for blockchain communication
|
|
13
|
+
*/
|
|
4
14
|
constructor(cometClient) {
|
|
5
15
|
super(cometClient);
|
|
6
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the consensus parameters from the blockchain network.
|
|
19
|
+
* This method creates a temporary connection to fetch the latest block results
|
|
20
|
+
* and extract consensus update information.
|
|
21
|
+
*
|
|
22
|
+
* @param url - RPC URL of the blockchain node
|
|
23
|
+
* @returns Promise resolving to consensus parameters or undefined if not available
|
|
24
|
+
*/
|
|
7
25
|
static async getConsensusParameters(url) {
|
|
8
26
|
// connect to comet rpc
|
|
9
27
|
const cometClient = await connectComet(url);
|
|
@@ -14,17 +32,49 @@ export class CheqdQuerier extends QueryClient {
|
|
|
14
32
|
// return consensus parameters
|
|
15
33
|
return result.consensusUpdates;
|
|
16
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new CheqdQuerier instance by establishing a connection to the specified RPC URL.
|
|
37
|
+
* This is the primary method for creating a querier instance for blockchain communication.
|
|
38
|
+
*
|
|
39
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
40
|
+
* @returns Promise resolving to a connected CheqdQuerier instance
|
|
41
|
+
*/
|
|
17
42
|
static async connect(url) {
|
|
18
43
|
const cometClient = await connectComet(url);
|
|
19
44
|
return new CheqdQuerier(cometClient);
|
|
20
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a CheqdQuerier instance from an existing Comet client.
|
|
48
|
+
* Useful when you already have an established client connection.
|
|
49
|
+
*
|
|
50
|
+
* @param client - Existing Comet client
|
|
51
|
+
* @returns Promise resolving to a CheqdQuerier instance using the provided client
|
|
52
|
+
*/
|
|
21
53
|
static async fromClient(client) {
|
|
22
54
|
return new CheqdQuerier(client);
|
|
23
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a CheqdQuerier instance with a single query extension.
|
|
58
|
+
* Extensions provide specialized query capabilities for specific blockchain modules.
|
|
59
|
+
*
|
|
60
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
61
|
+
* @param extension - Query extension setup to add specialized query functionality
|
|
62
|
+
* @returns Promise resolving to a CheqdQuerier instance with the specified extension
|
|
63
|
+
*/
|
|
24
64
|
static async connectWithExtension(url, extension) {
|
|
25
65
|
const cometClient = await connectComet(url);
|
|
26
66
|
return CheqdQuerier.withExtensions(cometClient, extension);
|
|
27
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a CheqdQuerier instance with multiple query extensions.
|
|
70
|
+
* This method supports adding multiple specialized query capabilities for different
|
|
71
|
+
* blockchain modules in a single operation. For single extensions, it delegates
|
|
72
|
+
* to connectWithExtension for efficiency.
|
|
73
|
+
*
|
|
74
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
75
|
+
* @param extensions - Variable number of query extension setups to add functionality
|
|
76
|
+
* @returns Promise resolving to a CheqdQuerier instance with all specified extensions
|
|
77
|
+
*/
|
|
28
78
|
static async connectWithExtensions(url, ...extensions) {
|
|
29
79
|
if (extensions.length === 1)
|
|
30
80
|
return CheqdQuerier.connectWithExtension(url, extensions[0]);
|
package/build/esm/querier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"querier.js","sourceRoot":"","sources":["../../esm/src/querier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAe,YAAY,EAAmB,MAAM,wBAAwB,CAAC;AAGpF,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC5C,YAAY,WAAwB;QACnC,KAAK,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC;IAED,MAAM,CAAC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AAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1F,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,UAKjB,CAAC;QACF,OAAO,YAAY,CAAC,cAAc,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,CAAC;IAC/D,CAAC;CACD"}
|
package/build/esm/registry.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { Registry, GeneratedType } from '@cosmjs/proto-signing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a default Cheqd registry with optional custom types.
|
|
4
|
+
* The registry is used for encoding and decoding protobuf messages in blockchain transactions.
|
|
5
|
+
* It includes all default Stargate types and any additional custom types provided.
|
|
6
|
+
*
|
|
7
|
+
* @param customTypes - Optional iterable of custom type mappings to add to the registry.
|
|
8
|
+
* Each entry should be a tuple of [typeUrl, GeneratedType].
|
|
9
|
+
* @returns A configured Registry instance with default and custom types
|
|
10
|
+
*/
|
|
2
11
|
export declare function createDefaultCheqdRegistry(customTypes?: Iterable<[string, GeneratedType]>): Registry;
|
|
12
|
+
/**
|
|
13
|
+
* Pre-configured Cheqd registry instance with default Stargate types.
|
|
14
|
+
* This is a ready-to-use registry for basic blockchain operations that don't require
|
|
15
|
+
* custom message types. For applications needing custom types, use createDefaultCheqdRegistry instead.
|
|
16
|
+
*/
|
|
3
17
|
export declare const CheqdRegistry: Registry;
|
|
4
18
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../esm/src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAIhE,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,GAAG,QAAQ,CAGpG;AAED,eAAO,MAAM,aAAa,UAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../esm/src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,GAAG,QAAQ,CAGpG;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAqC,CAAC"}
|
package/build/esm/registry.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { Registry } from '@cosmjs/proto-signing';
|
|
2
2
|
import { defaultRegistryTypes } from '@cosmjs/stargate';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a default Cheqd registry with optional custom types.
|
|
5
|
+
* The registry is used for encoding and decoding protobuf messages in blockchain transactions.
|
|
6
|
+
* It includes all default Stargate types and any additional custom types provided.
|
|
7
|
+
*
|
|
8
|
+
* @param customTypes - Optional iterable of custom type mappings to add to the registry.
|
|
9
|
+
* Each entry should be a tuple of [typeUrl, GeneratedType].
|
|
10
|
+
* @returns A configured Registry instance with default and custom types
|
|
11
|
+
*/
|
|
3
12
|
export function createDefaultCheqdRegistry(customTypes) {
|
|
4
13
|
if (!customTypes)
|
|
5
14
|
customTypes = [];
|
|
6
15
|
return new Registry([...defaultRegistryTypes, ...customTypes]);
|
|
7
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Pre-configured Cheqd registry instance with default Stargate types.
|
|
19
|
+
* This is a ready-to-use registry for basic blockchain operations that don't require
|
|
20
|
+
* custom message types. For applications needing custom types, use createDefaultCheqdRegistry instead.
|
|
21
|
+
*/
|
|
8
22
|
export const CheqdRegistry = new Registry(defaultRegistryTypes);
|
|
9
23
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../esm/src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,UAAU,0BAA0B,CAAC,WAA+C;IACzF,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,EAAE,CAAC;IACnC,OAAO,IAAI,QAAQ,CAAC,CAAC,GAAG,oBAAoB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../esm/src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA+C;IACzF,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,EAAE,CAAC;IACnC,OAAO,IAAI,QAAQ,CAAC,CAAC,GAAG,oBAAoB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC"}
|
package/build/esm/signer.d.ts
CHANGED
|
@@ -10,29 +10,115 @@ import { Any } from 'cosmjs-types/google/protobuf/any.js';
|
|
|
10
10
|
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin.js';
|
|
11
11
|
import { CheqdQuerier } from './querier.js';
|
|
12
12
|
import { TxExtension } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the transaction fee for DID operations using gas limit and gas price.
|
|
15
|
+
*
|
|
16
|
+
* @param gasLimit - Maximum amount of gas units that can be consumed by the transaction
|
|
17
|
+
* @param gasPrice - Price per gas unit, either as a string or GasPrice object
|
|
18
|
+
* @returns DidStdFee object containing the calculated fee structure
|
|
19
|
+
*/
|
|
13
20
|
export declare function calculateDidFee(gasLimit: number, gasPrice: string | GasPrice): DidStdFee;
|
|
21
|
+
/**
|
|
22
|
+
* Creates SignerInfo objects for transaction authentication from signer data.
|
|
23
|
+
* Each signer info contains the public key, sequence number, and signing mode.
|
|
24
|
+
*
|
|
25
|
+
* @param signers - Array of signer objects containing public keys and sequence numbers
|
|
26
|
+
* @param signMode - Signing mode to use (e.g., SIGN_MODE_DIRECT)
|
|
27
|
+
* @returns Array of SignerInfo objects for transaction authentication
|
|
28
|
+
*/
|
|
14
29
|
export declare function makeSignerInfos(signers: ReadonlyArray<{
|
|
15
30
|
readonly pubkey: Any;
|
|
16
31
|
readonly sequence: number;
|
|
17
32
|
}>, signMode: SignMode): SignerInfo[];
|
|
33
|
+
/**
|
|
34
|
+
* Creates encoded AuthInfo bytes for DID transactions with fee payer support.
|
|
35
|
+
* The AuthInfo contains signer information, fee details, and gas limit.
|
|
36
|
+
*
|
|
37
|
+
* @param signers - Array of signer objects with public keys and sequence numbers
|
|
38
|
+
* @param feeAmount - Array of coins representing the transaction fee
|
|
39
|
+
* @param gasLimit - Maximum gas units that can be consumed
|
|
40
|
+
* @param feePayer - Address of the account paying the transaction fees
|
|
41
|
+
* @param signMode - Signing mode to use, defaults to SIGN_MODE_DIRECT
|
|
42
|
+
* @returns Encoded AuthInfo as Uint8Array for transaction construction
|
|
43
|
+
*/
|
|
18
44
|
export declare function makeDidAuthInfoBytes(signers: ReadonlyArray<{
|
|
19
45
|
readonly pubkey: Any;
|
|
20
46
|
readonly sequence: number;
|
|
21
47
|
}>, feeAmount: readonly Coin[], gasLimit: bigint, feePayer: string, signMode?: SignMode): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Extended SigningStargateClient specifically designed for Cheqd blockchain operations.
|
|
50
|
+
* Provides enhanced transaction signing, broadcasting, and DID-specific functionality
|
|
51
|
+
* with support for custom fee payers and advanced retry mechanisms.
|
|
52
|
+
*/
|
|
22
53
|
export declare class CheqdSigningStargateClient extends SigningStargateClient {
|
|
54
|
+
/** Map of DID signing algorithms for different verification method types */
|
|
23
55
|
private didSigners;
|
|
56
|
+
/** Gas price configuration for transaction fee calculation */
|
|
24
57
|
private readonly _gasPrice;
|
|
58
|
+
/** Offline signer instance for transaction signing */
|
|
25
59
|
private readonly _signer;
|
|
60
|
+
/** RPC endpoint URL for blockchain communication */
|
|
26
61
|
private readonly endpoint?;
|
|
62
|
+
/** Maximum gas limit allowed for transactions */
|
|
27
63
|
static readonly maxGasLimit: number;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new CheqdSigningStargateClient by establishing a connection to the specified endpoint.
|
|
66
|
+
* This is the primary factory method for creating a signing client instance.
|
|
67
|
+
*
|
|
68
|
+
* @param endpoint - RPC endpoint URL or HttpEndpoint object to connect to
|
|
69
|
+
* @param signer - Offline signer for transaction signing
|
|
70
|
+
* @param options - Additional client configuration options including registry and gas price
|
|
71
|
+
* @returns Promise resolving to a connected CheqdSigningStargateClient instance
|
|
72
|
+
*/
|
|
28
73
|
static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineSigner, options?: (SigningStargateClientOptions & {
|
|
29
74
|
endpoint?: string;
|
|
30
75
|
}) | undefined): Promise<CheqdSigningStargateClient>;
|
|
76
|
+
/**
|
|
77
|
+
* Constructs a new CheqdSigningStargateClient instance with the provided Comet client and signer.
|
|
78
|
+
*
|
|
79
|
+
* @param cometClient - Comet client for blockchain communication
|
|
80
|
+
* @param signer - Offline signer for transaction signing
|
|
81
|
+
* @param options - Additional configuration options including registry, gas price, and endpoint
|
|
82
|
+
*/
|
|
31
83
|
constructor(cometClient: CometClient | undefined, signer: OfflineSigner, options?: SigningStargateClientOptions & {
|
|
32
84
|
endpoint?: string;
|
|
33
85
|
});
|
|
86
|
+
/**
|
|
87
|
+
* Signs and broadcasts a transaction to the blockchain network.
|
|
88
|
+
* Supports automatic fee calculation and custom fee payer functionality.
|
|
89
|
+
*
|
|
90
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
91
|
+
* @param messages - Array of messages to include in the transaction
|
|
92
|
+
* @param fee - Fee configuration: 'auto' for automatic calculation, number for multiplier, or DidStdFee object
|
|
93
|
+
* @param memo - Optional transaction memo string
|
|
94
|
+
* @returns Promise resolving to DeliverTxResponse with transaction results
|
|
95
|
+
* @throws Error if gas price is not set when using automatic fee calculation
|
|
96
|
+
*/
|
|
34
97
|
signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee | 'auto' | number, memo?: string): Promise<DeliverTxResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Signs a transaction without broadcasting it to the network.
|
|
100
|
+
* Creates a signed transaction that can be broadcast later.
|
|
101
|
+
*
|
|
102
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
103
|
+
* @param messages - Array of messages to include in the transaction
|
|
104
|
+
* @param fee - Fee configuration for the transaction
|
|
105
|
+
* @param memo - Transaction memo string
|
|
106
|
+
* @param explicitSignerData - Optional explicit signer data to avoid querying the chain
|
|
107
|
+
* @returns Promise resolving to TxRaw containing the signed transaction
|
|
108
|
+
*/
|
|
35
109
|
sign(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
|
|
110
|
+
/**
|
|
111
|
+
* Internal method for direct signing of transactions using SIGN_MODE_DIRECT.
|
|
112
|
+
* Handles the low-level transaction construction and signing process.
|
|
113
|
+
*
|
|
114
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
115
|
+
* @param messages - Array of messages to include in the transaction
|
|
116
|
+
* @param fee - Fee configuration for the transaction
|
|
117
|
+
* @param memo - Transaction memo string
|
|
118
|
+
* @param signerData - Account data including number, sequence, and chain ID
|
|
119
|
+
* @returns Promise resolving to TxRaw containing the signed transaction
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
36
122
|
private _signDirect;
|
|
37
123
|
/**
|
|
38
124
|
* Broadcasts a signed transaction to the network and monitors its inclusion in a block,
|
|
@@ -57,9 +143,45 @@ export declare class CheqdSigningStargateClient extends SigningStargateClient {
|
|
|
57
143
|
broadcastTx(tx: Uint8Array, timeoutMs?: number, pollIntervalMs?: number, maxRetries?: number): Promise<DeliverTxResponse>;
|
|
58
144
|
simulate(signerAddress: string, messages: readonly EncodeObject[], memo: string | undefined): Promise<number>;
|
|
59
145
|
constructSimulateExtension(querier: CheqdQuerier): Promise<TxExtension>;
|
|
146
|
+
/**
|
|
147
|
+
* Batches multiple messages into optimal groups based on gas limits.
|
|
148
|
+
* Simulates each message individually and groups them to maximize throughput
|
|
149
|
+
* while staying within gas constraints.
|
|
150
|
+
*
|
|
151
|
+
* @param messages - Array of messages to batch
|
|
152
|
+
* @param signerAddress - Address of the account that will sign the transactions
|
|
153
|
+
* @param memo - Optional transaction memo
|
|
154
|
+
* @param maxGasLimit - Maximum gas limit per batch, defaults to 30,000,000
|
|
155
|
+
* @returns Promise resolving to MessageBatch with grouped messages and gas estimates
|
|
156
|
+
*/
|
|
60
157
|
batchMessages(messages: readonly EncodeObject[], signerAddress: string, memo?: string, maxGasLimit?: number): Promise<MessageBatch>;
|
|
158
|
+
/**
|
|
159
|
+
* Validates and initializes DID signers for the provided verification methods.
|
|
160
|
+
* Ensures that all verification method types are supported and assigns appropriate signers.
|
|
161
|
+
*
|
|
162
|
+
* @param verificationMethods - Array of verification methods to validate
|
|
163
|
+
* @returns Promise resolving to the configured signer algorithm map
|
|
164
|
+
* @throws Error if no verification methods are provided or unsupported types are found
|
|
165
|
+
*/
|
|
61
166
|
checkDidSigners(verificationMethods?: Partial<VerificationMethod>[]): Promise<TSignerAlgo>;
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the appropriate DID signer for a specific verification method.
|
|
169
|
+
* Looks up the verification method by ID and returns the corresponding signer function.
|
|
170
|
+
*
|
|
171
|
+
* @param verificationMethodId - ID of the verification method to get signer for
|
|
172
|
+
* @param verificationMethods - Array of available verification methods
|
|
173
|
+
* @returns Promise resolving to a signer function that takes a secret key
|
|
174
|
+
* @throws Error if the verification method is not found
|
|
175
|
+
*/
|
|
62
176
|
getDidSigner(verificationMethodId: string, verificationMethods: Partial<VerificationMethod>[]): Promise<(secretKey: Uint8Array) => Signer>;
|
|
177
|
+
/**
|
|
178
|
+
* Signs a CreateDidDoc transaction payload using the provided signing inputs.
|
|
179
|
+
* Validates verification methods and creates signatures for each signing input.
|
|
180
|
+
*
|
|
181
|
+
* @param signInputs - Array of signing inputs containing verification method IDs and private keys
|
|
182
|
+
* @param payload - CreateDidDoc payload to sign
|
|
183
|
+
* @returns Promise resolving to array of SignInfo objects with signatures
|
|
184
|
+
*/
|
|
63
185
|
signCreateDidDocTx(signInputs: ISignInputs[], payload: MsgCreateDidDocPayload): Promise<SignInfo[]>;
|
|
64
186
|
signUpdateDidDocTx(signInputs: ISignInputs[], payload: MsgUpdateDidDocPayload, externalControllers?: DIDDocument[], previousDidDocument?: DIDDocument): Promise<SignInfo[]>;
|
|
65
187
|
signDeactivateDidDocTx(signInputs: ISignInputs[], payload: MsgDeactivateDidDocPayload, verificationMethod: VerificationMethod[]): Promise<SignInfo[]>;
|