@smoothsend/sdk 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Avalanche ERC-4337 (EntryPoint v0.7) via SmoothSend gateway — same idea as Aptos submitter.
3
+ *
4
+ * Minimal dApp flow:
5
+ * ```ts
6
+ * const avax = new SmoothSendAvaxSubmitter({ apiKey, network: 'testnet' });
7
+ * await avax.submitSponsoredUserOperation({ userOp: draft, signUserOp: wallet.sign });
8
+ * ```
9
+ */
10
+ import type { AvaxSponsorshipMode, GasEstimateAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SponsoredUserOpDraftAvax, UserOperationAvax, UserOperationReceiptAvax } from './types';
11
+ /** Options for {@link SmoothSendAvaxSubmitter.submitSponsoredUserOperation} */
12
+ export interface SubmitSponsoredAvaxUserOpOptions {
13
+ /** Sender must match your smart account; nonce/callData/fees from your app */
14
+ userOp: SponsoredUserOpDraftAvax;
15
+ /** Wallet / viem / ethers signs the UserOp hash your stack expects */
16
+ signUserOp: (userOp: UserOperationAvax) => Promise<string>;
17
+ mode?: AvaxSponsorshipMode;
18
+ /** Defaults to first entry point from `eth_supportedEntryPoints` */
19
+ entryPoint?: string;
20
+ /** Extra `paymaster/sign` fields (`token`, `receiver`, …) for user-pays-ERC20 */
21
+ paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
22
+ /** @default true */
23
+ waitForReceipt?: boolean;
24
+ receiptPoll?: {
25
+ pollMs?: number;
26
+ timeoutMs?: number;
27
+ };
28
+ }
29
+ export interface SmoothSendAvaxSubmitterConfig {
30
+ apiKey: string;
31
+ network?: 'testnet' | 'mainnet';
32
+ gatewayUrl?: string;
33
+ timeout?: number;
34
+ /**
35
+ * Gateway chain routing bucket. Default `avalanche` matches `core/gateway` routing.
36
+ */
37
+ chain?: string;
38
+ /**
39
+ * Public keys (`pk_nogas_*`) require an `Origin` header matching your project's allowed CORS origins.
40
+ * Set this for Node/scripts (e.g. `http://localhost:5173`). Browsers send Origin automatically.
41
+ */
42
+ corsOrigin?: string;
43
+ }
44
+ export declare class SmoothSendAvaxSubmitter {
45
+ private readonly config;
46
+ private readonly http;
47
+ private rpcId;
48
+ constructor(config: SmoothSendAvaxSubmitterConfig);
49
+ getConfig(): Readonly<SmoothSendAvaxSubmitterConfig>;
50
+ /** Merge gas estimate fields into a partial UserOp */
51
+ static applyGasEstimate(userOp: UserOperationAvax, gas: GasEstimateAvax): UserOperationAvax;
52
+ /** Attach packed paymaster data returned from {@link paymasterSign} */
53
+ static applyPaymasterAndData(userOp: UserOperationAvax, paymasterAndData: string): UserOperationAvax;
54
+ getChainId(): Promise<string>;
55
+ getSupportedEntryPoints(): Promise<string[]>;
56
+ estimateUserOperationGas(userOp: UserOperationAvax, entryPoint: string): Promise<GasEstimateAvax>;
57
+ sendUserOperation(userOp: UserOperationAvax, entryPoint: string): Promise<string>;
58
+ getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceiptAvax | null>;
59
+ waitForUserOperationReceipt(userOpHash: string, options?: {
60
+ pollMs?: number;
61
+ timeoutMs?: number;
62
+ }): Promise<UserOperationReceiptAvax | null>;
63
+ paymasterSign(body: PaymasterSignRequestAvax): Promise<PaymasterSignResponseAvax>;
64
+ getBundlerHealth(): Promise<unknown>;
65
+ /**
66
+ * One call: estimate gas → paymaster/sign → merge → your sign → send → (optional) wait for receipt.
67
+ */
68
+ submitSponsoredUserOperation(opts: SubmitSponsoredAvaxUserOpOptions): Promise<{
69
+ userOpHash: string;
70
+ receipt: UserOperationReceiptAvax | null;
71
+ }>;
72
+ private rpc;
73
+ }
74
+ /**
75
+ * @alias {@link SmoothSendAvaxSubmitter}
76
+ */
77
+ export declare const AvaxSubmitter: typeof SmoothSendAvaxSubmitter;
78
+ export declare function createSmoothSendAvaxSubmitter(config: SmoothSendAvaxSubmitterConfig): SmoothSendAvaxSubmitter;
79
+ //# sourceMappingURL=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;AAErD,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,6BAA6B,GACpC,uBAAuB,CAEzB"}
@@ -0,0 +1,7 @@
1
+ export type { AvaxSponsorshipMode, GasEstimateAvax, JsonRpcResponseAvax, PaymasterSignRequestAvax, PaymasterSignResponseAvax, SponsoredUserOpDraftAvax, UserOperationAvax, UserOperationReceiptAvax, } from './types';
2
+ export { AvaxSubmitter, SmoothSendAvaxSubmitter, createSmoothSendAvaxSubmitter, type SmoothSendAvaxSubmitterConfig, type SubmitSponsoredAvaxUserOpOptions, } from './SmoothSendAvaxSubmitter';
3
+ export { avaxExecuteAbi, encodeAvaxExecuteCalldata, hashUserOperationAvax, readAvaxSenderNonce, userOperationAvaxToViem, } from './viemHelpers';
4
+ export { SIMPLE_ACCOUNT_FACTORY_ABI, encodeCreateAccountFactoryData, predictSimpleAccountAddress, } from './simpleAccountFactory';
5
+ export { ENTRY_POINT_V07_ADDRESS, fetchAvaxAaPublicDefaults, type AvaxAaPublicDefaults, } from './publicAaDefaults';
6
+ export { SmoothSendAvaxProvider, useSmoothSendAvax, useSmoothSendAvaxContext, type SmoothSendAvaxContextValue, type UseSmoothSendAvaxParams, } from './useSmoothSendAvax';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/avax/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,GACtC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Public gateway defaults for Avalanche AA (no API key).
3
+ */
4
+ /** Canonical ERC-4337 EntryPoint v0.7 on Fuji / Avalanche C-Chain */
5
+ export declare const ENTRY_POINT_V07_ADDRESS: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
6
+ export type AvaxAaPublicDefaults = {
7
+ success?: boolean;
8
+ simpleAccountFactoryFuji: `0x${string}` | null;
9
+ entryPointV07: typeof ENTRY_POINT_V07_ADDRESS;
10
+ };
11
+ /**
12
+ * Fetch SimpleAccount factory hint from SmoothSend gateway (GET; no auth).
13
+ * Ops configure {@link https://proxy.smoothsend.xyz} `AVAX_FUJI_SIMPLE_ACCOUNT_FACTORY`; until then this returns null.
14
+ */
15
+ export declare function fetchAvaxAaPublicDefaults(gatewayUrl?: string): Promise<AvaxAaPublicDefaults>;
16
+ //# sourceMappingURL=publicAaDefaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publicAaDefaults.d.ts","sourceRoot":"","sources":["../../src/avax/publicAaDefaults.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,EAClC,4CAAqD,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,CAAC;IAC/C,aAAa,EAAE,OAAO,uBAAuB,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,UAAU,SAAiC,GAC1C,OAAO,CAAC,oBAAoB,CAAC,CA0B/B"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Standard SimpleAccountFactory (EntryPoint v0.7) helpers for counterfactual address + init calldata.
3
+ */
4
+ import type { Address, Hex, PublicClient } from 'viem';
5
+ /** Minimal ABI for eth-infinitism–style SimpleAccountFactory. */
6
+ export declare const SIMPLE_ACCOUNT_FACTORY_ABI: readonly [{
7
+ readonly inputs: readonly [{
8
+ readonly name: "owner";
9
+ readonly type: "address";
10
+ }, {
11
+ readonly name: "salt";
12
+ readonly type: "uint256";
13
+ }];
14
+ readonly name: "createAccount";
15
+ readonly outputs: readonly [{
16
+ readonly name: "account";
17
+ readonly type: "address";
18
+ }];
19
+ readonly stateMutability: "nonpayable";
20
+ readonly type: "function";
21
+ }, {
22
+ readonly inputs: readonly [{
23
+ readonly name: "owner";
24
+ readonly type: "address";
25
+ }, {
26
+ readonly name: "salt";
27
+ readonly type: "uint256";
28
+ }];
29
+ readonly name: "getAddress";
30
+ readonly outputs: readonly [{
31
+ readonly name: "";
32
+ readonly type: "address";
33
+ }];
34
+ readonly stateMutability: "view";
35
+ readonly type: "function";
36
+ }];
37
+ export declare function predictSimpleAccountAddress(params: {
38
+ publicClient: PublicClient;
39
+ factory: Address;
40
+ owner: Address;
41
+ salt?: bigint;
42
+ }): Promise<Address>;
43
+ export declare function encodeCreateAccountFactoryData(owner: Address, salt: bigint): Hex;
44
+ //# sourceMappingURL=simpleAccountFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simpleAccountFactory.d.ts","sourceRoot":"","sources":["../../src/avax/simpleAccountFactory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvD,iEAAiE;AACjE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB7B,CAAC;AAEX,wBAAsB,2BAA2B,CAAC,MAAM,EAAE;IACxD,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,OAAO,CAAC,CASnB;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,MAAM,GACX,GAAG,CAML"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * AVAX / ERC-4337 v0.7 types aligned with `chains/avax/bundler` API shapes.
3
+ */
4
+ export type AvaxSponsorshipMode = 'developer-sponsored' | 'user-pays-erc20';
5
+ /** Unpacked UserOperation as accepted by the bundler JSON-RPC + paymaster/sign */
6
+ export interface UserOperationAvax {
7
+ sender: string;
8
+ nonce: string;
9
+ factory?: string;
10
+ factoryData?: string;
11
+ initCode?: string;
12
+ callData: string;
13
+ callGasLimit?: string;
14
+ verificationGasLimit?: string;
15
+ preVerificationGas?: string;
16
+ maxFeePerGas?: string;
17
+ maxPriorityFeePerGas?: string;
18
+ paymaster?: string;
19
+ paymasterVerificationGasLimit?: string;
20
+ paymasterPostOpGasLimit?: string;
21
+ paymasterData?: string;
22
+ accountGasLimits?: string;
23
+ gasFees?: string;
24
+ paymasterAndData?: string;
25
+ /** Empty (`0x`) until the wallet/account signs the hash UserOp */
26
+ signature: string;
27
+ }
28
+ export interface GasEstimateAvax {
29
+ preVerificationGas: string;
30
+ verificationGasLimit: string;
31
+ callGasLimit: string;
32
+ paymasterVerificationGasLimit?: string;
33
+ paymasterPostOpGasLimit?: string;
34
+ }
35
+ export interface PaymasterSignRequestAvax {
36
+ mode: AvaxSponsorshipMode;
37
+ userOp: UserOperationAvax;
38
+ token?: string;
39
+ receiver?: string;
40
+ precheckBalance?: boolean;
41
+ prepaymentRequired?: boolean;
42
+ allowAnyBundler?: boolean;
43
+ sponsorUUID?: string;
44
+ }
45
+ export interface PaymasterSignResponseAvax {
46
+ success: boolean;
47
+ requestId?: string;
48
+ network?: string;
49
+ paymasterAndData: string;
50
+ paymasterData?: string;
51
+ signature?: string;
52
+ exchangeRate?: string;
53
+ paymasterDataParts?: Record<string, string>;
54
+ error?: string;
55
+ }
56
+ export interface UserOperationReceiptAvax {
57
+ userOpHash: string;
58
+ sender: string;
59
+ nonce: string;
60
+ paymaster: string;
61
+ success: boolean;
62
+ actualGasCost: string;
63
+ actualGasUsed: string;
64
+ reason?: string;
65
+ logs: unknown[];
66
+ receipt: {
67
+ transactionHash: string;
68
+ blockNumber: number;
69
+ blockHash: string;
70
+ };
71
+ }
72
+ export interface JsonRpcResponseAvax<T = unknown> {
73
+ jsonrpc: '2.0';
74
+ id: number | string;
75
+ result?: T;
76
+ error?: {
77
+ code: number;
78
+ message: string;
79
+ data?: unknown;
80
+ };
81
+ }
82
+ /** Partial UserOp before estimate/paymaster (signature optional, usually `0x` until wallet signs). */
83
+ export type SponsoredUserOpDraftAvax = Omit<UserOperationAvax, 'signature'> & {
84
+ signature?: string;
85
+ };
86
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/avax/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG,iBAAiB,CAAC;AAE5E,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAA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M,EAAE,MAAM,CAAC,CAAC;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,OAAO,EAAE;QACP,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO;IAC9C,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3D;AAED,sGAAsG;AACtG,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,iBAAiB,EAAE,WAAW,CAAC,GAAG;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * React: sponsored UserOps with minimal boilerplate.
3
+ *
4
+ * Works with wagmi — pass `usePublicClient()` / `useWalletClient()` results (wagmi v2: wrap app in
5
+ * `WagmiProvider` + `@tanstack/react-query` `QueryClientProvider`; see repo `resources/wagmi/playgrounds/vite-react`
6
+ * and `resources/permissionless.js/packages/wagmi-demo` for layout patterns).
7
+ * Optional {@link SmoothSendAvaxProvider} supplies apiKey + network + smartAccountAddress.
8
+ *
9
+ * Smart account must validate owner signatures like OpenZeppelin Account:
10
+ * `userOpHash` signed with Ethereum Signed Message prefix (`signMessage` + raw hash).
11
+ */
12
+ import { type ReactNode } from 'react';
13
+ import type { Address, Hex } from 'viem';
14
+ import type { PublicClient, WalletClient } from 'viem';
15
+ import { SmoothSendAvaxSubmitter } from './SmoothSendAvaxSubmitter';
16
+ import type { AvaxSponsorshipMode, PaymasterSignRequestAvax } from './types';
17
+ export type SmoothSendAvaxContextValue = {
18
+ apiKey: string;
19
+ network: 'testnet' | 'mainnet';
20
+ /** Set when the SCW is already known. If you use `accountFactory`, you can omit this. */
21
+ smartAccountAddress?: Address;
22
+ /**
23
+ * SimpleAccountFactory (v0.7). When set, the hook derives the counterfactual sender via
24
+ * `getAddress(owner, salt)` and, if the account has no code, adds `factory` + `factoryData` so the
25
+ * first sponsored UserOp deploys the SCW and runs `callData` in the same op.
26
+ */
27
+ accountFactory?: Address;
28
+ accountSalt?: bigint;
29
+ };
30
+ export declare function SmoothSendAvaxProvider({ apiKey, network, smartAccountAddress, accountFactory, accountSalt, children, }: {
31
+ apiKey: string;
32
+ network?: 'testnet' | 'mainnet';
33
+ smartAccountAddress?: Address;
34
+ accountFactory?: Address;
35
+ accountSalt?: bigint;
36
+ children: ReactNode;
37
+ }): import("react/jsx-runtime").JSX.Element;
38
+ export declare function useSmoothSendAvaxContext(): SmoothSendAvaxContextValue | null;
39
+ export type UseSmoothSendAvaxParams = {
40
+ apiKey?: string;
41
+ network?: 'testnet' | 'mainnet';
42
+ smartAccountAddress?: Address;
43
+ accountFactory?: Address;
44
+ /** @default 0n */
45
+ accountSalt?: bigint;
46
+ publicClient: PublicClient | null | undefined;
47
+ walletClient: WalletClient | null | undefined;
48
+ };
49
+ export declare function useSmoothSendAvax(params: UseSmoothSendAvaxParams): {
50
+ submitter: SmoothSendAvaxSubmitter;
51
+ submitCall: (args: {
52
+ to: Address;
53
+ data?: Hex;
54
+ value?: bigint;
55
+ mode?: AvaxSponsorshipMode;
56
+ paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
57
+ waitForReceipt?: boolean;
58
+ }) => ReturnType<SmoothSendAvaxSubmitter['submitSponsoredUserOperation']>;
59
+ };
60
+ //# sourceMappingURL=useSmoothSendAvax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSmoothSendAvax.d.ts","sourceRoot":"","sources":["../../src/avax/useSmoothSendAvax.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAW7E,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAC/B,yFAAyF;IACzF,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAMF,wBAAgB,sBAAsB,CAAC,EACrC,MAAM,EACN,OAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB,2CAgBA;AAED,wBAAgB,wBAAwB,IAAI,0BAA0B,GAAG,IAAI,CAE5E;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/C,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG;IAClE,SAAS,EAAE,uBAAuB,CAAC;IACnC,UAAU,EAAE,CAAC,IAAI,EAAE;QACjB,EAAE,EAAE,OAAO,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,mBAAmB,CAAC;QAC3B,SAAS,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,MAAM,GAAG,QAAQ,CAAC,CAAC;QAC9D,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,KAAK,UAAU,CAAC,uBAAuB,CAAC,8BAA8B,CAAC,CAAC,CAAC;CAC3E,CA+JA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Viem helpers for ERC-4337 v0.7 + common smart-account `execute` encoding.
3
+ * Peer dependency: `viem` (optional install).
4
+ */
5
+ import type { Address, Hex, PublicClient } from 'viem';
6
+ import type { UserOperation } from 'viem/account-abstraction';
7
+ import type { UserOperationAvax } from './types';
8
+ /** Typical SimpleAccount-style `execute(dest,value,func)`. */
9
+ export declare const avaxExecuteAbi: readonly [{
10
+ readonly name: "execute";
11
+ readonly type: "function";
12
+ readonly stateMutability: "nonpayable";
13
+ readonly inputs: readonly [{
14
+ readonly name: "dest";
15
+ readonly type: "address";
16
+ }, {
17
+ readonly name: "value";
18
+ readonly type: "uint256";
19
+ }, {
20
+ readonly name: "func";
21
+ readonly type: "bytes";
22
+ }];
23
+ readonly outputs: readonly [];
24
+ }];
25
+ export declare function encodeAvaxExecuteCalldata(to: Address, value: bigint, data?: Hex): Hex;
26
+ /** Convert API UserOp → viem shape for {@link getUserOperationHash}. */
27
+ export declare function userOperationAvaxToViem(u: UserOperationAvax): UserOperation<'0.7'>;
28
+ export declare function hashUserOperationAvax(params: {
29
+ chainId: number;
30
+ entryPointAddress: Address;
31
+ userOperation: UserOperationAvax;
32
+ }): Hex;
33
+ /** EntryPoint v0.7 `getNonce(sender, key)` with key `0`. */
34
+ export declare function readAvaxSenderNonce(params: {
35
+ publicClient: PublicClient;
36
+ entryPointAddress: Address;
37
+ sender: Address;
38
+ key?: bigint;
39
+ }): Promise<bigint>;
40
+ //# sourceMappingURL=viemHelpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viemHelpers.d.ts","sourceRoot":"","sources":["../../src/avax/viemHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAOvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAO9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,8DAA8D;AAC9D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAYjB,CAAC;AAEX,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,OAAO,EACX,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,GAAU,GACf,GAAG,CAML;AASD,wEAAwE;AACxE,wBAAgB,uBAAuB,CACrC,CAAC,EAAE,iBAAiB,GACnB,aAAa,CAAC,KAAK,CAAC,CA4DtB;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,iBAAiB,CAAC;CAClC,GAAG,GAAG,CAON;AAED,4DAA4D;AAC5D,wBAAsB,mBAAmB,CAAC,MAAM,EAAE;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAOlB"}