@dynamic-labs-wallet/node-evm 0.0.353 → 0.1.0-request-signing
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/index.cjs +1237 -189
- package/index.esm.js +1214 -192
- package/package.json +9 -8
- package/src/client/accountAdapter.d.ts +4 -3
- package/src/client/accountAdapter.d.ts.map +1 -1
- package/src/client/client.d.ts +110 -31
- package/src/client/client.d.ts.map +1 -1
- package/src/client/earn.client.d.ts +35 -0
- package/src/client/earn.client.d.ts.map +1 -0
- package/src/client/earn.constants.d.ts +42 -0
- package/src/client/earn.constants.d.ts.map +1 -0
- package/src/client/earn.types.d.ts +33 -0
- package/src/client/earn.types.d.ts.map +1 -0
- package/src/client/gasless.client.d.ts +54 -0
- package/src/client/gasless.client.d.ts.map +1 -0
- package/src/client/gasless.constants.d.ts +63 -0
- package/src/client/gasless.constants.d.ts.map +1 -0
- package/src/client/gasless.types.d.ts +148 -0
- package/src/client/gasless.types.d.ts.map +1 -0
- package/src/client/index.d.ts +6 -0
- package/src/client/index.d.ts.map +1 -1
- package/src/delegatedClient.d.ts +66 -9
- package/src/delegatedClient.d.ts.map +1 -1
- package/src/delegatedGasless.d.ts +78 -0
- package/src/delegatedGasless.d.ts.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/utils.d.ts +3 -1
- package/src/utils.d.ts.map +1 -1
- package/src/zerodev/types.d.ts +4 -3
- package/src/zerodev/types.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-request-signing",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "
|
|
9
|
-
"@dynamic-labs-sdk/client": "
|
|
10
|
-
"@dynamic-labs-sdk/zerodev": "
|
|
11
|
-
"@dynamic-labs-sdk/evm": "
|
|
7
|
+
"@dynamic-labs-wallet/node": "0.1.0-request-signing",
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.193.0",
|
|
9
|
+
"@dynamic-labs-sdk/client": "1.51.0",
|
|
10
|
+
"@dynamic-labs-sdk/zerodev": "1.51.0",
|
|
11
|
+
"@dynamic-labs-sdk/evm": "1.51.0",
|
|
12
12
|
"@zerodev/ecdsa-validator": "5.4.9",
|
|
13
|
-
"@zerodev/sdk": "5.4.36"
|
|
13
|
+
"@zerodev/sdk": "5.4.36",
|
|
14
|
+
"@dynamic-labs-wallet/core": "0.1.0-request-signing"
|
|
14
15
|
},
|
|
15
16
|
"publishConfig": {
|
|
16
17
|
"access": "public"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
|
-
"viem": "^2.
|
|
20
|
+
"viem": "^2.56.9"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"typescript": "^5.0.0",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import type { ServerKeyShare, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { Account } from 'viem';
|
|
3
3
|
import { type createDelegatedEvmWalletClient } from '../delegatedClient.js';
|
|
4
4
|
import type { EvmClientBase } from '../zerodev/types.js';
|
|
5
|
-
export declare const createAccountAdapter: ({ evmClient,
|
|
5
|
+
export declare const createAccountAdapter: ({ evmClient, walletMetadata, password, externalServerKeyShares, delegated, }: {
|
|
6
6
|
evmClient: EvmClientBase;
|
|
7
|
-
|
|
7
|
+
walletMetadata: WalletMetadata;
|
|
8
8
|
password?: string;
|
|
9
9
|
externalServerKeyShares?: ServerKeyShare[];
|
|
10
10
|
delegated?: {
|
|
11
11
|
delegatedClient: ReturnType<typeof createDelegatedEvmWalletClient>;
|
|
12
12
|
walletId: string;
|
|
13
|
+
shareSetId: string;
|
|
13
14
|
walletApiKey: string;
|
|
14
15
|
keyShare: ServerKeyShare;
|
|
15
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountAdapter.d.ts","sourceRoot":"","sources":["../../src/client/accountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"accountAdapter.d.ts","sourceRoot":"","sources":["../../src/client/accountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,MAAM,CAAC;AAGpD,OAAO,EACL,KAAK,8BAA8B,EAKpC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,oBAAoB,iFAM9B;IACD,SAAS,EAAE,aAAa,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3C,SAAS,CAAC,EAAE;QACV,eAAe,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;QACnE,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,cAAc,CAAC;KAC1B,CAAC;CACH,KAAG,OAiGH,CAAC"}
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
|
|
2
|
-
import type { SignMessageContext } from '@dynamic-labs/
|
|
3
|
-
import { type Account, type Chain, type PublicClient, type SignableMessage, type TransactionSerializable, type Transport, type TypedData, type WalletClient } from 'viem';
|
|
1
|
+
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type RawSignPreImage, type ServerKeyShare, type ThresholdSignatureScheme, type WalletApiKeyCreationResult, type WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import type { SignMessageContext, SponsorEVMTransactionResponse } from '@dynamic-labs-wallet/core';
|
|
3
|
+
import { type Account, type Chain, type Hex, type PublicClient, type SignableMessage, type TransactionSerializable, type Transport, type TypedData, type WalletClient } from 'viem';
|
|
4
|
+
import type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnTransactionResult, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams } from './earn.types.js';
|
|
5
|
+
import type { GetAvailableEvmGaslessRelayerParams, GetEVMSponsoredTransactionStatusParams, Is7702DelegationActiveParams, RelaySponsoredTransactionParams, SerializedAuthorization, Sign7702AuthorizationParams, SignedSponsoredTransaction, SignSponsoredTransactionParams, SponsoredTransactionStatusResult, WaitForSponsoredTransactionParams } from './gasless.types.js';
|
|
4
6
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
5
7
|
readonly chainName = "EVM";
|
|
6
|
-
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, enableMPCAccelerator, logger, }: DynamicWalletClientProps);
|
|
8
|
+
constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, baseClientKeysharesRelayApiUrl, debug, enableMPCAccelerator, logger, requestSigning, }: DynamicWalletClientProps);
|
|
7
9
|
get jwtAuthToken(): string | undefined;
|
|
8
10
|
get apiUrl(): string | undefined;
|
|
9
11
|
createViemPublicClient({ chain, rpcUrl }: {
|
|
10
12
|
chain: Chain;
|
|
11
13
|
rpcUrl?: string;
|
|
12
14
|
}): PublicClient;
|
|
13
|
-
getWalletClient({
|
|
14
|
-
|
|
15
|
+
getWalletClient({ walletMetadata, password, externalServerKeyShares, chain, chainId, rpcUrl, }: {
|
|
16
|
+
walletMetadata: WalletMetadata;
|
|
15
17
|
password?: string;
|
|
16
18
|
externalServerKeyShares?: ServerKeyShare[];
|
|
17
19
|
chain?: Chain;
|
|
@@ -23,29 +25,29 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
23
25
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
24
26
|
* @param password - The password to use for the wallet.
|
|
25
27
|
* @param onError - The function to call if an error occurs.
|
|
26
|
-
* @param
|
|
28
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
27
29
|
* @returns The account address, public key, raw public key, external server key shares, and wallet id.
|
|
28
30
|
*/
|
|
29
|
-
createWalletAccount({ thresholdSignatureScheme, password, onError,
|
|
31
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic, returnEncryptedWalletApiKey, }: {
|
|
30
32
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
31
33
|
password?: string;
|
|
32
34
|
onError?: (error: Error) => void;
|
|
33
|
-
|
|
35
|
+
backUpToDynamic?: boolean;
|
|
36
|
+
/** Opt in to an `encryptedWalletApiKey`; needs a delegated-access key registered for the environment. */
|
|
37
|
+
returnEncryptedWalletApiKey?: boolean;
|
|
34
38
|
}): Promise<{
|
|
35
|
-
|
|
39
|
+
walletMetadata: WalletMetadata;
|
|
36
40
|
publicKeyHex: string;
|
|
37
41
|
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
38
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
39
42
|
externalServerKeyShares: ServerKeyShare[];
|
|
40
43
|
externalKeySharesWithBackupStatus: Array<{
|
|
41
44
|
share: ServerKeyShare;
|
|
42
45
|
backedUpToClientKeyShareService: boolean;
|
|
43
46
|
}>;
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
signMessage({ message, accountAddress, password, externalServerKeyShares, context, onError, }: {
|
|
47
|
+
} & WalletApiKeyCreationResult>;
|
|
48
|
+
signMessage({ message, walletMetadata, password, externalServerKeyShares, context, onError, }: {
|
|
47
49
|
message: string;
|
|
48
|
-
|
|
50
|
+
walletMetadata: WalletMetadata;
|
|
49
51
|
password?: string;
|
|
50
52
|
externalServerKeyShares?: ServerKeyShare[];
|
|
51
53
|
context?: SignMessageContext;
|
|
@@ -53,9 +55,9 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
53
55
|
}): Promise<`0x${string}`>;
|
|
54
56
|
isSignAuthorizationSupported(): boolean;
|
|
55
57
|
private signPrehashedMessage;
|
|
56
|
-
signAuthorization({ authorization,
|
|
58
|
+
signAuthorization({ authorization, walletMetadata, password, externalServerKeyShares, onError, }: {
|
|
57
59
|
authorization: any;
|
|
58
|
-
|
|
60
|
+
walletMetadata: WalletMetadata;
|
|
59
61
|
password?: string;
|
|
60
62
|
externalServerKeyShares?: ServerKeyShare[];
|
|
61
63
|
onError?: (error: Error) => void;
|
|
@@ -70,16 +72,22 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
70
72
|
yParity: number;
|
|
71
73
|
v?: never;
|
|
72
74
|
}>;
|
|
73
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Signs an already-hashed digest. Provide either `rawSign` — the pre-image the
|
|
77
|
+
* digest comes from — or an explicit `context`, so a policy-enabled wallet can
|
|
78
|
+
* evaluate the request.
|
|
79
|
+
*/
|
|
80
|
+
signRawMessage({ message, walletMetadata, password, externalServerKeyShares, context, rawSign, onError, }: {
|
|
74
81
|
message: string;
|
|
75
|
-
|
|
82
|
+
walletMetadata: WalletMetadata;
|
|
76
83
|
password?: string;
|
|
77
84
|
externalServerKeyShares?: ServerKeyShare[];
|
|
78
85
|
context?: SignMessageContext;
|
|
86
|
+
rawSign?: RawSignPreImage;
|
|
79
87
|
onError?: (error: Error) => void;
|
|
80
88
|
}): Promise<string>;
|
|
81
|
-
signTypedData({
|
|
82
|
-
|
|
89
|
+
signTypedData({ walletMetadata, typedData, password, externalServerKeyShares, onError, }: {
|
|
90
|
+
walletMetadata: WalletMetadata;
|
|
83
91
|
typedData: TypedData;
|
|
84
92
|
password?: string;
|
|
85
93
|
externalServerKeyShares?: ServerKeyShare[];
|
|
@@ -90,19 +98,26 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
90
98
|
message: SignableMessage;
|
|
91
99
|
signature: any;
|
|
92
100
|
}): Promise<boolean>;
|
|
93
|
-
signTransaction({
|
|
94
|
-
|
|
101
|
+
signTransaction({ walletMetadata, transaction, password, externalServerKeyShares, context, }: {
|
|
102
|
+
walletMetadata: WalletMetadata;
|
|
95
103
|
transaction: TransactionSerializable;
|
|
96
104
|
password?: string;
|
|
97
105
|
externalServerKeyShares?: ServerKeyShare[];
|
|
106
|
+
context?: SignMessageContext;
|
|
98
107
|
}): Promise<string>;
|
|
99
|
-
exportPrivateKey({
|
|
100
|
-
|
|
108
|
+
exportPrivateKey({ walletMetadata, password, externalServerKeyShares, }: {
|
|
109
|
+
walletMetadata: WalletMetadata;
|
|
101
110
|
password?: string;
|
|
102
111
|
externalServerKeyShares?: ServerKeyShare[];
|
|
103
112
|
}): Promise<{
|
|
104
113
|
derivedPrivateKey: string | undefined;
|
|
105
114
|
}>;
|
|
115
|
+
/**
|
|
116
|
+
* `derivationPath` is the JSON-serialized index map that
|
|
117
|
+
* `walletMetadata.derivationPath` carries (e.g. `'{"0":44,"1":60,"2":0,"3":0,"4":0}'`
|
|
118
|
+
* or `'[44,60,0,0,0]'`). BIP-32 strings such as `"m/44'/60'/0'/0/0"` are rejected.
|
|
119
|
+
* Omit it to export without path derivation.
|
|
120
|
+
*/
|
|
106
121
|
offlineExportPrivateKey({ keyShares, derivationPath, }: {
|
|
107
122
|
keyShares: (EcdsaKeygenResult | Ed25519KeygenResult)[];
|
|
108
123
|
derivationPath?: string;
|
|
@@ -116,27 +131,91 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
116
131
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
117
132
|
* @param password - The password to use for the wallet.
|
|
118
133
|
* @param onError - The function to call if an error occurs.
|
|
119
|
-
* @param
|
|
134
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
120
135
|
* @returns The account address, public key, raw public key, external server key shares.
|
|
121
136
|
*/
|
|
122
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password,
|
|
137
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, backUpToDynamic, onError, }: {
|
|
123
138
|
privateKey: string;
|
|
124
139
|
chainName: string;
|
|
125
140
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
126
141
|
password?: string;
|
|
127
|
-
|
|
142
|
+
backUpToDynamic?: boolean;
|
|
128
143
|
onError?: (error: Error) => void;
|
|
129
144
|
}): Promise<{
|
|
130
|
-
|
|
145
|
+
walletMetadata: WalletMetadata;
|
|
131
146
|
publicKeyHex: string;
|
|
132
147
|
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
133
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
134
148
|
externalServerKeyShares: ServerKeyShare[];
|
|
135
149
|
externalKeySharesWithBackupStatus: Array<{
|
|
136
150
|
share: ServerKeyShare;
|
|
137
151
|
backedUpToClientKeyShareService: boolean;
|
|
138
152
|
}>;
|
|
139
153
|
}>;
|
|
140
|
-
|
|
154
|
+
/** @deprecated Use getWalletByAddress instead for better performance */
|
|
155
|
+
getEvmWallets(): Promise<{
|
|
156
|
+
walletId: string;
|
|
157
|
+
chainName: string;
|
|
158
|
+
accountAddress: string;
|
|
159
|
+
externalServerKeySharesBackupInfo: import("@dynamic-labs-wallet/core").KeyShareBackupInfo;
|
|
160
|
+
externalServerKeyShares: never[];
|
|
161
|
+
derivationPath: string | undefined;
|
|
162
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
163
|
+
}[]>;
|
|
164
|
+
private get evmGasless();
|
|
165
|
+
/**
|
|
166
|
+
* Checks whether the given wallet address has an active EIP-7702 delegation
|
|
167
|
+
* to the Universal Gasless Delegate (UGD) contract.
|
|
168
|
+
*/
|
|
169
|
+
is7702DelegationActive(params: Is7702DelegationActiveParams): Promise<boolean>;
|
|
170
|
+
/**
|
|
171
|
+
* Signs an EIP-7702 authorization that delegates the EOA to the UGD contract.
|
|
172
|
+
* The EOA nonce is fetched from the chain unless explicitly provided.
|
|
173
|
+
*/
|
|
174
|
+
sign7702Authorization(params: Sign7702AuthorizationParams): Promise<SerializedAuthorization>;
|
|
175
|
+
/**
|
|
176
|
+
* Fetches the available gasless relayer address for a given chain.
|
|
177
|
+
*/
|
|
178
|
+
getAvailableEvmGaslessRelayer(params: GetAvailableEvmGaslessRelayerParams): Promise<{
|
|
179
|
+
relayerAddress: Hex;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Signs a sponsored transaction intent: resolves 7702 authorization, generates
|
|
183
|
+
* a bitmap nonce, fetches the relayer, and MPC-signs the EIP-712 typed data.
|
|
184
|
+
*/
|
|
185
|
+
signSponsoredTransaction(params: SignSponsoredTransactionParams): Promise<SignedSponsoredTransaction>;
|
|
186
|
+
/**
|
|
187
|
+
* Returns the current status of an EVM sponsored transaction relay request.
|
|
188
|
+
*/
|
|
189
|
+
getEVMSponsoredTransactionStatus(params: GetEVMSponsoredTransactionStatusParams): Promise<SponsoredTransactionStatusResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Relays a sponsored transaction to the Dynamic API.
|
|
192
|
+
* Accepts either a pre-signed transaction or parameters to sign first.
|
|
193
|
+
*/
|
|
194
|
+
relaySponsoredTransaction(params: RelaySponsoredTransactionParams): Promise<SponsorEVMTransactionResponse>;
|
|
195
|
+
/**
|
|
196
|
+
* Relay then poll to completion. Fixed 60s/2s default (matches js-sdk).
|
|
197
|
+
* For a custom timeout, use relaySponsoredTransaction + waitForSponsoredTransaction.
|
|
198
|
+
*/
|
|
199
|
+
sendSponsoredTransaction(params: RelaySponsoredTransactionParams): Promise<{
|
|
200
|
+
transactionHash: Hex;
|
|
201
|
+
}>;
|
|
202
|
+
/**
|
|
203
|
+
* Polls the relay status until a terminal state (success or failure) is reached.
|
|
204
|
+
*/
|
|
205
|
+
waitForSponsoredTransaction(params: WaitForSponsoredTransactionParams): Promise<{
|
|
206
|
+
transactionHash: Hex;
|
|
207
|
+
}>;
|
|
208
|
+
private get evmEarn();
|
|
209
|
+
/**
|
|
210
|
+
* Executes an Earn signing payload returned by the prepare* methods, sending the
|
|
211
|
+
* ERC-20 approval first when the vault requires one.
|
|
212
|
+
*/
|
|
213
|
+
executeEarnTransaction(params: ExecuteEarnTransactionParams): Promise<EarnTransactionResult>;
|
|
214
|
+
/** Prepares and executes a deposit into an Earn vault. */
|
|
215
|
+
depositToEarnVault(params: DepositToEarnVaultParams): Promise<EarnTransactionResult>;
|
|
216
|
+
/** Prepares and executes a withdrawal from an Earn vault. */
|
|
217
|
+
withdrawFromEarnVault(params: WithdrawFromEarnVaultParams): Promise<EarnTransactionResult>;
|
|
218
|
+
/** Prepares and executes a claim of accrued Earn vault rewards. */
|
|
219
|
+
claimEarnRewards(params: ClaimEarnRewardsParams): Promise<EarnTransactionResult>;
|
|
141
220
|
}
|
|
142
221
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK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;OAGG;IACG,sBAAsB,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIlG,0DAA0D;IACpD,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI1F,6DAA6D;IACvD,qBAAqB,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhG,mEAAmE;IAC7D,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAGvF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EarnClient, ServerKeyShare, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import { type Account, type Chain, type Hex, type PublicClient, type Transport, type WalletClient } from 'viem';
|
|
3
|
+
import type { ClaimEarnRewardsParams, DepositToEarnVaultParams, EarnTransactionResult, ExecuteEarnTransactionParams, WithdrawFromEarnVaultParams } from './earn.types.js';
|
|
4
|
+
import type { RelaySponsoredTransactionParams } from './gasless.types.js';
|
|
5
|
+
/** Primitives the Earn client borrows from whoever owns the wallet. */
|
|
6
|
+
export type EvmEarnClientDeps = {
|
|
7
|
+
getEarnClient: () => EarnClient;
|
|
8
|
+
createViemPublicClient: (args: {
|
|
9
|
+
chain: Chain;
|
|
10
|
+
rpcUrl?: string;
|
|
11
|
+
}) => PublicClient;
|
|
12
|
+
getWalletClient: (args: {
|
|
13
|
+
walletMetadata: WalletMetadata;
|
|
14
|
+
password?: string;
|
|
15
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
16
|
+
chain?: Chain;
|
|
17
|
+
chainId?: number;
|
|
18
|
+
rpcUrl?: string;
|
|
19
|
+
}) => Promise<WalletClient<Transport, Chain, Account>>;
|
|
20
|
+
sendSponsoredTransaction: (args: RelaySponsoredTransactionParams) => Promise<{
|
|
21
|
+
transactionHash: Hex;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Builds a stateless Earn client for EVM vaults: it prepares vault actions through the
|
|
26
|
+
* Dynamic API and executes the returned unsigned transactions with the caller's wallet,
|
|
27
|
+
* sending an ERC-20 approval first when the vault requires one.
|
|
28
|
+
*/
|
|
29
|
+
export declare const createEvmEarnClient: ({ getEarnClient, createViemPublicClient, getWalletClient, sendSponsoredTransaction, }: EvmEarnClientDeps) => {
|
|
30
|
+
executeEarnTransaction: ({ signingPayload, traceContext, walletMetadata, password, externalServerKeyShares, sponsored, chain, rpcUrl, onStepChange, }: ExecuteEarnTransactionParams) => Promise<EarnTransactionResult>;
|
|
31
|
+
depositToEarnVault: ({ vaultId, amount, receiverAddress, traceContext, ...walletParams }: DepositToEarnVaultParams) => Promise<EarnTransactionResult>;
|
|
32
|
+
withdrawFromEarnVault: ({ vaultId, amount, receiverAddress, traceContext, ...walletParams }: WithdrawFromEarnVaultParams) => Promise<EarnTransactionResult>;
|
|
33
|
+
claimEarnRewards: ({ vaultId, traceContext, ...walletParams }: ClaimEarnRewardsParams) => Promise<EarnTransactionResult>;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=earn.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"earn.client.d.ts","sourceRoot":"","sources":["../../src/client/earn.client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChH,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAUd,OAAO,KAAK,EACV,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,+BAA+B,EAA4B,MAAM,oBAAoB,CAAC;AAEpG,uEAAuE;AACvE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,aAAa,EAAE,MAAM,UAAU,CAAC;IAChC,sBAAsB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,YAAY,CAAC;IAClF,eAAe,EAAE,CAAC,IAAI,EAAE;QACtB,cAAc,EAAE,cAAc,CAAC;QAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3C,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,KAAK,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,wBAAwB,EAAE,CAAC,IAAI,EAAE,+BAA+B,KAAK,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;CACxG,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,0FAK7B,iBAAiB;2JAoIf,4BAA4B,KAAG,OAAO,CAAC,qBAAqB,CAAC;8FAyH7D,wBAAwB,KAAG,OAAO,CAAC,qBAAqB,CAAC;iGAkBzD,2BAA2B,KAAG,OAAO,CAAC,qBAAqB,CAAC;mEAgB5D,sBAAsB,KAAG,OAAO,CAAC,qBAAqB,CAAC;CAgB3D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare const ERROR_EARN_NOT_EVM_WALLET = "Wallet metadata is not for an EVM wallet";
|
|
2
|
+
export declare const ERROR_EARN_MISSING_EVM_TRANSACTION = "Earn signing payload is missing EVM transaction data";
|
|
3
|
+
export declare const ERROR_EARN_CHAIN_MISMATCH = "The provided chain does not match the chain the Earn transaction was prepared for";
|
|
4
|
+
export declare const ERROR_EARN_APPROVAL_FAILED = "The ERC-20 approval for the Earn transaction reverted";
|
|
5
|
+
export declare const ERROR_EARN_CHAIN_REQUIRED = "Either chain or rpcUrl is required to execute an Earn transaction. Provide an RPC URL for the vault chain.";
|
|
6
|
+
/**
|
|
7
|
+
* Vault deposits and withdrawals rebalance the underlying lending markets, so gas estimated at
|
|
8
|
+
* the current block is regularly lower than what execution needs once the transaction is mined.
|
|
9
|
+
*/
|
|
10
|
+
export declare const EARN_GAS_LIMIT_BUFFER_PERCENT = 30n;
|
|
11
|
+
export declare const ERC20_ALLOWANCE_AND_APPROVE_ABI: readonly [{
|
|
12
|
+
readonly name: "allowance";
|
|
13
|
+
readonly type: "function";
|
|
14
|
+
readonly stateMutability: "view";
|
|
15
|
+
readonly inputs: readonly [{
|
|
16
|
+
readonly name: "owner";
|
|
17
|
+
readonly type: "address";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "spender";
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
}];
|
|
22
|
+
readonly outputs: readonly [{
|
|
23
|
+
readonly name: "";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}];
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "approve";
|
|
28
|
+
readonly type: "function";
|
|
29
|
+
readonly stateMutability: "nonpayable";
|
|
30
|
+
readonly inputs: readonly [{
|
|
31
|
+
readonly name: "spender";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "amount";
|
|
35
|
+
readonly type: "uint256";
|
|
36
|
+
}];
|
|
37
|
+
readonly outputs: readonly [{
|
|
38
|
+
readonly name: "";
|
|
39
|
+
readonly type: "bool";
|
|
40
|
+
}];
|
|
41
|
+
}];
|
|
42
|
+
//# sourceMappingURL=earn.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"earn.constants.d.ts","sourceRoot":"","sources":["../../src/client/earn.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,6CAA6C,CAAC;AAEpF,eAAO,MAAM,kCAAkC,yDAAyD,CAAC;AAEzG,eAAO,MAAM,yBAAyB,sFAC+C,CAAC;AAEtF,eAAO,MAAM,0BAA0B,0DAA0D,CAAC;AAElG,eAAO,MAAM,yBAAyB,+GACwE,CAAC;AAE/G;;;GAGG;AACH,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBlC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { EarnExecutionStep, EarnSigningPayload, ServerKeyShare, TraceContext, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import type { Chain } from 'viem';
|
|
3
|
+
export type { EarnExecutionStep, EarnTransactionResult } from '@dynamic-labs-wallet/node';
|
|
4
|
+
/** Wallet context and chain access every Earn write action needs. */
|
|
5
|
+
export type EvmEarnWalletParams = {
|
|
6
|
+
walletMetadata: WalletMetadata;
|
|
7
|
+
password?: string;
|
|
8
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
9
|
+
/** Viem chain for the vault. When omitted, the chain is built from the payload's chain id and `rpcUrl`. */
|
|
10
|
+
chain?: Chain;
|
|
11
|
+
rpcUrl?: string;
|
|
12
|
+
/** Opt in to Dynamic gas sponsorship: the approval and vault call are relayed as one batch. */
|
|
13
|
+
sponsored?: boolean;
|
|
14
|
+
onStepChange?: (step: EarnExecutionStep) => void;
|
|
15
|
+
traceContext?: TraceContext;
|
|
16
|
+
};
|
|
17
|
+
export type ExecuteEarnTransactionParams = EvmEarnWalletParams & {
|
|
18
|
+
signingPayload: EarnSigningPayload;
|
|
19
|
+
};
|
|
20
|
+
export type DepositToEarnVaultParams = EvmEarnWalletParams & {
|
|
21
|
+
vaultId: string;
|
|
22
|
+
amount: string;
|
|
23
|
+
receiverAddress?: string;
|
|
24
|
+
};
|
|
25
|
+
export type WithdrawFromEarnVaultParams = EvmEarnWalletParams & {
|
|
26
|
+
vaultId: string;
|
|
27
|
+
amount: string;
|
|
28
|
+
receiverAddress?: string;
|
|
29
|
+
};
|
|
30
|
+
export type ClaimEarnRewardsParams = EvmEarnWalletParams & {
|
|
31
|
+
vaultId: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=earn.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"earn.types.d.ts","sourceRoot":"","sources":["../../src/client/earn.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,EACZ,cAAc,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,YAAY,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE1F,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3C,2GAA2G;IAC3G,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+FAA+F;IAC/F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,mBAAmB,GAAG;IAC/D,cAAc,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,mBAAmB,GAAG;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,mBAAmB,GAAG;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG;IACzD,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ServerKeyShare, type WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
|
+
import type { DynamicApiClient, SponsorEVMTransactionResponse } from '@dynamic-labs-wallet/core';
|
|
3
|
+
import { type Chain, type Hex, type PublicClient, type TypedData } from 'viem';
|
|
4
|
+
import type { GaslessWalletRef, GetAvailableEvmGaslessRelayerParams, GetEVMSponsoredTransactionStatusParams, Is7702DelegationActiveParams, RelaySponsoredTransactionParams, SerializedAuthorization, Sign7702AuthorizationParams, SignedSponsoredTransaction, SignSponsoredTransactionParams, SponsoredTransactionStatusResult, WaitForSponsoredTransactionParams } from './gasless.types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Primitives the gasless client borrows from whoever owns the wallet. `TWallet` is
|
|
7
|
+
* the wallet reference handed back to the injected signers — full `WalletMetadata`
|
|
8
|
+
* for the class client, an address-only reference for delegated access.
|
|
9
|
+
*/
|
|
10
|
+
export type EvmGaslessClientDeps<TWallet extends GaslessWalletRef = WalletMetadata> = {
|
|
11
|
+
apiClient: DynamicApiClient;
|
|
12
|
+
createViemPublicClient: (args: {
|
|
13
|
+
chain: Chain;
|
|
14
|
+
rpcUrl?: string;
|
|
15
|
+
}) => PublicClient;
|
|
16
|
+
signAuthorization: (args: {
|
|
17
|
+
authorization: unknown;
|
|
18
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
19
|
+
password?: string;
|
|
20
|
+
walletMetadata: TWallet;
|
|
21
|
+
}) => Promise<{
|
|
22
|
+
r: string;
|
|
23
|
+
s: string;
|
|
24
|
+
yParity?: number;
|
|
25
|
+
}>;
|
|
26
|
+
signTypedData: (args: {
|
|
27
|
+
externalServerKeyShares?: ServerKeyShare[];
|
|
28
|
+
password?: string;
|
|
29
|
+
typedData: TypedData;
|
|
30
|
+
walletMetadata: TWallet;
|
|
31
|
+
}) => Promise<string>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Builds a stateless gasless client for EVM sponsored transactions (Fireblocks-relayer
|
|
35
|
+
* native gasless via EIP-7702 / AuthorizedExecutions). It holds no wallet state — the
|
|
36
|
+
* signing primitives and API client are injected by the caller that owns the wallet.
|
|
37
|
+
*/
|
|
38
|
+
export declare const createEvmGaslessClient: <TWallet extends GaslessWalletRef = WalletMetadata>({ apiClient, createViemPublicClient, signAuthorization, signTypedData, }: EvmGaslessClientDeps<TWallet>) => {
|
|
39
|
+
getAvailableEvmGaslessRelayer: ({ chainId, traceContext, }: GetAvailableEvmGaslessRelayerParams) => Promise<{
|
|
40
|
+
relayerAddress: Hex;
|
|
41
|
+
}>;
|
|
42
|
+
getEVMSponsoredTransactionStatus: ({ requestId, traceContext, }: GetEVMSponsoredTransactionStatusParams) => Promise<SponsoredTransactionStatusResult>;
|
|
43
|
+
is7702DelegationActive: ({ walletAddress, chainId, rpcUrl, }: Is7702DelegationActiveParams) => Promise<boolean>;
|
|
44
|
+
relaySponsoredTransaction: (params: RelaySponsoredTransactionParams<TWallet>) => Promise<SponsorEVMTransactionResponse>;
|
|
45
|
+
sendSponsoredTransaction: (params: RelaySponsoredTransactionParams<TWallet>) => Promise<{
|
|
46
|
+
transactionHash: Hex;
|
|
47
|
+
}>;
|
|
48
|
+
sign7702Authorization: ({ walletMetadata, chainId, rpcUrl, nonce, password, externalServerKeyShares, }: Sign7702AuthorizationParams<TWallet>) => Promise<SerializedAuthorization>;
|
|
49
|
+
signSponsoredTransaction: ({ walletMetadata, calls, chainId, rpcUrl, authorization, autoDelegate, nonce: providedNonce, validForSeconds, password, externalServerKeyShares, traceContext, }: SignSponsoredTransactionParams<TWallet>) => Promise<SignedSponsoredTransaction>;
|
|
50
|
+
waitForSponsoredTransaction: ({ requestId, pollInterval, timeout, traceContext, }: WaitForSponsoredTransactionParams) => Promise<{
|
|
51
|
+
transactionHash: Hex;
|
|
52
|
+
}>;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=gasless.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gasless.client.d.ts","sourceRoot":"","sources":["../../src/client/gasless.client.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,cAAc,EAAqB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACxH,OAAO,KAAK,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAe,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAiB5F,OAAO,KAAK,EACV,gBAAgB,EAChB,mCAAmC,EACnC,sCAAsC,EACtC,4BAA4B,EAC5B,+BAA+B,EAC/B,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,iCAAiC,EAClC,MAAM,oBAAoB,CAAC;AAI5B;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,OAAO,SAAS,gBAAgB,GAAG,cAAc,IAAI;IACpF,SAAS,EAAE,gBAAgB,CAAC;IAC5B,sBAAsB,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,YAAY,CAAC;IAClF,iBAAiB,EAAE,CAAC,IAAI,EAAE;QACxB,aAAa,EAAE,OAAO,CAAC;QACvB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,OAAO,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1D,aAAa,EAAE,CAAC,IAAI,EAAE;QACpB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,SAAS,CAAC;QACrB,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,SAAS,gBAAgB,6FAKpE,oBAAoB,CAAC,OAAO,CAAC;gEAgI3B,mCAAmC,KAAG,OAAO,CAAC;QAAE,cAAc,EAAE,GAAG,CAAA;KAAE,CAAC;qEAyItE,sCAAsC,KAAG,OAAO,CAAC,gCAAgC,CAAC;kEAjNlF,4BAA4B,KAAG,OAAO,CAAC,OAAO,CAAC;wCAgOxC,+BAA+B,CAAC,OAAO,CAAC,KAC/C,OAAO,CAAC,6BAA6B,CAAC;uCAyF/B,+BAA+B,CAAC,OAAO,CAAC,KAC/C,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;4GAzSjC,2BAA2B,CAAC,OAAO,CAAC,KAAG,OAAO,CAAC,uBAAuB,CAAC;iMA+HvE,8BAA8B,CAAC,OAAO,CAAC,KAAG,OAAO,CAAC,0BAA0B,CAAC;uFAmI7E,iCAAiC,KAAG,OAAO,CAAC;QAAE,eAAe,EAAE,GAAG,CAAA;KAAE,CAAC;CA0DzE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/** The Fireblocks Universal Gasless Delegate (UGD) contract address used for EIP-7702 delegation. */
|
|
3
|
+
export declare const DELEGATION_CONTRACT_ADDRESS: Hex;
|
|
4
|
+
/** Default sponsored transaction validity duration in seconds (10 minutes). */
|
|
5
|
+
export declare const DEFAULT_VALID_FOR_SECONDS = 600;
|
|
6
|
+
/** EIP-7702 delegation code prefix used to identify delegated accounts. */
|
|
7
|
+
export declare const DELEGATION_CODE_PREFIX = "0xef0100";
|
|
8
|
+
/** ERC-7579 batch call with opData and auth mode identifier. */
|
|
9
|
+
export declare const BATCH_CALL_OPDATA_AUTH_MODE: Hex;
|
|
10
|
+
/** EIP-712 typed data types for UGD AuthorizedExecutions signing. */
|
|
11
|
+
export declare const AUTHORIZED_EXECUTIONS_TYPES: {
|
|
12
|
+
readonly AuthorizedExecutions: readonly [{
|
|
13
|
+
readonly name: "calls";
|
|
14
|
+
readonly type: "Execution[]";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "deadline";
|
|
17
|
+
readonly type: "uint256";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "mode";
|
|
20
|
+
readonly type: "bytes32";
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "nonce";
|
|
23
|
+
readonly type: "uint256";
|
|
24
|
+
}, {
|
|
25
|
+
readonly name: "relayer";
|
|
26
|
+
readonly type: "address";
|
|
27
|
+
}];
|
|
28
|
+
readonly Execution: readonly [{
|
|
29
|
+
readonly name: "target";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "value";
|
|
33
|
+
readonly type: "uint256";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "data";
|
|
36
|
+
readonly type: "bytes";
|
|
37
|
+
}];
|
|
38
|
+
};
|
|
39
|
+
/** Minimal ABI for the UGD contract's nonce validation function. */
|
|
40
|
+
export declare const UGD_ABI: readonly [{
|
|
41
|
+
readonly inputs: readonly [{
|
|
42
|
+
readonly name: "nonce";
|
|
43
|
+
readonly type: "uint256";
|
|
44
|
+
}];
|
|
45
|
+
readonly name: "isNonceUsed";
|
|
46
|
+
readonly outputs: readonly [{
|
|
47
|
+
readonly name: "";
|
|
48
|
+
readonly type: "bool";
|
|
49
|
+
}];
|
|
50
|
+
readonly stateMutability: "view";
|
|
51
|
+
readonly type: "function";
|
|
52
|
+
}];
|
|
53
|
+
/** Default polling interval for sponsored transaction status checks (milliseconds). */
|
|
54
|
+
export declare const EVM_GASLESS_DEFAULT_POLL_INTERVAL_MS = 2000;
|
|
55
|
+
/** Default timeout for sponsored transaction polling (milliseconds). */
|
|
56
|
+
export declare const EVM_GASLESS_DEFAULT_TIMEOUT_MS = 60000;
|
|
57
|
+
export declare const ERROR_GASLESS_RPC_REQUIRED_FOR_AUTO_DELEGATE: string;
|
|
58
|
+
export declare const ERROR_GASLESS_RELAY_FAILED = "EVM sponsored transaction relay failed";
|
|
59
|
+
export declare const ERROR_GASLESS_TIMEOUT = "EVM sponsored transaction timed out waiting for terminal status";
|
|
60
|
+
export declare const ERROR_GASLESS_MISSING_REQUEST_ID = "Relay response did not include a requestId";
|
|
61
|
+
export declare const ERROR_GASLESS_MISSING_YPARITY = "Signed authorization is missing yParity";
|
|
62
|
+
export declare const ERROR_GASLESS_RPC_REQUIRED = "rpcUrl is required for this operation";
|
|
63
|
+
//# sourceMappingURL=gasless.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gasless.constants.d.ts","sourceRoot":"","sources":["../../src/client/gasless.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,qGAAqG;AACrG,eAAO,MAAM,2BAA2B,EAAE,GAAkD,CAAC;AAE7F,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C,2EAA2E;AAC3E,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD,gEAAgE;AAChE,eAAO,MAAM,2BAA2B,EAAE,GAA0E,CAAC;AAErH,qEAAqE;AACrE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa9B,CAAC;AAEX,oEAAoE;AACpE,eAAO,MAAM,OAAO;;;;;;;;;;;;EAQV,CAAC;AAEX,uFAAuF;AACvF,eAAO,MAAM,oCAAoC,OAAO,CAAC;AAEzD,wEAAwE;AACxE,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AAGpD,eAAO,MAAM,4CAA4C,QAEmB,CAAC;AAE7E,eAAO,MAAM,0BAA0B,2CAA2C,CAAC;AAEnF,eAAO,MAAM,qBAAqB,oEAAoE,CAAC;AAEvG,eAAO,MAAM,gCAAgC,+CAA+C,CAAC;AAE7F,eAAO,MAAM,6BAA6B,4CAA4C,CAAC;AAEvF,eAAO,MAAM,0BAA0B,0CAA0C,CAAC"}
|