@cheqd/sdk-esm 5.3.7-develop.1 → 5.4.0-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.
Files changed (179) hide show
  1. package/build/cjs/src/index.d.ts +142 -0
  2. package/build/cjs/src/index.d.ts.map +1 -0
  3. package/build/cjs/src/index.js +184 -0
  4. package/build/cjs/src/index.js.map +1 -0
  5. package/build/cjs/src/modules/_.d.ts +81 -0
  6. package/build/cjs/src/modules/_.d.ts.map +1 -0
  7. package/build/cjs/src/modules/_.js +93 -0
  8. package/build/cjs/src/modules/_.js.map +1 -0
  9. package/build/cjs/src/modules/did.d.ts +488 -0
  10. package/build/cjs/src/modules/did.d.ts.map +1 -0
  11. package/build/cjs/src/modules/did.js +1249 -0
  12. package/build/cjs/src/modules/did.js.map +1 -0
  13. package/build/cjs/src/modules/feeabstraction.d.ts +429 -0
  14. package/build/cjs/src/modules/feeabstraction.d.ts.map +1 -0
  15. package/build/cjs/src/modules/feeabstraction.js +474 -0
  16. package/build/cjs/src/modules/feeabstraction.js.map +1 -0
  17. package/build/cjs/src/modules/feemarket.d.ts +244 -0
  18. package/build/cjs/src/modules/feemarket.d.ts.map +1 -0
  19. package/build/cjs/src/modules/feemarket.js +297 -0
  20. package/build/cjs/src/modules/feemarket.js.map +1 -0
  21. package/build/cjs/src/modules/oracle.d.ts +563 -0
  22. package/build/cjs/src/modules/oracle.d.ts.map +1 -0
  23. package/build/cjs/src/modules/oracle.js +784 -0
  24. package/build/cjs/src/modules/oracle.js.map +1 -0
  25. package/build/cjs/src/modules/resource.d.ts +330 -0
  26. package/build/cjs/src/modules/resource.d.ts.map +1 -0
  27. package/build/cjs/src/modules/resource.js +556 -0
  28. package/build/cjs/src/modules/resource.js.map +1 -0
  29. package/build/cjs/src/querier.d.ts +62 -0
  30. package/build/cjs/src/querier.d.ts.map +1 -0
  31. package/build/cjs/src/querier.js +87 -0
  32. package/build/cjs/src/querier.js.map +1 -0
  33. package/build/cjs/src/registry.d.ts +18 -0
  34. package/build/cjs/src/registry.d.ts.map +1 -0
  35. package/build/cjs/src/registry.js +23 -0
  36. package/build/cjs/src/registry.js.map +1 -0
  37. package/build/cjs/src/signer.d.ts +250 -0
  38. package/build/cjs/src/signer.d.ts.map +1 -0
  39. package/build/cjs/src/signer.js +617 -0
  40. package/build/cjs/src/signer.js.map +1 -0
  41. package/build/cjs/src/types.d.ts +221 -0
  42. package/build/cjs/src/types.d.ts.map +1 -0
  43. package/build/cjs/src/types.js.map +1 -0
  44. package/build/cjs/src/utils.d.ts +233 -0
  45. package/build/cjs/src/utils.d.ts.map +1 -0
  46. package/build/cjs/src/utils.js +571 -0
  47. package/build/cjs/src/utils.js.map +1 -0
  48. package/build/{index.d.ts → esm/src/index.d.ts} +7 -3
  49. package/build/esm/src/index.d.ts.map +1 -0
  50. package/build/{index.js → esm/src/index.js} +3 -1
  51. package/build/esm/src/index.js.map +1 -0
  52. package/build/esm/src/modules/_.d.ts.map +1 -0
  53. package/build/esm/src/modules/_.js.map +1 -0
  54. package/build/{modules → esm/src/modules}/did.d.ts +109 -7
  55. package/build/esm/src/modules/did.d.ts.map +1 -0
  56. package/build/{modules → esm/src/modules}/did.js +212 -6
  57. package/build/esm/src/modules/did.js.map +1 -0
  58. package/build/esm/src/modules/feeabstraction.d.ts.map +1 -0
  59. package/build/esm/src/modules/feeabstraction.js.map +1 -0
  60. package/build/esm/src/modules/feemarket.d.ts.map +1 -0
  61. package/build/esm/src/modules/feemarket.js.map +1 -0
  62. package/build/esm/src/modules/oracle.d.ts +563 -0
  63. package/build/esm/src/modules/oracle.d.ts.map +1 -0
  64. package/build/esm/src/modules/oracle.js +784 -0
  65. package/build/esm/src/modules/oracle.js.map +1 -0
  66. package/build/{modules → esm/src/modules}/resource.d.ts +132 -6
  67. package/build/esm/src/modules/resource.d.ts.map +1 -0
  68. package/build/esm/src/modules/resource.js +556 -0
  69. package/build/esm/src/modules/resource.js.map +1 -0
  70. package/build/esm/src/querier.d.ts.map +1 -0
  71. package/build/esm/src/querier.js.map +1 -0
  72. package/build/esm/src/registry.d.ts.map +1 -0
  73. package/build/esm/src/registry.js.map +1 -0
  74. package/build/esm/src/signer.d.ts.map +1 -0
  75. package/build/esm/src/signer.js.map +1 -0
  76. package/build/{types → esm/src}/types.d.ts +27 -1
  77. package/build/esm/src/types.d.ts.map +1 -0
  78. package/build/esm/src/types.js +43 -0
  79. package/build/esm/src/types.js.map +1 -0
  80. package/build/esm/src/utils.d.ts.map +1 -0
  81. package/build/esm/src/utils.js.map +1 -0
  82. package/build/types/cjs/src/index.d.ts +142 -0
  83. package/build/types/cjs/src/index.d.ts.map +1 -0
  84. package/build/types/cjs/src/modules/_.d.ts +81 -0
  85. package/build/types/cjs/src/modules/_.d.ts.map +1 -0
  86. package/build/types/cjs/src/modules/did.d.ts +488 -0
  87. package/build/types/cjs/src/modules/did.d.ts.map +1 -0
  88. package/build/types/cjs/src/modules/feeabstraction.d.ts +429 -0
  89. package/build/types/cjs/src/modules/feeabstraction.d.ts.map +1 -0
  90. package/build/types/cjs/src/modules/feemarket.d.ts +244 -0
  91. package/build/types/cjs/src/modules/feemarket.d.ts.map +1 -0
  92. package/build/types/cjs/src/modules/oracle.d.ts +563 -0
  93. package/build/types/cjs/src/modules/oracle.d.ts.map +1 -0
  94. package/build/types/cjs/src/modules/resource.d.ts +330 -0
  95. package/build/types/cjs/src/modules/resource.d.ts.map +1 -0
  96. package/build/types/cjs/src/querier.d.ts +62 -0
  97. package/build/types/cjs/src/querier.d.ts.map +1 -0
  98. package/build/types/cjs/src/registry.d.ts +18 -0
  99. package/build/types/cjs/src/registry.d.ts.map +1 -0
  100. package/build/types/cjs/src/signer.d.ts +250 -0
  101. package/build/types/cjs/src/signer.d.ts.map +1 -0
  102. package/build/types/cjs/src/types.d.ts +221 -0
  103. package/build/types/cjs/src/types.d.ts.map +1 -0
  104. package/build/types/cjs/src/utils.d.ts +233 -0
  105. package/build/types/cjs/src/utils.d.ts.map +1 -0
  106. package/build/types/{index.d.ts → esm/src/index.d.ts} +7 -3
  107. package/build/types/esm/src/index.d.ts.map +1 -0
  108. package/build/types/esm/src/modules/_.d.ts.map +1 -0
  109. package/build/types/{modules → esm/src/modules}/did.d.ts +109 -7
  110. package/build/types/esm/src/modules/did.d.ts.map +1 -0
  111. package/build/types/esm/src/modules/feeabstraction.d.ts.map +1 -0
  112. package/build/types/esm/src/modules/feemarket.d.ts.map +1 -0
  113. package/build/types/esm/src/modules/oracle.d.ts +563 -0
  114. package/build/types/esm/src/modules/oracle.d.ts.map +1 -0
  115. package/build/types/{modules → esm/src/modules}/resource.d.ts +132 -6
  116. package/build/types/esm/src/modules/resource.d.ts.map +1 -0
  117. package/build/types/esm/src/querier.d.ts.map +1 -0
  118. package/build/types/esm/src/registry.d.ts.map +1 -0
  119. package/build/types/esm/src/signer.d.ts.map +1 -0
  120. package/build/{types.d.ts → types/esm/src/types.d.ts} +27 -1
  121. package/build/types/esm/src/types.d.ts.map +1 -0
  122. package/build/types/esm/src/utils.d.ts.map +1 -0
  123. package/package.json +2 -2
  124. package/build/index.d.ts.map +0 -1
  125. package/build/index.js.map +0 -1
  126. package/build/modules/_.d.ts.map +0 -1
  127. package/build/modules/_.js.map +0 -1
  128. package/build/modules/did.d.ts.map +0 -1
  129. package/build/modules/did.js.map +0 -1
  130. package/build/modules/feeabstraction.d.ts.map +0 -1
  131. package/build/modules/feeabstraction.js.map +0 -1
  132. package/build/modules/feemarket.d.ts.map +0 -1
  133. package/build/modules/feemarket.js.map +0 -1
  134. package/build/modules/resource.d.ts.map +0 -1
  135. package/build/modules/resource.js +0 -297
  136. package/build/modules/resource.js.map +0 -1
  137. package/build/querier.d.ts.map +0 -1
  138. package/build/querier.js.map +0 -1
  139. package/build/registry.d.ts.map +0 -1
  140. package/build/registry.js.map +0 -1
  141. package/build/signer.d.ts.map +0 -1
  142. package/build/signer.js.map +0 -1
  143. package/build/types/index.d.ts.map +0 -1
  144. package/build/types/modules/_.d.ts.map +0 -1
  145. package/build/types/modules/did.d.ts.map +0 -1
  146. package/build/types/modules/feeabstraction.d.ts.map +0 -1
  147. package/build/types/modules/feemarket.d.ts.map +0 -1
  148. package/build/types/modules/resource.d.ts.map +0 -1
  149. package/build/types/querier.d.ts.map +0 -1
  150. package/build/types/registry.d.ts.map +0 -1
  151. package/build/types/signer.d.ts.map +0 -1
  152. package/build/types/types.d.ts.map +0 -1
  153. package/build/types/utils.d.ts.map +0 -1
  154. package/build/types.d.ts.map +0 -1
  155. package/build/types.js.map +0 -1
  156. package/build/utils.d.ts.map +0 -1
  157. package/build/utils.js.map +0 -1
  158. /package/build/{types.js → cjs/src/types.js} +0 -0
  159. /package/build/{modules → esm/src/modules}/_.d.ts +0 -0
  160. /package/build/{modules → esm/src/modules}/_.js +0 -0
  161. /package/build/{modules → esm/src/modules}/feeabstraction.d.ts +0 -0
  162. /package/build/{modules → esm/src/modules}/feeabstraction.js +0 -0
  163. /package/build/{modules → esm/src/modules}/feemarket.d.ts +0 -0
  164. /package/build/{modules → esm/src/modules}/feemarket.js +0 -0
  165. /package/build/{querier.d.ts → esm/src/querier.d.ts} +0 -0
  166. /package/build/{querier.js → esm/src/querier.js} +0 -0
  167. /package/build/{registry.d.ts → esm/src/registry.d.ts} +0 -0
  168. /package/build/{registry.js → esm/src/registry.js} +0 -0
  169. /package/build/{signer.d.ts → esm/src/signer.d.ts} +0 -0
  170. /package/build/{signer.js → esm/src/signer.js} +0 -0
  171. /package/build/{types → esm/src}/utils.d.ts +0 -0
  172. /package/build/{utils.js → esm/src/utils.js} +0 -0
  173. /package/build/types/{modules → esm/src/modules}/_.d.ts +0 -0
  174. /package/build/types/{modules → esm/src/modules}/feeabstraction.d.ts +0 -0
  175. /package/build/types/{modules → esm/src/modules}/feemarket.d.ts +0 -0
  176. /package/build/types/{querier.d.ts → esm/src/querier.d.ts} +0 -0
  177. /package/build/types/{registry.d.ts → esm/src/registry.d.ts} +0 -0
  178. /package/build/types/{signer.d.ts → esm/src/signer.d.ts} +0 -0
  179. /package/build/{utils.d.ts → types/esm/src/utils.d.ts} +0 -0
