@smoothsend/sdk 2.2.0 → 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.
- package/README.md +121 -201
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts +79 -0
- package/dist/avax/SmoothSendAvaxSubmitter.d.ts.map +1 -0
- package/dist/avax/index.d.ts +7 -0
- package/dist/avax/index.d.ts.map +1 -0
- package/dist/avax/publicAaDefaults.d.ts +16 -0
- package/dist/avax/publicAaDefaults.d.ts.map +1 -0
- package/dist/avax/simpleAccountFactory.d.ts +44 -0
- package/dist/avax/simpleAccountFactory.d.ts.map +1 -0
- package/dist/avax/types.d.ts +86 -0
- package/dist/avax/types.d.ts.map +1 -0
- package/dist/avax/useSmoothSendAvax.d.ts +60 -0
- package/dist/avax/useSmoothSendAvax.d.ts.map +1 -0
- package/dist/avax/viemHelpers.d.ts +40 -0
- package/dist/avax/viemHelpers.d.ts.map +1 -0
- package/dist/index.d.ts +440 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2370 -131
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2390 -133
- package/dist/index.js.map +1 -1
- package/dist/session/SmoothSendSession.d.ts +1 -6
- package/dist/session/SmoothSendSession.d.ts.map +1 -1
- package/dist/session/constants.d.ts +17 -0
- package/dist/session/constants.d.ts.map +1 -0
- package/dist/true-gasless/TrueGaslessClient.d.ts +72 -0
- package/dist/true-gasless/TrueGaslessClient.d.ts.map +1 -0
- package/dist/true-gasless/index.d.ts +2 -0
- package/dist/true-gasless/index.d.ts.map +1 -0
- package/dist/utils/http.d.ts +2 -0
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts +53 -2
- package/dist/wallet-adapter/SmoothSendTransactionSubmitter.d.ts.map +1 -1
- package/dist/wallet-adapter/useSmoothSend.d.ts +10 -5
- package/dist/wallet-adapter/useSmoothSend.d.ts.map +1 -1
- package/package.json +18 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { AptosConfig, AnyRawTransaction, AccountAuthenticator, PendingTransactionResponse, Account } from '@aptos-labs/ts-sdk';
|
|
1
|
+
import { AptosConfig, AnyRawTransaction, AccountAuthenticator, PendingTransactionResponse, Account, InputGenerateTransactionPayloadData, Aptos } from '@aptos-labs/ts-sdk';
|
|
2
|
+
import { Address, Hex, PublicClient, WalletClient } from 'viem';
|
|
3
|
+
import { UserOperation } from 'viem/account-abstraction';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
2
6
|
import { AxiosRequestConfig } from 'axios';
|
|
3
7
|
|
|
4
8
|
/**
|
|
@@ -1486,8 +1490,8 @@ declare class SmoothSendSDK {
|
|
|
1486
1490
|
*/
|
|
1487
1491
|
|
|
1488
1492
|
/**
|
|
1489
|
-
|
|
1490
|
-
|
|
1493
|
+
* Configuration options for SmoothSendTransactionSubmitter
|
|
1494
|
+
*/
|
|
1491
1495
|
interface SmoothSendTransactionSubmitterConfig {
|
|
1492
1496
|
/**
|
|
1493
1497
|
* Your SmoothSend API key
|
|
@@ -1521,6 +1525,33 @@ interface SmoothSendTransactionSubmitterConfig {
|
|
|
1521
1525
|
* @default false
|
|
1522
1526
|
*/
|
|
1523
1527
|
debug?: boolean;
|
|
1528
|
+
/**
|
|
1529
|
+
* Enable session key mode — user signs once, all subsequent transactions
|
|
1530
|
+
* are signed silently by an in-memory session key. Zero wallet popups after setup.
|
|
1531
|
+
*
|
|
1532
|
+
* Uses Aptos Account Abstraction (AIP-103 Permissioned Signers) — enforced on-chain.
|
|
1533
|
+
* Live on mainnet and testnet (as of April 2025).
|
|
1534
|
+
* SmoothSend pays gas for the one-time session setup transaction too.
|
|
1535
|
+
*
|
|
1536
|
+
* @default false
|
|
1537
|
+
*
|
|
1538
|
+
* @example
|
|
1539
|
+
* ```typescript
|
|
1540
|
+
* const smoothSend = new SmoothSendTransactionSubmitter({
|
|
1541
|
+
* apiKey: 'pk_nogas_xxx',
|
|
1542
|
+
* network: 'mainnet',
|
|
1543
|
+
* session: true,
|
|
1544
|
+
* });
|
|
1545
|
+
* ```
|
|
1546
|
+
*/
|
|
1547
|
+
session?: boolean;
|
|
1548
|
+
/**
|
|
1549
|
+
* How long the session key stays valid.
|
|
1550
|
+
* Format: number + unit (s, m, h, d)
|
|
1551
|
+
* Use "never" for client-side indefinite session validity.
|
|
1552
|
+
* @default '24h'
|
|
1553
|
+
*/
|
|
1554
|
+
sessionDuration?: string;
|
|
1524
1555
|
}
|
|
1525
1556
|
/**
|
|
1526
1557
|
* TransactionSubmitter interface compatible with @aptos-labs/ts-sdk v2.x
|
|
@@ -1551,7 +1582,30 @@ declare class SmoothSendTransactionSubmitter implements TransactionSubmitter {
|
|
|
1551
1582
|
private readonly timeout;
|
|
1552
1583
|
private readonly getCaptchaToken?;
|
|
1553
1584
|
private readonly debug;
|
|
1585
|
+
readonly sessionEnabled: boolean;
|
|
1586
|
+
private readonly sessionDuration;
|
|
1587
|
+
private _session;
|
|
1554
1588
|
constructor(config: SmoothSendTransactionSubmitterConfig);
|
|
1589
|
+
/**
|
|
1590
|
+
* Whether a valid session is currently active.
|
|
1591
|
+
*/
|
|
1592
|
+
hasSession(): boolean;
|
|
1593
|
+
/**
|
|
1594
|
+
* Create a session key for the given master account.
|
|
1595
|
+
* Called once by useSmoothSend when session: true and no session exists.
|
|
1596
|
+
* SmoothSend pays gas for the setup transaction.
|
|
1597
|
+
*
|
|
1598
|
+
* @param masterAccount - The user's wallet account (from wallet adapter)
|
|
1599
|
+
*/
|
|
1600
|
+
createSession(masterAccount: Account): Promise<void>;
|
|
1601
|
+
private isPermissionedSignerEnabled;
|
|
1602
|
+
private signSenderAuthenticator;
|
|
1603
|
+
/**
|
|
1604
|
+
* Submit a transaction using the active session key — no wallet popup.
|
|
1605
|
+
* Called by useSmoothSend after session is established.
|
|
1606
|
+
*/
|
|
1607
|
+
submitWithSession(functionName: `${string}::${string}::${string}`, functionArguments?: any[], typeArguments?: string[]): Promise<PendingTransactionResponse>;
|
|
1608
|
+
private _parseDuration;
|
|
1555
1609
|
/**
|
|
1556
1610
|
* Submit a transaction through SmoothSend's gasless relayer
|
|
1557
1611
|
*
|
|
@@ -1612,6 +1666,10 @@ declare function createSmoothSendSubmitter(apiKey: string, options?: Partial<Omi
|
|
|
1612
1666
|
* - Function in allowlist → fee-payer gasless path via SmoothSend
|
|
1613
1667
|
* - Function not in allowlist → regular wallet submission (user pays gas)
|
|
1614
1668
|
*
|
|
1669
|
+
* When submitter has session: true, the first transaction triggers a one-time
|
|
1670
|
+
* wallet sign to register a session key on-chain. Every transaction after that
|
|
1671
|
+
* is signed silently — zero wallet popups.
|
|
1672
|
+
*
|
|
1615
1673
|
* Requires: react >=17, @aptos-labs/wallet-adapter-react >=3, @aptos-labs/ts-sdk >=1
|
|
1616
1674
|
*
|
|
1617
1675
|
* @example
|
|
@@ -1628,18 +1686,316 @@ interface UseSmoothSendResult {
|
|
|
1628
1686
|
/**
|
|
1629
1687
|
* Smart signAndSubmitTransaction — same signature as the wallet adapter's version.
|
|
1630
1688
|
* Sponsored functions go gasless via SmoothSend; others fall back to user-pays-gas.
|
|
1689
|
+
* With session: true, zero wallet popups after the first transaction.
|
|
1631
1690
|
*/
|
|
1632
1691
|
signAndSubmitTransaction: (input: {
|
|
1633
1692
|
data: any;
|
|
1634
1693
|
options?: any;
|
|
1635
1694
|
}) => Promise<any>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Whether a session key is currently active (only relevant when session: true).
|
|
1697
|
+
* Updates reactively when session is created or expires.
|
|
1698
|
+
*/
|
|
1699
|
+
hasSession: boolean;
|
|
1700
|
+
}
|
|
1701
|
+
declare function useSmoothSend(submitter: SmoothSendTransactionSubmitter): UseSmoothSendResult;
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* AVAX / ERC-4337 v0.7 types aligned with `chains/avax/bundler` API shapes.
|
|
1705
|
+
*/
|
|
1706
|
+
type AvaxSponsorshipMode = 'developer-sponsored' | 'user-pays-erc20';
|
|
1707
|
+
/** Unpacked UserOperation as accepted by the bundler JSON-RPC + paymaster/sign */
|
|
1708
|
+
interface UserOperationAvax {
|
|
1709
|
+
sender: string;
|
|
1710
|
+
nonce: string;
|
|
1711
|
+
factory?: string;
|
|
1712
|
+
factoryData?: string;
|
|
1713
|
+
initCode?: string;
|
|
1714
|
+
callData: string;
|
|
1715
|
+
callGasLimit?: string;
|
|
1716
|
+
verificationGasLimit?: string;
|
|
1717
|
+
preVerificationGas?: string;
|
|
1718
|
+
maxFeePerGas?: string;
|
|
1719
|
+
maxPriorityFeePerGas?: string;
|
|
1720
|
+
paymaster?: string;
|
|
1721
|
+
paymasterVerificationGasLimit?: string;
|
|
1722
|
+
paymasterPostOpGasLimit?: string;
|
|
1723
|
+
paymasterData?: string;
|
|
1724
|
+
accountGasLimits?: string;
|
|
1725
|
+
gasFees?: string;
|
|
1726
|
+
paymasterAndData?: string;
|
|
1727
|
+
/** Empty (`0x`) until the wallet/account signs the hash UserOp */
|
|
1728
|
+
signature: string;
|
|
1636
1729
|
}
|
|
1730
|
+
interface GasEstimateAvax {
|
|
1731
|
+
preVerificationGas: string;
|
|
1732
|
+
verificationGasLimit: string;
|
|
1733
|
+
callGasLimit: string;
|
|
1734
|
+
paymasterVerificationGasLimit?: string;
|
|
1735
|
+
paymasterPostOpGasLimit?: string;
|
|
1736
|
+
}
|
|
1737
|
+
interface PaymasterSignRequestAvax {
|
|
1738
|
+
mode: AvaxSponsorshipMode;
|
|
1739
|
+
userOp: UserOperationAvax;
|
|
1740
|
+
token?: string;
|
|
1741
|
+
receiver?: string;
|
|
1742
|
+
precheckBalance?: boolean;
|
|
1743
|
+
prepaymentRequired?: boolean;
|
|
1744
|
+
allowAnyBundler?: boolean;
|
|
1745
|
+
sponsorUUID?: string;
|
|
1746
|
+
}
|
|
1747
|
+
interface PaymasterSignResponseAvax {
|
|
1748
|
+
success: boolean;
|
|
1749
|
+
requestId?: string;
|
|
1750
|
+
network?: string;
|
|
1751
|
+
paymasterAndData: string;
|
|
1752
|
+
paymasterData?: string;
|
|
1753
|
+
signature?: string;
|
|
1754
|
+
exchangeRate?: string;
|
|
1755
|
+
paymasterDataParts?: Record<string, string>;
|
|
1756
|
+
error?: string;
|
|
1757
|
+
}
|
|
1758
|
+
interface UserOperationReceiptAvax {
|
|
1759
|
+
userOpHash: string;
|
|
1760
|
+
sender: string;
|
|
1761
|
+
nonce: string;
|
|
1762
|
+
paymaster: string;
|
|
1763
|
+
success: boolean;
|
|
1764
|
+
actualGasCost: string;
|
|
1765
|
+
actualGasUsed: string;
|
|
1766
|
+
reason?: string;
|
|
1767
|
+
logs: unknown[];
|
|
1768
|
+
receipt: {
|
|
1769
|
+
transactionHash: string;
|
|
1770
|
+
blockNumber: number;
|
|
1771
|
+
blockHash: string;
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
/** Partial UserOp before estimate/paymaster (signature optional, usually `0x` until wallet signs). */
|
|
1775
|
+
type SponsoredUserOpDraftAvax = Omit<UserOperationAvax, 'signature'> & {
|
|
1776
|
+
signature?: string;
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1637
1779
|
/**
|
|
1638
|
-
*
|
|
1780
|
+
* Avalanche ERC-4337 (EntryPoint v0.7) via SmoothSend gateway — same idea as Aptos submitter.
|
|
1639
1781
|
*
|
|
1640
|
-
*
|
|
1782
|
+
* Minimal dApp flow:
|
|
1783
|
+
* ```ts
|
|
1784
|
+
* const avax = new SmoothSendAvaxSubmitter({ apiKey, network: 'testnet' });
|
|
1785
|
+
* await avax.submitSponsoredUserOperation({ userOp: draft, signUserOp: wallet.sign });
|
|
1786
|
+
* ```
|
|
1787
|
+
*/
|
|
1788
|
+
|
|
1789
|
+
/** Options for {@link SmoothSendAvaxSubmitter.submitSponsoredUserOperation} */
|
|
1790
|
+
interface SubmitSponsoredAvaxUserOpOptions {
|
|
1791
|
+
/** Sender must match your smart account; nonce/callData/fees from your app */
|
|
1792
|
+
userOp: SponsoredUserOpDraftAvax;
|
|
1793
|
+
/** Wallet / viem / ethers signs the UserOp hash your stack expects */
|
|
1794
|
+
signUserOp: (userOp: UserOperationAvax) => Promise<string>;
|
|
1795
|
+
mode?: AvaxSponsorshipMode;
|
|
1796
|
+
/** Defaults to first entry point from `eth_supportedEntryPoints` */
|
|
1797
|
+
entryPoint?: string;
|
|
1798
|
+
/** Extra `paymaster/sign` fields (`token`, `receiver`, …) for user-pays-ERC20 */
|
|
1799
|
+
paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
|
|
1800
|
+
/** @default true */
|
|
1801
|
+
waitForReceipt?: boolean;
|
|
1802
|
+
receiptPoll?: {
|
|
1803
|
+
pollMs?: number;
|
|
1804
|
+
timeoutMs?: number;
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
1807
|
+
interface SmoothSendAvaxSubmitterConfig {
|
|
1808
|
+
apiKey: string;
|
|
1809
|
+
network?: 'testnet' | 'mainnet';
|
|
1810
|
+
gatewayUrl?: string;
|
|
1811
|
+
timeout?: number;
|
|
1812
|
+
/**
|
|
1813
|
+
* Gateway chain routing bucket. Default `avalanche` matches `core/gateway` routing.
|
|
1814
|
+
*/
|
|
1815
|
+
chain?: string;
|
|
1816
|
+
/**
|
|
1817
|
+
* Public keys (`pk_nogas_*`) require an `Origin` header matching your project's allowed CORS origins.
|
|
1818
|
+
* Set this for Node/scripts (e.g. `http://localhost:5173`). Browsers send Origin automatically.
|
|
1819
|
+
*/
|
|
1820
|
+
corsOrigin?: string;
|
|
1821
|
+
}
|
|
1822
|
+
declare class SmoothSendAvaxSubmitter {
|
|
1823
|
+
private readonly config;
|
|
1824
|
+
private readonly http;
|
|
1825
|
+
private rpcId;
|
|
1826
|
+
constructor(config: SmoothSendAvaxSubmitterConfig);
|
|
1827
|
+
getConfig(): Readonly<SmoothSendAvaxSubmitterConfig>;
|
|
1828
|
+
/** Merge gas estimate fields into a partial UserOp */
|
|
1829
|
+
static applyGasEstimate(userOp: UserOperationAvax, gas: GasEstimateAvax): UserOperationAvax;
|
|
1830
|
+
/** Attach packed paymaster data returned from {@link paymasterSign} */
|
|
1831
|
+
static applyPaymasterAndData(userOp: UserOperationAvax, paymasterAndData: string): UserOperationAvax;
|
|
1832
|
+
getChainId(): Promise<string>;
|
|
1833
|
+
getSupportedEntryPoints(): Promise<string[]>;
|
|
1834
|
+
estimateUserOperationGas(userOp: UserOperationAvax, entryPoint: string): Promise<GasEstimateAvax>;
|
|
1835
|
+
sendUserOperation(userOp: UserOperationAvax, entryPoint: string): Promise<string>;
|
|
1836
|
+
getUserOperationReceipt(userOpHash: string): Promise<UserOperationReceiptAvax | null>;
|
|
1837
|
+
waitForUserOperationReceipt(userOpHash: string, options?: {
|
|
1838
|
+
pollMs?: number;
|
|
1839
|
+
timeoutMs?: number;
|
|
1840
|
+
}): Promise<UserOperationReceiptAvax | null>;
|
|
1841
|
+
paymasterSign(body: PaymasterSignRequestAvax): Promise<PaymasterSignResponseAvax>;
|
|
1842
|
+
getBundlerHealth(): Promise<unknown>;
|
|
1843
|
+
/**
|
|
1844
|
+
* One call: estimate gas → paymaster/sign → merge → your sign → send → (optional) wait for receipt.
|
|
1845
|
+
*/
|
|
1846
|
+
submitSponsoredUserOperation(opts: SubmitSponsoredAvaxUserOpOptions): Promise<{
|
|
1847
|
+
userOpHash: string;
|
|
1848
|
+
receipt: UserOperationReceiptAvax | null;
|
|
1849
|
+
}>;
|
|
1850
|
+
private rpc;
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* @alias {@link SmoothSendAvaxSubmitter}
|
|
1854
|
+
*/
|
|
1855
|
+
declare const AvaxSubmitter: typeof SmoothSendAvaxSubmitter;
|
|
1856
|
+
declare function createSmoothSendAvaxSubmitter(config: SmoothSendAvaxSubmitterConfig): SmoothSendAvaxSubmitter;
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* Viem helpers for ERC-4337 v0.7 + common smart-account `execute` encoding.
|
|
1860
|
+
* Peer dependency: `viem` (optional install).
|
|
1641
1861
|
*/
|
|
1642
|
-
|
|
1862
|
+
|
|
1863
|
+
/** Typical SimpleAccount-style `execute(dest,value,func)`. */
|
|
1864
|
+
declare const avaxExecuteAbi: readonly [{
|
|
1865
|
+
readonly name: "execute";
|
|
1866
|
+
readonly type: "function";
|
|
1867
|
+
readonly stateMutability: "nonpayable";
|
|
1868
|
+
readonly inputs: readonly [{
|
|
1869
|
+
readonly name: "dest";
|
|
1870
|
+
readonly type: "address";
|
|
1871
|
+
}, {
|
|
1872
|
+
readonly name: "value";
|
|
1873
|
+
readonly type: "uint256";
|
|
1874
|
+
}, {
|
|
1875
|
+
readonly name: "func";
|
|
1876
|
+
readonly type: "bytes";
|
|
1877
|
+
}];
|
|
1878
|
+
readonly outputs: readonly [];
|
|
1879
|
+
}];
|
|
1880
|
+
declare function encodeAvaxExecuteCalldata(to: Address, value: bigint, data?: Hex): Hex;
|
|
1881
|
+
/** Convert API UserOp → viem shape for {@link getUserOperationHash}. */
|
|
1882
|
+
declare function userOperationAvaxToViem(u: UserOperationAvax): UserOperation<'0.7'>;
|
|
1883
|
+
declare function hashUserOperationAvax(params: {
|
|
1884
|
+
chainId: number;
|
|
1885
|
+
entryPointAddress: Address;
|
|
1886
|
+
userOperation: UserOperationAvax;
|
|
1887
|
+
}): Hex;
|
|
1888
|
+
/** EntryPoint v0.7 `getNonce(sender, key)` with key `0`. */
|
|
1889
|
+
declare function readAvaxSenderNonce(params: {
|
|
1890
|
+
publicClient: PublicClient;
|
|
1891
|
+
entryPointAddress: Address;
|
|
1892
|
+
sender: Address;
|
|
1893
|
+
key?: bigint;
|
|
1894
|
+
}): Promise<bigint>;
|
|
1895
|
+
|
|
1896
|
+
/**
|
|
1897
|
+
* Standard SimpleAccountFactory (EntryPoint v0.7) helpers for counterfactual address + init calldata.
|
|
1898
|
+
*/
|
|
1899
|
+
|
|
1900
|
+
/** Minimal ABI for eth-infinitism–style SimpleAccountFactory. */
|
|
1901
|
+
declare const SIMPLE_ACCOUNT_FACTORY_ABI: readonly [{
|
|
1902
|
+
readonly inputs: readonly [{
|
|
1903
|
+
readonly name: "owner";
|
|
1904
|
+
readonly type: "address";
|
|
1905
|
+
}, {
|
|
1906
|
+
readonly name: "salt";
|
|
1907
|
+
readonly type: "uint256";
|
|
1908
|
+
}];
|
|
1909
|
+
readonly name: "createAccount";
|
|
1910
|
+
readonly outputs: readonly [{
|
|
1911
|
+
readonly name: "account";
|
|
1912
|
+
readonly type: "address";
|
|
1913
|
+
}];
|
|
1914
|
+
readonly stateMutability: "nonpayable";
|
|
1915
|
+
readonly type: "function";
|
|
1916
|
+
}, {
|
|
1917
|
+
readonly inputs: readonly [{
|
|
1918
|
+
readonly name: "owner";
|
|
1919
|
+
readonly type: "address";
|
|
1920
|
+
}, {
|
|
1921
|
+
readonly name: "salt";
|
|
1922
|
+
readonly type: "uint256";
|
|
1923
|
+
}];
|
|
1924
|
+
readonly name: "getAddress";
|
|
1925
|
+
readonly outputs: readonly [{
|
|
1926
|
+
readonly name: "";
|
|
1927
|
+
readonly type: "address";
|
|
1928
|
+
}];
|
|
1929
|
+
readonly stateMutability: "view";
|
|
1930
|
+
readonly type: "function";
|
|
1931
|
+
}];
|
|
1932
|
+
declare function predictSimpleAccountAddress(params: {
|
|
1933
|
+
publicClient: PublicClient;
|
|
1934
|
+
factory: Address;
|
|
1935
|
+
owner: Address;
|
|
1936
|
+
salt?: bigint;
|
|
1937
|
+
}): Promise<Address>;
|
|
1938
|
+
declare function encodeCreateAccountFactoryData(owner: Address, salt: bigint): Hex;
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Public gateway defaults for Avalanche AA (no API key).
|
|
1942
|
+
*/
|
|
1943
|
+
/** Canonical ERC-4337 EntryPoint v0.7 on Fuji / Avalanche C-Chain */
|
|
1944
|
+
declare const ENTRY_POINT_V07_ADDRESS: "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
|
|
1945
|
+
type AvaxAaPublicDefaults = {
|
|
1946
|
+
success?: boolean;
|
|
1947
|
+
simpleAccountFactoryFuji: `0x${string}` | null;
|
|
1948
|
+
entryPointV07: typeof ENTRY_POINT_V07_ADDRESS;
|
|
1949
|
+
};
|
|
1950
|
+
/**
|
|
1951
|
+
* Fetch SimpleAccount factory hint from SmoothSend gateway (GET; no auth).
|
|
1952
|
+
* Ops configure {@link https://proxy.smoothsend.xyz} `AVAX_FUJI_SIMPLE_ACCOUNT_FACTORY`; until then this returns null.
|
|
1953
|
+
*/
|
|
1954
|
+
declare function fetchAvaxAaPublicDefaults(gatewayUrl?: string): Promise<AvaxAaPublicDefaults>;
|
|
1955
|
+
|
|
1956
|
+
type SmoothSendAvaxContextValue = {
|
|
1957
|
+
apiKey: string;
|
|
1958
|
+
network: 'testnet' | 'mainnet';
|
|
1959
|
+
/** Set when the SCW is already known. If you use `accountFactory`, you can omit this. */
|
|
1960
|
+
smartAccountAddress?: Address;
|
|
1961
|
+
/**
|
|
1962
|
+
* SimpleAccountFactory (v0.7). When set, the hook derives the counterfactual sender via
|
|
1963
|
+
* `getAddress(owner, salt)` and, if the account has no code, adds `factory` + `factoryData` so the
|
|
1964
|
+
* first sponsored UserOp deploys the SCW and runs `callData` in the same op.
|
|
1965
|
+
*/
|
|
1966
|
+
accountFactory?: Address;
|
|
1967
|
+
accountSalt?: bigint;
|
|
1968
|
+
};
|
|
1969
|
+
declare function SmoothSendAvaxProvider({ apiKey, network, smartAccountAddress, accountFactory, accountSalt, children, }: {
|
|
1970
|
+
apiKey: string;
|
|
1971
|
+
network?: 'testnet' | 'mainnet';
|
|
1972
|
+
smartAccountAddress?: Address;
|
|
1973
|
+
accountFactory?: Address;
|
|
1974
|
+
accountSalt?: bigint;
|
|
1975
|
+
children: ReactNode;
|
|
1976
|
+
}): react_jsx_runtime.JSX.Element;
|
|
1977
|
+
declare function useSmoothSendAvaxContext(): SmoothSendAvaxContextValue | null;
|
|
1978
|
+
type UseSmoothSendAvaxParams = {
|
|
1979
|
+
apiKey?: string;
|
|
1980
|
+
network?: 'testnet' | 'mainnet';
|
|
1981
|
+
smartAccountAddress?: Address;
|
|
1982
|
+
accountFactory?: Address;
|
|
1983
|
+
/** @default 0n */
|
|
1984
|
+
accountSalt?: bigint;
|
|
1985
|
+
publicClient: PublicClient | null | undefined;
|
|
1986
|
+
walletClient: WalletClient | null | undefined;
|
|
1987
|
+
};
|
|
1988
|
+
declare function useSmoothSendAvax(params: UseSmoothSendAvaxParams): {
|
|
1989
|
+
submitter: SmoothSendAvaxSubmitter;
|
|
1990
|
+
submitCall: (args: {
|
|
1991
|
+
to: Address;
|
|
1992
|
+
data?: Hex;
|
|
1993
|
+
value?: bigint;
|
|
1994
|
+
mode?: AvaxSponsorshipMode;
|
|
1995
|
+
paymaster?: Omit<PaymasterSignRequestAvax, 'mode' | 'userOp'>;
|
|
1996
|
+
waitForReceipt?: boolean;
|
|
1997
|
+
}) => ReturnType<SmoothSendAvaxSubmitter['submitSponsoredUserOperation']>;
|
|
1998
|
+
};
|
|
1643
1999
|
|
|
1644
2000
|
interface CreateSessionOptions {
|
|
1645
2001
|
/**
|
|
@@ -1654,7 +2010,7 @@ interface CreateSessionOptions {
|
|
|
1654
2010
|
/**
|
|
1655
2011
|
* How long the session should stay valid.
|
|
1656
2012
|
* Format: number + unit (s = seconds, m = minutes, h = hours, d = days)
|
|
1657
|
-
* @example '2h' | '24h' | '7d'
|
|
2013
|
+
* @example '2h' | '24h' | '7d' | 'never'
|
|
1658
2014
|
*/
|
|
1659
2015
|
expiresIn: string;
|
|
1660
2016
|
/**
|
|
@@ -1676,11 +2032,6 @@ interface SubmitResult {
|
|
|
1676
2032
|
hash: string;
|
|
1677
2033
|
}
|
|
1678
2034
|
/**
|
|
1679
|
-
* @experimental
|
|
1680
|
-
* Session keys require ACCOUNT_ABSTRACTION (feature 85) and PERMISSIONED_SIGNER (feature 84)
|
|
1681
|
-
* to be enabled on the Aptos network. As of now these features are only live on devnet/local node.
|
|
1682
|
-
* This will be fully released when the features are activated on testnet and mainnet.
|
|
1683
|
-
*
|
|
1684
2035
|
* A session that lets your app submit transactions on behalf of a user
|
|
1685
2036
|
* without any wallet popup after the initial one-time setup.
|
|
1686
2037
|
*
|
|
@@ -2011,6 +2362,78 @@ declare class ScriptComposerClient {
|
|
|
2011
2362
|
*/
|
|
2012
2363
|
declare function createScriptComposerClient(config: ScriptComposerConfig): ScriptComposerClient;
|
|
2013
2364
|
|
|
2365
|
+
/**
|
|
2366
|
+
* True Gasless Client
|
|
2367
|
+
*
|
|
2368
|
+
* Designed for server-side (backend) environments to securely build, sign,
|
|
2369
|
+
* and submit 100% sponsored gasless transactions using a Secret Key.
|
|
2370
|
+
*
|
|
2371
|
+
* @example
|
|
2372
|
+
* ```typescript
|
|
2373
|
+
* import { TrueGaslessClient } from '@smoothsend/sdk';
|
|
2374
|
+
* import { Account } from '@aptos-labs/ts-sdk';
|
|
2375
|
+
*
|
|
2376
|
+
* const backendWallet = Account.fromPrivateKey({ privateKey: '...' });
|
|
2377
|
+
* const client = new TrueGaslessClient({ apiKey: 'sk_nogas_...', network: 'mainnet' });
|
|
2378
|
+
*
|
|
2379
|
+
* const result = await client.execute({
|
|
2380
|
+
* senderAccount: backendWallet,
|
|
2381
|
+
* payload: {
|
|
2382
|
+
* function: "0x123::my_module::mint_nft",
|
|
2383
|
+
* functionArguments: []
|
|
2384
|
+
* }
|
|
2385
|
+
* });
|
|
2386
|
+
*
|
|
2387
|
+
* console.log("Gasless NFT Minted!", result.txHash);
|
|
2388
|
+
* ```
|
|
2389
|
+
*/
|
|
2390
|
+
|
|
2391
|
+
interface TrueGaslessConfig {
|
|
2392
|
+
/** API key for authentication (must be sk_nogas_* for backend) */
|
|
2393
|
+
apiKey: string;
|
|
2394
|
+
/** Network to use: 'testnet' | 'mainnet' */
|
|
2395
|
+
network: 'testnet' | 'mainnet';
|
|
2396
|
+
/** Custom proxy URL (optional) */
|
|
2397
|
+
proxyUrl?: string;
|
|
2398
|
+
/** Request timeout in milliseconds */
|
|
2399
|
+
timeout?: number;
|
|
2400
|
+
/** Enable debug logging */
|
|
2401
|
+
debug?: boolean;
|
|
2402
|
+
}
|
|
2403
|
+
interface ExecuteGaslessParams {
|
|
2404
|
+
/** The backend sender wallet identity */
|
|
2405
|
+
senderAccount: Account;
|
|
2406
|
+
/** Raw transaction payload to execute */
|
|
2407
|
+
payload: InputGenerateTransactionPayloadData;
|
|
2408
|
+
}
|
|
2409
|
+
interface ExecuteGaslessResult {
|
|
2410
|
+
success: boolean;
|
|
2411
|
+
requestId?: string;
|
|
2412
|
+
txHash?: string;
|
|
2413
|
+
gasUsed?: string;
|
|
2414
|
+
vmStatus?: string;
|
|
2415
|
+
sender?: string;
|
|
2416
|
+
}
|
|
2417
|
+
declare class TrueGaslessClient {
|
|
2418
|
+
private httpClient;
|
|
2419
|
+
private config;
|
|
2420
|
+
private aptos;
|
|
2421
|
+
constructor(config: TrueGaslessConfig);
|
|
2422
|
+
private log;
|
|
2423
|
+
/**
|
|
2424
|
+
* Builds, signs (as sender), and relays an arbitrary payload for complete sponsorship.
|
|
2425
|
+
*/
|
|
2426
|
+
execute(params: ExecuteGaslessParams): Promise<ExecuteGaslessResult>;
|
|
2427
|
+
/**
|
|
2428
|
+
* Expose the core Aptos instance to allow backend developers to access chain state if needed
|
|
2429
|
+
*/
|
|
2430
|
+
getAptosClient(): Aptos;
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Helper to initialize TrueGaslessClient
|
|
2434
|
+
*/
|
|
2435
|
+
declare function createTrueGaslessClient(config: TrueGaslessConfig): TrueGaslessClient;
|
|
2436
|
+
|
|
2014
2437
|
/**
|
|
2015
2438
|
* Aptos Multi-Chain Adapter - v2 Proxy Architecture
|
|
2016
2439
|
* Handles all Aptos chains (aptos-testnet, aptos-mainnet)
|
|
@@ -2119,6 +2542,8 @@ interface HttpClientConfig {
|
|
|
2119
2542
|
retries?: number;
|
|
2120
2543
|
customHeaders?: Record<string, string>;
|
|
2121
2544
|
includeOrigin?: boolean;
|
|
2545
|
+
/** Override the default proxy base URL (e.g. for self-hosted relayers) */
|
|
2546
|
+
baseUrl?: string;
|
|
2122
2547
|
}
|
|
2123
2548
|
/**
|
|
2124
2549
|
* HTTP Client for proxy worker integration
|
|
@@ -2422,7 +2847,7 @@ declare class StellarAdapter implements IChainAdapter {
|
|
|
2422
2847
|
* SDK version
|
|
2423
2848
|
* @public
|
|
2424
2849
|
*/
|
|
2425
|
-
declare const VERSION = "2.2.
|
|
2850
|
+
declare const VERSION = "2.2.1";
|
|
2426
2851
|
|
|
2427
|
-
export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, CHAIN_ECOSYSTEM_MAP, HttpClient, NetworkError, RateLimitError, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendError, SmoothSendSDK, SmoothSendSession, SmoothSendTransactionSubmitter, StellarAdapter, StellarCAddressAdapter, VERSION, ValidationError, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendSubmitter, SmoothSendSDK as default, useSmoothSend };
|
|
2428
|
-
export type { ApiResponse, AptosErrorCode, AptosTransferData, AptosWallet, AvalancheTransferData, BatchRelayTransferRequest, BatchTransferRequest, BuildTransferParams, BuildTransferResult, CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, ChainConfig, ChainEcosystem, ChainInfo, CreateSessionOptions, DomainSeparatorResponse, EVMTransferData, ErrorResponse, EstimateGasRequest, EventListener, FeeEstimate, FeeEstimateResult, GasEstimateResponse, HealthResponse, IChainAdapter, PermitData, PrepareSignatureRequest, PrepareSignatureResponse, RelayTransferRequest, RelayTransferResponse, ScriptComposerConfig, SessionInfo, SignatureData, SignedTransferData, SmoothSendConfig, SmoothSendTransactionSubmitterConfig, StellarWallet, SubmitResult, SubmitSignedTransactionParams, SubmitTransactionResult, SuccessResponse, SupportedChain, TokenBalance, TokenInfo, TransactionSubmitter, TransferData, TransferEvent, TransferQuote, TransferQuoteRequest, TransferQuoteResponse, TransferRequest, TransferResult, TransferStatusResponse, UsageMetadata, UseSmoothSendResult };
|
|
2852
|
+
export { APTOS_ERROR_CODES, AptosAdapter, AuthenticationError, AvaxSubmitter, CHAIN_ECOSYSTEM_MAP, ENTRY_POINT_V07_ADDRESS, HttpClient, NetworkError, RateLimitError, SIMPLE_ACCOUNT_FACTORY_ABI, STELLAR_ERROR_CODES, ScriptComposerClient, SmoothSendAvaxProvider, SmoothSendAvaxSubmitter, SmoothSendError, SmoothSendSDK, SmoothSendSession, SmoothSendTransactionSubmitter, StellarAdapter, StellarCAddressAdapter, TrueGaslessClient, VERSION, ValidationError, avaxExecuteAbi, createErrorFromResponse, createNetworkError, createScriptComposerClient, createSmoothSendAvaxSubmitter, createSmoothSendSubmitter, createTrueGaslessClient, SmoothSendSDK as default, encodeAvaxExecuteCalldata, encodeCreateAccountFactoryData, fetchAvaxAaPublicDefaults, hashUserOperationAvax, predictSimpleAccountAddress, readAvaxSenderNonce, useSmoothSend, useSmoothSendAvax, useSmoothSendAvaxContext, userOperationAvaxToViem };
|
|
2853
|
+
export type { ApiResponse, AptosErrorCode, AptosTransferData, AptosWallet, AvalancheTransferData, AvaxAaPublicDefaults, AvaxSponsorshipMode, BatchRelayTransferRequest, BatchTransferRequest, BuildTransferParams, BuildTransferResult, CAddressBalance, CAddressBalanceResult, CAddressBuildTransferResult, CAddressCreateResult, CAddressHealthResult, CAddressHistoryResult, CAddressLookupResult, CAddressSubmitResult, CAddressTransaction, ChainConfig, ChainEcosystem, ChainInfo, CreateSessionOptions, DomainSeparatorResponse, EVMTransferData, ErrorResponse, EstimateGasRequest, EventListener, ExecuteGaslessParams, ExecuteGaslessResult, FeeEstimate, FeeEstimateResult, GasEstimateAvax, GasEstimateResponse, HealthResponse, IChainAdapter, PaymasterSignRequestAvax, PaymasterSignResponseAvax, PermitData, PrepareSignatureRequest, PrepareSignatureResponse, RelayTransferRequest, RelayTransferResponse, ScriptComposerConfig, SessionInfo, SignatureData, SignedTransferData, SmoothSendAvaxContextValue, SmoothSendAvaxSubmitterConfig, SmoothSendConfig, SmoothSendTransactionSubmitterConfig, SponsoredUserOpDraftAvax, StellarWallet, SubmitResult, SubmitSignedTransactionParams, SubmitSponsoredAvaxUserOpOptions, SubmitTransactionResult, SuccessResponse, SupportedChain, TokenBalance, TokenInfo, TransactionSubmitter, TransferData, TransferEvent, TransferQuote, TransferQuoteRequest, TransferQuoteResponse, TransferRequest, TransferResult, TransferStatusResponse, TrueGaslessConfig, UsageMetadata, UseSmoothSendAvaxParams, UseSmoothSendResult, UserOperationAvax, UserOperationReceiptAvax };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,KAAK,oCAAoC,EACzC,KAAK,oBAAoB,EACzB,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,EACzB,KAAK,oCAAoC,EACzC,KAAK,oBAAoB,EACzB,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,0BAA0B,EAC1B,8BAA8B,EAC9B,2BAA2B,EAC3B,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,QAAQ,CAAC;AAIhB,OAAO,EACL,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,WAAW,CAAC;AAInB,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EACL,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,8BAA8B,CAAC;AAGtC,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|