@dynamic-labs/ethereum-gasless-core 0.0.0 → 4.84.0

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 (67) hide show
  1. package/CHANGELOG.md +6525 -0
  2. package/LICENSE +21 -0
  3. package/README.md +7 -0
  4. package/package.cjs +8 -0
  5. package/package.js +4 -0
  6. package/package.json +23 -1
  7. package/src/index.cjs +53 -0
  8. package/src/index.d.ts +20 -0
  9. package/src/index.js +24 -0
  10. package/src/lib/activate7702Delegation/activate7702Delegation.cjs +17 -0
  11. package/src/lib/activate7702Delegation/activate7702Delegation.d.ts +18 -0
  12. package/src/lib/activate7702Delegation/activate7702Delegation.js +13 -0
  13. package/src/lib/constants.cjs +69 -0
  14. package/src/lib/constants.d.ts +76 -0
  15. package/src/lib/constants.js +60 -0
  16. package/src/lib/create7702DelegationRegistry/create7702DelegationRegistry.cjs +22 -0
  17. package/src/lib/create7702DelegationRegistry/create7702DelegationRegistry.d.ts +7 -0
  18. package/src/lib/create7702DelegationRegistry/create7702DelegationRegistry.js +18 -0
  19. package/src/lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError.cjs +18 -0
  20. package/src/lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError.d.ts +8 -0
  21. package/src/lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError.js +14 -0
  22. package/src/lib/errors/SponsorTransactionError/SponsorTransactionError.cjs +23 -0
  23. package/src/lib/errors/SponsorTransactionError/SponsorTransactionError.d.ts +10 -0
  24. package/src/lib/errors/SponsorTransactionError/SponsorTransactionError.js +19 -0
  25. package/src/lib/generateIntentNonce/generateIntentNonce.cjs +39 -0
  26. package/src/lib/generateIntentNonce/generateIntentNonce.d.ts +20 -0
  27. package/src/lib/generateIntentNonce/generateIntentNonce.js +35 -0
  28. package/src/lib/generateRandomNonce/generateRandomNonce.cjs +22 -0
  29. package/src/lib/generateRandomNonce/generateRandomNonce.d.ts +11 -0
  30. package/src/lib/generateRandomNonce/generateRandomNonce.js +18 -0
  31. package/src/lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.cjs +35 -0
  32. package/src/lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.d.ts +21 -0
  33. package/src/lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.js +31 -0
  34. package/src/lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.cjs +35 -0
  35. package/src/lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.d.ts +15 -0
  36. package/src/lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.js +31 -0
  37. package/src/lib/is7702DelegationActive/is7702DelegationActive.cjs +32 -0
  38. package/src/lib/is7702DelegationActive/is7702DelegationActive.d.ts +21 -0
  39. package/src/lib/is7702DelegationActive/is7702DelegationActive.js +28 -0
  40. package/src/lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled.cjs +14 -0
  41. package/src/lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled.d.ts +23 -0
  42. package/src/lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled.js +10 -0
  43. package/src/lib/relaySponsoredTransaction/relaySponsoredTransaction.cjs +58 -0
  44. package/src/lib/relaySponsoredTransaction/relaySponsoredTransaction.d.ts +29 -0
  45. package/src/lib/relaySponsoredTransaction/relaySponsoredTransaction.js +54 -0
  46. package/src/lib/resolveAuthorization/resolveAuthorization.cjs +32 -0
  47. package/src/lib/resolveAuthorization/resolveAuthorization.d.ts +27 -0
  48. package/src/lib/resolveAuthorization/resolveAuthorization.js +28 -0
  49. package/src/lib/resolveChainId/resolveChainId.cjs +12 -0
  50. package/src/lib/resolveChainId/resolveChainId.d.ts +11 -0
  51. package/src/lib/resolveChainId/resolveChainId.js +8 -0
  52. package/src/lib/sendSponsoredTransaction/sendSponsoredTransaction.cjs +21 -0
  53. package/src/lib/sendSponsoredTransaction/sendSponsoredTransaction.d.ts +29 -0
  54. package/src/lib/sendSponsoredTransaction/sendSponsoredTransaction.js +17 -0
  55. package/src/lib/sign7702Authorization/sign7702Authorization.cjs +22 -0
  56. package/src/lib/sign7702Authorization/sign7702Authorization.d.ts +21 -0
  57. package/src/lib/sign7702Authorization/sign7702Authorization.js +18 -0
  58. package/src/lib/signSponsoredTransaction/signSponsoredTransaction.cjs +61 -0
  59. package/src/lib/signSponsoredTransaction/signSponsoredTransaction.d.ts +22 -0
  60. package/src/lib/signSponsoredTransaction/signSponsoredTransaction.js +57 -0
  61. package/src/lib/toSerializedAuthorization/toSerializedAuthorization.cjs +28 -0
  62. package/src/lib/toSerializedAuthorization/toSerializedAuthorization.d.ts +11 -0
  63. package/src/lib/toSerializedAuthorization/toSerializedAuthorization.js +24 -0
  64. package/src/lib/types.d.ts +83 -0
  65. package/src/lib/waitForSponsoredTransaction/waitForSponsoredTransaction.cjs +38 -0
  66. package/src/lib/waitForSponsoredTransaction/waitForSponsoredTransaction.d.ts +16 -0
  67. package/src/lib/waitForSponsoredTransaction/waitForSponsoredTransaction.js +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dynamic Labs, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @dynamic-labs/ethereum-gasless-core