@@ -0,0 +1,617 @@
1
+ import { isOfflineDirectSigner, encodePubkey, makeSignDoc, } from '@cosmjs/proto-signing-cjs';
2
+ import { SigningStargateClient, calculateFee, createProtobufRpcClient, TimeoutError, BroadcastTxError, } from '@cosmjs/stargate-cjs';
3
+ import { Tendermint37Client } from '@cosmjs/tendermint-rpc-cjs';
4
+ import { createDefaultCheqdRegistry } from './registry';
5
+ import { MsgCreateDidDocPayload, MsgUpdateDidDocPayload, MsgDeactivateDidDocPayload, } from '@cheqd/ts-proto-cjs/cheqd/did/v2';
6
+ import { VerificationMethods, } from './types';
7
+ import { base64ToBytes, EdDSASigner, hexToBytes, ES256Signer, ES256KSigner } from 'did-jwt-cjs';
8
+ import { assert, assertDefined, sleep } from '@cosmjs/utils-cjs';
9
+ import { encodeSecp256k1Pubkey } from '@cosmjs/amino-cjs';
10
+ import { Int53 } from '@cosmjs/math-cjs';
11
+ import { fromBase64, toHex } from '@cosmjs/encoding-cjs';
12
+ import { AuthInfo, TxRaw } from 'cosmjs-types-cjs/cosmos/tx/v1beta1/tx';
13
+ import { SignMode } from 'cosmjs-types-cjs/cosmos/tx/signing/v1beta1/signing';
14
+ import Long from 'long-cjs';
15
+ import { CheqdQuerier } from './querier';
16
+ import { Uint53 } from '@cosmjs/math-cjs';
17
+ import { ServiceClientImpl, SimulateRequest, } from 'cosmjs-types-cjs/cosmos/tx/v1beta1/service';
18
+ import { Tx, TxBody, Fee } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
19
+ /**
20
+ * Calculates the transaction fee for DID operations using gas limit and gas price.
21
+ *
22
+ * @param gasLimit - Maximum amount of gas units that can be consumed by the transaction
23
+ * @param gasPrice - Price per gas unit, either as a string or GasPrice object
24
+ * @returns DidStdFee object containing the calculated fee structure
25
+ */
26
+ export function calculateDidFee(gasLimit, gasPrice) {
27
+ return calculateFee(gasLimit, gasPrice);
28
+ }
29
+ /**
30
+ * Creates SignerInfo objects for transaction authentication from signer data.
31
+ * Each signer info contains the public key, sequence number, and signing mode.
32
+ *
33
+ * @param signers - Array of signer objects containing public keys and sequence numbers
34
+ * @param signMode - Signing mode to use (e.g., SIGN_MODE_DIRECT)
35
+ * @returns Array of SignerInfo objects for transaction authentication
36
+ */
37
+ export function makeSignerInfos(signers, signMode) {
38
+ return signers.map(({ pubkey, sequence }) => ({
39
+ publicKey: pubkey,
40
+ modeInfo: {
41
+ single: { mode: signMode },
42
+ },
43
+ sequence: Long.fromNumber(sequence),
44
+ }));
45
+ }
46
+ /**
47
+ * Creates encoded AuthInfo bytes for DID transactions with fee payer support.
48
+ * The AuthInfo contains signer information, fee details, and gas limit.
49
+ *
50
+ * @param signers - Array of signer objects with public keys and sequence numbers
51
+ * @param feeAmount - Array of coins representing the transaction fee
52
+ * @param gasLimit - Maximum gas units that can be consumed
53
+ * @param feePayer - Address of the account paying the transaction fees
54
+ * @param signMode - Signing mode to use, defaults to SIGN_MODE_DIRECT
55
+ * @returns Encoded AuthInfo as Uint8Array for transaction construction
56
+ */
57
+ export function makeDidAuthInfoBytes(signers, feeAmount, gasLimit, feePayer, signMode = SignMode.SIGN_MODE_DIRECT) {
58
+ const authInfo = {
59
+ signerInfos: makeSignerInfos(signers, signMode),
60
+ fee: {
61
+ amount: [...feeAmount],
62
+ gasLimit: Long.fromNumber(gasLimit),
63
+ payer: feePayer,
64
+ },
65
+ };
66
+ return AuthInfo.encode(AuthInfo.fromPartial(authInfo)).finish();
67
+ }
68
+ /**
69
+ * Extended SigningStargateClient specifically designed for Cheqd blockchain operations.
70
+ * Provides enhanced transaction signing, broadcasting, and DID-specific functionality
71
+ * with support for custom fee payers and advanced retry mechanisms.
72
+ */
73
+ export class CheqdSigningStargateClient extends SigningStargateClient {
74
+ /** Map of DID signing algorithms for different verification method types */
75
+ didSigners = {};
76
+ /** Gas price configuration for transaction fee calculation */
77
+ _gasPrice;
78
+ /** Offline signer instance for transaction signing */
79
+ _signer;
80
+ /** RPC endpoint URL for blockchain communication */
81
+ endpoint;
82
+ /** Maximum gas limit allowed for transactions */
83
+ static maxGasLimit = Number.MAX_SAFE_INTEGER;
84
+ /**
85
+ * Creates a new CheqdSigningStargateClient by establishing a connection to the specified endpoint.
86
+ * This is the primary factory method for creating a signing client instance.
87
+ *
88
+ * @param endpoint - RPC endpoint URL or HttpEndpoint object to connect to
89
+ * @param signer - Offline signer for transaction signing
90
+ * @param options - Additional client configuration options including registry and gas price
91
+ * @returns Promise resolving to a connected CheqdSigningStargateClient instance
92
+ */
93
+ static async connectWithSigner(endpoint, signer, options) {
94
+ const cometClient = await Tendermint37Client.connect(endpoint);
95
+ return new CheqdSigningStargateClient(cometClient, signer, {
96
+ registry: options?.registry ? options.registry : createDefaultCheqdRegistry(),
97
+ endpoint: options?.endpoint
98
+ ? typeof options.endpoint === 'string'
99
+ ? options.endpoint
100
+ : options.endpoint.url
101
+ : undefined,
102
+ ...options,
103
+ });
104
+ }
105
+ /**
106
+ * Constructs a new CheqdSigningStargateClient instance with the provided Comet client and signer.
107
+ *
108
+ * @param cometClient - Tendermint client for blockchain communication
109
+ * @param signer - Offline signer for transaction signing
110
+ * @param options - Additional configuration options including registry, gas price, and endpoint
111
+ */
112
+ constructor(cometClient, signer, options = {}) {
113
+ super(cometClient, signer, options);
114
+ this._signer = signer;
115
+ this._gasPrice = options.gasPrice;
116
+ this.endpoint = options.endpoint;
117
+ }
118
+ /**
119
+ * Signs and broadcasts a transaction to the blockchain network.
120
+ * Supports automatic fee calculation and custom fee payer functionality.
121
+ *
122
+ * @param signerAddress - Address of the account signing the transaction
123
+ * @param messages - Array of messages to include in the transaction
124
+ * @param fee - Fee configuration: 'auto' for automatic calculation, number for multiplier, or DidStdFee object
125
+ * @param memo - Optional transaction memo string
126
+ * @returns Promise resolving to DeliverTxResponse with transaction results
127
+ * @throws Error if gas price is not set when using automatic fee calculation
128
+ */
129
+ async signAndBroadcast(signerAddress, messages, fee, memo = '') {
130
+ let usedFee;
131
+ if (fee == 'auto' || typeof fee === 'number') {
132
+ assertDefined(this._gasPrice, 'Gas price must be set in the client options when auto gas is used.');
133
+ const gasEstimation = await this.simulate(signerAddress, messages, memo);
134
+ const multiplier = typeof fee === 'number' ? fee : 1.3;
135
+ usedFee = calculateDidFee(Math.round(gasEstimation * multiplier), this._gasPrice);
136
+ usedFee.payer = signerAddress;
137
+ }
138
+ else {
139
+ usedFee = fee;
140
+ assertDefined(usedFee.payer, 'Payer address must be set when fee is not auto.');
141
+ signerAddress = usedFee.payer;
142
+ }
143
+ const txRaw = await this.sign(signerAddress, messages, usedFee, memo);
144
+ const txBytes = TxRaw.encode(txRaw).finish();
145
+ return this.broadcastTx(txBytes, this.broadcastTimeoutMs, this.broadcastPollIntervalMs);
146
+ }
147
+ /**
148
+ * Signs a transaction without broadcasting it to the network.
149
+ * Creates a signed transaction that can be broadcast later.
150
+ *
151
+ * @param signerAddress - Address of the account signing the transaction
152
+ * @param messages - Array of messages to include in the transaction
153
+ * @param fee - Fee configuration for the transaction
154
+ * @param memo - Transaction memo string
155
+ * @param explicitSignerData - Optional explicit signer data to avoid querying the chain
156
+ * @returns Promise resolving to TxRaw containing the signed transaction
157
+ */
158
+ async sign(signerAddress, messages, fee, memo, explicitSignerData) {
159
+ let signerData;
160
+ if (explicitSignerData) {
161
+ signerData = explicitSignerData;
162
+ }
163
+ else {
164
+ const { accountNumber, sequence } = await this.getSequence(signerAddress);
165
+ const chainId = await this.getChainId();
166
+ signerData = {
167
+ accountNumber: accountNumber,
168
+ sequence: sequence,
169
+ chainId: chainId,
170
+ };
171
+ }
172
+ return this._signDirect(signerAddress, messages, fee, memo, signerData);
173
+ }
174
+ /**
175
+ * Internal method for direct signing of transactions using SIGN_MODE_DIRECT.
176
+ * Handles the low-level transaction construction and signing process.
177
+ *
178
+ * @param signerAddress - Address of the account signing the transaction
179
+ * @param messages - Array of messages to include in the transaction
180
+ * @param fee - Fee configuration for the transaction
181
+ * @param memo - Transaction memo string
182
+ * @param signerData - Account data including number, sequence, and chain ID
183
+ * @returns Promise resolving to TxRaw containing the signed transaction
184
+ * @private
185
+ */
186
+ async _signDirect(signerAddress, messages, fee, memo, { accountNumber, sequence, chainId }) {
187
+ assert(isOfflineDirectSigner(this._signer));
188
+ const accountFromSigner = (await this._signer.getAccounts()).find((account) => account.address === signerAddress);
189
+ if (!accountFromSigner) {
190
+ throw new Error('Failed to retrieve account from signer');
191
+ }
192
+ const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));
193
+ const txBodyEncodeObject = {
194
+ typeUrl: '/cosmos.tx.v1beta1.TxBody',
195
+ value: {
196
+ messages: messages,
197
+ memo: memo,
198
+ },
199
+ };
200
+ const txBodyBytes = this.registry.encode(txBodyEncodeObject);
201
+ const gasLimit = Int53.fromString(fee.gas).toNumber();
202
+ const authInfoBytes = makeDidAuthInfoBytes([{ pubkey, sequence }], fee.amount, gasLimit, fee.payer);
203
+ const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
204
+ const { signature, signed } = await this._signer.signDirect(signerAddress, signDoc);
205
+ return TxRaw.fromPartial({
206
+ bodyBytes: signed.bodyBytes,
207
+ authInfoBytes: signed.authInfoBytes,
208
+ signatures: [fromBase64(signature.signature)],
209
+ });
210
+ }
211
+ /**
212
+ * Broadcasts a signed transaction to the network and monitors its inclusion in a block,
213
+ * with support for retrying on failure and graceful timeout handling.
214
+ *
215
+ * ## Optimizations over base implementation:
216
+ * - Implements a retry policy (`maxRetries`, default: 3) to handle transient broadcast errors.
217
+ * - Prevents double spend by reusing the exact same signed transaction (immutable `Uint8Array`).
218
+ * - Tracks and returns the last known transaction hash (`txId`), even in the case of timeout or failure.
219
+ * - Throws a `TimeoutError` if the transaction is not found within `timeoutMs`, attaching the `txHash` if known.
220
+ * - Polling frequency and timeout are customizable via `pollIntervalMs` and `timeoutMs` parameters.
221
+ *
222
+ * @param tx - The signed transaction bytes to broadcast.
223
+ * @param timeoutMs - Maximum duration (in milliseconds) to wait for block inclusion. Defaults to 60,000 ms.
224
+ * @param pollIntervalMs - Polling interval (in milliseconds) when checking for transaction inclusion. Defaults to 3,000 ms.
225
+ * @param maxRetries - Maximum number of times to retry `broadcastTxSync` on failure. Defaults to 3.
226
+ *
227
+ * @returns A `Promise` that resolves to `DeliverTxResponse` upon successful inclusion in a block.
228
+ * @throws `BroadcastTxError` if the transaction is rejected by the node during CheckTx.
229
+ * @throws `TimeoutError` if the transaction is not found on-chain within the timeout window. Includes `txHash` if available.
230
+ */
231
+ async broadcastTx(tx, timeoutMs = 60_000, pollIntervalMs = 3_000, maxRetries = 3) {
232
+ // define polling callback
233
+ const pollForTx = async (txId, startTime) => {
234
+ // define immutable timeout
235
+ const timedOut = Date.now() - startTime > timeoutMs;
236
+ // check if timed out
237
+ if (timedOut) {
238
+ // if so, throw timeout error with txId (or transaction hash)
239
+ throw new TimeoutError(`Transaction with ID ${txId} was submitted but was not yet found on the chain. Waited ${timeoutMs / 1000} seconds.`, txId);
240
+ }
241
+ // otherwise, poll for tx
242
+ await sleep(pollIntervalMs);
243
+ // query for tx
244
+ const result = await this.getTx(txId);
245
+ // return result if found, otherwise poll again
246
+ return result
247
+ ? {
248
+ code: result.code,
249
+ height: result.height,
250
+ txIndex: result.txIndex,
251
+ events: result.events,
252
+ rawLog: result.rawLog,
253
+ transactionHash: txId,
254
+ gasUsed: result.gasUsed,
255
+ gasWanted: result.gasWanted,
256
+ }
257
+ : pollForTx(txId, startTime);
258
+ };
259
+ // define immutable array of errors
260
+ const errors = [];
261
+ // define last known transaction hash
262
+ let lastKnownTxHash;
263
+ // attempt to broadcast tx until maxRetries or tx is found
264
+ for (const attempt of Array.from({ length: maxRetries }, (_, i) => i + 1)) {
265
+ try {
266
+ // broadcast tx
267
+ const txId = await this.broadcastTxSync(tx);
268
+ // set last known transaction hash
269
+ lastKnownTxHash = txId;
270
+ // recompute start time
271
+ const startTime = Date.now();
272
+ // poll for tx
273
+ const result = await pollForTx(txId, startTime);
274
+ // if successful, return result
275
+ return result;
276
+ }
277
+ catch (error) {
278
+ // if error, push to errors array
279
+ errors.push(error);
280
+ // define last error
281
+ const lastError = error;
282
+ // if error is not a TimeoutError, throw it
283
+ if (lastError.name !== 'TimeoutError')
284
+ throw lastError;
285
+ // define whether final attempt
286
+ const isFinalAttempt = attempt === maxRetries;
287
+ // define enriched error, attaching last known transaction hash
288
+ const enrichedError = isFinalAttempt && lastKnownTxHash && lastError.name === 'TimeoutError'
289
+ ? new TimeoutError(`Transaction broadcast failed after ${maxRetries} attempts. Transaction hash: ${lastKnownTxHash}`, lastKnownTxHash)
290
+ : lastError;
291
+ // if final attempt and error does not have txHash, throw the last error
292
+ if (isFinalAttempt)
293
+ throw lastError;
294
+ // otherwise, brief backoff before retrying
295
+ await sleep(1000);
296
+ }
297
+ }
298
+ // should not reach here
299
+ throw new TimeoutError(`Broadcast failed unexpectedly. Last known transaction hash: ${lastKnownTxHash ?? 'unknown'}`, lastKnownTxHash || 'unknown');
300
+ }
301
+ /**
302
+ * Broadcasts a signed transaction to the network without monitoring it.
303
+ * Returns the transaction hash immediately after broadcast submission.
304
+ *
305
+ * If broadcasting is rejected by the node for some reason (e.g. because of a CheckTx failure),
306
+ * an error is thrown.
307
+ *
308
+ * If the transaction is broadcasted, a `string` containing the hash of the transaction is returned. The caller then
309
+ * usually needs to check if the transaction was included in a block and was successful.
310
+ *
311
+ * @param tx - Signed transaction bytes to broadcast
312
+ * @returns Promise resolving to the hash of the transaction
313
+ * @throws BroadcastTxError if the transaction is rejected during CheckTx
314
+ */
315
+ async broadcastTxSync(tx) {
316
+ const broadcasted = await this.forceGetTmClient().broadcastTxSync({ tx });
317
+ if (broadcasted.code) {
318
+ return Promise.reject(new BroadcastTxError(broadcasted.code, broadcasted.codespace ?? '', broadcasted.log));
319
+ }
320
+ const transactionId = toHex(broadcasted.hash).toUpperCase();
321
+ return transactionId;
322
+ }
323
+ /**
324
+ * Simulates transaction execution to estimate gas usage.
325
+ * Uses the configured endpoint to query the blockchain for gas estimation.
326
+ *
327
+ * @param signerAddress - Address of the account that would sign the transaction
328
+ * @param messages - Array of messages to simulate
329
+ * @param memo - Transaction memo string
330
+ * @returns Promise resolving to the estimated gas units required
331
+ * @throws Error if endpoint is not configured
332
+ */
333
+ async simulate(signerAddress, messages, memo) {
334
+ if (!this.endpoint) {
335
+ throw new Error('querier: endpoint is not set');
336
+ }
337
+ const querier = await CheqdQuerier.connect(this.endpoint);
338
+ const anyMsgs = messages.map((msg) => this.registry.encodeAsAny(msg));
339
+ const accountFromSigner = (await this._signer.getAccounts()).find((account) => account.address === signerAddress);
340
+ if (!accountFromSigner) {
341
+ throw new Error('Failed to retrieve account from signer');
342
+ }
343
+ const pubkey = encodeSecp256k1Pubkey(accountFromSigner.pubkey);
344
+ const { sequence } = await this.getSequence(signerAddress);
345
+ const gasLimit = this.endpoint.includes('localhost')
346
+ ? CheqdSigningStargateClient.maxGasLimit
347
+ : (await CheqdQuerier.getConsensusParameters(this.endpoint)).block.maxGas;
348
+ const { gasInfo } = await (await this.constructSimulateExtension(querier)).tx.simulate(anyMsgs, memo, pubkey, signerAddress, sequence, gasLimit);
349
+ assertDefined(gasInfo);
350
+ return Uint53.fromString(gasInfo.gasUsed.toString()).toNumber();
351
+ }
352
+ /**
353
+ * Constructs a transaction extension object for simulation and query operations.
354
+ * Provides methods for transaction simulation and retrieval.
355
+ *
356
+ * @param querier - CheqdQuerier instance for blockchain communication
357
+ * @returns Promise resolving to TxExtension with simulation and query capabilities
358
+ */
359
+ async constructSimulateExtension(querier) {
360
+ // setup rpc client
361
+ const rpc = createProtobufRpcClient(querier);
362
+ // setup query tx query service
363
+ const queryService = new ServiceClientImpl(rpc);
364
+ // setup + return tx extension
365
+ return {
366
+ tx: {
367
+ getTx: async (txId) => {
368
+ // construct request
369
+ const request = { hash: txId };
370
+ // query + return tx
371
+ return await queryService.GetTx(request);
372
+ },
373
+ simulate: async (messages, memo, signer, signerAddress, sequence, gasLimit) => {
374
+ // encode public key
375
+ const publicKey = encodePubkey(signer);
376
+ // construct max gas limit
377
+ const maxGasLimit = Int53.fromString(gasLimit.toString()).toNumber();
378
+ // construct unsigned tx
379
+ const tx = Tx.fromPartial({
380
+ body: TxBody.fromPartial({
381
+ messages: Array.from(messages),
382
+ memo,
383
+ }),
384
+ authInfo: AuthInfo.fromPartial({
385
+ fee: Fee.fromPartial({
386
+ amount: [],
387
+ gasLimit: maxGasLimit,
388
+ payer: signerAddress,
389
+ }),
390
+ signerInfos: [
391
+ {
392
+ publicKey,
393
+ modeInfo: {
394
+ single: { mode: SignMode.SIGN_MODE_DIRECT },
395
+ },
396
+ sequence: sequence,
397
+ },
398
+ ],
399
+ }),
400
+ signatures: [new Uint8Array()],
401
+ });
402
+ // construct request
403
+ const request = SimulateRequest.fromPartial({
404
+ txBytes: Tx.encode(tx).finish(),
405
+ });
406
+ // query + return simulation response
407
+ return await queryService.Simulate(request);
408
+ },
409
+ },
410
+ };
411
+ }
412
+ /**
413
+ * Batches multiple messages into optimal groups based on gas limits.
414
+ * Simulates each message individually and groups them to maximize throughput
415
+ * while staying within gas constraints.
416
+ *
417
+ * @param messages - Array of messages to batch
418
+ * @param signerAddress - Address of the account that will sign the transactions
419
+ * @param memo - Optional transaction memo
420
+ * @param maxGasLimit - Maximum gas limit per batch, defaults to 30,000,000
421
+ * @returns Promise resolving to MessageBatch with grouped messages and gas estimates
422
+ */
423
+ async batchMessages(messages, signerAddress, memo, maxGasLimit = 30000000 // default gas limit, use consensus params if available
424
+ ) {
425
+ // simulate
426
+ const gasEstimates = await Promise.all(messages.map(async (message) => this.simulate(signerAddress, [message], memo)));
427
+ // batch messages
428
+ const { batches, gasPerBatch, currentBatch, currentBatchGas } = gasEstimates.reduce((acc, gasUsed, index) => {
429
+ // finalise current batch, if limit is surpassed
430
+ if (acc.currentBatchGas + gasUsed > maxGasLimit) {
431
+ return {
432
+ batches: [...acc.batches, acc.currentBatch],
433
+ gasPerBatch: [...acc.gasPerBatch, acc.currentBatchGas],
434
+ currentBatch: [messages[index]],
435
+ currentBatchGas: gasUsed,
436
+ };
437
+ }
438
+ // otherwise, add to current batch
439
+ return {
440
+ batches: acc.batches,
441
+ gasPerBatch: acc.gasPerBatch,
442
+ currentBatch: [...acc.currentBatch, messages[index]],
443
+ currentBatchGas: acc.currentBatchGas + gasUsed,
444
+ };
445
+ }, {
446
+ batches: [],
447
+ gasPerBatch: [],
448
+ currentBatch: [],
449
+ currentBatchGas: 0,
450
+ });
451
+ // push final batch to batches, if not empty + return
452
+ return currentBatch.length > 0
453
+ ? {
454
+ batches: [...batches, currentBatch],
455
+ gas: [...gasPerBatch, currentBatchGas],
456
+ }
457
+ : {
458
+ batches,
459
+ gas: gasPerBatch,
460
+ };
461
+ }
462
+ /**
463
+ * Validates and initializes DID signers for the provided verification methods.
464
+ * Ensures that all verification method types are supported and assigns appropriate signers.
465
+ *
466
+ * @param verificationMethods - Array of verification methods to validate
467
+ * @returns Promise resolving to the configured signer algorithm map
468
+ * @throws Error if no verification methods are provided or unsupported types are found
469
+ */
470
+ async checkDidSigners(verificationMethods = []) {
471
+ if (verificationMethods.length === 0) {
472
+ throw new Error('No verification methods provided');
473
+ }
474
+ verificationMethods.forEach((verificationMethod) => {
475
+ if (!Object.values(VerificationMethods).includes(verificationMethod.verificationMethodType ?? '')) {
476
+ throw new Error(`Unsupported verification method type: ${verificationMethod.verificationMethodType}`);
477
+ }
478
+ if (!this.didSigners[verificationMethod.verificationMethodType ?? '']) {
479
+ this.didSigners[verificationMethod.verificationMethodType ?? ''] = EdDSASigner;
480
+ }
481
+ });
482
+ return this.didSigners;
483
+ }
484
+ /**
485
+ * Retrieves the appropriate DID signer for a specific verification method.
486
+ * Looks up the verification method by ID and returns the corresponding signer function.
487
+ *
488
+ * @param verificationMethodId - ID of the verification method to get signer for
489
+ * @param verificationMethods - Array of available verification methods
490
+ * @returns Promise resolving to a signer function that takes a secret key
491
+ * @throws Error if the verification method is not found
492
+ */
493
+ async getDidSigner(verificationMethodId, verificationMethods) {
494
+ await this.checkDidSigners(verificationMethods);
495
+ const verificationMethod = verificationMethods.find((method) => method.id === verificationMethodId)?.verificationMethodType;
496
+ if (!verificationMethod) {
497
+ throw new Error(`Verification method for ${verificationMethodId} not found`);
498
+ }
499
+ return this.didSigners[verificationMethod];
500
+ }
501
+ /**
502
+ * Signs a CreateDidDoc transaction payload using the provided signing inputs.
503
+ * Validates verification methods and creates signatures for each signing input.
504
+ *
505
+ * @param signInputs - Array of signing inputs containing verification method IDs and private keys
506
+ * @param payload - CreateDidDoc payload to sign
507
+ * @returns Promise resolving to array of SignInfo objects with signatures
508
+ */
509
+ async signCreateDidDocTx(signInputs, payload) {
510
+ await this.checkDidSigners(payload?.verificationMethod);
511
+ const signBytes = MsgCreateDidDocPayload.encode(payload).finish();
512
+ const signInfos = await Promise.all(signInputs.map(async (signInput) => {
513
+ return {
514
+ verificationMethodId: signInput.verificationMethodId,
515
+ signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes))),
516
+ };
517
+ }));
518
+ return signInfos;
519
+ }
520
+ /**
521
+ * Signs an UpdateDidDoc transaction payload using the provided signing inputs.
522
+ * Handles complex verification method resolution including external controllers
523
+ * and previous DID document verification methods.
524
+ *
525
+ * @param signInputs - Array of signing inputs containing verification method IDs and private keys
526
+ * @param payload - UpdateDidDoc payload to sign
527
+ * @param externalControllers - Optional external controller DID documents
528
+ * @param previousDidDocument - Optional previous version of the DID document
529
+ * @returns Promise resolving to array of SignInfo objects with signatures
530
+ */
531
+ async signUpdateDidDocTx(signInputs, payload, externalControllers, previousDidDocument) {
532
+ await this.checkDidSigners(payload?.verificationMethod);
533
+ const signBytes = MsgUpdateDidDocPayload.encode(payload).finish();
534
+ const signInfos = await Promise.all(signInputs.map(async (signInput) => {
535
+ return {
536
+ verificationMethodId: signInput.verificationMethodId,
537
+ signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, payload.verificationMethod
538
+ .concat(externalControllers
539
+ ?.flatMap((controller) => controller.verificationMethod)
540
+ .map((vm) => {
541
+ return {
542
+ id: vm.id,
543
+ verificationMethodType: vm.type,
544
+ controller: vm.controller,
545
+ verificationMaterial: '<ignored>',
546
+ };
547
+ }) ?? [])
548
+ .concat(previousDidDocument?.verificationMethod?.map((vm) => {
549
+ return {
550
+ id: vm.id,
551
+ verificationMethodType: vm.type,
552
+ controller: vm.controller,
553
+ verificationMaterial: '<ignored>',
554
+ };
555
+ }) ?? [])))(hexToBytes(signInput.privateKeyHex))(signBytes))),
556
+ };
557
+ }));
558
+ return signInfos;
559
+ }
560
+ /**
561
+ * Signs a DeactivateDidDoc transaction payload using the provided signing inputs.
562
+ * Validates verification methods and creates signatures for DID deactivation.
563
+ *
564
+ * @param signInputs - Array of signing inputs containing verification method IDs and private keys
565
+ * @param payload - DeactivateDidDoc payload to sign
566
+ * @param verificationMethod - Array of verification methods for signature validation
567
+ * @returns Promise resolving to array of SignInfo objects with signatures
568
+ */
569
+ async signDeactivateDidDocTx(signInputs, payload, verificationMethod) {
570
+ await this.checkDidSigners(verificationMethod);
571
+ const signBytes = MsgDeactivateDidDocPayload.encode(payload).finish();
572
+ const signInfos = await Promise.all(signInputs.map(async (signInput) => {
573
+ return {
574
+ verificationMethodId: signInput.verificationMethodId,
575
+ signature: base64ToBytes((await (await this.getDidSigner(signInput.verificationMethodId, verificationMethod))(hexToBytes(signInput.privateKeyHex))(signBytes))),
576
+ };
577
+ }));
578
+ return signInfos;
579
+ }
580
+ /**
581
+ * Static method for signing identity transactions with multiple key types.
582
+ * Supports Ed25519, Secp256k1, and P256 signature algorithms.
583
+ *
584
+ * @param signBytes - Raw bytes to sign
585
+ * @param signInputs - Array of signing inputs with key types and private keys
586
+ * @returns Promise resolving to array of SignInfo objects with signatures
587
+ * @throws Error if key type is undefined or unsupported
588
+ */
589
+ static async signIdentityTx(signBytes, signInputs) {
590
+ let signInfos = [];
591
+ for (let signInput of signInputs) {
592
+ if (typeof signInput.keyType === undefined) {
593
+ throw new Error('Key type is not defined');
594
+ }
595
+ let signature;
596
+ switch (signInput.keyType) {
597
+ case 'Ed25519':
598
+ signature = (await EdDSASigner(hexToBytes(signInput.privateKeyHex))(signBytes));
599
+ break;
600
+ case 'Secp256k1':
601
+ signature = (await ES256KSigner(hexToBytes(signInput.privateKeyHex))(signBytes));
602
+ break;
603
+ case 'P256':
604
+ signature = (await ES256Signer(hexToBytes(signInput.privateKeyHex))(signBytes));
605
+ break;
606
+ default:
607
+ throw new Error(`Unsupported signature type: ${signInput.keyType}`);
608
+ }
609
+ signInfos.push({
610
+ verificationMethodId: signInput.verificationMethodId,
611
+ signature: base64ToBytes(signature),
612
+ });
613
+ }
614
+ return signInfos;
615
+ }
616
+ }
617
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../cjs/src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,qBAAqB,EAErB,YAAY,EAEZ,WAAW,GACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAIN,qBAAqB,EAErB,YAAY,EAEZ,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EACN,sBAAsB,EAEtB,sBAAsB,EACtB,0BAA0B,GAG1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAON,mBAAmB,GACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAU,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAU,M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