@cheqd/sdk-esm 5.3.4-develop.2
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/build/index.d.ts +140 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +182 -0
- package/build/index.js.map +1 -0
- package/build/modules/_.d.ts +62 -0
- package/build/modules/_.d.ts.map +1 -0
- package/build/modules/_.js +75 -0
- package/build/modules/_.js.map +1 -0
- package/build/modules/did.d.ts +386 -0
- package/build/modules/did.d.ts.map +1 -0
- package/build/modules/did.js +1013 -0
- package/build/modules/did.js.map +1 -0
- package/build/modules/feeabstraction.d.ts +409 -0
- package/build/modules/feeabstraction.d.ts.map +1 -0
- package/build/modules/feeabstraction.js +462 -0
- package/build/modules/feeabstraction.js.map +1 -0
- package/build/modules/feemarket.d.ts +242 -0
- package/build/modules/feemarket.d.ts.map +1 -0
- package/build/modules/feemarket.js +296 -0
- package/build/modules/feemarket.js.map +1 -0
- package/build/modules/resource.d.ts +204 -0
- package/build/modules/resource.d.ts.map +1 -0
- package/build/modules/resource.js +297 -0
- package/build/modules/resource.js.map +1 -0
- package/build/package.json +64 -0
- package/build/querier.d.ts +62 -0
- package/build/querier.d.ts.map +1 -0
- package/build/querier.js +86 -0
- package/build/querier.js.map +1 -0
- package/build/registry.d.ts +18 -0
- package/build/registry.d.ts.map +1 -0
- package/build/registry.js +23 -0
- package/build/registry.js.map +1 -0
- package/build/signer.d.ts +190 -0
- package/build/signer.d.ts.map +1 -0
- package/build/signer.js +547 -0
- package/build/signer.js.map +1 -0
- package/build/types/index.d.ts +140 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/modules/_.d.ts +62 -0
- package/build/types/modules/_.d.ts.map +1 -0
- package/build/types/modules/did.d.ts +386 -0
- package/build/types/modules/did.d.ts.map +1 -0
- package/build/types/modules/feeabstraction.d.ts +409 -0
- package/build/types/modules/feeabstraction.d.ts.map +1 -0
- package/build/types/modules/feemarket.d.ts +242 -0
- package/build/types/modules/feemarket.d.ts.map +1 -0
- package/build/types/modules/resource.d.ts +204 -0
- package/build/types/modules/resource.d.ts.map +1 -0
- package/build/types/querier.d.ts +62 -0
- package/build/types/querier.d.ts.map +1 -0
- package/build/types/registry.d.ts +18 -0
- package/build/types/registry.d.ts.map +1 -0
- package/build/types/signer.d.ts +190 -0
- package/build/types/signer.d.ts.map +1 -0
- package/build/types/types.d.ts +196 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils.d.ts +223 -0
- package/build/types/utils.d.ts.map +1 -0
- package/build/types.d.ts +196 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +43 -0
- package/build/types.js.map +1 -0
- package/build/utils.d.ts +223 -0
- package/build/utils.d.ts.map +1 -0
- package/build/utils.js +541 -0
- package/build/utils.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { AbstractCheqdSDKModule, MinimalImportableCheqdSDKModule } from './_.js';
|
|
2
|
+
import { CheqdSigningStargateClient } from '../signer.js';
|
|
3
|
+
import { EncodeObject, GeneratedType } from '@cosmjs/proto-signing';
|
|
4
|
+
import { DidStdFee, IContext, ISignInputs, QueryExtensionSetup } from '../types.js';
|
|
5
|
+
import { Metadata, MsgCreateResource, MsgCreateResourcePayload, QueryCollectionResourcesResponse, ResourceWithMetadata } from '@cheqd/ts-proto/cheqd/resource/v2/index.js';
|
|
6
|
+
import { DeliverTxResponse, QueryClient } from '@cosmjs/stargate';
|
|
7
|
+
import { SignInfo } from '@cheqd/ts-proto/cheqd/did/v2/index.js';
|
|
8
|
+
import { CheqdQuerier } from '../querier.js';
|
|
9
|
+
/** Default extension key for resource-related query operations */
|
|
10
|
+
export declare const defaultResourceExtensionKey: "resource";
|
|
11
|
+
/**
|
|
12
|
+
* Protobuf message type literals for resource operations.
|
|
13
|
+
* Used for consistent message type identification across the module.
|
|
14
|
+
*/
|
|
15
|
+
export declare const protobufLiterals: {
|
|
16
|
+
/** Create resource message type */
|
|
17
|
+
readonly MsgCreateResource: "MsgCreateResource";
|
|
18
|
+
/** Create resource response message type */
|
|
19
|
+
readonly MsgCreateResourceResponse: "MsgCreateResourceResponse";
|
|
20
|
+
};
|
|
21
|
+
/** Type URL for MsgCreateResource messages */
|
|
22
|
+
export declare const typeUrlMsgCreateResource: "/cheqd.resource.v2.MsgCreateResource";
|
|
23
|
+
/** Type URL for MsgCreateResourceResponse messages */
|
|
24
|
+
export declare const typeUrlMsgCreateResourceResponse: "/cheqd.resource.v2.MsgCreateResourceResponse";
|
|
25
|
+
/**
|
|
26
|
+
* Encode object interface for MsgCreateResource messages.
|
|
27
|
+
* Used for type-safe message encoding in resource creation transactions.
|
|
28
|
+
*/
|
|
29
|
+
export interface MsgCreateResourceEncodeObject extends EncodeObject {
|
|
30
|
+
readonly typeUrl: typeof typeUrlMsgCreateResource;
|
|
31
|
+
readonly value: Partial<MsgCreateResource>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Type guard function to check if an object is a MsgCreateResourceEncodeObject.
|
|
35
|
+
*
|
|
36
|
+
* @param obj - EncodeObject to check
|
|
37
|
+
* @returns True if the object is a MsgCreateResourceEncodeObject
|
|
38
|
+
*/
|
|
39
|
+
export declare function isMsgCreateResourceEncodeObject(obj: EncodeObject): obj is MsgCreateResourceEncodeObject;
|
|
40
|
+
/** Minimal importable version of the resource module for clean external interfaces */
|
|
41
|
+
export type MinimalImportableResourceModule = MinimalImportableCheqdSDKModule<ResourceModule>;
|
|
42
|
+
/**
|
|
43
|
+
* Resource extension interface for querier functionality.
|
|
44
|
+
* Provides methods for querying resources and their metadata.
|
|
45
|
+
*/
|
|
46
|
+
export type ResourceExtension = {
|
|
47
|
+
readonly [defaultResourceExtensionKey]: {
|
|
48
|
+
/** Query a specific resource by collection and resource ID */
|
|
49
|
+
readonly resource: (collectionId: string, resourceId: string) => Promise<ResourceWithMetadata>;
|
|
50
|
+
/** Query metadata for a specific resource */
|
|
51
|
+
readonly resourceMetadata: (collectionId: string, resourceId: string) => Promise<Metadata>;
|
|
52
|
+
/** Query all resources in a collection with pagination support */
|
|
53
|
+
readonly collectionResources: (collectionId: string, paginationKey?: Uint8Array) => Promise<QueryCollectionResourcesResponse>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Sets up the resource extension for the querier client.
|
|
58
|
+
* Creates and configures the resource-specific query methods.
|
|
59
|
+
*
|
|
60
|
+
* @param base - Base QueryClient to extend
|
|
61
|
+
* @returns Configured resource extension with query methods
|
|
62
|
+
*/
|
|
63
|
+
export declare const setupResourceExtension: (base: QueryClient) => ResourceExtension;
|
|
64
|
+
/**
|
|
65
|
+
* Resource Module class providing comprehensive linked resource functionality.
|
|
66
|
+
* Handles creation, querying, and metadata management of resources linked to DID documents.
|
|
67
|
+
*/
|
|
68
|
+
export declare class ResourceModule extends AbstractCheqdSDKModule {
|
|
69
|
+
static readonly registryTypes: Iterable<[string, GeneratedType]>;
|
|
70
|
+
/** Base denomination for Cheqd network transactions */
|
|
71
|
+
static readonly baseMinimalDenom: "ncheq";
|
|
72
|
+
/**
|
|
73
|
+
* Standard fee amounts for different resource types.
|
|
74
|
+
* Fees vary based on resource content type and processing requirements.
|
|
75
|
+
*/
|
|
76
|
+
static readonly fees: {
|
|
77
|
+
/** Default fee for creating image resources */
|
|
78
|
+
readonly DefaultCreateResourceImageFee: {
|
|
79
|
+
readonly amount: "10000000000";
|
|
80
|
+
readonly denom: "ncheq";
|
|
81
|
+
};
|
|
82
|
+
/** Default fee for creating JSON resources */
|
|
83
|
+
readonly DefaultCreateResourceJsonFee: {
|
|
84
|
+
readonly amount: "10000000000";
|
|
85
|
+
readonly denom: "ncheq";
|
|
86
|
+
};
|
|
87
|
+
/** Default fee for creating other types of resources */
|
|
88
|
+
readonly DefaultCreateResourceDefaultFee: {
|
|
89
|
+
readonly amount: "10000000000";
|
|
90
|
+
readonly denom: "ncheq";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/** Querier extension setup function for resource operations */
|
|
94
|
+
static readonly querierExtensionSetup: QueryExtensionSetup<ResourceExtension>;
|
|
95
|
+
/** Querier instance with resource extension capabilities */
|
|
96
|
+
querier: CheqdQuerier & ResourceExtension;
|
|
97
|
+
/**
|
|
98
|
+
* Constructs a new resource module instance.
|
|
99
|
+
*
|
|
100
|
+
* @param signer - Signing client for blockchain transactions
|
|
101
|
+
* @param querier - Querier client with resource extension for data retrieval
|
|
102
|
+
*/
|
|
103
|
+
constructor(signer: CheqdSigningStargateClient, querier: CheqdQuerier & ResourceExtension);
|
|
104
|
+
/**
|
|
105
|
+
* Gets the registry types for resource message encoding/decoding.
|
|
106
|
+
*
|
|
107
|
+
* @returns Iterable of [typeUrl, GeneratedType] pairs for the registry
|
|
108
|
+
*/
|
|
109
|
+
getRegistryTypes(): Iterable<[string, GeneratedType]>;
|
|
110
|
+
/**
|
|
111
|
+
* Gets the querier extension setup for resource operations.
|
|
112
|
+
*
|
|
113
|
+
* @returns Query extension setup function for resource functionality
|
|
114
|
+
*/
|
|
115
|
+
getQuerierExtensionSetup(): QueryExtensionSetup<ResourceExtension>;
|
|
116
|
+
/**
|
|
117
|
+
* Signs a resource payload with provided signature inputs.
|
|
118
|
+
* Creates a complete signed resource message ready for blockchain submission.
|
|
119
|
+
*
|
|
120
|
+
* @param payload - Resource payload to sign
|
|
121
|
+
* @param signInputs - Signing inputs or pre-computed signatures
|
|
122
|
+
* @returns Promise resolving to the signed resource message
|
|
123
|
+
*/
|
|
124
|
+
static signPayload(payload: MsgCreateResourcePayload, signInputs: ISignInputs[] | SignInfo[]): Promise<MsgCreateResource>;
|
|
125
|
+
/**
|
|
126
|
+
* Creates a linked resource transaction on the blockchain.
|
|
127
|
+
* Handles automatic fee calculation based on resource content type and size.
|
|
128
|
+
*
|
|
129
|
+
* @param signInputs - Signing inputs or pre-computed signatures for the transaction
|
|
130
|
+
* @param resourcePayload - Resource payload containing data and metadata
|
|
131
|
+
* @param address - Address of the account submitting the transaction
|
|
132
|
+
* @param fee - Transaction fee configuration or 'auto' for automatic calculation
|
|
133
|
+
* @param memo - Optional transaction memo
|
|
134
|
+
* @param context - Optional SDK context for accessing clients
|
|
135
|
+
* @returns Promise resolving to the transaction response
|
|
136
|
+
* @throws Error if linked resource data is empty when automatic fee calculation is requested
|
|
137
|
+
*/
|
|
138
|
+
createLinkedResourceTx(signInputs: ISignInputs[] | SignInfo[], resourcePayload: Partial<MsgCreateResourcePayload>, address: string, fee?: DidStdFee | 'auto' | number, memo?: string, context?: IContext): Promise<DeliverTxResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* Queries a specific linked resource by collection and resource ID.
|
|
141
|
+
* Retrieves the complete resource data along with its metadata.
|
|
142
|
+
*
|
|
143
|
+
* @param collectionId - ID of the collection containing the resource
|
|
144
|
+
* @param resourceId - ID of the resource to query
|
|
145
|
+
* @param context - Optional SDK context for accessing clients
|
|
146
|
+
* @returns Promise resolving to the resource with metadata
|
|
147
|
+
*/
|
|
148
|
+
queryLinkedResource(collectionId: string, resourceId: string, context?: IContext): Promise<ResourceWithMetadata>;
|
|
149
|
+
/**
|
|
150
|
+
* Queries metadata for a specific linked resource.
|
|
151
|
+
* Retrieves only the metadata without the resource content data.
|
|
152
|
+
*
|
|
153
|
+
* @param collectionId - ID of the collection containing the resource
|
|
154
|
+
* @param resourceId - ID of the resource to query metadata for
|
|
155
|
+
* @param context - Optional SDK context for accessing clients
|
|
156
|
+
* @returns Promise resolving to the resource metadata
|
|
157
|
+
*/
|
|
158
|
+
queryLinkedResourceMetadata(collectionId: string, resourceId: string, context?: IContext): Promise<Metadata>;
|
|
159
|
+
/**
|
|
160
|
+
* Queries all resources in a collection with pagination support.
|
|
161
|
+
* Retrieves a list of all resources belonging to a specific collection.
|
|
162
|
+
*
|
|
163
|
+
* @param collectionId - ID of the collection to query resources for
|
|
164
|
+
* @param context - Optional SDK context for accessing clients
|
|
165
|
+
* @returns Promise resolving to the collection resources response with pagination
|
|
166
|
+
*/
|
|
167
|
+
queryLinkedResources(collectionId: string, context?: IContext): Promise<QueryCollectionResourcesResponse>;
|
|
168
|
+
/**
|
|
169
|
+
* Reads and determines the MIME type of resource content.
|
|
170
|
+
* Analyzes the content to identify the appropriate MIME type for fee calculation and validation.
|
|
171
|
+
*
|
|
172
|
+
* @param content - Resource content as byte array
|
|
173
|
+
* @returns Promise resolving to the detected MIME type string
|
|
174
|
+
*/
|
|
175
|
+
static readMimeType(content: Uint8Array): Promise<string>;
|
|
176
|
+
/**
|
|
177
|
+
* Generates fee configuration for image resource creation transactions.
|
|
178
|
+
* Uses higher gas limits appropriate for image processing and storage.
|
|
179
|
+
*
|
|
180
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
181
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
182
|
+
* @returns Promise resolving to the fee configuration for image resources
|
|
183
|
+
*/
|
|
184
|
+
static generateCreateResourceImageFees(feePayer: string, granter?: string): Promise<DidStdFee>;
|
|
185
|
+
/**
|
|
186
|
+
* Generates fee configuration for JSON resource creation transactions.
|
|
187
|
+
* Uses gas limits optimized for JSON data processing and validation.
|
|
188
|
+
*
|
|
189
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
190
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
191
|
+
* @returns Promise resolving to the fee configuration for JSON resources
|
|
192
|
+
*/
|
|
193
|
+
static generateCreateResourceJsonFees(feePayer: string, granter?: string): Promise<DidStdFee>;
|
|
194
|
+
/**
|
|
195
|
+
* Generates fee configuration for default resource creation transactions.
|
|
196
|
+
* Uses standard gas limits for generic resource types and binary data.
|
|
197
|
+
*
|
|
198
|
+
* @param feePayer - Address of the account that will pay the transaction fees
|
|
199
|
+
* @param granter - Optional address of the account granting fee payment permissions
|
|
200
|
+
* @returns Promise resolving to the fee configuration for default resources
|
|
201
|
+
*/
|
|
202
|
+
static generateCreateResourceDefaultFees(feePayer: string, granter?: string): Promise<DidStdFee>;
|
|
203
|
+
}
|
|
204
|
+
//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ASpG;;;;;;;OAOG;WACU,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IASnG;;;;;;;OAOG;WACU,iCAAiC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAQtG"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { AbstractCheqdSDKModule } from './_.js';
|
|
2
|
+
import { CheqdSigningStargateClient } from '../signer.js';
|
|
3
|
+
import { ISignInputs } from '../types.js';
|
|
4
|
+
import { MsgCreateResource, MsgCreateResourcePayload, MsgCreateResourceResponse, QueryClientImpl, protobufPackage, } from '@cheqd/ts-proto/cheqd/resource/v2/index.js';
|
|
5
|
+
import { createPagination, createProtobufRpcClient } from '@cosmjs/stargate';
|
|
6
|
+
import { fileTypeFromBuffer } from 'file-type';
|
|
7
|
+
import { toString } from 'uint8arrays/to-string';
|
|
8
|
+
import { assert } from '@cosmjs/utils';
|
|
9
|
+
import { isJSON } from '../utils.js';
|
|
10
|
+
/** Default extension key for resource-related query operations */
|
|
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
|
+
*/
|
|
16
|
+
export const protobufLiterals = {
|
|
17
|
+
/** Create resource message type */
|
|
18
|
+
MsgCreateResource: 'MsgCreateResource',
|
|
19
|
+
/** Create resource response message type */
|
|
20
|
+
MsgCreateResourceResponse: 'MsgCreateResourceResponse',
|
|
21
|
+
};
|
|
22
|
+
/** Type URL for MsgCreateResource messages */
|
|
23
|
+
export const typeUrlMsgCreateResource = `/${protobufPackage}.${protobufLiterals.MsgCreateResource}`;
|
|
24
|
+
/** Type URL for MsgCreateResourceResponse messages */
|
|
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
|
+
*/
|
|
32
|
+
export function isMsgCreateResourceEncodeObject(obj) {
|
|
33
|
+
return obj.typeUrl === typeUrlMsgCreateResource;
|
|
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
|
+
*/
|
|
42
|
+
export const setupResourceExtension = (base) => {
|
|
43
|
+
const rpc = createProtobufRpcClient(base);
|
|
44
|
+
const queryService = new QueryClientImpl(rpc);
|
|
45
|
+
return {
|
|
46
|
+
[defaultResourceExtensionKey]: {
|
|
47
|
+
resource: async (collectionId, resourceId) => {
|
|
48
|
+
const { resource } = await queryService.Resource({ collectionId, id: resourceId });
|
|
49
|
+
assert(resource);
|
|
50
|
+
return resource;
|
|
51
|
+
},
|
|
52
|
+
resourceMetadata: async (collectionId, resourceId) => {
|
|
53
|
+
const { resource } = await queryService.ResourceMetadata({ collectionId, id: resourceId });
|
|
54
|
+
assert(resource);
|
|
55
|
+
return resource;
|
|
56
|
+
},
|
|
57
|
+
collectionResources: async (collectionId, paginationKey) => {
|
|
58
|
+
const response = await queryService.CollectionResources({
|
|
59
|
+
collectionId,
|
|
60
|
+
pagination: createPagination(paginationKey),
|
|
61
|
+
});
|
|
62
|
+
return response;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
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
|
+
*/
|
|
71
|
+
export class ResourceModule extends AbstractCheqdSDKModule {
|
|
72
|
+
// @ts-expect-error underlying type `GeneratedType` is intentionally wider
|
|
73
|
+
static registryTypes = [
|
|
74
|
+
[typeUrlMsgCreateResource, MsgCreateResource],
|
|
75
|
+
[typeUrlMsgCreateResourceResponse, MsgCreateResourceResponse],
|
|
76
|
+
];
|
|
77
|
+
/** Base denomination for Cheqd network transactions */
|
|
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
|
+
*/
|
|
83
|
+
static fees = {
|
|
84
|
+
/** Default fee for creating image resources */
|
|
85
|
+
DefaultCreateResourceImageFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
86
|
+
/** Default fee for creating JSON resources */
|
|
87
|
+
DefaultCreateResourceJsonFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
88
|
+
/** Default fee for creating other types of resources */
|
|
89
|
+
DefaultCreateResourceDefaultFee: { amount: '10000000000', denom: ResourceModule.baseMinimalDenom },
|
|
90
|
+
};
|
|
91
|
+
/** Querier extension setup function for resource operations */
|
|
92
|
+
static querierExtensionSetup = setupResourceExtension;
|
|
93
|
+
/** Querier instance with resource extension capabilities */
|
|
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
|
+
*/
|
|
101
|
+
constructor(signer, querier) {
|
|
102
|
+
super(signer, querier);
|
|
103
|
+
this.querier = querier;
|
|
104
|
+
this.methods = {
|
|
105
|
+
createLinkedResourceTx: this.createLinkedResourceTx.bind(this),
|
|
106
|
+
queryLinkedResource: this.queryLinkedResource.bind(this),
|
|
107
|
+
queryLinkedResourceMetadata: this.queryLinkedResourceMetadata.bind(this),
|
|
108
|
+
queryLinkedResources: this.queryLinkedResources.bind(this),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Gets the registry types for resource message encoding/decoding.
|
|
113
|
+
*
|
|
114
|
+
* @returns Iterable of [typeUrl, GeneratedType] pairs for the registry
|
|
115
|
+
*/
|
|
116
|
+
getRegistryTypes() {
|
|
117
|
+
return ResourceModule.registryTypes;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Gets the querier extension setup for resource operations.
|
|
121
|
+
*
|
|
122
|
+
* @returns Query extension setup function for resource functionality
|
|
123
|
+
*/
|
|
124
|
+
getQuerierExtensionSetup() {
|
|
125
|
+
return ResourceModule.querierExtensionSetup;
|
|
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
|
+
*/
|
|
135
|
+
static async signPayload(payload, signInputs) {
|
|
136
|
+
const signBytes = MsgCreateResourcePayload.encode(payload).finish();
|
|
137
|
+
let signatures;
|
|
138
|
+
if (ISignInputs.isSignInput(signInputs)) {
|
|
139
|
+
signatures = await CheqdSigningStargateClient.signIdentityTx(signBytes, signInputs);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
signatures = signInputs;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
payload,
|
|
146
|
+
signatures,
|
|
147
|
+
};
|
|
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
|
+
*/
|
|
162
|
+
async createLinkedResourceTx(signInputs, resourcePayload, address, fee, memo, context) {
|
|
163
|
+
if (!this._signer) {
|
|
164
|
+
this._signer = context.sdk.signer;
|
|
165
|
+
}
|
|
166
|
+
const payload = MsgCreateResourcePayload.fromPartial(resourcePayload);
|
|
167
|
+
const msg = await ResourceModule.signPayload(payload, signInputs);
|
|
168
|
+
const encObj = {
|
|
169
|
+
typeUrl: typeUrlMsgCreateResource,
|
|
170
|
+
value: msg,
|
|
171
|
+
};
|
|
172
|
+
if (address === '') {
|
|
173
|
+
address = (await context.sdk.options.wallet.getAccounts())[0].address;
|
|
174
|
+
}
|
|
175
|
+
if (!fee) {
|
|
176
|
+
if (payload.data.length === 0) {
|
|
177
|
+
throw new Error('Linked resource data is empty');
|
|
178
|
+
}
|
|
179
|
+
fee = await (async function () {
|
|
180
|
+
const mimeType = await ResourceModule.readMimeType(payload.data);
|
|
181
|
+
if (mimeType.startsWith('image/')) {
|
|
182
|
+
return await ResourceModule.generateCreateResourceImageFees(address);
|
|
183
|
+
}
|
|
184
|
+
if (mimeType.startsWith('application/json')) {
|
|
185
|
+
return await ResourceModule.generateCreateResourceJsonFees(address);
|
|
186
|
+
}
|
|
187
|
+
return await ResourceModule.generateCreateResourceDefaultFees(address);
|
|
188
|
+
})();
|
|
189
|
+
}
|
|
190
|
+
return this._signer.signAndBroadcast(address, [encObj], fee, memo);
|
|
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
|
+
*/
|
|
201
|
+
async queryLinkedResource(collectionId, resourceId, context) {
|
|
202
|
+
if (!this.querier) {
|
|
203
|
+
this.querier = context.sdk.querier;
|
|
204
|
+
}
|
|
205
|
+
return await this.querier[defaultResourceExtensionKey].resource(collectionId, resourceId);
|
|
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
|
+
*/
|
|
216
|
+
async queryLinkedResourceMetadata(collectionId, resourceId, context) {
|
|
217
|
+
if (!this.querier) {
|
|
218
|
+
this.querier = context.sdk.querier;
|
|
219
|
+
}
|
|
220
|
+
return await this.querier[defaultResourceExtensionKey].resourceMetadata(collectionId, resourceId);
|
|
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
|
+
*/
|
|
230
|
+
async queryLinkedResources(collectionId, context) {
|
|
231
|
+
if (!this.querier) {
|
|
232
|
+
this.querier = context.sdk.querier;
|
|
233
|
+
}
|
|
234
|
+
return await this.querier[defaultResourceExtensionKey].collectionResources(collectionId);
|
|
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
|
+
*/
|
|
243
|
+
static async readMimeType(content) {
|
|
244
|
+
if (isJSON(toString(content, 'utf-8')))
|
|
245
|
+
return 'application/json';
|
|
246
|
+
return (await fileTypeFromBuffer(content))?.mime ?? 'application/octet-stream';
|
|
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
|
+
*/
|
|
256
|
+
static async generateCreateResourceImageFees(feePayer, granter) {
|
|
257
|
+
return {
|
|
258
|
+
amount: [ResourceModule.fees.DefaultCreateResourceImageFee],
|
|
259
|
+
gas: '2000000',
|
|
260
|
+
payer: feePayer,
|
|
261
|
+
granter: granter,
|
|
262
|
+
};
|
|
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
|
+
*/
|
|
272
|
+
static async generateCreateResourceJsonFees(feePayer, granter) {
|
|
273
|
+
return {
|
|
274
|
+
amount: [ResourceModule.fees.DefaultCreateResourceJsonFee],
|
|
275
|
+
gas: '2000000',
|
|
276
|
+
payer: feePayer,
|
|
277
|
+
granter: granter,
|
|
278
|
+
};
|
|
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
|
+
*/
|
|
288
|
+
static async generateCreateResourceDefaultFees(feePayer, granter) {
|
|
289
|
+
return {
|
|
290
|
+
amount: [ResourceModule.fees.DefaultCreateResourceDefaultFee],
|
|
291
|
+
gas: '2000000',
|
|
292
|
+
payer: feePayer,
|
|
293
|
+
granter: granter,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../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,kEAAkE;AAClE,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAmB,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,mCAAmC;IACnC,iBAAiB,EAAE,mBAAmB;IACtC,4CAA4C;IAC5C,yBAAyB,EAAE,2BAA2B;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AAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,QAAgB,EAAE,OAAgB;QAC7E,OAAO;YACN,MAAM,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,4BAA4B,CAAC;YAC1D,GAAG,EAAE,SAAS;YACd,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,OAAO;SACH,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,QAAgB,EAAE,OAAgB;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"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cheqd/sdk-esm",
|
|
3
|
+
"version": "5.0.1",
|
|
4
|
+
"description": "A TypeScript SDK built with CosmJS to interact with cheqd network ledger",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Cheqd Foundation Limited (https://github.com/cheqd)",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./build/types/index.d.ts",
|
|
11
|
+
"import": "./build/index.js",
|
|
12
|
+
"default": "./build/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./*": {
|
|
15
|
+
"types": "./build/types/*.d.ts",
|
|
16
|
+
"import": "./build/*.js",
|
|
17
|
+
"default": "./build/*.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"build"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --colors --passWithNoTests --maxWorkers 1 --maxConcurrency 1",
|
|
28
|
+
"test:watch": "cross-env NODE_OPTIONS='--experimental-vm-modules' jest --colors --passWithNoTests --maxWorkers 1 --maxConcurrency 1 --watch",
|
|
29
|
+
"build": "npm run build:types && npm run build:esm",
|
|
30
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
31
|
+
"build:esm": "tsc -p tsconfig.json",
|
|
32
|
+
"format": "prettier --write '**/*.{js,ts,cjs,mjs,json}'"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@cheqd/ts-proto": "^4.1.1",
|
|
36
|
+
"@cosmjs/amino": "^0.33.1",
|
|
37
|
+
"@cosmjs/crypto": "^0.33.1",
|
|
38
|
+
"@cosmjs/encoding": "^0.33.1",
|
|
39
|
+
"@cosmjs/math": "^0.33.1",
|
|
40
|
+
"@cosmjs/proto-signing": "^0.33.1",
|
|
41
|
+
"@cosmjs/stargate": "^0.33.1",
|
|
42
|
+
"@cosmjs/tendermint-rpc": "^0.33.1",
|
|
43
|
+
"@cosmjs/utils": "^0.33.1",
|
|
44
|
+
"@stablelib/ed25519": "^2.0.2",
|
|
45
|
+
"@types/secp256k1": "^4.0.6",
|
|
46
|
+
"cosmjs-types": "^0.9.0",
|
|
47
|
+
"did-jwt": "^8.0.16",
|
|
48
|
+
"did-resolver": "^4.1.0",
|
|
49
|
+
"exponential-backoff": "^3.1.2",
|
|
50
|
+
"file-type": "^21.0.0",
|
|
51
|
+
"multiformats": "^13.3.6",
|
|
52
|
+
"secp256k1": "^5.0.1",
|
|
53
|
+
"uint8arrays": "^5.1.0",
|
|
54
|
+
"uuid": "^11.1.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/node": "^22.15.30",
|
|
58
|
+
"@types/uuid": "^10.0.0",
|
|
59
|
+
"cross-env": "^7.0.3"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=22.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { QueryClient } from '@cosmjs/stargate';
|
|
2
|
+
import { CometClient, ConsensusParams } from '@cosmjs/tendermint-rpc';
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
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
|
+
*/
|
|
60
|
+
static connectWithExtensions(url: string, ...extensions: QueryExtensionSetup<CheqdExtensions>[]): Promise<CheqdQuerier & CheqdExtensions>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=querier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querier.d.ts","sourceRoot":"","sources":["../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"}
|