@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
package/build/querier.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { QueryClient } from '@cosmjs/stargate';
|
|
2
|
+
import { connectComet } from '@cosmjs/tendermint-rpc';
|
|
3
|
+
/**
|
|
4
|
+
* Extended QueryClient specifically designed for the Cheqd blockchain network.
|
|
5
|
+
* Provides enhanced querying capabilities with support for custom extensions
|
|
6
|
+
* and consensus parameter retrieval.
|
|
7
|
+
*/
|
|
8
|
+
export class CheqdQuerier extends QueryClient {
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a new CheqdQuerier instance with the provided Comet client.
|
|
11
|
+
*
|
|
12
|
+
* @param cometClient - Comet client for blockchain communication
|
|
13
|
+
*/
|
|
14
|
+
constructor(cometClient) {
|
|
15
|
+
super(cometClient);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the consensus parameters from the blockchain network.
|
|
19
|
+
* This method creates a temporary connection to fetch the latest block results
|
|
20
|
+
* and extract consensus update information.
|
|
21
|
+
*
|
|
22
|
+
* @param url - RPC URL of the blockchain node
|
|
23
|
+
* @returns Promise resolving to consensus parameters or undefined if not available
|
|
24
|
+
*/
|
|
25
|
+
static async getConsensusParameters(url) {
|
|
26
|
+
// connect to comet rpc
|
|
27
|
+
const cometClient = await connectComet(url);
|
|
28
|
+
// get block results
|
|
29
|
+
const result = await cometClient.blockResults();
|
|
30
|
+
// disconnect comet client
|
|
31
|
+
cometClient.disconnect();
|
|
32
|
+
// return consensus parameters
|
|
33
|
+
return result.consensusUpdates;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new CheqdQuerier instance by establishing a connection to the specified RPC URL.
|
|
37
|
+
* This is the primary method for creating a querier instance for blockchain communication.
|
|
38
|
+
*
|
|
39
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
40
|
+
* @returns Promise resolving to a connected CheqdQuerier instance
|
|
41
|
+
*/
|
|
42
|
+
static async connect(url) {
|
|
43
|
+
const cometClient = await connectComet(url);
|
|
44
|
+
return new CheqdQuerier(cometClient);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates a CheqdQuerier instance from an existing Comet client.
|
|
48
|
+
* Useful when you already have an established client connection.
|
|
49
|
+
*
|
|
50
|
+
* @param client - Existing Comet client
|
|
51
|
+
* @returns Promise resolving to a CheqdQuerier instance using the provided client
|
|
52
|
+
*/
|
|
53
|
+
static async fromClient(client) {
|
|
54
|
+
return new CheqdQuerier(client);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a CheqdQuerier instance with a single query extension.
|
|
58
|
+
* Extensions provide specialized query capabilities for specific blockchain modules.
|
|
59
|
+
*
|
|
60
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
61
|
+
* @param extension - Query extension setup to add specialized query functionality
|
|
62
|
+
* @returns Promise resolving to a CheqdQuerier instance with the specified extension
|
|
63
|
+
*/
|
|
64
|
+
static async connectWithExtension(url, extension) {
|
|
65
|
+
const cometClient = await connectComet(url);
|
|
66
|
+
return CheqdQuerier.withExtensions(cometClient, extension);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a CheqdQuerier instance with multiple query extensions.
|
|
70
|
+
* This method supports adding multiple specialized query capabilities for different
|
|
71
|
+
* blockchain modules in a single operation. For single extensions, it delegates
|
|
72
|
+
* to connectWithExtension for efficiency.
|
|
73
|
+
*
|
|
74
|
+
* @param url - RPC URL of the blockchain node to connect to
|
|
75
|
+
* @param extensions - Variable number of query extension setups to add functionality
|
|
76
|
+
* @returns Promise resolving to a CheqdQuerier instance with all specified extensions
|
|
77
|
+
*/
|
|
78
|
+
static async connectWithExtensions(url, ...extensions) {
|
|
79
|
+
if (extensions.length === 1)
|
|
80
|
+
return CheqdQuerier.connectWithExtension(url, extensions[0]);
|
|
81
|
+
const cometClient = await connectComet(url);
|
|
82
|
+
const tupleLike = extensions;
|
|
83
|
+
return CheqdQuerier.withExtensions(cometClient, ...tupleLike);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=querier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"querier.js","sourceRoot":"","sources":["../src/querier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAe,YAAY,EAAmB,MAAM,wBAAwB,CAAC;AAGpF;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC5C;;;;OAIG;IACH,YAAY,WAAwB;QACnC,KAAK,CAAC,WAAW,CAAC,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,GAAW;QAC9C,uBAAuB;QACvB,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAE5C,oBAAoB;QACpB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,YAAY,EAAE,CAAC;QAEhD,0BAA0B;QAC1B,WAAW,CAAC,UAAU,EAAE,CAAC;QAEzB,8BAA8B;QAC9B,OAAO,MAAM,CAAC,gBAAgB,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAW;QAC/B,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAmB;QAC1C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAChC,GAAW,EACX,SAA+C;QAE/C,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,YAAY,CAAC,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,qBAAqB,CACjC,GAAW,EACX,GAAG,UAAkD;QAErD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1F,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QAC5C,MAAM,SAAS,GAAG,UAKjB,CAAC;QACF,OAAO,YAAY,CAAC,cAAc,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,CAAC;IAC/D,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Registry, GeneratedType } from '@cosmjs/proto-signing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a default Cheqd registry with optional custom types.
|
|
4
|
+
* The registry is used for encoding and decoding protobuf messages in blockchain transactions.
|
|
5
|
+
* It includes all default Stargate types and any additional custom types provided.
|
|
6
|
+
*
|
|
7
|
+
* @param customTypes - Optional iterable of custom type mappings to add to the registry.
|
|
8
|
+
* Each entry should be a tuple of [typeUrl, GeneratedType].
|
|
9
|
+
* @returns A configured Registry instance with default and custom types
|
|
10
|
+
*/
|
|
11
|
+
export declare function createDefaultCheqdRegistry(customTypes?: Iterable<[string, GeneratedType]>): Registry;
|
|
12
|
+
/**
|
|
13
|
+
* Pre-configured Cheqd registry instance with default Stargate types.
|
|
14
|
+
* This is a ready-to-use registry for basic blockchain operations that don't require
|
|
15
|
+
* custom message types. For applications needing custom types, use createDefaultCheqdRegistry instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CheqdRegistry: Registry;
|
|
18
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAIhE;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,GAAG,QAAQ,CAGpG;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,UAAqC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Registry } from '@cosmjs/proto-signing';
|
|
2
|
+
import { defaultRegistryTypes } from '@cosmjs/stargate';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a default Cheqd registry with optional custom types.
|
|
5
|
+
* The registry is used for encoding and decoding protobuf messages in blockchain transactions.
|
|
6
|
+
* It includes all default Stargate types and any additional custom types provided.
|
|
7
|
+
*
|
|
8
|
+
* @param customTypes - Optional iterable of custom type mappings to add to the registry.
|
|
9
|
+
* Each entry should be a tuple of [typeUrl, GeneratedType].
|
|
10
|
+
* @returns A configured Registry instance with default and custom types
|
|
11
|
+
*/
|
|
12
|
+
export function createDefaultCheqdRegistry(customTypes) {
|
|
13
|
+
if (!customTypes)
|
|
14
|
+
customTypes = [];
|
|
15
|
+
return new Registry([...defaultRegistryTypes, ...customTypes]);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Pre-configured Cheqd registry instance with default Stargate types.
|
|
19
|
+
* This is a ready-to-use registry for basic blockchain operations that don't require
|
|
20
|
+
* custom message types. For applications needing custom types, use createDefaultCheqdRegistry instead.
|
|
21
|
+
*/
|
|
22
|
+
export const CheqdRegistry = new Registry(defaultRegistryTypes);
|
|
23
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA+C;IACzF,IAAI,CAAC,WAAW;QAAE,WAAW,GAAG,EAAE,CAAC;IACnC,OAAO,IAAI,QAAQ,CAAC,CAAC,GAAG,oBAAoB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { EncodeObject, OfflineSigner } from '@cosmjs/proto-signing';
|
|
2
|
+
import { DeliverTxResponse, GasPrice, HttpEndpoint, SigningStargateClient, SigningStargateClientOptions, SignerData } from '@cosmjs/stargate';
|
|
3
|
+
import { CometClient } from '@cosmjs/tendermint-rpc';
|
|
4
|
+
import { MsgCreateDidDocPayload, SignInfo, MsgUpdateDidDocPayload, MsgDeactivateDidDocPayload, VerificationMethod } from '@cheqd/ts-proto/cheqd/did/v2/index.js';
|
|
5
|
+
import { DIDDocument, DidStdFee, ISignInputs, MessageBatch, TSignerAlgo } from './types.js';
|
|
6
|
+
import { Signer } from 'did-jwt';
|
|
7
|
+
import { SignerInfo, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
8
|
+
import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing.js';
|
|
9
|
+
import { Any } from 'cosmjs-types/google/protobuf/any.js';
|
|
10
|
+
import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin.js';
|
|
11
|
+
import { CheqdQuerier } from './querier.js';
|
|
12
|
+
import { TxExtension } from './types';
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the transaction fee for DID operations using gas limit and gas price.
|
|
15
|
+
*
|
|
16
|
+
* @param gasLimit - Maximum amount of gas units that can be consumed by the transaction
|
|
17
|
+
* @param gasPrice - Price per gas unit, either as a string or GasPrice object
|
|
18
|
+
* @returns DidStdFee object containing the calculated fee structure
|
|
19
|
+
*/
|
|
20
|
+
export declare function calculateDidFee(gasLimit: number, gasPrice: string | GasPrice): DidStdFee;
|
|
21
|
+
/**
|
|
22
|
+
* Creates SignerInfo objects for transaction authentication from signer data.
|
|
23
|
+
* Each signer info contains the public key, sequence number, and signing mode.
|
|
24
|
+
*
|
|
25
|
+
* @param signers - Array of signer objects containing public keys and sequence numbers
|
|
26
|
+
* @param signMode - Signing mode to use (e.g., SIGN_MODE_DIRECT)
|
|
27
|
+
* @returns Array of SignerInfo objects for transaction authentication
|
|
28
|
+
*/
|
|
29
|
+
export declare function makeSignerInfos(signers: ReadonlyArray<{
|
|
30
|
+
readonly pubkey: Any;
|
|
31
|
+
readonly sequence: number;
|
|
32
|
+
}>, signMode: SignMode): SignerInfo[];
|
|
33
|
+
/**
|
|
34
|
+
* Creates encoded AuthInfo bytes for DID transactions with fee payer support.
|
|
35
|
+
* The AuthInfo contains signer information, fee details, and gas limit.
|
|
36
|
+
*
|
|
37
|
+
* @param signers - Array of signer objects with public keys and sequence numbers
|
|
38
|
+
* @param feeAmount - Array of coins representing the transaction fee
|
|
39
|
+
* @param gasLimit - Maximum gas units that can be consumed
|
|
40
|
+
* @param feePayer - Address of the account paying the transaction fees
|
|
41
|
+
* @param signMode - Signing mode to use, defaults to SIGN_MODE_DIRECT
|
|
42
|
+
* @returns Encoded AuthInfo as Uint8Array for transaction construction
|
|
43
|
+
*/
|
|
44
|
+
export declare function makeDidAuthInfoBytes(signers: ReadonlyArray<{
|
|
45
|
+
readonly pubkey: Any;
|
|
46
|
+
readonly sequence: number;
|
|
47
|
+
}>, feeAmount: readonly Coin[], gasLimit: bigint, feePayer: string, signMode?: SignMode): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Extended SigningStargateClient specifically designed for Cheqd blockchain operations.
|
|
50
|
+
* Provides enhanced transaction signing, broadcasting, and DID-specific functionality
|
|
51
|
+
* with support for custom fee payers and advanced retry mechanisms.
|
|
52
|
+
*/
|
|
53
|
+
export declare class CheqdSigningStargateClient extends SigningStargateClient {
|
|
54
|
+
/** Map of DID signing algorithms for different verification method types */
|
|
55
|
+
private didSigners;
|
|
56
|
+
/** Gas price configuration for transaction fee calculation */
|
|
57
|
+
private readonly _gasPrice;
|
|
58
|
+
/** Offline signer instance for transaction signing */
|
|
59
|
+
private readonly _signer;
|
|
60
|
+
/** RPC endpoint URL for blockchain communication */
|
|
61
|
+
private readonly endpoint?;
|
|
62
|
+
/** Maximum gas limit allowed for transactions */
|
|
63
|
+
static readonly maxGasLimit: number;
|
|
64
|
+
/**
|
|
65
|
+
* Creates a new CheqdSigningStargateClient by establishing a connection to the specified endpoint.
|
|
66
|
+
* This is the primary factory method for creating a signing client instance.
|
|
67
|
+
*
|
|
68
|
+
* @param endpoint - RPC endpoint URL or HttpEndpoint object to connect to
|
|
69
|
+
* @param signer - Offline signer for transaction signing
|
|
70
|
+
* @param options - Additional client configuration options including registry and gas price
|
|
71
|
+
* @returns Promise resolving to a connected CheqdSigningStargateClient instance
|
|
72
|
+
*/
|
|
73
|
+
static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineSigner, options?: (SigningStargateClientOptions & {
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
}) | undefined): Promise<CheqdSigningStargateClient>;
|
|
76
|
+
/**
|
|
77
|
+
* Constructs a new CheqdSigningStargateClient instance with the provided Comet client and signer.
|
|
78
|
+
*
|
|
79
|
+
* @param cometClient - Comet client for blockchain communication
|
|
80
|
+
* @param signer - Offline signer for transaction signing
|
|
81
|
+
* @param options - Additional configuration options including registry, gas price, and endpoint
|
|
82
|
+
*/
|
|
83
|
+
constructor(cometClient: CometClient | undefined, signer: OfflineSigner, options?: SigningStargateClientOptions & {
|
|
84
|
+
endpoint?: string;
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Signs and broadcasts a transaction to the blockchain network.
|
|
88
|
+
* Supports automatic fee calculation and custom fee payer functionality.
|
|
89
|
+
*
|
|
90
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
91
|
+
* @param messages - Array of messages to include in the transaction
|
|
92
|
+
* @param fee - Fee configuration: 'auto' for automatic calculation, number for multiplier, or DidStdFee object
|
|
93
|
+
* @param memo - Optional transaction memo string
|
|
94
|
+
* @returns Promise resolving to DeliverTxResponse with transaction results
|
|
95
|
+
* @throws Error if gas price is not set when using automatic fee calculation
|
|
96
|
+
*/
|
|
97
|
+
signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee | 'auto' | number, memo?: string): Promise<DeliverTxResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Signs a transaction without broadcasting it to the network.
|
|
100
|
+
* Creates a signed transaction that can be broadcast later.
|
|
101
|
+
*
|
|
102
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
103
|
+
* @param messages - Array of messages to include in the transaction
|
|
104
|
+
* @param fee - Fee configuration for the transaction
|
|
105
|
+
* @param memo - Transaction memo string
|
|
106
|
+
* @param explicitSignerData - Optional explicit signer data to avoid querying the chain
|
|
107
|
+
* @returns Promise resolving to TxRaw containing the signed transaction
|
|
108
|
+
*/
|
|
109
|
+
sign(signerAddress: string, messages: readonly EncodeObject[], fee: DidStdFee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
|
|
110
|
+
/**
|
|
111
|
+
* Internal method for direct signing of transactions using SIGN_MODE_DIRECT.
|
|
112
|
+
* Handles the low-level transaction construction and signing process.
|
|
113
|
+
*
|
|
114
|
+
* @param signerAddress - Address of the account signing the transaction
|
|
115
|
+
* @param messages - Array of messages to include in the transaction
|
|
116
|
+
* @param fee - Fee configuration for the transaction
|
|
117
|
+
* @param memo - Transaction memo string
|
|
118
|
+
* @param signerData - Account data including number, sequence, and chain ID
|
|
119
|
+
* @returns Promise resolving to TxRaw containing the signed transaction
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
private _signDirect;
|
|
123
|
+
/**
|
|
124
|
+
* Broadcasts a signed transaction to the network and monitors its inclusion in a block,
|
|
125
|
+
* with support for retrying on failure and graceful timeout handling.
|
|
126
|
+
*
|
|
127
|
+
* ## Optimizations over base implementation:
|
|
128
|
+
* - Implements a retry policy (`maxRetries`, default: 3) to handle transient broadcast errors.
|
|
129
|
+
* - Prevents double spend by reusing the exact same signed transaction (immutable `Uint8Array`).
|
|
130
|
+
* - Tracks and returns the last known transaction hash (`txId`), even in the case of timeout or failure.
|
|
131
|
+
* - Throws a `TimeoutError` if the transaction is not found within `timeoutMs`, attaching the `txHash` if known.
|
|
132
|
+
* - Polling frequency and timeout are customizable via `pollIntervalMs` and `timeoutMs` parameters.
|
|
133
|
+
*
|
|
134
|
+
* @param tx - The signed transaction bytes to broadcast.
|
|
135
|
+
* @param timeoutMs - Maximum duration (in milliseconds) to wait for block inclusion. Defaults to 60,000 ms.
|
|
136
|
+
* @param pollIntervalMs - Polling interval (in milliseconds) when checking for transaction inclusion. Defaults to 3,000 ms.
|
|
137
|
+
* @param maxRetries - Maximum number of times to retry `broadcastTxSync` on failure. Defaults to 3.
|
|
138
|
+
*
|
|
139
|
+
* @returns A `Promise` that resolves to `DeliverTxResponse` upon successful inclusion in a block.
|
|
140
|
+
* @throws `BroadcastTxError` if the transaction is rejected by the node during CheckTx.
|
|
141
|
+
* @throws `TimeoutError` if the transaction is not found on-chain within the timeout window. Includes `txHash` if available.
|
|
142
|
+
*/
|
|
143
|
+
broadcastTx(tx: Uint8Array, timeoutMs?: number, pollIntervalMs?: number, maxRetries?: number): Promise<DeliverTxResponse>;
|
|
144
|
+
simulate(signerAddress: string, messages: readonly EncodeObject[], memo: string | undefined): Promise<number>;
|
|
145
|
+
constructSimulateExtension(querier: CheqdQuerier): Promise<TxExtension>;
|
|
146
|
+
/**
|
|
147
|
+
* Batches multiple messages into optimal groups based on gas limits.
|
|
148
|
+
* Simulates each message individually and groups them to maximize throughput
|
|
149
|
+
* while staying within gas constraints.
|
|
150
|
+
*
|
|
151
|
+
* @param messages - Array of messages to batch
|
|
152
|
+
* @param signerAddress - Address of the account that will sign the transactions
|
|
153
|
+
* @param memo - Optional transaction memo
|
|
154
|
+
* @param maxGasLimit - Maximum gas limit per batch, defaults to 30,000,000
|
|
155
|
+
* @returns Promise resolving to MessageBatch with grouped messages and gas estimates
|
|
156
|
+
*/
|
|
157
|
+
batchMessages(messages: readonly EncodeObject[], signerAddress: string, memo?: string, maxGasLimit?: number): Promise<MessageBatch>;
|
|
158
|
+
/**
|
|
159
|
+
* Validates and initializes DID signers for the provided verification methods.
|
|
160
|
+
* Ensures that all verification method types are supported and assigns appropriate signers.
|
|
161
|
+
*
|
|
162
|
+
* @param verificationMethods - Array of verification methods to validate
|
|
163
|
+
* @returns Promise resolving to the configured signer algorithm map
|
|
164
|
+
* @throws Error if no verification methods are provided or unsupported types are found
|
|
165
|
+
*/
|
|
166
|
+
checkDidSigners(verificationMethods?: Partial<VerificationMethod>[]): Promise<TSignerAlgo>;
|
|
167
|
+
/**
|
|
168
|
+
* Retrieves the appropriate DID signer for a specific verification method.
|
|
169
|
+
* Looks up the verification method by ID and returns the corresponding signer function.
|
|
170
|
+
*
|
|
171
|
+
* @param verificationMethodId - ID of the verification method to get signer for
|
|
172
|
+
* @param verificationMethods - Array of available verification methods
|
|
173
|
+
* @returns Promise resolving to a signer function that takes a secret key
|
|
174
|
+
* @throws Error if the verification method is not found
|
|
175
|
+
*/
|
|
176
|
+
getDidSigner(verificationMethodId: string, verificationMethods: Partial<VerificationMethod>[]): Promise<(secretKey: Uint8Array) => Signer>;
|
|
177
|
+
/**
|
|
178
|
+
* Signs a CreateDidDoc transaction payload using the provided signing inputs.
|
|
179
|
+
* Validates verification methods and creates signatures for each signing input.
|
|
180
|
+
*
|
|
181
|
+
* @param signInputs - Array of signing inputs containing verification method IDs and private keys
|
|
182
|
+
* @param payload - CreateDidDoc payload to sign
|
|
183
|
+
* @returns Promise resolving to array of SignInfo objects with signatures
|
|
184
|
+
*/
|
|
185
|
+
signCreateDidDocTx(signInputs: ISignInputs[], payload: MsgCreateDidDocPayload): Promise<SignInfo[]>;
|
|
186
|
+
signUpdateDidDocTx(signInputs: ISignInputs[], payload: MsgUpdateDidDocPayload, externalControllers?: DIDDocument[], previousDidDocument?: DIDDocument): Promise<SignInfo[]>;
|
|
187
|
+
signDeactivateDidDocTx(signInputs: ISignInputs[], payload: MsgDeactivateDidDocPayload, verificationMethod: VerificationMethod[]): Promise<SignInfo[]>;
|
|
188
|
+
static signIdentityTx(signBytes: Uint8Array, signInputs: ISignInputs[]): Promise<SignInfo[]>;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAEZ,aAAa,EAIb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,4BAA4B,EAE5B,UAAU,EAGV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAgB,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EACN,sBAAsB,EAC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