@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.
Files changed (68) hide show
  1. package/build/index.d.ts +140 -0
  2. package/build/index.d.ts.map +1 -0
  3. package/build/index.js +182 -0
  4. package/build/index.js.map +1 -0
  5. package/build/modules/_.d.ts +62 -0
  6. package/build/modules/_.d.ts.map +1 -0
  7. package/build/modules/_.js +75 -0
  8. package/build/modules/_.js.map +1 -0
  9. package/build/modules/did.d.ts +386 -0
  10. package/build/modules/did.d.ts.map +1 -0
  11. package/build/modules/did.js +1013 -0
  12. package/build/modules/did.js.map +1 -0
  13. package/build/modules/feeabstraction.d.ts +409 -0
  14. package/build/modules/feeabstraction.d.ts.map +1 -0
  15. package/build/modules/feeabstraction.js +462 -0
  16. package/build/modules/feeabstraction.js.map +1 -0
  17. package/build/modules/feemarket.d.ts +242 -0
  18. package/build/modules/feemarket.d.ts.map +1 -0
  19. package/build/modules/feemarket.js +296 -0
  20. package/build/modules/feemarket.js.map +1 -0
  21. package/build/modules/resource.d.ts +204 -0
  22. package/build/modules/resource.d.ts.map +1 -0
  23. package/build/modules/resource.js +297 -0
  24. package/build/modules/resource.js.map +1 -0
  25. package/build/package.json +64 -0
  26. package/build/querier.d.ts +62 -0
  27. package/build/querier.d.ts.map +1 -0
  28. package/build/querier.js +86 -0
  29. package/build/querier.js.map +1 -0
  30. package/build/registry.d.ts +18 -0
  31. package/build/registry.d.ts.map +1 -0
  32. package/build/registry.js +23 -0
  33. package/build/registry.js.map +1 -0
  34. package/build/signer.d.ts +190 -0
  35. package/build/signer.d.ts.map +1 -0
  36. package/build/signer.js +547 -0
  37. package/build/signer.js.map +1 -0
  38. package/build/types/index.d.ts +140 -0
  39. package/build/types/index.d.ts.map +1 -0
  40. package/build/types/modules/_.d.ts +62 -0
  41. package/build/types/modules/_.d.ts.map +1 -0
  42. package/build/types/modules/did.d.ts +386 -0
  43. package/build/types/modules/did.d.ts.map +1 -0
  44. package/build/types/modules/feeabstraction.d.ts +409 -0
  45. package/build/types/modules/feeabstraction.d.ts.map +1 -0
  46. package/build/types/modules/feemarket.d.ts +242 -0
  47. package/build/types/modules/feemarket.d.ts.map +1 -0
  48. package/build/types/modules/resource.d.ts +204 -0
  49. package/build/types/modules/resource.d.ts.map +1 -0
  50. package/build/types/querier.d.ts +62 -0
  51. package/build/types/querier.d.ts.map +1 -0
  52. package/build/types/registry.d.ts +18 -0
  53. package/build/types/registry.d.ts.map +1 -0
  54. package/build/types/signer.d.ts +190 -0
  55. package/build/types/signer.d.ts.map +1 -0
  56. package/build/types/types.d.ts +196 -0
  57. package/build/types/types.d.ts.map +1 -0
  58. package/build/types/utils.d.ts +223 -0
  59. package/build/types/utils.d.ts.map +1 -0
  60. package/build/types.d.ts +196 -0
  61. package/build/types.d.ts.map +1 -0
  62. package/build/types.js +43 -0
  63. package/build/types.js.map +1 -0
  64. package/build/utils.d.ts +223 -0
  65. package/build/utils.d.ts.map +1 -0
  66. package/build/utils.js +541 -0
  67. package/build/utils.js.map +1 -0
  68. package/package.json +64 -0
