@dag-kit/kit 1.0.0 → 1.0.4-alpha.3
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/index.cjs +564 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -0
- package/dist/index.js +544 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -11
- package/src/clients/actions/contract.ts +1 -1
- package/src/clients/actions/example.ts +252 -252
- package/src/clients/actions/example2.ts +60 -57
- package/src/clients/actions/index.ts +145 -0
- package/src/clients/actions/main.ts +228 -39
- package/src/clients/actions/test.ts +210 -0
- package/src/clients/actions/testPaymasterService.ts +94 -0
- package/src/clients/chains.ts +6 -1
- package/src/clients/types.ts +3 -1
- package/src/exports/index.ts +8 -3
- package/src/exports/public-types.ts +6 -0
- package/src/index.ts +17 -0
- package/src/signers/PrivateKeySigner.ts +41 -0
- package/src/signers/PrivySigner.ts +93 -0
- package/src/signers/types.ts +45 -0
- package/src/version.ts +3 -0
- package/dist/esm/clients/actions/contract.js +0 -42
- package/dist/esm/clients/actions/example.js +0 -211
- package/dist/esm/clients/actions/example2.js +0 -47
- package/dist/esm/clients/actions/index.js +0 -1
- package/dist/esm/clients/actions/main.js +0 -266
- package/dist/esm/clients/actions/test.js +0 -1
- package/dist/esm/clients/chains.js +0 -14
- package/dist/esm/clients/types.js +0 -1
- package/dist/esm/exports/index.js +0 -1
- package/dist/esm/script.js +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { LocalAccount, WalletClient, Chain, Address, Hash } from 'viem';
|
|
3
|
+
export { Address, Chain, Hash } from 'viem';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Common interface for all signers
|
|
7
|
+
* This allows users to plug in different signing methods
|
|
8
|
+
*/
|
|
9
|
+
interface ISigner {
|
|
10
|
+
/**
|
|
11
|
+
* Get the viem Account object for signing
|
|
12
|
+
*/
|
|
13
|
+
getAccount(): LocalAccount | Promise<LocalAccount>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the wallet client for transactions
|
|
16
|
+
*/
|
|
17
|
+
getWalletClient(): WalletClient | Promise<WalletClient>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the signer's address
|
|
20
|
+
*/
|
|
21
|
+
getAddress(): `0x${string}` | Promise<`0x${string}`>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if signer is ready/connected
|
|
24
|
+
*/
|
|
25
|
+
isReady(): boolean | Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface DagAAConfig {
|
|
29
|
+
chain: Chain;
|
|
30
|
+
rpcUrl: string;
|
|
31
|
+
bundlerUrl: string;
|
|
32
|
+
factoryAddress: Address;
|
|
33
|
+
entryPointAddress?: Address;
|
|
34
|
+
paymasterUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
interface SmartAccountConfig {
|
|
37
|
+
signer: ISigner;
|
|
38
|
+
accountAddress?: Address;
|
|
39
|
+
}
|
|
40
|
+
interface SendUserOperationParams {
|
|
41
|
+
target: Address;
|
|
42
|
+
data?: `0x${string}`;
|
|
43
|
+
value?: bigint;
|
|
44
|
+
maxFeePerGas?: bigint;
|
|
45
|
+
maxPriorityFeePerGas?: bigint;
|
|
46
|
+
callGasLimit?: bigint;
|
|
47
|
+
verificationGasLimit?: bigint;
|
|
48
|
+
preVerificationGas?: bigint;
|
|
49
|
+
}
|
|
50
|
+
interface UserOperationReceipt {
|
|
51
|
+
userOpHash: Hash;
|
|
52
|
+
transactionHash?: Hash;
|
|
53
|
+
success: boolean;
|
|
54
|
+
blockNumber?: bigint;
|
|
55
|
+
blockHash?: Hash;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class DagAAClient {
|
|
59
|
+
private config;
|
|
60
|
+
private publicClient;
|
|
61
|
+
private walletClient;
|
|
62
|
+
private bundlerClient;
|
|
63
|
+
private smartAccount;
|
|
64
|
+
private paymasterClient;
|
|
65
|
+
private smartAccountClient;
|
|
66
|
+
constructor(config: DagAAConfig);
|
|
67
|
+
private createPaymasterClient;
|
|
68
|
+
connectSmartAccount(accountConfig: SmartAccountConfig): Promise<Address>;
|
|
69
|
+
getAddress(): Address;
|
|
70
|
+
getBalance(): Promise<bigint>;
|
|
71
|
+
isDeployed(): Promise<boolean>;
|
|
72
|
+
getNonce(): Promise<bigint>;
|
|
73
|
+
sendUserOperation(params: SendUserOperationParams): Promise<Hash>;
|
|
74
|
+
writeContract(params: {
|
|
75
|
+
address: Address;
|
|
76
|
+
abi: any[];
|
|
77
|
+
functionName: string;
|
|
78
|
+
args?: any[];
|
|
79
|
+
value?: bigint;
|
|
80
|
+
maxFeePerGas?: bigint;
|
|
81
|
+
maxPriorityFeePerGas?: bigint;
|
|
82
|
+
}): Promise<Hash>;
|
|
83
|
+
readContract(params: {
|
|
84
|
+
address: Address;
|
|
85
|
+
abi: any[];
|
|
86
|
+
functionName: string;
|
|
87
|
+
args?: any[];
|
|
88
|
+
}): Promise<any>;
|
|
89
|
+
waitForUserOperationReceipt(userOpHash: Hash, timeout?: number): Promise<UserOperationReceipt>;
|
|
90
|
+
fundAccount(amount: bigint, fromPrivateKey: `0x${string}`): Promise<Hash>;
|
|
91
|
+
sendBatchUserOperations(operations: SendUserOperationParams[]): Promise<Hash[]>;
|
|
92
|
+
}
|
|
93
|
+
declare function createDagAAClient(config: DagAAConfig): DagAAClient;
|
|
94
|
+
declare function parseDAG(amount: string): bigint;
|
|
95
|
+
|
|
96
|
+
declare const awakening: {
|
|
97
|
+
bundler_rpc: string;
|
|
98
|
+
chain_config: {
|
|
99
|
+
blockExplorers: {
|
|
100
|
+
readonly default: {
|
|
101
|
+
readonly name: "Explorer";
|
|
102
|
+
readonly url: "https://awakening.bdagscan.com/";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
contracts?: viem.Prettify<{
|
|
106
|
+
[key: string]: viem.ChainContract | {
|
|
107
|
+
[sourceId: number]: viem.ChainContract | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
} & {
|
|
110
|
+
ensRegistry?: viem.ChainContract | undefined;
|
|
111
|
+
ensUniversalResolver?: viem.ChainContract | undefined;
|
|
112
|
+
multicall3?: viem.ChainContract | undefined;
|
|
113
|
+
universalSignatureVerifier?: viem.ChainContract | undefined;
|
|
114
|
+
}> | undefined;
|
|
115
|
+
ensTlds?: readonly string[] | undefined;
|
|
116
|
+
id: 1043;
|
|
117
|
+
name: "Awakening Testnet";
|
|
118
|
+
nativeCurrency: {
|
|
119
|
+
readonly decimals: 18;
|
|
120
|
+
readonly name: "Dag";
|
|
121
|
+
readonly symbol: "DAG";
|
|
122
|
+
};
|
|
123
|
+
rpcUrls: {
|
|
124
|
+
readonly default: {
|
|
125
|
+
readonly http: readonly ["https://public-bdag.nownodes.io"];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
sourceId?: number | undefined;
|
|
129
|
+
testnet?: boolean | undefined;
|
|
130
|
+
custom?: Record<string, unknown>;
|
|
131
|
+
fees?: viem.ChainFees<undefined>;
|
|
132
|
+
formatters?: undefined;
|
|
133
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable>;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
declare const arbitrumSep: {
|
|
137
|
+
bundler_rpc: string;
|
|
138
|
+
chain_config: {
|
|
139
|
+
blockExplorers: {
|
|
140
|
+
readonly default: {
|
|
141
|
+
readonly name: "Arbiscan";
|
|
142
|
+
readonly url: "https://sepolia.arbiscan.io";
|
|
143
|
+
readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
contracts: {
|
|
147
|
+
readonly multicall3: {
|
|
148
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
149
|
+
readonly blockCreated: 81930;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
ensTlds?: readonly string[] | undefined;
|
|
153
|
+
id: 421614;
|
|
154
|
+
name: "Arbitrum Sepolia";
|
|
155
|
+
nativeCurrency: {
|
|
156
|
+
readonly name: "Arbitrum Sepolia Ether";
|
|
157
|
+
readonly symbol: "ETH";
|
|
158
|
+
readonly decimals: 18;
|
|
159
|
+
};
|
|
160
|
+
rpcUrls: {
|
|
161
|
+
readonly default: {
|
|
162
|
+
readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
sourceId?: number | undefined | undefined;
|
|
166
|
+
testnet: true;
|
|
167
|
+
custom?: Record<string, unknown> | undefined;
|
|
168
|
+
fees?: viem.ChainFees<undefined> | undefined;
|
|
169
|
+
formatters?: undefined;
|
|
170
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Privy Signer - Works with Privy's embedded wallets
|
|
176
|
+
*
|
|
177
|
+
* Usage in React:
|
|
178
|
+
* ```tsx
|
|
179
|
+
* import { useWallets } from '@privy-io/react-auth';
|
|
180
|
+
*
|
|
181
|
+
* const { wallets } = useWallets();
|
|
182
|
+
* const embeddedWallet = wallets.find(w => w.walletClientType === 'privy');
|
|
183
|
+
*
|
|
184
|
+
* const signer = new PrivySigner(embeddedWallet, chain);
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare class PrivySigner implements ISigner {
|
|
188
|
+
private privyWallet;
|
|
189
|
+
private chain;
|
|
190
|
+
private cachedAddress?;
|
|
191
|
+
private cachedWalletClient;
|
|
192
|
+
constructor(privyWallet: any, chain: Chain);
|
|
193
|
+
getAccount(): Promise<LocalAccount>;
|
|
194
|
+
getWalletClient(): Promise<WalletClient>;
|
|
195
|
+
getAddress(): Promise<`0x${string}`>;
|
|
196
|
+
isReady(): Promise<boolean>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare class PrivateKeySigner implements ISigner {
|
|
200
|
+
private account;
|
|
201
|
+
private walletClient;
|
|
202
|
+
constructor(privateKey: `0x${string}`, chain: Chain, rpcUrl: string);
|
|
203
|
+
getAccount(): LocalAccount;
|
|
204
|
+
getWalletClient(): WalletClient;
|
|
205
|
+
getAddress(): `0x${string}`;
|
|
206
|
+
isReady(): boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { DagAAClient, type DagAAConfig, type ISigner, PrivateKeySigner, PrivySigner, type SendUserOperationParams, type SmartAccountConfig, type UserOperationReceipt, arbitrumSep, awakening, createDagAAClient, parseDAG };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import * as viem from 'viem';
|
|
2
|
+
import { LocalAccount, WalletClient, Chain, Address, Hash } from 'viem';
|
|
3
|
+
export { Address, Chain, Hash } from 'viem';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Common interface for all signers
|
|
7
|
+
* This allows users to plug in different signing methods
|
|
8
|
+
*/
|
|
9
|
+
interface ISigner {
|
|
10
|
+
/**
|
|
11
|
+
* Get the viem Account object for signing
|
|
12
|
+
*/
|
|
13
|
+
getAccount(): LocalAccount | Promise<LocalAccount>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the wallet client for transactions
|
|
16
|
+
*/
|
|
17
|
+
getWalletClient(): WalletClient | Promise<WalletClient>;
|
|
18
|
+
/**
|
|
19
|
+
* Get the signer's address
|
|
20
|
+
*/
|
|
21
|
+
getAddress(): `0x${string}` | Promise<`0x${string}`>;
|
|
22
|
+
/**
|
|
23
|
+
* Check if signer is ready/connected
|
|
24
|
+
*/
|
|
25
|
+
isReady(): boolean | Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface DagAAConfig {
|
|
29
|
+
chain: Chain;
|
|
30
|
+
rpcUrl: string;
|
|
31
|
+
bundlerUrl: string;
|
|
32
|
+
factoryAddress: Address;
|
|
33
|
+
entryPointAddress?: Address;
|
|
34
|
+
paymasterUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
interface SmartAccountConfig {
|
|
37
|
+
signer: ISigner;
|
|
38
|
+
accountAddress?: Address;
|
|
39
|
+
}
|
|
40
|
+
interface SendUserOperationParams {
|
|
41
|
+
target: Address;
|
|
42
|
+
data?: `0x${string}`;
|
|
43
|
+
value?: bigint;
|
|
44
|
+
maxFeePerGas?: bigint;
|
|
45
|
+
maxPriorityFeePerGas?: bigint;
|
|
46
|
+
callGasLimit?: bigint;
|
|
47
|
+
verificationGasLimit?: bigint;
|
|
48
|
+
preVerificationGas?: bigint;
|
|
49
|
+
}
|
|
50
|
+
interface UserOperationReceipt {
|
|
51
|
+
userOpHash: Hash;
|
|
52
|
+
transactionHash?: Hash;
|
|
53
|
+
success: boolean;
|
|
54
|
+
blockNumber?: bigint;
|
|
55
|
+
blockHash?: Hash;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare class DagAAClient {
|
|
59
|
+
private config;
|
|
60
|
+
private publicClient;
|
|
61
|
+
private walletClient;
|
|
62
|
+
private bundlerClient;
|
|
63
|
+
private smartAccount;
|
|
64
|
+
private paymasterClient;
|
|
65
|
+
private smartAccountClient;
|
|
66
|
+
constructor(config: DagAAConfig);
|
|
67
|
+
private createPaymasterClient;
|
|
68
|
+
connectSmartAccount(accountConfig: SmartAccountConfig): Promise<Address>;
|
|
69
|
+
getAddress(): Address;
|
|
70
|
+
getBalance(): Promise<bigint>;
|
|
71
|
+
isDeployed(): Promise<boolean>;
|
|
72
|
+
getNonce(): Promise<bigint>;
|
|
73
|
+
sendUserOperation(params: SendUserOperationParams): Promise<Hash>;
|
|
74
|
+
writeContract(params: {
|
|
75
|
+
address: Address;
|
|
76
|
+
abi: any[];
|
|
77
|
+
functionName: string;
|
|
78
|
+
args?: any[];
|
|
79
|
+
value?: bigint;
|
|
80
|
+
maxFeePerGas?: bigint;
|
|
81
|
+
maxPriorityFeePerGas?: bigint;
|
|
82
|
+
}): Promise<Hash>;
|
|
83
|
+
readContract(params: {
|
|
84
|
+
address: Address;
|
|
85
|
+
abi: any[];
|
|
86
|
+
functionName: string;
|
|
87
|
+
args?: any[];
|
|
88
|
+
}): Promise<any>;
|
|
89
|
+
waitForUserOperationReceipt(userOpHash: Hash, timeout?: number): Promise<UserOperationReceipt>;
|
|
90
|
+
fundAccount(amount: bigint, fromPrivateKey: `0x${string}`): Promise<Hash>;
|
|
91
|
+
sendBatchUserOperations(operations: SendUserOperationParams[]): Promise<Hash[]>;
|
|
92
|
+
}
|
|
93
|
+
declare function createDagAAClient(config: DagAAConfig): DagAAClient;
|
|
94
|
+
declare function parseDAG(amount: string): bigint;
|
|
95
|
+
|
|
96
|
+
declare const awakening: {
|
|
97
|
+
bundler_rpc: string;
|
|
98
|
+
chain_config: {
|
|
99
|
+
blockExplorers: {
|
|
100
|
+
readonly default: {
|
|
101
|
+
readonly name: "Explorer";
|
|
102
|
+
readonly url: "https://awakening.bdagscan.com/";
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
contracts?: viem.Prettify<{
|
|
106
|
+
[key: string]: viem.ChainContract | {
|
|
107
|
+
[sourceId: number]: viem.ChainContract | undefined;
|
|
108
|
+
} | undefined;
|
|
109
|
+
} & {
|
|
110
|
+
ensRegistry?: viem.ChainContract | undefined;
|
|
111
|
+
ensUniversalResolver?: viem.ChainContract | undefined;
|
|
112
|
+
multicall3?: viem.ChainContract | undefined;
|
|
113
|
+
universalSignatureVerifier?: viem.ChainContract | undefined;
|
|
114
|
+
}> | undefined;
|
|
115
|
+
ensTlds?: readonly string[] | undefined;
|
|
116
|
+
id: 1043;
|
|
117
|
+
name: "Awakening Testnet";
|
|
118
|
+
nativeCurrency: {
|
|
119
|
+
readonly decimals: 18;
|
|
120
|
+
readonly name: "Dag";
|
|
121
|
+
readonly symbol: "DAG";
|
|
122
|
+
};
|
|
123
|
+
rpcUrls: {
|
|
124
|
+
readonly default: {
|
|
125
|
+
readonly http: readonly ["https://public-bdag.nownodes.io"];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
sourceId?: number | undefined;
|
|
129
|
+
testnet?: boolean | undefined;
|
|
130
|
+
custom?: Record<string, unknown>;
|
|
131
|
+
fees?: viem.ChainFees<undefined>;
|
|
132
|
+
formatters?: undefined;
|
|
133
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable>;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
declare const arbitrumSep: {
|
|
137
|
+
bundler_rpc: string;
|
|
138
|
+
chain_config: {
|
|
139
|
+
blockExplorers: {
|
|
140
|
+
readonly default: {
|
|
141
|
+
readonly name: "Arbiscan";
|
|
142
|
+
readonly url: "https://sepolia.arbiscan.io";
|
|
143
|
+
readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
contracts: {
|
|
147
|
+
readonly multicall3: {
|
|
148
|
+
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
149
|
+
readonly blockCreated: 81930;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
ensTlds?: readonly string[] | undefined;
|
|
153
|
+
id: 421614;
|
|
154
|
+
name: "Arbitrum Sepolia";
|
|
155
|
+
nativeCurrency: {
|
|
156
|
+
readonly name: "Arbitrum Sepolia Ether";
|
|
157
|
+
readonly symbol: "ETH";
|
|
158
|
+
readonly decimals: 18;
|
|
159
|
+
};
|
|
160
|
+
rpcUrls: {
|
|
161
|
+
readonly default: {
|
|
162
|
+
readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
sourceId?: number | undefined | undefined;
|
|
166
|
+
testnet: true;
|
|
167
|
+
custom?: Record<string, unknown> | undefined;
|
|
168
|
+
fees?: viem.ChainFees<undefined> | undefined;
|
|
169
|
+
formatters?: undefined;
|
|
170
|
+
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Privy Signer - Works with Privy's embedded wallets
|
|
176
|
+
*
|
|
177
|
+
* Usage in React:
|
|
178
|
+
* ```tsx
|
|
179
|
+
* import { useWallets } from '@privy-io/react-auth';
|
|
180
|
+
*
|
|
181
|
+
* const { wallets } = useWallets();
|
|
182
|
+
* const embeddedWallet = wallets.find(w => w.walletClientType === 'privy');
|
|
183
|
+
*
|
|
184
|
+
* const signer = new PrivySigner(embeddedWallet, chain);
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
declare class PrivySigner implements ISigner {
|
|
188
|
+
private privyWallet;
|
|
189
|
+
private chain;
|
|
190
|
+
private cachedAddress?;
|
|
191
|
+
private cachedWalletClient;
|
|
192
|
+
constructor(privyWallet: any, chain: Chain);
|
|
193
|
+
getAccount(): Promise<LocalAccount>;
|
|
194
|
+
getWalletClient(): Promise<WalletClient>;
|
|
195
|
+
getAddress(): Promise<`0x${string}`>;
|
|
196
|
+
isReady(): Promise<boolean>;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare class PrivateKeySigner implements ISigner {
|
|
200
|
+
private account;
|
|
201
|
+
private walletClient;
|
|
202
|
+
constructor(privateKey: `0x${string}`, chain: Chain, rpcUrl: string);
|
|
203
|
+
getAccount(): LocalAccount;
|
|
204
|
+
getWalletClient(): WalletClient;
|
|
205
|
+
getAddress(): `0x${string}`;
|
|
206
|
+
isReady(): boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export { DagAAClient, type DagAAConfig, type ISigner, PrivateKeySigner, PrivySigner, type SendUserOperationParams, type SmartAccountConfig, type UserOperationReceipt, arbitrumSep, awakening, createDagAAClient, parseDAG };
|