@crossmint/client-sdk-smart-wallet 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SmartWalletSDK.cjs +1 -34
- package/dist/SmartWalletSDK.js +1 -34
- package/dist/api/CrossmintWalletService.cjs +1 -13
- package/dist/api/CrossmintWalletService.js +1 -13
- package/dist/blockchain/chains.cjs +1 -23
- package/dist/blockchain/chains.js +1 -23
- package/dist/blockchain/rpc.cjs +1 -11
- package/dist/blockchain/rpc.js +1 -11
- package/dist/blockchain/transfer.cjs +1 -7
- package/dist/blockchain/transfer.js +1 -7
- package/dist/blockchain/wallets/EVMSmartWallet.cjs +1 -10
- package/dist/blockchain/wallets/EVMSmartWallet.js +1 -10
- package/dist/blockchain/wallets/SendTransactionService.cjs +1 -11
- package/dist/blockchain/wallets/SendTransactionService.js +1 -11
- package/dist/blockchain/wallets/account/cache.cjs +1 -9
- package/dist/blockchain/wallets/account/cache.js +1 -9
- package/dist/blockchain/wallets/account/config.cjs +1 -9
- package/dist/blockchain/wallets/account/config.js +1 -9
- package/dist/blockchain/wallets/account/creator.cjs +1 -10
- package/dist/blockchain/wallets/account/creator.js +1 -10
- package/dist/blockchain/wallets/account/eoa.cjs +1 -11
- package/dist/blockchain/wallets/account/eoa.js +1 -11
- package/dist/blockchain/wallets/account/passkey.cjs +1 -9
- package/dist/blockchain/wallets/account/passkey.js +1 -9
- package/dist/blockchain/wallets/account/signer.cjs +1 -9
- package/dist/blockchain/wallets/account/signer.js +1 -9
- package/dist/blockchain/wallets/account/strategy.cjs +1 -1
- package/dist/blockchain/wallets/account/strategy.js +0 -1
- package/dist/blockchain/wallets/clientDecorator.cjs +1 -12
- package/dist/blockchain/wallets/clientDecorator.js +1 -12
- package/dist/blockchain/wallets/index.cjs +1 -10
- package/dist/blockchain/wallets/index.js +1 -10
- package/dist/blockchain/wallets/paymaster.cjs +1 -10
- package/dist/blockchain/wallets/paymaster.js +1 -10
- package/dist/blockchain/wallets/service.cjs +1 -16
- package/dist/blockchain/wallets/service.js +1 -16
- package/dist/chunk-265KNPZR.js +1 -0
- package/dist/chunk-2GS5TXEY.cjs +1 -0
- package/dist/chunk-2R6HK64N.cjs +1 -0
- package/dist/chunk-3F6P4HUZ.js +1 -0
- package/dist/chunk-4SPA557P.js +0 -0
- package/dist/chunk-7AVDZZGD.cjs +1 -0
- package/dist/chunk-7FXFOOQU.cjs +1 -0
- package/dist/chunk-7KTCGFU5.js +1 -0
- package/dist/chunk-AK6IIUTM.js +1 -0
- package/dist/chunk-ATQ4WGCW.js +1 -0
- package/dist/chunk-BIJAOWPS.js +1 -0
- package/dist/chunk-BJZQA5VC.js +1 -0
- package/dist/chunk-C3VZY7VJ.js +1 -0
- package/dist/chunk-CUTQYF3F.js +1 -0
- package/dist/chunk-D4NDUT36.js +1 -0
- package/dist/chunk-DIDKPOO2.cjs +1 -0
- package/dist/chunk-DQNKQDE2.cjs +1 -0
- package/dist/chunk-E3NG3YWO.js +1 -0
- package/dist/chunk-ETVJGLNY.js +1 -0
- package/dist/chunk-FHNNZVNU.js +1 -0
- package/dist/chunk-GB35YMN4.cjs +1 -0
- package/dist/chunk-H4CMXNVK.js +1 -0
- package/dist/chunk-HGA3WK6L.cjs +1 -0
- package/dist/chunk-II4HKF7X.cjs +1 -0
- package/dist/chunk-IQTGPM2U.cjs +1 -0
- package/dist/chunk-KYPTGHC6.cjs +1 -0
- package/dist/chunk-LDNU6SJL.cjs +3 -0
- package/dist/chunk-M4K3IZTT.cjs +1 -0
- package/dist/chunk-MJ62KCTK.cjs +1 -0
- package/dist/chunk-NAX6LRUY.cjs +1 -0
- package/dist/chunk-NLGILHJS.js +1 -0
- package/dist/chunk-O2ACORII.cjs +1 -0
- package/dist/chunk-ODAUWGUU.cjs +1 -0
- package/dist/chunk-PZ6Q22YJ.js +1 -0
- package/dist/chunk-QD2JKGX6.cjs +1 -0
- package/dist/chunk-S2XBSAGM.js +1 -0
- package/dist/chunk-SBW2PS63.cjs +1 -0
- package/dist/chunk-SCXFZMLR.cjs +1 -0
- package/dist/chunk-STH2LE35.cjs +1 -0
- package/dist/chunk-SWWOVT47.cjs +1 -0
- package/dist/chunk-TBTRV56U.cjs +2 -0
- package/dist/chunk-TWADESPF.cjs +1 -0
- package/dist/chunk-TXLAUKCK.cjs +1 -0
- package/dist/chunk-TZG6MROQ.js +1 -0
- package/dist/chunk-UG47CBKR.js +1 -0
- package/dist/chunk-UPURFW46.js +1 -0
- package/dist/chunk-UXNWF66Q.js +1 -0
- package/dist/chunk-VMOQWOZV.js +3 -0
- package/dist/chunk-VXGNAQOW.js +1 -0
- package/dist/chunk-WJ6XJMRD.cjs +1 -0
- package/dist/{chunk-5MG5CIEX.cjs → chunk-XJGFG3RT.cjs} +1 -13
- package/dist/chunk-XQ2K2K23.cjs +1 -0
- package/dist/chunk-YBHSEZMB.js +1 -0
- package/dist/chunk-YJUD5MVS.js +1 -0
- package/dist/chunk-YUWCRSYD.js +1 -0
- package/dist/chunk-Z7MMOBIC.js +2 -0
- package/dist/error/index.cjs +1 -25
- package/dist/error/index.js +1 -25
- package/dist/error/processor.cjs +1 -9
- package/dist/error/processor.js +1 -9
- package/dist/index.cjs +1 -86
- package/dist/index.js +1 -86
- package/dist/services/index.cjs +1 -11
- package/dist/services/index.js +1 -11
- package/dist/services/logger.cjs +1 -10
- package/dist/services/logger.js +1 -10
- package/dist/types/internal.cjs +1 -18
- package/dist/types/internal.js +1 -18
- package/dist/types/params.cjs +1 -1
- package/dist/types/params.js +0 -1
- package/dist/types/schema.cjs +1 -16
- package/dist/types/schema.js +1 -16
- package/dist/types/service.cjs +1 -1
- package/dist/types/service.js +0 -1
- package/dist/types/token.cjs +1 -1
- package/dist/types/token.js +0 -1
- package/dist/utils/api.cjs +1 -9
- package/dist/utils/api.js +1 -9
- package/dist/utils/blockchain.cjs +1 -7
- package/dist/utils/blockchain.js +1 -7
- package/dist/utils/constants.cjs +1 -19
- package/dist/utils/constants.js +1 -19
- package/dist/utils/environment.cjs +1 -7
- package/dist/utils/environment.js +1 -7
- package/dist/utils/helpers.cjs +1 -9
- package/dist/utils/helpers.js +1 -9
- package/dist/utils/signer.cjs +1 -10
- package/dist/utils/signer.js +1 -10
- package/dist/utils/test.cjs +1 -27
- package/dist/utils/test.js +1 -27
- package/package.json +3 -4
- package/dist/SmartWalletSDK.cjs.map +0 -1
- package/dist/SmartWalletSDK.js.map +0 -1
- package/dist/api/CrossmintWalletService.cjs.map +0 -1
- package/dist/api/CrossmintWalletService.js.map +0 -1
- package/dist/blockchain/chains.cjs.map +0 -1
- package/dist/blockchain/chains.js.map +0 -1
- package/dist/blockchain/rpc.cjs.map +0 -1
- package/dist/blockchain/rpc.js.map +0 -1
- package/dist/blockchain/transfer.cjs.map +0 -1
- package/dist/blockchain/transfer.js.map +0 -1
- package/dist/blockchain/wallets/EVMSmartWallet.cjs.map +0 -1
- package/dist/blockchain/wallets/EVMSmartWallet.js.map +0 -1
- package/dist/blockchain/wallets/SendTransactionService.cjs.map +0 -1
- package/dist/blockchain/wallets/SendTransactionService.js.map +0 -1
- package/dist/blockchain/wallets/account/cache.cjs.map +0 -1
- package/dist/blockchain/wallets/account/cache.js.map +0 -1
- package/dist/blockchain/wallets/account/config.cjs.map +0 -1
- package/dist/blockchain/wallets/account/config.js.map +0 -1
- package/dist/blockchain/wallets/account/creator.cjs.map +0 -1
- package/dist/blockchain/wallets/account/creator.js.map +0 -1
- package/dist/blockchain/wallets/account/eoa.cjs.map +0 -1
- package/dist/blockchain/wallets/account/eoa.js.map +0 -1
- package/dist/blockchain/wallets/account/passkey.cjs.map +0 -1
- package/dist/blockchain/wallets/account/passkey.js.map +0 -1
- package/dist/blockchain/wallets/account/signer.cjs.map +0 -1
- package/dist/blockchain/wallets/account/signer.js.map +0 -1
- package/dist/blockchain/wallets/account/strategy.cjs.map +0 -1
- package/dist/blockchain/wallets/account/strategy.js.map +0 -1
- package/dist/blockchain/wallets/clientDecorator.cjs.map +0 -1
- package/dist/blockchain/wallets/clientDecorator.js.map +0 -1
- package/dist/blockchain/wallets/index.cjs.map +0 -1
- package/dist/blockchain/wallets/index.js.map +0 -1
- package/dist/blockchain/wallets/paymaster.cjs.map +0 -1
- package/dist/blockchain/wallets/paymaster.js.map +0 -1
- package/dist/blockchain/wallets/service.cjs.map +0 -1
- package/dist/blockchain/wallets/service.js.map +0 -1
- package/dist/chunk-22PW4SGD.cjs +0 -36
- package/dist/chunk-22PW4SGD.cjs.map +0 -1
- package/dist/chunk-2HB65Y7D.js +0 -79
- package/dist/chunk-2HB65Y7D.js.map +0 -1
- package/dist/chunk-3EQHAQXO.js +0 -112
- package/dist/chunk-3EQHAQXO.js.map +0 -1
- package/dist/chunk-3PVQ4P74.cjs +0 -66
- package/dist/chunk-3PVQ4P74.cjs.map +0 -1
- package/dist/chunk-3R6PW6HY.js +0 -30
- package/dist/chunk-3R6PW6HY.js.map +0 -1
- package/dist/chunk-5EJ2YW7L.cjs +0 -93
- package/dist/chunk-5EJ2YW7L.cjs.map +0 -1
- package/dist/chunk-5IZ57G5A.js +0 -123
- package/dist/chunk-5IZ57G5A.js.map +0 -1
- package/dist/chunk-5MG5CIEX.cjs.map +0 -1
- package/dist/chunk-5URMCCO6.js +0 -9
- package/dist/chunk-5URMCCO6.js.map +0 -1
- package/dist/chunk-5WVQ7J3E.cjs +0 -369
- package/dist/chunk-5WVQ7J3E.cjs.map +0 -1
- package/dist/chunk-6IJLWHUN.cjs +0 -44
- package/dist/chunk-6IJLWHUN.cjs.map +0 -1
- package/dist/chunk-6NJVFL2X.js +0 -60
- package/dist/chunk-6NJVFL2X.js.map +0 -1
- package/dist/chunk-6O7DYITB.js +0 -99
- package/dist/chunk-6O7DYITB.js.map +0 -1
- package/dist/chunk-6OFQWFH6.cjs +0 -22
- package/dist/chunk-6OFQWFH6.cjs.map +0 -1
- package/dist/chunk-77GT6B5L.cjs +0 -79
- package/dist/chunk-77GT6B5L.cjs.map +0 -1
- package/dist/chunk-7KAFEHUT.js +0 -36
- package/dist/chunk-7KAFEHUT.js.map +0 -1
- package/dist/chunk-7KTQNIAZ.cjs +0 -112
- package/dist/chunk-7KTQNIAZ.cjs.map +0 -1
- package/dist/chunk-ASIPMVRQ.js +0 -90
- package/dist/chunk-ASIPMVRQ.js.map +0 -1
- package/dist/chunk-BARW756O.js +0 -27
- package/dist/chunk-BARW756O.js.map +0 -1
- package/dist/chunk-BXSAJOIV.cjs +0 -90
- package/dist/chunk-BXSAJOIV.cjs.map +0 -1
- package/dist/chunk-DMTDBTI6.js +0 -39
- package/dist/chunk-DMTDBTI6.js.map +0 -1
- package/dist/chunk-DTEA33DF.cjs +0 -59
- package/dist/chunk-DTEA33DF.cjs.map +0 -1
- package/dist/chunk-DYO4HODM.cjs +0 -36
- package/dist/chunk-DYO4HODM.cjs.map +0 -1
- package/dist/chunk-E44QR6BR.js +0 -41
- package/dist/chunk-E44QR6BR.js.map +0 -1
- package/dist/chunk-EP2KTXWN.cjs +0 -39
- package/dist/chunk-EP2KTXWN.cjs.map +0 -1
- package/dist/chunk-EPEGJY6N.cjs +0 -9
- package/dist/chunk-EPEGJY6N.cjs.map +0 -1
- package/dist/chunk-EQSMHR77.js +0 -30
- package/dist/chunk-EQSMHR77.js.map +0 -1
- package/dist/chunk-FSIMJYXR.js +0 -36
- package/dist/chunk-FSIMJYXR.js.map +0 -1
- package/dist/chunk-FVEUQ5LF.js +0 -14
- package/dist/chunk-FVEUQ5LF.js.map +0 -1
- package/dist/chunk-FXGOVLZW.cjs +0 -9
- package/dist/chunk-FXGOVLZW.cjs.map +0 -1
- package/dist/chunk-IHXCFM4Q.js +0 -22
- package/dist/chunk-IHXCFM4Q.js.map +0 -1
- package/dist/chunk-JOB7STIS.js +0 -9
- package/dist/chunk-JOB7STIS.js.map +0 -1
- package/dist/chunk-KHROQTVY.js +0 -1
- package/dist/chunk-KHROQTVY.js.map +0 -1
- package/dist/chunk-L5OEF7W3.cjs +0 -14
- package/dist/chunk-L5OEF7W3.cjs.map +0 -1
- package/dist/chunk-LGDLTGAS.js +0 -66
- package/dist/chunk-LGDLTGAS.js.map +0 -1
- package/dist/chunk-MGDAIRKC.cjs +0 -82
- package/dist/chunk-MGDAIRKC.cjs.map +0 -1
- package/dist/chunk-MPF4K2EV.cjs +0 -123
- package/dist/chunk-MPF4K2EV.cjs.map +0 -1
- package/dist/chunk-N6DG5EZG.cjs +0 -156
- package/dist/chunk-N6DG5EZG.cjs.map +0 -1
- package/dist/chunk-O6IFYHDP.cjs +0 -36
- package/dist/chunk-O6IFYHDP.cjs.map +0 -1
- package/dist/chunk-OGA3YDWS.cjs +0 -112
- package/dist/chunk-OGA3YDWS.cjs.map +0 -1
- package/dist/chunk-ON4DOYVD.js +0 -369
- package/dist/chunk-ON4DOYVD.js.map +0 -1
- package/dist/chunk-PVFA6PBX.cjs +0 -60
- package/dist/chunk-PVFA6PBX.cjs.map +0 -1
- package/dist/chunk-QHCELEYE.cjs +0 -99
- package/dist/chunk-QHCELEYE.cjs.map +0 -1
- package/dist/chunk-QIXYNYYS.js +0 -82
- package/dist/chunk-QIXYNYYS.js.map +0 -1
- package/dist/chunk-QJ3BSVGV.js +0 -36
- package/dist/chunk-QJ3BSVGV.js.map +0 -1
- package/dist/chunk-QZRRIK7N.cjs +0 -41
- package/dist/chunk-QZRRIK7N.cjs.map +0 -1
- package/dist/chunk-S5RL5PJD.js +0 -44
- package/dist/chunk-S5RL5PJD.js.map +0 -1
- package/dist/chunk-SLF7WWDT.js +0 -93
- package/dist/chunk-SLF7WWDT.js.map +0 -1
- package/dist/chunk-SMDX2MXU.js +0 -13
- package/dist/chunk-SMDX2MXU.js.map +0 -1
- package/dist/chunk-TDJDKTRS.js +0 -156
- package/dist/chunk-TDJDKTRS.js.map +0 -1
- package/dist/chunk-U4OBHCIP.js +0 -59
- package/dist/chunk-U4OBHCIP.js.map +0 -1
- package/dist/chunk-UQKE6R5W.cjs +0 -27
- package/dist/chunk-UQKE6R5W.cjs.map +0 -1
- package/dist/chunk-UZGHOTKZ.js +0 -112
- package/dist/chunk-UZGHOTKZ.js.map +0 -1
- package/dist/chunk-YWCXHOSD.cjs +0 -30
- package/dist/chunk-YWCXHOSD.cjs.map +0 -1
- package/dist/chunk-ZN42AA2G.cjs +0 -1
- package/dist/chunk-ZN42AA2G.cjs.map +0 -1
- package/dist/chunk-ZOXKITU4.cjs +0 -30
- package/dist/chunk-ZOXKITU4.cjs.map +0 -1
- package/dist/error/index.cjs.map +0 -1
- package/dist/error/index.js.map +0 -1
- package/dist/error/processor.cjs.map +0 -1
- package/dist/error/processor.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/services/index.cjs.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/services/logger.cjs.map +0 -1
- package/dist/services/logger.js.map +0 -1
- package/dist/types/internal.cjs.map +0 -1
- package/dist/types/internal.js.map +0 -1
- package/dist/types/params.cjs.map +0 -1
- package/dist/types/params.js.map +0 -1
- package/dist/types/schema.cjs.map +0 -1
- package/dist/types/schema.js.map +0 -1
- package/dist/types/service.cjs.map +0 -1
- package/dist/types/service.js.map +0 -1
- package/dist/types/token.cjs.map +0 -1
- package/dist/types/token.js.map +0 -1
- package/dist/utils/api.cjs.map +0 -1
- package/dist/utils/api.js.map +0 -1
- package/dist/utils/blockchain.cjs.map +0 -1
- package/dist/utils/blockchain.js.map +0 -1
- package/dist/utils/constants.cjs.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- package/dist/utils/environment.cjs.map +0 -1
- package/dist/utils/environment.js.map +0 -1
- package/dist/utils/helpers.cjs.map +0 -1
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/signer.cjs.map +0 -1
- package/dist/utils/signer.js.map +0 -1
- package/dist/utils/test.cjs.map +0 -1
- package/dist/utils/test.js.map +0 -1
- package/src/ABI/ERC1155.json +0 -325
- package/src/ABI/ERC20.json +0 -222
- package/src/ABI/ERC721.json +0 -320
- package/src/SmartWalletSDK.test.ts +0 -31
- package/src/SmartWalletSDK.ts +0 -104
- package/src/api/CrossmintWalletService.test.ts +0 -43
- package/src/api/CrossmintWalletService.ts +0 -84
- package/src/blockchain/chains.ts +0 -57
- package/src/blockchain/rpc.ts +0 -25
- package/src/blockchain/transfer.ts +0 -54
- package/src/blockchain/wallets/EVMSmartWallet.ts +0 -157
- package/src/blockchain/wallets/SendTransactionService.test.ts +0 -159
- package/src/blockchain/wallets/SendTransactionService.ts +0 -188
- package/src/blockchain/wallets/account/cache.test.ts +0 -67
- package/src/blockchain/wallets/account/cache.ts +0 -43
- package/src/blockchain/wallets/account/config.test.ts +0 -103
- package/src/blockchain/wallets/account/config.ts +0 -116
- package/src/blockchain/wallets/account/creator.ts +0 -40
- package/src/blockchain/wallets/account/eoa.ts +0 -51
- package/src/blockchain/wallets/account/passkey.ts +0 -198
- package/src/blockchain/wallets/account/signer.ts +0 -44
- package/src/blockchain/wallets/account/strategy.ts +0 -5
- package/src/blockchain/wallets/clientDecorator.ts +0 -128
- package/src/blockchain/wallets/index.ts +0 -1
- package/src/blockchain/wallets/paymaster.ts +0 -41
- package/src/blockchain/wallets/service.ts +0 -107
- package/src/error/index.ts +0 -100
- package/src/error/processor.ts +0 -36
- package/src/index.ts +0 -47
- package/src/services/index.ts +0 -1
- package/src/services/logger.ts +0 -6
- package/src/types/internal.ts +0 -76
- package/src/types/params.ts +0 -34
- package/src/types/schema.ts +0 -63
- package/src/types/service.ts +0 -31
- package/src/types/token.ts +0 -29
- package/src/utils/api.ts +0 -39
- package/src/utils/blockchain.ts +0 -5
- package/src/utils/constants.ts +0 -9
- package/src/utils/environment.ts +0 -3
- package/src/utils/helpers.ts +0 -7
- package/src/utils/signer.ts +0 -33
- package/src/utils/test.ts +0 -24
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { CrossmintWalletService } from "@/api/CrossmintWalletService";
|
|
2
|
-
import type { Middleware } from "permissionless/actions/smartAccount";
|
|
3
|
-
import type { PimlicoBundlerClient } from "permissionless/clients/pimlico";
|
|
4
|
-
import type { EntryPoint } from "permissionless/types/entrypoint";
|
|
5
|
-
|
|
6
|
-
import type { UserParams } from "../../types/params";
|
|
7
|
-
import { usesGelatoBundler } from "../../utils/blockchain";
|
|
8
|
-
import type { SmartWalletChain } from "../chains";
|
|
9
|
-
|
|
10
|
-
export function usePaymaster(chain: SmartWalletChain) {
|
|
11
|
-
return !usesGelatoBundler(chain);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function paymasterMiddleware({
|
|
15
|
-
bundlerClient,
|
|
16
|
-
entryPoint,
|
|
17
|
-
chain,
|
|
18
|
-
walletService,
|
|
19
|
-
user,
|
|
20
|
-
}: {
|
|
21
|
-
bundlerClient: PimlicoBundlerClient<EntryPoint>;
|
|
22
|
-
entryPoint: EntryPoint;
|
|
23
|
-
chain: SmartWalletChain;
|
|
24
|
-
walletService: CrossmintWalletService;
|
|
25
|
-
user: UserParams;
|
|
26
|
-
}): Middleware<EntryPoint> {
|
|
27
|
-
return {
|
|
28
|
-
middleware: {
|
|
29
|
-
gasPrice: async () => (await bundlerClient.getUserOperationGasPrice()).fast,
|
|
30
|
-
sponsorUserOperation: async ({ userOperation }) => {
|
|
31
|
-
const { sponsorUserOpParams } = await walletService.sponsorUserOperation(
|
|
32
|
-
user,
|
|
33
|
-
userOperation,
|
|
34
|
-
entryPoint,
|
|
35
|
-
chain
|
|
36
|
-
);
|
|
37
|
-
return sponsorUserOpParams;
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { KernelSmartAccount } from "@zerodev/sdk";
|
|
2
|
-
import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, createSmartAccountClient } from "permissionless";
|
|
3
|
-
import { createPimlicoBundlerClient } from "permissionless/clients/pimlico";
|
|
4
|
-
import type { EntryPoint } from "permissionless/types/entrypoint";
|
|
5
|
-
import { type HttpTransport, createPublicClient, http } from "viem";
|
|
6
|
-
|
|
7
|
-
import { blockchainToChainId } from "@crossmint/common-sdk-base";
|
|
8
|
-
|
|
9
|
-
import type { CrossmintWalletService } from "../../api/CrossmintWalletService";
|
|
10
|
-
import type { SmartWalletClient } from "../../types/internal";
|
|
11
|
-
import type { UserParams, WalletParams } from "../../types/params";
|
|
12
|
-
import { CURRENT_VERSION, ZERO_DEV_TYPE } from "../../utils/constants";
|
|
13
|
-
import { type SmartWalletChain, viemNetworks } from "../chains";
|
|
14
|
-
import { getAlchemyRPC, getPimlicoBundlerRPC } from "../rpc";
|
|
15
|
-
import { EVMSmartWallet } from "./EVMSmartWallet";
|
|
16
|
-
import type { AccountConfigService } from "./account/config";
|
|
17
|
-
import type { AccountCreator } from "./account/creator";
|
|
18
|
-
import type { ClientDecorator } from "./clientDecorator";
|
|
19
|
-
import { paymasterMiddleware, usePaymaster } from "./paymaster";
|
|
20
|
-
|
|
21
|
-
export class SmartWalletService {
|
|
22
|
-
constructor(
|
|
23
|
-
private readonly crossmintService: CrossmintWalletService,
|
|
24
|
-
private readonly accountConfigService: AccountConfigService,
|
|
25
|
-
private readonly accountCreator: AccountCreator,
|
|
26
|
-
private readonly clientDecorator: ClientDecorator
|
|
27
|
-
) {}
|
|
28
|
-
|
|
29
|
-
public async getOrCreate(
|
|
30
|
-
user: UserParams,
|
|
31
|
-
chain: SmartWalletChain,
|
|
32
|
-
walletParams: WalletParams
|
|
33
|
-
): Promise<EVMSmartWallet> {
|
|
34
|
-
const {
|
|
35
|
-
config: { entryPointVersion, kernelVersion, existing, userWithId },
|
|
36
|
-
cached,
|
|
37
|
-
} = await this.accountConfigService.get(user, chain);
|
|
38
|
-
|
|
39
|
-
const publicClient = createPublicClient({ transport: http(getAlchemyRPC(chain)) });
|
|
40
|
-
|
|
41
|
-
const { account, signerConfig } = await this.accountCreator.get({
|
|
42
|
-
chain,
|
|
43
|
-
walletParams,
|
|
44
|
-
publicClient,
|
|
45
|
-
user: userWithId,
|
|
46
|
-
entryPoint: entryPointVersion === "v0.6" ? ENTRYPOINT_ADDRESS_V06 : ENTRYPOINT_ADDRESS_V07,
|
|
47
|
-
kernelVersion,
|
|
48
|
-
existing,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (existing == null) {
|
|
52
|
-
await this.crossmintService.idempotentCreateSmartWallet(user, {
|
|
53
|
-
type: ZERO_DEV_TYPE,
|
|
54
|
-
smartContractWalletAddress: account.address,
|
|
55
|
-
signerData: signerConfig.data,
|
|
56
|
-
version: CURRENT_VERSION,
|
|
57
|
-
baseLayer: "evm",
|
|
58
|
-
chainId: blockchainToChainId(chain),
|
|
59
|
-
entryPointVersion,
|
|
60
|
-
kernelVersion,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!cached) {
|
|
65
|
-
this.accountConfigService.cache({
|
|
66
|
-
entryPointVersion,
|
|
67
|
-
kernelVersion,
|
|
68
|
-
user: userWithId,
|
|
69
|
-
existing: { address: account.address, signerConfig },
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return new EVMSmartWallet(
|
|
74
|
-
{ wallet: this.smartAccountClient(chain, account, user), public: publicClient },
|
|
75
|
-
chain,
|
|
76
|
-
this.crossmintService
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private smartAccountClient(
|
|
81
|
-
chain: SmartWalletChain,
|
|
82
|
-
account: KernelSmartAccount<EntryPoint, HttpTransport>,
|
|
83
|
-
user: UserParams
|
|
84
|
-
): SmartWalletClient {
|
|
85
|
-
const transport = http(getPimlicoBundlerRPC(chain));
|
|
86
|
-
const bundlerConfig = { chain: viemNetworks[chain], entryPoint: account.entryPoint };
|
|
87
|
-
const bundlerClient = createPimlicoBundlerClient({ ...bundlerConfig, transport });
|
|
88
|
-
const smartAccountClient: SmartWalletClient = createSmartAccountClient({
|
|
89
|
-
account,
|
|
90
|
-
bundlerTransport: transport,
|
|
91
|
-
...bundlerConfig,
|
|
92
|
-
...(usePaymaster(chain) &&
|
|
93
|
-
paymasterMiddleware({
|
|
94
|
-
bundlerClient,
|
|
95
|
-
entryPoint: account.entryPoint,
|
|
96
|
-
chain,
|
|
97
|
-
walletService: this.crossmintService,
|
|
98
|
-
user,
|
|
99
|
-
})),
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return this.clientDecorator.decorate({
|
|
103
|
-
crossmintChain: chain,
|
|
104
|
-
smartAccountClient,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
package/src/error/index.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { CrossmintSDKError, SmartWalletErrorCode } from "@crossmint/client-sdk-base";
|
|
2
|
-
|
|
3
|
-
import type { PasskeyDisplay, SignerDisplay } from "../types/service";
|
|
4
|
-
|
|
5
|
-
export class SmartWalletError extends CrossmintSDKError {
|
|
6
|
-
constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrorCode.UNCATEGORIZED) {
|
|
7
|
-
super(message, code, details);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class AdminMismatchError extends SmartWalletError {
|
|
12
|
-
public readonly required: SignerDisplay;
|
|
13
|
-
public readonly used?: SignerDisplay;
|
|
14
|
-
|
|
15
|
-
constructor(message: string, required: SignerDisplay, used?: SignerDisplay) {
|
|
16
|
-
super(message, SmartWalletErrorCode.ADMIN_MISMATCH);
|
|
17
|
-
this.required = required;
|
|
18
|
-
this.used = used;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export class PasskeyMismatchError extends SmartWalletError {
|
|
23
|
-
public readonly required: PasskeyDisplay;
|
|
24
|
-
public readonly used?: PasskeyDisplay;
|
|
25
|
-
|
|
26
|
-
constructor(message: string, required: PasskeyDisplay, used?: PasskeyDisplay) {
|
|
27
|
-
super(message, SmartWalletErrorCode.PASSKEY_MISMATCH);
|
|
28
|
-
this.required = required;
|
|
29
|
-
this.used = used;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export class UserWalletAlreadyCreatedError extends SmartWalletError {
|
|
34
|
-
public readonly code = SmartWalletErrorCode.USER_WALLET_ALREADY_CREATED;
|
|
35
|
-
|
|
36
|
-
constructor(userId: string) {
|
|
37
|
-
super(`The user with userId ${userId.toString()} already has a wallet created for this project`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class PasskeyPromptError extends SmartWalletError {
|
|
42
|
-
public passkeyName: string;
|
|
43
|
-
|
|
44
|
-
constructor(passkeyName: string) {
|
|
45
|
-
super(
|
|
46
|
-
`Prompt was either cancelled or timed out for passkey ${passkeyName}`,
|
|
47
|
-
undefined,
|
|
48
|
-
SmartWalletErrorCode.PASSKEY_PROMPT
|
|
49
|
-
);
|
|
50
|
-
this.passkeyName = passkeyName;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class PasskeyRegistrationError extends SmartWalletError {
|
|
55
|
-
public passkeyName: string;
|
|
56
|
-
|
|
57
|
-
constructor(passkeyName: string) {
|
|
58
|
-
super(
|
|
59
|
-
`Registration for passkey ${passkeyName} failed, either the registration took too long, or passkey signature vaildation failed.`,
|
|
60
|
-
undefined,
|
|
61
|
-
SmartWalletErrorCode.PASSKEY_REGISTRATION
|
|
62
|
-
);
|
|
63
|
-
this.passkeyName = passkeyName;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export class PasskeyIncompatibleAuthenticatorError extends SmartWalletError {
|
|
68
|
-
public passkeyName: string;
|
|
69
|
-
|
|
70
|
-
constructor(passkeyName: string) {
|
|
71
|
-
super(
|
|
72
|
-
`User selected authenticator for passkey ${passkeyName} is not compatible with Crossmint's Smart Wallets.`,
|
|
73
|
-
undefined,
|
|
74
|
-
SmartWalletErrorCode.PASSKEY_INCOMPATIBLE_AUTHENTICATOR
|
|
75
|
-
);
|
|
76
|
-
this.passkeyName = passkeyName;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class ConfigError extends SmartWalletError {
|
|
81
|
-
constructor(message: string) {
|
|
82
|
-
super(message, undefined, SmartWalletErrorCode.WALLET_CONFIG);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export class AdminAlreadyUsedError extends ConfigError {
|
|
87
|
-
public readonly code = SmartWalletErrorCode.ADMIN_SIGNER_ALREADY_USED;
|
|
88
|
-
constructor() {
|
|
89
|
-
super("This signer was already used to create another wallet. Please use a different signer.");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export class SmartWalletsNotEnabledError extends ConfigError {
|
|
94
|
-
public readonly code = SmartWalletErrorCode.SMART_WALLETS_NOT_ENABLED;
|
|
95
|
-
constructor() {
|
|
96
|
-
super(
|
|
97
|
-
"Smart wallets are not enabled for this project. They can be enabled on the project settings page in the developer console."
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
}
|
package/src/error/processor.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BaseError, stringify } from "viem";
|
|
2
|
-
|
|
3
|
-
import type { SDKLogger } from "@crossmint/client-sdk-base";
|
|
4
|
-
|
|
5
|
-
import { SmartWalletError } from ".";
|
|
6
|
-
import { SDK_VERSION } from "../utils/constants";
|
|
7
|
-
|
|
8
|
-
export class ErrorProcessor {
|
|
9
|
-
constructor(private readonly logger: SDKLogger) {}
|
|
10
|
-
|
|
11
|
-
public map(error: unknown, fallback: SmartWalletError): SmartWalletError | BaseError {
|
|
12
|
-
this.record(error);
|
|
13
|
-
|
|
14
|
-
if (error instanceof SmartWalletError) {
|
|
15
|
-
return error;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Allow viem errors, which are generally pretty friendly.
|
|
19
|
-
if (error instanceof BaseError) {
|
|
20
|
-
return error;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return fallback;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private record(error: unknown) {
|
|
27
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
28
|
-
this.logger.error(`Smart Wallet SDK Error: ${message}`, {
|
|
29
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
30
|
-
name: error instanceof Error ? error.name : "UnknownError",
|
|
31
|
-
details: stringify(error),
|
|
32
|
-
domain: window.location.hostname,
|
|
33
|
-
sdk_version: SDK_VERSION,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export { blockchainToChainId, EVMBlockchainIncludingTestnet as Chain } from "@crossmint/common-sdk-base";
|
|
2
|
-
|
|
3
|
-
export { EVMSmartWallet } from "./blockchain/wallets/EVMSmartWallet";
|
|
4
|
-
|
|
5
|
-
export type {
|
|
6
|
-
SmartWalletSDKInitParams,
|
|
7
|
-
UserParams,
|
|
8
|
-
ViemAccount,
|
|
9
|
-
PasskeySigner,
|
|
10
|
-
ExternalSigner,
|
|
11
|
-
WalletParams,
|
|
12
|
-
} from "./types/params";
|
|
13
|
-
|
|
14
|
-
export type { SmartWalletChain as EVMSmartWalletChain } from "./blockchain/chains";
|
|
15
|
-
|
|
16
|
-
export type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from "./types/token";
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
SmartWalletError,
|
|
20
|
-
UserWalletAlreadyCreatedError,
|
|
21
|
-
AdminAlreadyUsedError,
|
|
22
|
-
AdminMismatchError,
|
|
23
|
-
PasskeyMismatchError,
|
|
24
|
-
PasskeyPromptError,
|
|
25
|
-
PasskeyRegistrationError,
|
|
26
|
-
PasskeyIncompatibleAuthenticatorError,
|
|
27
|
-
ConfigError,
|
|
28
|
-
SmartWalletsNotEnabledError,
|
|
29
|
-
} from "./error";
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
EVMSendTransactionError,
|
|
33
|
-
EVMSendTransactionExecutionRevertedError,
|
|
34
|
-
} from "./blockchain/wallets/SendTransactionService";
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
SmartWalletErrorCode,
|
|
38
|
-
CrossmintSDKError,
|
|
39
|
-
CrossmintServiceError,
|
|
40
|
-
JWTDecryptionError,
|
|
41
|
-
JWTExpiredError,
|
|
42
|
-
JWTIdentifierError,
|
|
43
|
-
JWTInvalidError,
|
|
44
|
-
NotAuthorizedError,
|
|
45
|
-
} from "@crossmint/client-sdk-base";
|
|
46
|
-
|
|
47
|
-
export { SmartWalletSDK } from "./SmartWalletSDK";
|
package/src/services/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./logger";
|
package/src/services/logger.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SDKLogger, getBrowserLogger } from "@crossmint/client-sdk-base";
|
|
2
|
-
|
|
3
|
-
import { SCW_SERVICE } from "../utils/constants";
|
|
4
|
-
|
|
5
|
-
export const scwLogger = new SDKLogger(SCW_SERVICE);
|
|
6
|
-
export const scwDatadogLogger = new SDKLogger(SCW_SERVICE, getBrowserLogger(SCW_SERVICE, { onlyDatadog: true }));
|
package/src/types/internal.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { KernelSmartAccount } from "@zerodev/sdk";
|
|
2
|
-
import type { SmartAccountClient } from "permissionless";
|
|
3
|
-
import type { SmartAccount } from "permissionless/accounts";
|
|
4
|
-
import type { EntryPoint } from "permissionless/types/entrypoint";
|
|
5
|
-
import type { Address, Chain, HttpTransport, PublicClient } from "viem";
|
|
6
|
-
|
|
7
|
-
import type { SmartWalletChain } from "../blockchain/chains";
|
|
8
|
-
import type { EOASignerConfig, PasskeySignerConfig, SignerConfig } from "../blockchain/wallets/account/signer";
|
|
9
|
-
import { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from "../utils/constants";
|
|
10
|
-
import type { ExternalSigner, PasskeySigner, UserParams, WalletParams } from "./params";
|
|
11
|
-
|
|
12
|
-
export type SupportedKernelVersion = (typeof SUPPORTED_KERNEL_VERSIONS)[number];
|
|
13
|
-
export function isSupportedKernelVersion(version: string): version is SupportedKernelVersion {
|
|
14
|
-
return SUPPORTED_KERNEL_VERSIONS.includes(version as any);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type SupportedEntryPointVersion = (typeof SUPPORTED_ENTRYPOINT_VERSIONS)[number];
|
|
18
|
-
export function isSupportedEntryPointVersion(version: string): version is SupportedEntryPointVersion {
|
|
19
|
-
return SUPPORTED_ENTRYPOINT_VERSIONS.includes(version as any);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface PreExistingWalletProperties {
|
|
23
|
-
signerConfig: SignerConfig;
|
|
24
|
-
address: Address;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface WalletCreationContext {
|
|
28
|
-
user: UserParams & { id: string };
|
|
29
|
-
chain: SmartWalletChain;
|
|
30
|
-
publicClient: PublicClient<HttpTransport>;
|
|
31
|
-
walletParams: WalletParams;
|
|
32
|
-
entryPoint: EntryPoint;
|
|
33
|
-
kernelVersion: SupportedKernelVersion;
|
|
34
|
-
existing?: PreExistingWalletProperties;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface PasskeyCreationContext extends WalletCreationContext {
|
|
38
|
-
walletParams: WalletParams & { signer: PasskeySigner };
|
|
39
|
-
existing?: { signerConfig: PasskeySignerConfig; address: Address };
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface EOACreationContext extends WalletCreationContext {
|
|
43
|
-
walletParams: WalletParams & { signer: ExternalSigner };
|
|
44
|
-
existing?: { signerConfig: EOASignerConfig; address: Address };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function isPasskeyWalletParams(params: WalletParams): params is WalletParams & { signer: PasskeySigner } {
|
|
48
|
-
return "signer" in params && "type" in params.signer && params.signer.type === "PASSKEY";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function isPasskeyCreationContext(params: WalletCreationContext): params is PasskeyCreationContext {
|
|
52
|
-
const signerIsPasskeyOrUndefined = params.existing == null || params.existing.signerConfig.type === "passkeys";
|
|
53
|
-
|
|
54
|
-
return isPasskeyWalletParams(params.walletParams) && signerIsPasskeyOrUndefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function isEOAWalletParams(params: WalletParams): params is WalletParams & { signer: ExternalSigner } {
|
|
58
|
-
return (
|
|
59
|
-
"signer" in params &&
|
|
60
|
-
(("type" in params.signer && params.signer.type === "VIEM_ACCOUNT") ||
|
|
61
|
-
("request" in params.signer && typeof params.signer.request === "function"))
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function isEOACreationContext(params: WalletCreationContext): params is EOACreationContext {
|
|
66
|
-
const signerIsEOAOrUndefined = params.existing == null || params.existing.signerConfig.type === "eoa";
|
|
67
|
-
|
|
68
|
-
return isEOAWalletParams(params.walletParams) && signerIsEOAOrUndefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface AccountAndSigner {
|
|
72
|
-
account: KernelSmartAccount<EntryPoint, HttpTransport>;
|
|
73
|
-
signerConfig: SignerConfig;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type SmartWalletClient = SmartAccountClient<EntryPoint, HttpTransport, Chain, SmartAccount<EntryPoint>>;
|
package/src/types/params.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { EIP1193Provider, LocalAccount } from "viem";
|
|
2
|
-
|
|
3
|
-
export type SmartWalletSDKInitParams = {
|
|
4
|
-
clientApiKey: string;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type UserParams = {
|
|
8
|
-
jwt: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ViemAccount = {
|
|
12
|
-
type: "VIEM_ACCOUNT";
|
|
13
|
-
account: LocalAccount & { source: "custom" };
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type PasskeySigner = {
|
|
17
|
-
type: "PASSKEY";
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Displayed to the user during passkey registration or signing prompts.
|
|
21
|
-
* If not provided, a default name identifier within the JWT
|
|
22
|
-
* that is specified in the project settings (typically `sub`) will be used.
|
|
23
|
-
*/
|
|
24
|
-
passkeyName?: string;
|
|
25
|
-
onPrePasskeyRegistration?: () => Promise<void> | void;
|
|
26
|
-
onPasskeyRegistrationError?: (error: unknown) => Promise<void>;
|
|
27
|
-
onFirstTimePasskeySigning?: () => Promise<void> | void;
|
|
28
|
-
onFirstTimePasskeySigningError?: (error: unknown) => Promise<void>;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type ExternalSigner = EIP1193Provider | ViemAccount;
|
|
32
|
-
export interface WalletParams {
|
|
33
|
-
signer: ExternalSigner | PasskeySigner;
|
|
34
|
-
}
|
package/src/types/schema.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { PasskeyValidatorContractVersion } from "@zerodev/passkey-validator";
|
|
2
|
-
import { isAddress, isHex } from "viem";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
5
|
-
import { SUPPORTED_ENTRYPOINT_VERSIONS, SUPPORTED_KERNEL_VERSIONS } from "../utils/constants";
|
|
6
|
-
|
|
7
|
-
const HexSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isHex(val as string), {
|
|
8
|
-
message: "Invalid hex string",
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const evmAddressSchema = z.custom<`0x${string}`>((val): val is `0x${string}` => isAddress(val as string), {
|
|
12
|
-
message: "Invalid evm address",
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const EOASignerDataSchema = z.object({
|
|
16
|
-
eoaAddress: evmAddressSchema,
|
|
17
|
-
type: z.literal("eoa"),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export const PasskeyValidatorSerializedDataSchema = z.object({
|
|
21
|
-
entryPoint: evmAddressSchema,
|
|
22
|
-
validatorAddress: evmAddressSchema,
|
|
23
|
-
pubKeyX: z.string(),
|
|
24
|
-
pubKeyY: z.string(),
|
|
25
|
-
authenticatorIdHash: HexSchema,
|
|
26
|
-
authenticatorId: z.string(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const PasskeySignerDataSchema = PasskeyValidatorSerializedDataSchema.extend({
|
|
30
|
-
passkeyName: z.string(),
|
|
31
|
-
validatorContractVersion: z.nativeEnum(PasskeyValidatorContractVersion),
|
|
32
|
-
domain: z.string(),
|
|
33
|
-
type: z.literal("passkeys"),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const SignerDataSchema = z.discriminatedUnion("type", [PasskeySignerDataSchema, EOASignerDataSchema]);
|
|
37
|
-
|
|
38
|
-
export const SmartWalletConfigSchema = z.object({
|
|
39
|
-
kernelVersion: z.enum(SUPPORTED_KERNEL_VERSIONS, {
|
|
40
|
-
errorMap: (_, ctx) => ({
|
|
41
|
-
message: `Unsupported kernel version. Supported versions: ${SUPPORTED_KERNEL_VERSIONS.join(
|
|
42
|
-
", "
|
|
43
|
-
)}. Version used: ${ctx.data}. Please contact support`,
|
|
44
|
-
}),
|
|
45
|
-
}),
|
|
46
|
-
entryPointVersion: z.enum(SUPPORTED_ENTRYPOINT_VERSIONS, {
|
|
47
|
-
errorMap: (_, ctx) => ({
|
|
48
|
-
message: `Unsupported entry point version. Supported versions: ${SUPPORTED_ENTRYPOINT_VERSIONS.join(
|
|
49
|
-
", "
|
|
50
|
-
)}. Version used: ${ctx.data}. Please contact support`,
|
|
51
|
-
}),
|
|
52
|
-
}),
|
|
53
|
-
userId: z.string().min(1),
|
|
54
|
-
signers: z
|
|
55
|
-
.array(
|
|
56
|
-
z.object({
|
|
57
|
-
signerData: SignerDataSchema,
|
|
58
|
-
})
|
|
59
|
-
)
|
|
60
|
-
.min(0)
|
|
61
|
-
.max(1, "Invalid wallet signer configuration. Please contact support"),
|
|
62
|
-
smartContractWalletAddress: evmAddressSchema.optional(),
|
|
63
|
-
});
|
package/src/types/service.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
|
|
3
|
-
import type { SupportedEntryPointVersion, SupportedKernelVersion } from "./internal";
|
|
4
|
-
import type {
|
|
5
|
-
EOASignerDataSchema,
|
|
6
|
-
PasskeySignerDataSchema,
|
|
7
|
-
PasskeyValidatorSerializedDataSchema,
|
|
8
|
-
SignerDataSchema,
|
|
9
|
-
SmartWalletConfigSchema,
|
|
10
|
-
} from "./schema";
|
|
11
|
-
|
|
12
|
-
export type EOASignerData = z.infer<typeof EOASignerDataSchema>;
|
|
13
|
-
export type PasskeyValidatorSerializedData = z.infer<typeof PasskeyValidatorSerializedDataSchema>;
|
|
14
|
-
export type PasskeySignerData = z.infer<typeof PasskeySignerDataSchema>;
|
|
15
|
-
export type SmartWalletConfig = z.infer<typeof SmartWalletConfigSchema>;
|
|
16
|
-
export type SignerData = z.infer<typeof SignerDataSchema>;
|
|
17
|
-
|
|
18
|
-
export type PasskeyDisplay = Pick<PasskeySignerData, "type" | "passkeyName" | "pubKeyX" | "pubKeyY">;
|
|
19
|
-
export type SignerDisplay = EOASignerData | PasskeyDisplay;
|
|
20
|
-
|
|
21
|
-
export type StoreSmartWalletParams = {
|
|
22
|
-
type: string;
|
|
23
|
-
smartContractWalletAddress: string;
|
|
24
|
-
signerData: SignerData;
|
|
25
|
-
sessionKeySignerAddress?: string;
|
|
26
|
-
version: number;
|
|
27
|
-
baseLayer: string;
|
|
28
|
-
chainId: number;
|
|
29
|
-
entryPointVersion: SupportedEntryPointVersion;
|
|
30
|
-
kernelVersion: SupportedKernelVersion;
|
|
31
|
-
};
|
package/src/types/token.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
|
|
3
|
-
import type { SmartWalletChain } from "../blockchain/chains";
|
|
4
|
-
|
|
5
|
-
export interface EVMToken {
|
|
6
|
-
chain: SmartWalletChain;
|
|
7
|
-
contractAddress: Address;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface NFTEVMToken extends EVMToken {
|
|
11
|
-
tokenId: string;
|
|
12
|
-
type: "nft";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface SFTEVMToken extends EVMToken {
|
|
16
|
-
tokenId: string;
|
|
17
|
-
type: "sft";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface ERC2OEVMToken extends EVMToken {
|
|
21
|
-
type: "ft";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type TokenType = "nft" | "sft" | "ft";
|
|
25
|
-
|
|
26
|
-
export type ERC20TransferType = { token: ERC2OEVMToken; amount: bigint };
|
|
27
|
-
export type SFTTransferType = { token: SFTEVMToken; quantity: number };
|
|
28
|
-
export type NFTTransferType = { token: NFTEVMToken };
|
|
29
|
-
export type TransferType = ERC20TransferType | SFTTransferType | NFTTransferType;
|
package/src/utils/api.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { toHex } from "viem";
|
|
2
|
-
|
|
3
|
-
function mapObject(data: any, fn: (value: unknown) => { value: unknown; replace: boolean }): any {
|
|
4
|
-
const result = fn(data);
|
|
5
|
-
if (result.replace) {
|
|
6
|
-
return result.value;
|
|
7
|
-
}
|
|
8
|
-
if (Array.isArray(data)) {
|
|
9
|
-
return data.map((item) => mapObject(item, fn));
|
|
10
|
-
} else if (data !== null && typeof data === "object") {
|
|
11
|
-
return Object.fromEntries(Object.entries(data).map(([key, value]) => [key, mapObject(value, fn)]));
|
|
12
|
-
}
|
|
13
|
-
return result.value;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function bigintsToHex(data: any): any {
|
|
17
|
-
return mapObject(data, (value) => {
|
|
18
|
-
if (typeof value === "bigint") {
|
|
19
|
-
return { value: toHex(value), replace: true };
|
|
20
|
-
}
|
|
21
|
-
return { value, replace: false };
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function parseBigintAPIResponse(data: any): any {
|
|
26
|
-
return mapObject(data, (value) => {
|
|
27
|
-
if (
|
|
28
|
-
value != null &&
|
|
29
|
-
typeof value == "object" &&
|
|
30
|
-
"__xm_serializedType" in value &&
|
|
31
|
-
"value" in value &&
|
|
32
|
-
value.__xm_serializedType === "bigint" &&
|
|
33
|
-
typeof value.value === "string"
|
|
34
|
-
) {
|
|
35
|
-
return { value: BigInt(value.value), replace: true };
|
|
36
|
-
}
|
|
37
|
-
return { value, replace: false };
|
|
38
|
-
});
|
|
39
|
-
}
|
package/src/utils/blockchain.ts
DELETED
package/src/utils/constants.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { version } from "../../package.json";
|
|
2
|
-
|
|
3
|
-
export const ZERO_DEV_TYPE = "ZeroDev";
|
|
4
|
-
export const CURRENT_VERSION = 0;
|
|
5
|
-
export const SCW_SERVICE = "SCW_SDK";
|
|
6
|
-
export const SDK_VERSION = version;
|
|
7
|
-
export const API_VERSION = "2024-06-09";
|
|
8
|
-
export const SUPPORTED_KERNEL_VERSIONS = ["0.3.1", "0.3.0", "0.2.4"] as const;
|
|
9
|
-
export const SUPPORTED_ENTRYPOINT_VERSIONS = ["v0.6", "v0.7"] as const;
|
package/src/utils/environment.ts
DELETED
package/src/utils/helpers.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export function isEmpty(str: string | undefined | null): str is undefined | null {
|
|
2
|
-
return !str || str.length === 0 || str.trim().length === 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function equalsIgnoreCase(a?: string, b?: string): boolean {
|
|
6
|
-
return a?.toLowerCase() === b?.toLowerCase();
|
|
7
|
-
}
|