@@ -0,0 +1,140 @@
1
+ import { OfflineSigner } from '@cosmjs/proto-signing';
2
+ import { DIDModule, MinimalImportableDIDModule, DidExtension } from './modules/did.js';
3
+ import { MinimalImportableResourceModule, ResourceModule, ResourceExtension } from './modules/resource.js';
4
+ import { FeemarketModule, FeemarketExtension, MinimalImportableFeemarketModule } from './modules/feemarket.js';
5
+ import { AbstractCheqdSDKModule } from './modules/_.js';
6
+ import { CheqdSigningStargateClient } from './signer.js';
7
+ import { CheqdNetwork, IModuleMethodMap } from './types.js';
8
+ import { GasPrice } from '@cosmjs/stargate';
9
+ import { CheqdQuerier } from './querier.js';
10
+ import { FeeabstractionExtension, FeeabstractionModule, MinimalImportableFeeabstractionModule } from './modules/feeabstraction.js';
11
+ /**
12
+ * Configuration options for initializing the CheqdSDK
13
+ */
14
+ export interface ICheqdSDKOptions {
15
+ /** Array of modules to be loaded and registered with the SDK */
16
+ modules: AbstractCheqdSDKModule[];
17
+ /** Optional querier extensions to extend query functionality */
18
+ querierExtensions?: Record<string, any>[];
19
+ /** RPC URL of the blockchain node to connect to */
20
+ rpcUrl: string;
21
+ /** Network configuration (Mainnet, Testnet, etc.) */
22
+ network?: CheqdNetwork;
23
+ /** Gas price configuration for transactions */
24
+ gasPrice?: GasPrice;
25
+ /** List of method names that are authorized for execution */
26
+ authorizedMethods?: string[];
27
+ /** Wallet instance for signing transactions */
28
+ readonly wallet: OfflineSigner;
29
+ }
30
+ /**
31
+ * Default SDK modules that provide core functionality for DID, Resource, Feemarket, and Fee abstraction operations
32
+ */
33
+ export type DefaultCheqdSDKModules = MinimalImportableDIDModule & MinimalImportableResourceModule & MinimalImportableFeemarketModule & MinimalImportableFeeabstractionModule;
34
+ /**
35
+ * Main CheqdSDK class that provides a comprehensive interface for interacting with the Cheqd blockchain.
36
+ * This class orchestrates modules for DID operations, resource management, fee market interactions,
37
+ * and fee abstraction functionality.
38
+ */
39
+ export interface CheqdSDK extends DefaultCheqdSDKModules {
40
+ }
41
+ /**
42
+ * Main CheqdSDK class that provides a comprehensive interface for interacting with the Cheqd blockchain.
43
+ * This class orchestrates modules for DID operations, resource management, fee market interactions,
44
+ * and fee abstraction functionality.
45
+ */
46
+ export declare class CheqdSDK {
47
+ /** Map of available methods from loaded modules */
48
+ methods: IModuleMethodMap;
49
+ /** Signing client for executing transactions on the blockchain */
50
+ signer: CheqdSigningStargateClient;
51
+ /** Query client with extensions for reading blockchain data */
52
+ querier: CheqdQuerier & DidExtension & ResourceExtension & FeemarketExtension & FeeabstractionExtension;
53
+ /** Configuration options passed during SDK initialization */
54
+ options: ICheqdSDKOptions;
55
+ /** List of method names that are protected from external access */
56
+ private protectedMethods;
57
+ /**
58
+ * Constructs a new CheqdSDK instance with the provided configuration options.
59
+ *
60
+ * @param options - Configuration options for the SDK including wallet, modules, and network settings
61
+ * @throws {Error} Throws an error if no wallet is provided in the options
62
+ */
63
+ constructor(options: ICheqdSDKOptions);
64
+ /**
65
+ * Executes a method from the loaded modules with the provided parameters.
66
+ * Only authorized methods can be executed through this interface.
67
+ *
68
+ * @template P - Type of parameters to pass to the method
69
+ * @template R - Return type of the method
70
+ * @param method - Name of the method to execute
71
+ * @param params - Parameters to pass to the method
72
+ * @returns Promise resolving to the method's return value
73
+ * @throws {Error} Throws an error if the method is not authorized
74
+ */
75
+ execute<P = any, R = any>(method: string, ...params: P[]): Promise<R>;
76
+ /**
77
+ * Loads and instantiates the provided modules, making their methods available for execution.
78
+ * This method also applies mixins to make module methods accessible on the SDK instance.
79
+ *
80
+ * @param modules - Array of modules to load and integrate
81
+ * @returns Promise resolving to the CheqdSDK instance with loaded modules
82
+ * @private
83
+ */
84
+ private loadModules;
85
+ /**
86
+ * Creates and configures a registry with types from all loaded modules.
87
+ * The registry is used for encoding and decoding blockchain messages.
88
+ *
89
+ * @returns Configured Registry instance with all module types
90
+ * @private
91
+ */
92
+ private loadRegistry;
93
+ /**
94
+ * Establishes a connection to the blockchain querier with all necessary extensions.
95
+ * Extensions provide specialized query capabilities for different modules.
96
+ *
97
+ * @returns Promise resolving to a CheqdQuerier instance with all extensions
98
+ * @private
99
+ */
100
+ private loadQuerierExtensions;
101
+ /**
102
+ * Builds and initializes the complete SDK instance by loading all components:
103
+ * registry, querier extensions, modules, gas price configuration, and signing client.
104
+ * This method must be called before the SDK can be used for blockchain operations.
105
+ *
106
+ * @returns Promise resolving to the fully initialized CheqdSDK instance
107
+ */
108
+ build(): Promise<CheqdSDK>;
109
+ }
110
+ /**
111
+ * Filters methods based on authorization rules and protected method restrictions.
112
+ * Returns only methods that are explicitly authorized (if authorization list is provided)
113
+ * and excludes protected methods from external access.
114
+ *
115
+ * @param methods - Map of all available methods from modules
116
+ * @param authorizedMethods - List of method names that are explicitly authorized
117
+ * @param protectedMethods - List of method names that should be protected from external access
118
+ * @returns Filtered map containing only authorized and non-protected methods
119
+ */
120
+ export declare function filterUnauthorizedMethods(methods: IModuleMethodMap, authorizedMethods: string[], protectedMethods: string[]): IModuleMethodMap;
121
+ /**
122
+ * Factory function that creates and builds a fully initialized CheqdSDK instance.
123
+ * This is the recommended way to create an SDK instance as it handles all initialization steps.
124
+ *
125
+ * @param options - Configuration options for the SDK including wallet, modules, and network settings
126
+ * @returns Promise resolving to a fully initialized and ready-to-use CheqdSDK instance
127
+ */
128
+ export declare function createCheqdSDK(options: ICheqdSDKOptions): Promise<CheqdSDK>;
129
+ export { DIDModule, ResourceModule, FeemarketModule, FeeabstractionModule };
130
+ export { AbstractCheqdSDKModule, applyMixins } from './modules/_.js';
131
+ export { DidExtension, MinimalImportableDIDModule, MsgCreateDidDocEncodeObject, MsgCreateDidDocResponseEncodeObject, MsgUpdateDidDocEncodeObject, MsgUpdateDidDocResponseEncodeObject, MsgDeactivateDidDocEncodeObject, MsgDeactivateDidDocResponseEncodeObject, contexts, defaultDidExtensionKey, protobufLiterals as protobufLiteralsDid, typeUrlMsgCreateDidDoc, typeUrlMsgCreateDidDocResponse, typeUrlMsgUpdateDidDoc, typeUrlMsgUpdateDidDocResponse, typeUrlMsgDeactivateDidDoc, typeUrlMsgDeactivateDidDocResponse, setupDidExtension, isMsgCreateDidDocEncodeObject, isMsgUpdateDidDocEncodeObject, isMsgDeactivateDidDocEncodeObject, } from './modules/did.js';
132
+ export { ResourceExtension, MinimalImportableResourceModule, defaultResourceExtensionKey, protobufLiterals as protobufLiteralsResource, typeUrlMsgCreateResource, typeUrlMsgCreateResourceResponse, setupResourceExtension, isMsgCreateResourceEncodeObject, } from './modules/resource.js';
133
+ export { FeemarketExtension, MinimalImportableFeemarketModule, DefaultGasPriceTiers, defaultFeemarketExtensionKey, defaultGasPriceTiers, protobufLiterals as protobufLiteralsFeemarket, typeUrlGasPriceResponse, typeUrlGasPricesResponse, typeUrlParamsResponse, setupFeemarketExtension, isGasPriceEncodeObject, isGasPricesEncodeObject, isParamsEncodeObject, } from './modules/feemarket.js';
134
+ export { FeeabstractionExtension, MinimalImportableFeeabstractionModule, defaultFeeabstractionExtensionKey, protobufLiterals as protobufLiteralsFeeabstraction, typeUrlMsgAddHostZone, typeUrlMsgAddHostZoneResponse, typeUrlMsgFundFeeAbsModuleAccount, typeUrlMsgFundFeeAbsModuleAccountResponse, typeUrlMsgRemoveHostZone, typeUrlMsgRemoveHostZoneResponse, typeUrlMsgUpdateHostZone, typeUrlMsgUpdateHostZoneResponse, typeUrlMsgSendQueryIbcDenomTWAP, typeUrlMsgSendQueryIbcDenomTWAPResponse, typeUrlMsgSwapCrossChain, typeUrlMsgSwapCrossChainResponse, typeUrlMsgUpdateParams, typeUrlMsgUpdateParamsResponse, setupFeeabstractionExtension, isMsgAddHostZoneEncodeObject, isMsgAddHostZoneResponseEncodeObject, isMsgFundFeeAbsModuleAccountEncodeObject, isMsgFundFeeAbsModuleAccountResponseEncodeObject, isMsgRemoveHostZoneEncodeObject, isMsgRemoveHostZoneResponseEncodeObject, isMsgUpdateHostZoneEncodeObject, isMsgUpdateHostZoneResponseEncodeObject, isMsgSendQueryIbcDenomTWAPEncodeObject, isMsgSendQueryIbcDenomTWAPResponseEncodeObject, isMsgSwapCrossChainEncodeObject, isMsgSwapCrossChainResponseEncodeObject, isMsgUpdateParamsEncodeObject, isMsgUpdateParamsResponseEncodeObject, } from './modules/feeabstraction.js';
135
+ export * from './signer.js';
136
+ export * from './querier.js';
137
+ export * from './registry.js';
138
+ export * from './types.js';
139
+ export { TImportableEd25519Key, createKeyPairRaw, createKeyPairBase64, createKeyPairHex, createVerificationKeys, createDidVerificationMethod, createDidPayload, createSignInputsFromImportableEd25519Key, validateSpecCompliantPayload, isEqualKeyValuePair, createCosmosPayerWallet, getCosmosAccount, checkBalance, toMultibaseRaw, } from './utils.js';
140
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAY,MAAM,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AAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,wCAAwC,EACxC,4BAA4B,EAC5B,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,YAAY,EACZ,cAAc,GACd,MAAM,YAAY,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,182 @@
1
+ import { DIDModule } from './modules/did.js';
2
+ import { ResourceModule } from './modules/resource.js';
3
+ import { FeemarketModule, defaultGasPriceTiers, } from './modules/feemarket.js';
4
+ import { applyMixins, instantiateCheqdSDKModule, instantiateCheqdSDKModuleRegistryTypes, instantiateCheqdSDKModuleQuerierExtensionSetup, } from './modules/_.js';
5
+ import { createDefaultCheqdRegistry } from './registry.js';
6
+ import { CheqdSigningStargateClient } from './signer.js';
7
+ import { CheqdNetwork } from './types.js';
8
+ import { QueryClient } from '@cosmjs/stargate';
9
+ import { CheqdQuerier } from './querier.js';
10
+ import { FeeabstractionModule, } from './modules/feeabstraction.js';
11
+ /**
12
+ * Main CheqdSDK class that provides a comprehensive interface for interacting with the Cheqd blockchain.
13
+ * This class orchestrates modules for DID operations, resource management, fee market interactions,
14
+ * and fee abstraction functionality.
15
+ */
16
+ export class CheqdSDK {
17
+ /** Map of available methods from loaded modules */
18
+ methods;
19
+ /** Signing client for executing transactions on the blockchain */
20
+ signer;
21
+ /** Query client with extensions for reading blockchain data */
22
+ querier;
23
+ /** Configuration options passed during SDK initialization */
24
+ options;
25
+ /** List of method names that are protected from external access */
26
+ protectedMethods = ['constructor', 'build', 'loadModules', 'loadRegistry'];
27
+ /**
28
+ * Constructs a new CheqdSDK instance with the provided configuration options.
29
+ *
30
+ * @param options - Configuration options for the SDK including wallet, modules, and network settings
31
+ * @throws {Error} Throws an error if no wallet is provided in the options
32
+ */
33
+ constructor(options) {
34
+ if (!options?.wallet) {
35
+ throw new Error('No wallet provided');
36
+ }
37
+ this.options = {
38
+ authorizedMethods: [],
39
+ network: CheqdNetwork.Testnet,
40
+ ...options,
41
+ };
42
+ this.methods = {};
43
+ this.signer = new CheqdSigningStargateClient(undefined, this.options.wallet, {});
44
+ this.querier = new QueryClient({});
45
+ }
46
+ /**
47
+ * Executes a method from the loaded modules with the provided parameters.
48
+ * Only authorized methods can be executed through this interface.
49
+ *
50
+ * @template P - Type of parameters to pass to the method
51
+ * @template R - Return type of the method
52
+ * @param method - Name of the method to execute
53
+ * @param params - Parameters to pass to the method
54
+ * @returns Promise resolving to the method's return value
55
+ * @throws {Error} Throws an error if the method is not authorized
56
+ */
57
+ async execute(method, ...params) {
58
+ if (!Object.keys(this.methods).includes(method)) {
59
+ throw new Error(`Method ${method} is not authorized`);
60
+ }
61
+ return await this.methods[method](...params, { sdk: this });
62
+ }
63
+ /**
64
+ * Loads and instantiates the provided modules, making their methods available for execution.
65
+ * This method also applies mixins to make module methods accessible on the SDK instance.
66
+ *
67
+ * @param modules - Array of modules to load and integrate
68
+ * @returns Promise resolving to the CheqdSDK instance with loaded modules
69
+ * @private
70
+ */
71
+ async loadModules(modules) {
72
+ this.options.modules = this.options.modules.map((module) => instantiateCheqdSDKModule(module, this.signer, this.querier, {
73
+ sdk: this,
74
+ }));
75
+ const methods = applyMixins(this, modules);
76
+ this.methods = {
77
+ ...this.methods,
78
+ ...filterUnauthorizedMethods(methods, this.options.authorizedMethods || [], this.protectedMethods),
79
+ };
80
+ for (const method of Object.keys(this.methods)) {
81
+ // @ts-ignore
82
+ this[method] = async (...params) => {
83
+ return await this.execute(method, ...params);
84
+ };
85
+ }
86
+ return this;
87
+ }
88
+ /**
89
+ * Creates and configures a registry with types from all loaded modules.
90
+ * The registry is used for encoding and decoding blockchain messages.
91
+ *
92
+ * @returns Configured Registry instance with all module types
93
+ * @private
94
+ */
95
+ loadRegistry() {
96
+ const registryTypes = this.options.modules
97
+ .map((module) => instantiateCheqdSDKModuleRegistryTypes(module))
98
+ .reduce((acc, types) => {
99
+ return [...acc, ...types];
100
+ });
101
+ return createDefaultCheqdRegistry(registryTypes);
102
+ }
103
+ /**
104
+ * Establishes a connection to the blockchain querier with all necessary extensions.
105
+ * Extensions provide specialized query capabilities for different modules.
106
+ *
107
+ * @returns Promise resolving to a CheqdQuerier instance with all extensions
108
+ * @private
109
+ */
110
+ async loadQuerierExtensions() {
111
+ const querierExtensions = this.options.modules.map((module) => instantiateCheqdSDKModuleQuerierExtensionSetup(module));
112
+ const querier = await CheqdQuerier.connectWithExtensions(this.options.rpcUrl, ...querierExtensions);
113
+ return querier;
114
+ }
115
+ /**
116
+ * Builds and initializes the complete SDK instance by loading all components:
117
+ * registry, querier extensions, modules, gas price configuration, and signing client.
118
+ * This method must be called before the SDK can be used for blockchain operations.
119
+ *
120
+ * @returns Promise resolving to the fully initialized CheqdSDK instance
121
+ */
122
+ async build() {
123
+ const registry = this.loadRegistry();
124
+ this.querier = await this.loadQuerierExtensions();
125
+ // ensure feemarket module is loaded, if not already
126
+ if (!this.options.modules.find((module) => module instanceof FeemarketModule)) {
127
+ this.options.modules.push(FeemarketModule);
128
+ }
129
+ const sdk = await this.loadModules(this.options.modules);
130
+ // define gas price
131
+ this.options.gasPrice =
132
+ this.options.gasPrice ||
133
+ (await this.generateSafeGasPriceWithExponentialBackoff(DIDModule.baseMinimalDenom, defaultGasPriceTiers.Low, undefined, { sdk }));
134
+ this.signer = await CheqdSigningStargateClient.connectWithSigner(this.options.rpcUrl, this.options.wallet, {
135
+ registry,
136
+ gasPrice: this.options.gasPrice,
137
+ });
138
+ return sdk;
139
+ }
140
+ }
141
+ /**
142
+ * Filters methods based on authorization rules and protected method restrictions.
143
+ * Returns only methods that are explicitly authorized (if authorization list is provided)
144
+ * and excludes protected methods from external access.
145
+ *
146
+ * @param methods - Map of all available methods from modules
147
+ * @param authorizedMethods - List of method names that are explicitly authorized
148
+ * @param protectedMethods - List of method names that should be protected from external access
149
+ * @returns Filtered map containing only authorized and non-protected methods
150
+ */
151
+ export function filterUnauthorizedMethods(methods, authorizedMethods, protectedMethods) {
152
+ let _methods = Object.keys(methods);
153
+ if (authorizedMethods.length === 0)
154
+ return _methods
155
+ .filter((method) => !protectedMethods.includes(method))
156
+ .reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
157
+ return _methods
158
+ .filter((method) => authorizedMethods.includes(method) && !protectedMethods.includes(method))
159
+ .reduce((acc, method) => ({ ...acc, [method]: methods[method] }), {});
160
+ }
161
+ /**
162
+ * Factory function that creates and builds a fully initialized CheqdSDK instance.
163
+ * This is the recommended way to create an SDK instance as it handles all initialization steps.
164
+ *
165
+ * @param options - Configuration options for the SDK including wallet, modules, and network settings
166
+ * @returns Promise resolving to a fully initialized and ready-to-use CheqdSDK instance
167
+ */
168
+ export async function createCheqdSDK(options) {
169
+ return await new CheqdSDK(options).build();
170
+ }
171
+ export { DIDModule, ResourceModule, FeemarketModule, FeeabstractionModule };
172
+ export { AbstractCheqdSDKModule, applyMixins } from './modules/_.js';
173
+ export { MsgCreateDidDocResponseEncodeObject, MsgUpdateDidDocEncodeObject, MsgUpdateDidDocResponseEncodeObject, MsgDeactivateDidDocEncodeObject, contexts, defaultDidExtensionKey, protobufLiterals as protobufLiteralsDid, typeUrlMsgCreateDidDoc, typeUrlMsgCreateDidDocResponse, typeUrlMsgUpdateDidDoc, typeUrlMsgUpdateDidDocResponse, typeUrlMsgDeactivateDidDoc, typeUrlMsgDeactivateDidDocResponse, setupDidExtension, isMsgCreateDidDocEncodeObject, isMsgUpdateDidDocEncodeObject, isMsgDeactivateDidDocEncodeObject, } from './modules/did.js';
174
+ export { defaultResourceExtensionKey, protobufLiterals as protobufLiteralsResource, typeUrlMsgCreateResource, typeUrlMsgCreateResourceResponse, setupResourceExtension, isMsgCreateResourceEncodeObject, } from './modules/resource.js';
175
+ export { defaultFeemarketExtensionKey, defaultGasPriceTiers, protobufLiterals as protobufLiteralsFeemarket, typeUrlGasPriceResponse, typeUrlGasPricesResponse, typeUrlParamsResponse, setupFeemarketExtension, isGasPriceEncodeObject, isGasPricesEncodeObject, isParamsEncodeObject, } from './modules/feemarket.js';
176
+ export { defaultFeeabstractionExtensionKey, protobufLiterals as protobufLiteralsFeeabstraction, typeUrlMsgAddHostZone, typeUrlMsgAddHostZoneResponse, typeUrlMsgFundFeeAbsModuleAccount, typeUrlMsgFundFeeAbsModuleAccountResponse, typeUrlMsgRemoveHostZone, typeUrlMsgRemoveHostZoneResponse, typeUrlMsgUpdateHostZone, typeUrlMsgUpdateHostZoneResponse, typeUrlMsgSendQueryIbcDenomTWAP, typeUrlMsgSendQueryIbcDenomTWAPResponse, typeUrlMsgSwapCrossChain, typeUrlMsgSwapCrossChainResponse, typeUrlMsgUpdateParams, typeUrlMsgUpdateParamsResponse, setupFeeabstractionExtension, isMsgAddHostZoneEncodeObject, isMsgAddHostZoneResponseEncodeObject, isMsgFundFeeAbsModuleAccountEncodeObject, isMsgFundFeeAbsModuleAccountResponseEncodeObject, isMsgRemoveHostZoneEncodeObject, isMsgRemoveHostZoneResponseEncodeObject, isMsgUpdateHostZoneEncodeObject, isMsgUpdateHostZoneResponseEncodeObject, isMsgSendQueryIbcDenomTWAPEncodeObject, isMsgSendQueryIbcDenomTWAPResponseEncodeObject, isMsgSwapCrossChainEncodeObject, isMsgSwapCrossChainResponseEncodeObject, isMsgUpdateParamsEncodeObject, isMsgUpdateParamsResponseEncodeObject, } from './modules/feeabstraction.js';
177
+ export * from './signer.js';
178
+ export * from './querier.js';
179
+ export * from './registry.js';
180
+ export * from './types.js';
181
+ export { TImportableEd25519Key, createKeyPairRaw, createKeyPairBase64, createKeyPairHex, createVerificationKeys, createDidVerificationMethod, createDidPayload, createSignInputsFromImportableEd25519Key, validateSpecCompliantPayload, isEqualKeyValuePair, createCosmosPayerWallet, getCosmosAccount, checkBalance, toMultibaseRaw, } from './utils.js';
182
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+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AGN,iCAAiC,EACjC,gBAAgB,IAAI,8BAA8B,EAClD,qBAAqB,EACrB,6BAA6B,EAC7B,iCAAiC,EACjC,yCAAyC,EACzC,wBAAwB,EACxB,gCAAgC,EAChC,wBAAwB,EACxB,gCAAgC,EAChC,+BAA+B,EAC/B,uCAAuC,EACvC,wBAAwB,EACxB,gCAAgC,EAChC,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC5B,4BAA4B,EAC5B,oCAAoC,EACpC,wCAAwC,EACxC,gDAAgD,EAChD,+BAA+B,EAC/B,uCAAuC,EACvC,+BAA+B,EAC/B,uCAAuC,EACvC,sCAAsC,EACtC,8CAA8C,EAC9C,+BAA+B,EAC/B,uCAAuC,EACvC,6BAA6B,EAC7B,qCAAqC,GACrC,MAAM,6BAA6B,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,2BAA2B,EAC3B,gBAAgB,EAChB,wCAAwC,EACxC,4BAA4B,EAC5B,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,YAAY,EACZ,cAAc,GACd,MAAM,YAAY,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { GeneratedType } from '@cosmjs/proto-signing';
2
+ import { CheqdSigningStargateClient } from '../signer.js';
3
+ import { IModuleMethodMap, QueryExtensionSetup } from '../types.js';
4
+ import { CheqdQuerier } from '../querier.js';
5
+ /**
6
+ * Abstract base class for all Cheqd SDK modules.
7
+ * Provides common functionality and enforces implementation of required methods.
8
+ */
9
+ export declare abstract class AbstractCheqdSDKModule {
10
+ /** Signing client for blockchain transactions */
11
+ _signer: CheqdSigningStargateClient;
12
+ /** Module methods registry */
13
+ methods: IModuleMethodMap;
14
+ /** Querier client for data retrieval */
15
+ querier: CheqdQuerier;
16
+ /** List of methods that should not be exposed externally */
17
+ readonly _protectedMethods: string[];
18
+ /** Static registry of protobuf message types */
19
+ static readonly registryTypes: Iterable<[string, GeneratedType]>;
20
+ /** Static querier extension setup function */
21
+ static readonly querierExtensionSetup: QueryExtensionSetup<any>;
22
+ /**
23
+ * Creates a new SDK module instance.
24
+ *
25
+ * @param signer - Signing client for blockchain transactions
26
+ * @param querier - Querier client for data retrieval
27
+ * @throws Error if signer or querier is not provided
28
+ */
29
+ constructor(signer: CheqdSigningStargateClient, querier: CheqdQuerier);
30
+ /**
31
+ * Gets the registry types for message encoding/decoding.
32
+ * Must be implemented by each module to provide its specific message types.
33
+ *
34
+ * @returns Iterable of [typeUrl, GeneratedType] pairs for the registry
35
+ */
36
+ abstract getRegistryTypes(): Iterable<[string, GeneratedType]>;
37
+ }
38
+ /**
39
+ * Minimal importable interface for SDK modules.
40
+ * Excludes internal implementation details and protected methods for clean external APIs.
41
+ */
42
+ export type MinimalImportableCheqdSDKModule<T extends AbstractCheqdSDKModule> = Omit<T, '_signer' | '_protectedMethods' | 'registryTypes' | 'querierExtensionSetup' | 'getRegistryTypes' | 'getQuerierExtensionSetup'>;
43
+ /**
44
+ * Creates a new instance of a Cheqd SDK module.
45
+ * Generic factory function for instantiating any module type.
46
+ *
47
+ * @param module - Module constructor class
48
+ * @param args - Constructor arguments for the module
49
+ * @returns New instance of the specified module
50
+ */
51
+ export declare function instantiateCheqdSDKModule<T extends new (...args: any[]) => T>(module: T, ...args: ConstructorParameters<T>): T;
52
+ /**
53
+ * Extracts registry types from a module instance.
54
+ * Safely retrieves protobuf message types with fallback to empty array.
55
+ *
56
+ * @param module - Module instance to extract registry types from
57
+ * @returns Iterable of [typeUrl, GeneratedType] pairs for protobuf messages
58
+ */
59
+ export declare function instantiateCheqdSDKModuleRegistryTypes(module: any): Iterable<[string, GeneratedType]>;
60
+ export declare function instantiateCheqdSDKModuleQuerierExtensionSetup(module: any): QueryExtensionSetup<any>;
61
+ export declare function applyMixins(derivedCtor: any, constructors: any[]): IModuleMethodMap;
62
+ //# sourceMappingURL=_.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_.d.ts","sourceRoot":"","sources":["../../src/modules/_.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;GAGG;AACH,8BAAsB,sBAAsB;IAC3C,iDAAiD;IACjD,OAAO,EAAE,0BAA0B,CAAC;IACpC,8BAA8B;IAC9B,OAAO,EAAE,gBAAgB,CAAM;IAC/B,wCAAwC;IACxC,OAAO,EAAE,YAAY,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAmE;IACvG,gDAAgD;IAChD,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAM;IACtE,8CAA8C;IAC9C,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAA+B;IAE9F;;;;;;OAMG;gBACS,MAAM,EAAE,0BAA0B,EAAE,OAAO,EAAE,YAAY;IAWrE;;;;;OAKG;IACH,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC9D;AASD;;;GAGG;AACH,MAAM,MAAM,+BAA+B,CAAC,CAAC,SAAS,sBAAsB,IAAI,IAAI,CACnF,CAAC,EACC,SAAS,GACT,mBAAmB,GACnB,eAAe,GACf,uBAAuB,GACvB,kBAAkB,GAClB,0BAA0B,CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAC5E,MAAM,EAAE,CAAC,EACT,GAAG,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAC/B,CAAC,CAEH;AAED;;;;;;GAMG;AAEH,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,GAAG,GAAG,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAErG;AAED,wBAAgB,8CAA8C,CAAC,MAAM,EAAE,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAEpG;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,gBAAgB,CAmBnF"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Abstract base class for all Cheqd SDK modules.
3
+ * Provides common functionality and enforces implementation of required methods.
4
+ */
5
+ export class AbstractCheqdSDKModule {
6
+ /** Signing client for blockchain transactions */
7
+ _signer;
8
+ /** Module methods registry */
9
+ methods = {};
10
+ /** Querier client for data retrieval */
11
+ querier;
12
+ /** List of methods that should not be exposed externally */
13
+ _protectedMethods = ['constructor', 'getRegistryTypes', 'getQuerierExtensionSetup'];
14
+ /** Static registry of protobuf message types */
15
+ static registryTypes = [];
16
+ /** Static querier extension setup function */
17
+ static querierExtensionSetup = (base) => ({});
18
+ /**
19
+ * Creates a new SDK module instance.
20
+ *
21
+ * @param signer - Signing client for blockchain transactions
22
+ * @param querier - Querier client for data retrieval
23
+ * @throws Error if signer or querier is not provided
24
+ */
25
+ constructor(signer, querier) {
26
+ if (!signer) {
27
+ throw new Error('signer is required');
28
+ }
29
+ if (!querier) {
30
+ throw new Error('querier is required');
31
+ }
32
+ this._signer = signer;
33
+ this.querier = querier;
34
+ }
35
+ }
36
+ /**
37
+ * Creates a new instance of a Cheqd SDK module.
38
+ * Generic factory function for instantiating any module type.
39
+ *
40
+ * @param module - Module constructor class
41
+ * @param args - Constructor arguments for the module
42
+ * @returns New instance of the specified module
43
+ */
44
+ export function instantiateCheqdSDKModule(module, ...args) {
45
+ return new module(...args);
46
+ }
47
+ /**
48
+ * Extracts registry types from a module instance.
49
+ * Safely retrieves protobuf message types with fallback to empty array.
50
+ *
51
+ * @param module - Module instance to extract registry types from
52
+ * @returns Iterable of [typeUrl, GeneratedType] pairs for protobuf messages
53
+ */
54
+ export function instantiateCheqdSDKModuleRegistryTypes(module) {
55
+ return module.registryTypes ?? [];
56
+ }
57
+ export function instantiateCheqdSDKModuleQuerierExtensionSetup(module) {
58
+ return module.querierExtensionSetup ?? {};
59
+ }
60
+ export function applyMixins(derivedCtor, constructors) {
61
+ let methods = {};
62
+ constructors.forEach((baseCtor) => {
63
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
64
+ const property = baseCtor.prototype[name];
65
+ if (typeof property !== 'function' ||
66
+ derivedCtor.hasOwnProperty(name) ||
67
+ derivedCtor?.protectedMethods.includes(name) ||
68
+ baseCtor.prototype?._protectedMethods?.includes(name))
69
+ return;
70
+ methods = { ...methods, [name]: property };
71
+ });
72
+ });
73
+ return methods;
74
+ }
75
+ //# sourceMappingURL=_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_.js","sourceRoot":"","sources":["../../src/modules/_.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,OAAgB,sBAAsB;IAC3C,iDAAiD;IACjD,OAAO,CAA6B;IACpC,8BAA8B;IAC9B,OAAO,GAAqB,EAAE,CAAC;IAC/B,wCAAwC;IACxC,OAAO,CAAe;IACtB,4DAA4D;IACnD,iBAAiB,GAAa,CAAC,aAAa,EAAE,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;IACvG,gDAAgD;IAChD,MAAM,CAAU,aAAa,GAAsC,EAAE,CAAC;IACtE,8CAA8C;IAC9C,MAAM,CAAU,qBAAqB,GAA6B,CAAC,IAAiB,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAE9F;;;;;;OAMG;IACH,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