@etherkit/viem-tx-tracker 0.0.3 → 0.0.5
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/dist/TrackedWalletClient.d.ts +74 -7
- package/dist/TrackedWalletClient.d.ts.map +1 -1
- package/dist/TrackedWalletClient.js +452 -224
- package/dist/TrackedWalletClient.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +187 -53
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/TrackedWalletClient.ts +943 -366
- package/src/index.ts +5 -1
- package/src/types.ts +331 -53
|
@@ -1,17 +1,84 @@
|
|
|
1
1
|
import { type Account, type Chain, type PublicClient, type Transport, type WalletClient } from 'viem';
|
|
2
|
-
import type { TrackedWalletClient } from './types.js';
|
|
2
|
+
import type { PopulatedMetadata, TrackedWalletClient, TrackedWalletClientAutoPopulate } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Infer transport type from WalletClient
|
|
5
|
+
*/
|
|
6
|
+
type InferTransport<T> = T extends WalletClient<infer TTransport, any, any> ? TTransport : Transport;
|
|
7
|
+
/**
|
|
8
|
+
* Infer chain type from WalletClient
|
|
9
|
+
*/
|
|
10
|
+
type InferChain<T> = T extends WalletClient<any, infer TChain, any> ? TChain : Chain | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Infer account type from WalletClient
|
|
13
|
+
*/
|
|
14
|
+
type InferAccount<T> = T extends WalletClient<any, any, infer TAccount> ? TAccount : Account | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Builder interface returned by createTrackedWalletClient for the curried API.
|
|
17
|
+
*/
|
|
18
|
+
export interface TrackedWalletClientBuilder<TMetadata> {
|
|
19
|
+
/**
|
|
20
|
+
* Create the tracked wallet client using the provided wallet and public clients.
|
|
21
|
+
*
|
|
22
|
+
* @param walletClient - The underlying viem WalletClient
|
|
23
|
+
* @param publicClient - A PublicClient for nonce fetching and tx verification
|
|
24
|
+
* @returns A TrackedWalletClient instance
|
|
25
|
+
*/
|
|
26
|
+
using<TClient extends WalletClient>(walletClient: TClient, publicClient: PublicClient): TrackedWalletClient<TMetadata, InferTransport<TClient>, InferChain<TClient>, InferAccount<TClient>>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Builder interface returned by createTrackedWalletClient with populateMetadata: true.
|
|
30
|
+
* This builder returns a TrackedWalletClientAutoPopulate that auto-populates operation, functionName and args.
|
|
31
|
+
* TMetadata must be a type where FunctionCallMetadata is assignable to it.
|
|
32
|
+
*/
|
|
33
|
+
export interface TrackedWalletClientAutoPopulateBuilder<TMetadata> {
|
|
34
|
+
/**
|
|
35
|
+
* Create the tracked wallet client using the provided wallet and public clients.
|
|
36
|
+
* writeContract and writeContractSync will automatically populate operation, functionName and args.
|
|
37
|
+
*
|
|
38
|
+
* @param walletClient - The underlying viem WalletClient
|
|
39
|
+
* @param publicClient - A PublicClient for nonce fetching and tx verification
|
|
40
|
+
* @returns A TrackedWalletClientAutoPopulate instance
|
|
41
|
+
*/
|
|
42
|
+
using<TClient extends WalletClient>(walletClient: TClient, publicClient: PublicClient): TrackedWalletClientAutoPopulate<TMetadata, InferTransport<TClient>, InferChain<TClient>, InferAccount<TClient>>;
|
|
43
|
+
}
|
|
3
44
|
/**
|
|
4
45
|
* Create a tracked wallet client that wraps a viem WalletClient.
|
|
5
46
|
*
|
|
6
47
|
* The tracked client provides the same API as WalletClient but with:
|
|
7
|
-
* -
|
|
48
|
+
* - Metadata field for transaction tracking (required unless TMetadata includes undefined)
|
|
8
49
|
* - Automatic nonce fetching (with 'pending' by default)
|
|
9
50
|
* - Post-broadcast transaction verification
|
|
10
|
-
* -
|
|
51
|
+
* - Event emission for tracking
|
|
52
|
+
*
|
|
53
|
+
* @typeParam TMetadata - The metadata type. Use `MyMeta | undefined` to make metadata optional.
|
|
54
|
+
* @returns A builder with a `.using()` method to provide the wallet and public clients
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Standard mode with required metadata
|
|
59
|
+
* const tracked = createTrackedWalletClient<{purpose: string}>()
|
|
60
|
+
* .using(walletClient, publicClient);
|
|
61
|
+
*
|
|
62
|
+
* // Standard mode with optional metadata
|
|
63
|
+
* const tracked = createTrackedWalletClient<{purpose: string} | undefined>()
|
|
64
|
+
* .using(walletClient, publicClient);
|
|
65
|
+
*
|
|
66
|
+
* // Auto-populate mode - functionName and args are auto-populated
|
|
67
|
+
* const tracked = createTrackedWalletClient({ populateMetadata: true })
|
|
68
|
+
* .using(walletClient, publicClient);
|
|
11
69
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
70
|
+
* // Auto-populate mode with extended metadata
|
|
71
|
+
* type MyMetadata = OperationMetadata & { purpose: string };
|
|
72
|
+
* const tracked = createTrackedWalletClient<MyMetadata>({ populateMetadata: true })
|
|
73
|
+
* .using(walletClient, publicClient);
|
|
74
|
+
* ```
|
|
15
75
|
*/
|
|
16
|
-
export declare function createTrackedWalletClient<
|
|
76
|
+
export declare function createTrackedWalletClient<TMetadata>(): TrackedWalletClientBuilder<TMetadata>;
|
|
77
|
+
export declare function createTrackedWalletClient(options: {
|
|
78
|
+
populateMetadata: true;
|
|
79
|
+
}): TrackedWalletClientAutoPopulateBuilder<PopulatedMetadata>;
|
|
80
|
+
export declare function createTrackedWalletClient<TMetadata>(options: {
|
|
81
|
+
populateMetadata: true;
|
|
82
|
+
}): TrackedWalletClientAutoPopulateBuilder<TMetadata>;
|
|
83
|
+
export {};
|
|
17
84
|
//# sourceMappingURL=TrackedWalletClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TrackedWalletClient.d.ts","sourceRoot":"","sources":["../src/TrackedWalletClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,OAAO,EAEZ,KAAK,KAAK,EAIV,K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