2
+
3
+ Pure (no React, no message-transport) implementation of Dynamic's EVM gasless flows: sponsored transactions and EIP-7702 delegation.
4
+
5
+ The package mirrors the gasless surface of `@dynamic-labs-sdk/evm` but is wallet-provider-agnostic: every function receives the viem `WalletClient` / `PublicClient` it needs as part of an explicit `deps` argument, so callers wire the package up against any signer (wallet-connector-core, an in-memory account, an EIP-1193 provider, etc.).
6
+
7
+ It is consumed by `@dynamic-labs/ethereum-gasless-extension` on the React Native host and by `apps/webview-controller`'s `EthereumGaslessController` inside the embedded WebView.
package/package.cjs ADDED
@@ -0,0 +1,8 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var version = "4.84.0";
7
+
8
+ exports.version = version;
package/package.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use client'
2
+ var version = "4.84.0";
3
+
4
+ export { version };
package/package.json CHANGED
@@ -1 +1,23 @@
1
- { "name": "@dynamic-labs/ethereum-gasless-core", "version": "0.0.0" }
1
+ {
2
+ "name": "@dynamic-labs/ethereum-gasless-core",
3
+ "version": "4.84.0",
4
+ "main": "./src/index.cjs",
5
+ "module": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./src/index.js",
12
+ "require": "./src/index.cjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "dependencies": {
17
+ "@dynamic-labs/sdk-api-core": "0.0.985",
18
+ "@dynamic-labs/assert-package-version": "4.84.0"
19
+ },
20
+ "peerDependencies": {
21
+ "viem": "^2.45.3"
22
+ }
23
+ }
package/src/index.cjs ADDED
@@ -0,0 +1,53 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var assertPackageVersion = require('@dynamic-labs/assert-package-version');
7
+ var _package = require('../package.cjs');
8
+ var activate7702Delegation = require('./lib/activate7702Delegation/activate7702Delegation.cjs');
9
+ var create7702DelegationRegistry = require('./lib/create7702DelegationRegistry/create7702DelegationRegistry.cjs');
10
+ var generateIntentNonce = require('./lib/generateIntentNonce/generateIntentNonce.cjs');
11
+ var generateRandomNonce = require('./lib/generateRandomNonce/generateRandomNonce.cjs');
12
+ var getAvailableEvmGaslessRelayer = require('./lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.cjs');
13
+ var getEVMSponsoredTransactionStatus = require('./lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.cjs');
14
+ var is7702DelegationActive = require('./lib/is7702DelegationActive/is7702DelegationActive.cjs');
15
+ var isEthereumGasSponsorshipEnabled = require('./lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled.cjs');
16
+ var relaySponsoredTransaction = require('./lib/relaySponsoredTransaction/relaySponsoredTransaction.cjs');
17
+ var resolveAuthorization = require('./lib/resolveAuthorization/resolveAuthorization.cjs');
18
+ var resolveChainId = require('./lib/resolveChainId/resolveChainId.cjs');
19
+ var sendSponsoredTransaction = require('./lib/sendSponsoredTransaction/sendSponsoredTransaction.cjs');
20
+ var sign7702Authorization = require('./lib/sign7702Authorization/sign7702Authorization.cjs');
21
+ var signSponsoredTransaction = require('./lib/signSponsoredTransaction/signSponsoredTransaction.cjs');
22
+ var toSerializedAuthorization = require('./lib/toSerializedAuthorization/toSerializedAuthorization.cjs');
23
+ var waitForSponsoredTransaction = require('./lib/waitForSponsoredTransaction/waitForSponsoredTransaction.cjs');
24
+ var EthereumGasSponsorshipNotEnabledError = require('./lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError.cjs');
25
+ var SponsorTransactionError = require('./lib/errors/SponsorTransactionError/SponsorTransactionError.cjs');
26
+ var constants = require('./lib/constants.cjs');
27
+
28
+ assertPackageVersion.assertPackageVersion('@dynamic-labs/ethereum-gasless-core', _package.version);
29
+
30
+ exports.activate7702Delegation = activate7702Delegation.activate7702Delegation;
31
+ exports.create7702DelegationRegistry = create7702DelegationRegistry.create7702DelegationRegistry;
32
+ exports.generateIntentNonce = generateIntentNonce.generateIntentNonce;
33
+ exports.generateRandomNonce = generateRandomNonce.generateRandomNonce;
34
+ exports.getAvailableEvmGaslessRelayer = getAvailableEvmGaslessRelayer.getAvailableEvmGaslessRelayer;
35
+ exports.getEVMSponsoredTransactionStatus = getEVMSponsoredTransactionStatus.getEVMSponsoredTransactionStatus;
36
+ exports.is7702DelegationActive = is7702DelegationActive.is7702DelegationActive;
37
+ exports.isEthereumGasSponsorshipEnabled = isEthereumGasSponsorshipEnabled.isEthereumGasSponsorshipEnabled;
38
+ exports.relaySponsoredTransaction = relaySponsoredTransaction.relaySponsoredTransaction;
39
+ exports.resolveAuthorization = resolveAuthorization.resolveAuthorization;
40
+ exports.resolveChainId = resolveChainId.resolveChainId;
41
+ exports.sendSponsoredTransaction = sendSponsoredTransaction.sendSponsoredTransaction;
42
+ exports.sign7702Authorization = sign7702Authorization.sign7702Authorization;
43
+ exports.signSponsoredTransaction = signSponsoredTransaction.signSponsoredTransaction;
44
+ exports.toSerializedAuthorization = toSerializedAuthorization.toSerializedAuthorization;
45
+ exports.waitForSponsoredTransaction = waitForSponsoredTransaction.waitForSponsoredTransaction;
46
+ exports.EthereumGasSponsorshipNotEnabledError = EthereumGasSponsorshipNotEnabledError.EthereumGasSponsorshipNotEnabledError;
47
+ exports.SponsorTransactionError = SponsorTransactionError.SponsorTransactionError;
48
+ exports.AUTHORIZED_EXECUTIONS_TYPES = constants.AUTHORIZED_EXECUTIONS_TYPES;
49
+ exports.BATCH_CALL_OPDATA_AUTH_MODE = constants.BATCH_CALL_OPDATA_AUTH_MODE;
50
+ exports.DEFAULT_VALID_FOR_SECONDS = constants.DEFAULT_VALID_FOR_SECONDS;
51
+ exports.DELEGATION_CODE_PREFIX = constants.DELEGATION_CODE_PREFIX;
52
+ exports.DELEGATION_CONTRACT_ADDRESS = constants.DELEGATION_CONTRACT_ADDRESS;
53
+ exports.UGD_ABI = constants.UGD_ABI;
package/src/index.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ export { activate7702Delegation } from './lib/activate7702Delegation/activate7702Delegation';
2
+ export { create7702DelegationRegistry } from './lib/create7702DelegationRegistry/create7702DelegationRegistry';
3
+ export { generateIntentNonce } from './lib/generateIntentNonce/generateIntentNonce';
4
+ export { generateRandomNonce } from './lib/generateRandomNonce/generateRandomNonce';
5
+ export { getAvailableEvmGaslessRelayer } from './lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer';
6
+ export { getEVMSponsoredTransactionStatus } from './lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus';
7
+ export { is7702DelegationActive } from './lib/is7702DelegationActive/is7702DelegationActive';
8
+ export { isEthereumGasSponsorshipEnabled } from './lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled';
9
+ export { relaySponsoredTransaction } from './lib/relaySponsoredTransaction/relaySponsoredTransaction';
10
+ export { resolveAuthorization } from './lib/resolveAuthorization/resolveAuthorization';
11
+ export { resolveChainId } from './lib/resolveChainId/resolveChainId';
12
+ export { sendSponsoredTransaction } from './lib/sendSponsoredTransaction/sendSponsoredTransaction';
13
+ export { sign7702Authorization } from './lib/sign7702Authorization/sign7702Authorization';
14
+ export { signSponsoredTransaction } from './lib/signSponsoredTransaction/signSponsoredTransaction';
15
+ export { toSerializedAuthorization } from './lib/toSerializedAuthorization/toSerializedAuthorization';
16
+ export { waitForSponsoredTransaction } from './lib/waitForSponsoredTransaction/waitForSponsoredTransaction';
17
+ export { EthereumGasSponsorshipNotEnabledError } from './lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError';
18
+ export { SponsorTransactionError } from './lib/errors/SponsorTransactionError/SponsorTransactionError';
19
+ export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, UGD_ABI, } from './lib/constants';
20
+ export type { Delegation7702Registry, EvmGaslessApiDeps, EvmGaslessChainDeps, SerializedAuthorization, SignedSponsoredTransaction, SponsoredTransactionCall, SponsoredTransactionStatus, SponsoredTransactionStatusResult, } from './lib/types';
package/src/index.js ADDED
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
3
+ import { version } from '../package.js';
4
+ export { activate7702Delegation } from './lib/activate7702Delegation/activate7702Delegation.js';
5
+ export { create7702DelegationRegistry } from './lib/create7702DelegationRegistry/create7702DelegationRegistry.js';
6
+ export { generateIntentNonce } from './lib/generateIntentNonce/generateIntentNonce.js';
7
+ export { generateRandomNonce } from './lib/generateRandomNonce/generateRandomNonce.js';
8
+ export { getAvailableEvmGaslessRelayer } from './lib/getAvailableEvmGaslessRelayer/getAvailableEvmGaslessRelayer.js';
9
+ export { getEVMSponsoredTransactionStatus } from './lib/getEVMSponsoredTransactionStatus/getEVMSponsoredTransactionStatus.js';
10
+ export { is7702DelegationActive } from './lib/is7702DelegationActive/is7702DelegationActive.js';
11
+ export { isEthereumGasSponsorshipEnabled } from './lib/isEthereumGasSponsorshipEnabled/isEthereumGasSponsorshipEnabled.js';
12
+ export { relaySponsoredTransaction } from './lib/relaySponsoredTransaction/relaySponsoredTransaction.js';
13
+ export { resolveAuthorization } from './lib/resolveAuthorization/resolveAuthorization.js';
14
+ export { resolveChainId } from './lib/resolveChainId/resolveChainId.js';
15
+ export { sendSponsoredTransaction } from './lib/sendSponsoredTransaction/sendSponsoredTransaction.js';
16
+ export { sign7702Authorization } from './lib/sign7702Authorization/sign7702Authorization.js';
17
+ export { signSponsoredTransaction } from './lib/signSponsoredTransaction/signSponsoredTransaction.js';
18
+ export { toSerializedAuthorization } from './lib/toSerializedAuthorization/toSerializedAuthorization.js';
19
+ export { waitForSponsoredTransaction } from './lib/waitForSponsoredTransaction/waitForSponsoredTransaction.js';
20
+ export { EthereumGasSponsorshipNotEnabledError } from './lib/errors/EthereumGasSponsorshipNotEnabledError/EthereumGasSponsorshipNotEnabledError.js';
21
+ export { SponsorTransactionError } from './lib/errors/SponsorTransactionError/SponsorTransactionError.js';
22
+ export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, UGD_ABI } from './lib/constants.js';
23
+
24
+ assertPackageVersion('@dynamic-labs/ethereum-gasless-core', version);
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var sendSponsoredTransaction = require('../sendSponsoredTransaction/sendSponsoredTransaction.cjs');
7
+
8
+ /**
9
+ * Activates EIP-7702 delegation for the wallet by sending a sponsored
10
+ * transaction whose only payload is the 7702 authorization itself.
11
+ *
12
+ * After activation the delegation is persisted on-chain and subsequent
13
+ * sponsored transactions can omit the authorization.
14
+ */
15
+ const activate7702Delegation = ({ authorization }, deps) => sendSponsoredTransaction.sendSponsoredTransaction({ authorization, calls: [] }, deps);
16
+
17
+ exports.activate7702Delegation = activate7702Delegation;
@@ -0,0 +1,18 @@
1
+ import type { Hex } from 'viem';
2
+ import type { SignAuthorizationReturnType } from 'viem/accounts';
3
+ import type { EvmGaslessChainDeps } from '../types';
4
+ type Activate7702DelegationParams = {
5
+ /** Pre-signed EIP-7702 authorization. If omitted, one will be signed automatically. */
6
+ authorization?: SignAuthorizationReturnType;
7
+ };
8
+ /**
9
+ * Activates EIP-7702 delegation for the wallet by sending a sponsored
10
+ * transaction whose only payload is the 7702 authorization itself.
11
+ *
12
+ * After activation the delegation is persisted on-chain and subsequent
13
+ * sponsored transactions can omit the authorization.
14
+ */
15
+ export declare const activate7702Delegation: ({ authorization }: Activate7702DelegationParams, deps: EvmGaslessChainDeps) => Promise<{
16
+ transactionHash: Hex;
17
+ }>;
18
+ export {};
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ import { sendSponsoredTransaction } from '../sendSponsoredTransaction/sendSponsoredTransaction.js';
3
+
4
+ /**
5
+ * Activates EIP-7702 delegation for the wallet by sending a sponsored
6
+ * transaction whose only payload is the 7702 authorization itself.
7
+ *
8
+ * After activation the delegation is persisted on-chain and subsequent
9
+ * sponsored transactions can omit the authorization.
10
+ */
11
+ const activate7702Delegation = ({ authorization }, deps) => sendSponsoredTransaction({ authorization, calls: [] }, deps);
12
+
13
+ export { activate7702Delegation };
@@ -0,0 +1,69 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Address of the Dynamic gasless EIP-7702 delegation contract.
8
+ *
9
+ * When a wallet has 7702 delegation active, its on-chain bytecode is
10
+ * `DELEGATION_CODE_PREFIX + this address` (minus the leading "0x").
11
+ */
12
+ const DELEGATION_CONTRACT_ADDRESS = '0x0000Fb7702036ff9f76044a501ac1aA74cbab16b';
13
+ /**
14
+ * Default lifetime of a signed sponsored-transaction intent, in seconds.
15
+ */
16
+ const DEFAULT_VALID_FOR_SECONDS = 600;
17
+ /**
18
+ * EIP-7702 delegation code prefix (`0xef0100`). When a wallet is delegated,
19
+ * its code is this prefix followed by the lowercase delegate address.
20
+ */
21
+ const DELEGATION_CODE_PREFIX = '0xef0100';
22
+ /**
23
+ * UGD authorization mode bytes for a batch-call OpData EIP-712 intent.
24
+ */
25
+ const BATCH_CALL_OPDATA_AUTH_MODE = '0x0100000000007821000100000000000000000000000000000000000000000000';
26
+ /**
27
+ * EIP-712 typed-data definitions for the UGD `AuthorizedExecutions` primary
28
+ * type. Used by `signTypedData` when signing a sponsored intent.
29
+ *
30
+ * Struct name `Execution` and field order are part of the on-chain typehash
31
+ * (`keccak256("AuthorizedExecutions(...)Execution(...)")`). Any divergence
32
+ * produces a different digest, the delegate's `ecrecover` returns a different
33
+ * address, and the call reverts with `UnauthorizedExecution()` (`0x7daadde3`).
34
+ */
35
+ const AUTHORIZED_EXECUTIONS_TYPES = {
36
+ AuthorizedExecutions: [
37
+ { name: 'calls', type: 'Execution[]' },
38
+ { name: 'deadline', type: 'uint256' },
39
+ { name: 'mode', type: 'bytes32' },
40
+ { name: 'nonce', type: 'uint256' },
41
+ { name: 'relayer', type: 'address' },
42
+ ],
43
+ Execution: [
44
+ { name: 'target', type: 'address' },
45
+ { name: 'value', type: 'uint256' },
46
+ { name: 'data', type: 'bytes' },
47
+ ],
48
+ };
49
+ /**
50
+ * Minimal ABI fragment for the UGD `isNonceUsed(uint256)` view, used to
51
+ * sanity-check randomly-generated intent nonces against the delegation
52
+ * contract's bitmap.
53
+ */
54
+ const UGD_ABI = [
55
+ {
56
+ inputs: [{ name: 'nonce', type: 'uint256' }],
57
+ name: 'isNonceUsed',
58
+ outputs: [{ name: '', type: 'bool' }],
59
+ stateMutability: 'view',
60
+ type: 'function',
61
+ },
62
+ ];
63
+
64
+ exports.AUTHORIZED_EXECUTIONS_TYPES = AUTHORIZED_EXECUTIONS_TYPES;
65
+ exports.BATCH_CALL_OPDATA_AUTH_MODE = BATCH_CALL_OPDATA_AUTH_MODE;
66
+ exports.DEFAULT_VALID_FOR_SECONDS = DEFAULT_VALID_FOR_SECONDS;
67
+ exports.DELEGATION_CODE_PREFIX = DELEGATION_CODE_PREFIX;
68
+ exports.DELEGATION_CONTRACT_ADDRESS = DELEGATION_CONTRACT_ADDRESS;
69
+ exports.UGD_ABI = UGD_ABI;
@@ -0,0 +1,76 @@
1
+ import type { Hex } from 'viem';
2
+ /**
3
+ * Address of the Dynamic gasless EIP-7702 delegation contract.
4
+ *
5
+ * When a wallet has 7702 delegation active, its on-chain bytecode is
6
+ * `DELEGATION_CODE_PREFIX + this address` (minus the leading "0x").
7
+ */
8
+ export declare const DELEGATION_CONTRACT_ADDRESS: Hex;
9
+ /**
10
+ * Default lifetime of a signed sponsored-transaction intent, in seconds.
11
+ */
12
+ export declare const DEFAULT_VALID_FOR_SECONDS = 600;
13
+ /**
14
+ * EIP-7702 delegation code prefix (`0xef0100`). When a wallet is delegated,
15
+ * its code is this prefix followed by the lowercase delegate address.
16
+ */
17
+ export declare const DELEGATION_CODE_PREFIX = "0xef0100";
18
+ /**
19
+ * UGD authorization mode bytes for a batch-call OpData EIP-712 intent.
20
+ */
21
+ export declare const BATCH_CALL_OPDATA_AUTH_MODE: Hex;
22
+ /**
23
+ * EIP-712 typed-data definitions for the UGD `AuthorizedExecutions` primary
24
+ * type. Used by `signTypedData` when signing a sponsored intent.
25
+ *
26
+ * Struct name `Execution` and field order are part of the on-chain typehash
27
+ * (`keccak256("AuthorizedExecutions(...)Execution(...)")`). Any divergence
28
+ * produces a different digest, the delegate's `ecrecover` returns a different
29
+ * address, and the call reverts with `UnauthorizedExecution()` (`0x7daadde3`).
30
+ */
31
+ export declare const AUTHORIZED_EXECUTIONS_TYPES: {
32
+ readonly AuthorizedExecutions: readonly [{
33
+ readonly name: "calls";
34
+ readonly type: "Execution[]";
35
+ }, {
36
+ readonly name: "deadline";
37
+ readonly type: "uint256";
38
+ }, {
39
+ readonly name: "mode";
40
+ readonly type: "bytes32";
41
+ }, {
42
+ readonly name: "nonce";
43
+ readonly type: "uint256";
44
+ }, {
45
+ readonly name: "relayer";
46
+ readonly type: "address";
47
+ }];
48
+ readonly Execution: readonly [{
49
+ readonly name: "target";
50
+ readonly type: "address";
51
+ }, {
52
+ readonly name: "value";
53
+ readonly type: "uint256";
54
+ }, {
55
+ readonly name: "data";
56
+ readonly type: "bytes";
57
+ }];
58
+ };
59
+ /**
60
+ * Minimal ABI fragment for the UGD `isNonceUsed(uint256)` view, used to
61
+ * sanity-check randomly-generated intent nonces against the delegation
62
+ * contract's bitmap.
63
+ */
64
+ export declare const UGD_ABI: readonly [{
65
+ readonly inputs: readonly [{
66
+ readonly name: "nonce";
67
+ readonly type: "uint256";
68
+ }];
69
+ readonly name: "isNonceUsed";
70
+ readonly outputs: readonly [{
71
+ readonly name: "";
72
+ readonly type: "bool";
73
+ }];
74
+ readonly stateMutability: "view";
75
+ readonly type: "function";
76
+ }];
@@ -0,0 +1,60 @@
1
+ 'use client'
2
+ /**
3
+ * Address of the Dynamic gasless EIP-7702 delegation contract.
4
+ *
5
+ * When a wallet has 7702 delegation active, its on-chain bytecode is
6
+ * `DELEGATION_CODE_PREFIX + this address` (minus the leading "0x").
7
+ */
8
+ const DELEGATION_CONTRACT_ADDRESS = '0x0000Fb7702036ff9f76044a501ac1aA74cbab16b';
9
+ /**
10
+ * Default lifetime of a signed sponsored-transaction intent, in seconds.
11
+ */
12
+ const DEFAULT_VALID_FOR_SECONDS = 600;
13
+ /**
14
+ * EIP-7702 delegation code prefix (`0xef0100`). When a wallet is delegated,
15
+ * its code is this prefix followed by the lowercase delegate address.
16
+ */
17
+ const DELEGATION_CODE_PREFIX = '0xef0100';
18
+ /**
19
+ * UGD authorization mode bytes for a batch-call OpData EIP-712 intent.
20
+ */
21
+ const BATCH_CALL_OPDATA_AUTH_MODE = '0x0100000000007821000100000000000000000000000000000000000000000000';
22
+ /**
23
+ * EIP-712 typed-data definitions for the UGD `AuthorizedExecutions` primary
24
+ * type. Used by `signTypedData` when signing a sponsored intent.
25
+ *
26
+ * Struct name `Execution` and field order are part of the on-chain typehash
27
+ * (`keccak256("AuthorizedExecutions(...)Execution(...)")`). Any divergence
28
+ * produces a different digest, the delegate's `ecrecover` returns a different
29
+ * address, and the call reverts with `UnauthorizedExecution()` (`0x7daadde3`).
30
+ */
31
+ const AUTHORIZED_EXECUTIONS_TYPES = {
32
+ AuthorizedExecutions: [
33
+ { name: 'calls', type: 'Execution[]' },
34
+ { name: 'deadline', type: 'uint256' },
35
+ { name: 'mode', type: 'bytes32' },
36
+ { name: 'nonce', type: 'uint256' },
37
+ { name: 'relayer', type: 'address' },
38
+ ],
39
+ Execution: [
40
+ { name: 'target', type: 'address' },
41
+ { name: 'value', type: 'uint256' },
42
+ { name: 'data', type: 'bytes' },
43
+ ],
44
+ };
45
+ /**
46
+ * Minimal ABI fragment for the UGD `isNonceUsed(uint256)` view, used to
47
+ * sanity-check randomly-generated intent nonces against the delegation
48
+ * contract's bitmap.
49
+ */
50
+ const UGD_ABI = [
51
+ {
52
+ inputs: [{ name: 'nonce', type: 'uint256' }],
53
+ name: 'isNonceUsed',
54
+ outputs: [{ name: '', type: 'bool' }],
55
+ stateMutability: 'view',
56
+ type: 'function',
57
+ },
58
+ ];
59
+
60
+ export { AUTHORIZED_EXECUTIONS_TYPES, BATCH_CALL_OPDATA_AUTH_MODE, DEFAULT_VALID_FOR_SECONDS, DELEGATION_CODE_PREFIX, DELEGATION_CONTRACT_ADDRESS, UGD_ABI };
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const buildKey = ({ chainId, walletAddress, }) => `${walletAddress.toLowerCase()}:${chainId}`;
7
+ /**
8
+ * Creates an in-memory registry that tracks which wallet+chain combinations
9
+ * have active EIP-7702 delegation. Only positive delegations are cached — a
10
+ * missing entry means the status is unknown and should be checked via RPC.
11
+ */
12
+ const create7702DelegationRegistry = () => {
13
+ const delegated = new Map();
14
+ return {
15
+ isDelegated: (params) => delegated.has(buildKey(params)),
16
+ markDelegated: (params) => {
17
+ delegated.set(buildKey(params), true);
18
+ },
19
+ };
20
+ };
21
+
22
+ exports.create7702DelegationRegistry = create7702DelegationRegistry;
@@ -0,0 +1,7 @@
1
+ import type { Delegation7702Registry } from '../types';
2
+ /**
3
+ * Creates an in-memory registry that tracks which wallet+chain combinations
4
+ * have active EIP-7702 delegation. Only positive delegations are cached — a
5
+ * missing entry means the status is unknown and should be checked via RPC.
6
+ */
7
+ export declare const create7702DelegationRegistry: () => Delegation7702Registry;
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+ const buildKey = ({ chainId, walletAddress, }) => `${walletAddress.toLowerCase()}:${chainId}`;
3
+ /**
4
+ * Creates an in-memory registry that tracks which wallet+chain combinations
5
+ * have active EIP-7702 delegation. Only positive delegations are cached — a
6
+ * missing entry means the status is unknown and should be checked via RPC.
7
+ */
8
+ const create7702DelegationRegistry = () => {
9
+ const delegated = new Map();
10
+ return {
11
+ isDelegated: (params) => delegated.has(buildKey(params)),
12
+ markDelegated: (params) => {
13
+ delegated.set(buildKey(params), true);
14
+ },
15
+ };
16
+ };
17
+
18
+ export { create7702DelegationRegistry };
@@ -0,0 +1,18 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Error thrown when a caller attempts to use sponsored transactions or 7702
8
+ * delegation while EVM gas sponsorship is disabled for the project.
9
+ */
10
+ class EthereumGasSponsorshipNotEnabledError extends Error {
11
+ constructor() {
12
+ super('EVM gas sponsorship is not enabled for this project');
13
+ this.code = 'evm_gas_sponsorship_not_enabled_error';
14
+ this.name = 'EthereumGasSponsorshipNotEnabledError';
15
+ }
16
+ }
17
+
18
+ exports.EthereumGasSponsorshipNotEnabledError = EthereumGasSponsorshipNotEnabledError;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Error thrown when a caller attempts to use sponsored transactions or 7702
3
+ * delegation while EVM gas sponsorship is disabled for the project.
4
+ */
5
+ export declare class EthereumGasSponsorshipNotEnabledError extends Error {
6
+ readonly code = "evm_gas_sponsorship_not_enabled_error";
7
+ constructor();
8
+ }
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ /**
3
+ * Error thrown when a caller attempts to use sponsored transactions or 7702
4
+ * delegation while EVM gas sponsorship is disabled for the project.
5
+ */
6
+ class EthereumGasSponsorshipNotEnabledError extends Error {
7
+ constructor() {
8
+ super('EVM gas sponsorship is not enabled for this project');
9
+ this.code = 'evm_gas_sponsorship_not_enabled_error';
10
+ this.name = 'EthereumGasSponsorshipNotEnabledError';
11
+ }
12
+ }
13
+
14
+ export { EthereumGasSponsorshipNotEnabledError };
@@ -0,0 +1,23 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Error thrown when the sponsored-transaction relay flow fails. Wraps an
8
+ * optional underlying cause and an optional terminal-failure message returned
9
+ * by the relay.
10
+ */
11
+ class SponsorTransactionError extends Error {
12
+ constructor(cause, details) {
13
+ super(details ?? 'Failed to sponsor EVM transaction');
14
+ this.code = 'sponsor_transaction_error';
15
+ this.name = 'SponsorTransactionError';
16
+ this.details = details;
17
+ if (cause) {
18
+ this.cause = cause;
19
+ }
20
+ }
21
+ }
22
+
23
+ exports.SponsorTransactionError = SponsorTransactionError;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Error thrown when the sponsored-transaction relay flow fails. Wraps an
3
+ * optional underlying cause and an optional terminal-failure message returned
4
+ * by the relay.
5
+ */
6
+ export declare class SponsorTransactionError extends Error {
7
+ readonly code = "sponsor_transaction_error";
8
+ readonly details?: string;
9
+ constructor(cause?: Error | null, details?: string);
10
+ }
@@ -0,0 +1,19 @@
1
+ 'use client'
2
+ /**
3
+ * Error thrown when the sponsored-transaction relay flow fails. Wraps an
4
+ * optional underlying cause and an optional terminal-failure message returned
5
+ * by the relay.
6
+ */
7
+ class SponsorTransactionError extends Error {
8
+ constructor(cause, details) {
9
+ super(details ?? 'Failed to sponsor EVM transaction');
10
+ this.code = 'sponsor_transaction_error';
11
+ this.name = 'SponsorTransactionError';
12
+ this.details = details;
13
+ if (cause) {
14
+ this.cause = cause;
15
+ }
16
+ }
17
+ }
18
+
19
+ export { SponsorTransactionError };
@@ -0,0 +1,39 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var constants = require('../constants.cjs');
7
+ var generateRandomNonce = require('../generateRandomNonce/generateRandomNonce.cjs');
8
+
9
+ /**
10
+ * Generates a random 256-bit bitmap nonce for UGD `AuthorizedExecutions`
11
+ * signing.
12
+ *
13
+ * Uses `crypto.getRandomValues` for entropy; collisions are essentially
14
+ * impossible at 256 bits. As a safety check the freshly-generated nonce is
15
+ * validated against the on-chain `isNonceUsed` view — if the contract call
16
+ * fails (e.g. delegation not yet active), the random nonce is still safe to
17
+ * use because it was generated locally with 256 bits of entropy.
18
+ */
19
+ const generateIntentNonce = async ({ walletAddress }, { publicClient }) => {
20
+ const nonce = generateRandomNonce.generateRandomNonce();
21
+ try {
22
+ const isUsed = await publicClient.readContract({
23
+ abi: constants.UGD_ABI,
24
+ address: walletAddress,
25
+ args: [nonce],
26
+ functionName: 'isNonceUsed',
27
+ });
28
+ if (isUsed) {
29
+ return generateRandomNonce.generateRandomNonce();
30
+ }
31
+ }
32
+ catch {
33
+ // Contract call may fail if delegation is not yet active — the nonce is
34
+ // still safe to use since it was randomly generated.
35
+ }
36
+ return nonce;
37
+ };
38
+
39
+ exports.generateIntentNonce = generateIntentNonce;
@@ -0,0 +1,20 @@
1
+ import type { Chain, Hex, PublicClient, Transport } from 'viem';
2
+ type GenerateIntentNonceParams = {
3
+ /** The wallet address whose delegation contract is queried for `isNonceUsed`. */
4
+ walletAddress: Hex;
5
+ };
6
+ type GenerateIntentNonceDeps = {
7
+ publicClient: PublicClient<Transport, Chain>;
8
+ };
9
+ /**
10
+ * Generates a random 256-bit bitmap nonce for UGD `AuthorizedExecutions`
11
+ * signing.
12
+ *
13
+ * Uses `crypto.getRandomValues` for entropy; collisions are essentially
14
+ * impossible at 256 bits. As a safety check the freshly-generated nonce is
15
+ * validated against the on-chain `isNonceUsed` view — if the contract call
16
+ * fails (e.g. delegation not yet active), the random nonce is still safe to
17
+ * use because it was generated locally with 256 bits of entropy.
18
+ */
19
+ export declare const generateIntentNonce: ({ walletAddress }: GenerateIntentNonceParams, { publicClient }: GenerateIntentNonceDeps) => Promise<bigint>;
20
+ export {};