@crossmint/client-sdk-smart-wallet 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,46 +1,47 @@
1
1
  {
2
- "name": "@crossmint/client-sdk-smart-wallet",
3
- "version": "0.1.0",
4
- "repository": "https://github.com/Crossmint/crossmint-sdk",
5
- "license": "Apache-2.0",
6
- "author": "Paella Labs Inc",
7
- "sideEffects": false,
8
- "type": "module",
9
- "exports": {
10
- "import": "./dist/index.js",
11
- "require": "./dist/index.cjs"
12
- },
13
- "main": "./dist/index.cjs",
14
- "module": "./dist/index.js",
15
- "types": "./dist/index.d.ts",
16
- "files": [
17
- "dist",
18
- "src",
19
- "LICENSE"
20
- ],
21
- "scripts": {
22
- "build": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --minify --dts --sourcemap",
23
- "build-no-minify": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --dts --sourcemap",
24
- "dev": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --dts --sourcemap --watch",
25
- "link:common-sdk-base": "yalc add @crossmint/common-sdk-base && yalc link @crossmint/common-sdk-base && pnpm i && pnpm build && yalc push",
26
- "test": "cross-env NODE_ENV=test jest",
27
- "test-coverage": "cross-env NODE_ENV=test jest --coverage",
28
- "unlink:common-sdk-base": "yalc remove @crossmint/common-sdk-base && pnpm i"
29
- },
30
- "dependencies": {
31
- "@crossmint/common-sdk-base": "0.0.13",
32
- "@datadog/browser-logs": "4.42.2",
33
- "@zerodev/ecdsa-validator": "5.3.1",
34
- "@zerodev/passkey-validator": "5.4.0",
35
- "@zerodev/sdk": "5.3.3",
36
- "@zerodev/webauthn-key": "5.3.1",
37
- "permissionless": "0.1.36",
38
- "uuid": "10.0.0",
39
- "viem": "2.17.5"
40
- },
41
- "devDependencies": {
42
- "@playwright/test": "^1.41.2",
43
- "@types/node": "20.12.7",
44
- "@types/uuid": "10.0.0"
45
- }
46
- }
2
+ "name": "@crossmint/client-sdk-smart-wallet",
3
+ "version": "0.1.2",
4
+ "repository": "https://github.com/Crossmint/crossmint-sdk",
5
+ "license": "Apache-2.0",
6
+ "author": "Paella Labs Inc",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist",
18
+ "src",
19
+ "LICENSE"
20
+ ],
21
+ "dependencies": {
22
+ "@datadog/browser-logs": "4.42.2",
23
+ "@zerodev/ecdsa-validator": "5.3.1",
24
+ "@zerodev/passkey-validator": "5.4.0",
25
+ "@zerodev/sdk": "5.3.3",
26
+ "@zerodev/webauthn-key": "5.3.1",
27
+ "permissionless": "0.1.36",
28
+ "uuid": "10.0.0",
29
+ "viem": "2.17.5",
30
+ "@crossmint/common-sdk-base": "0.1.0"
31
+ },
32
+ "devDependencies": {
33
+ "@playwright/test": "^1.41.2",
34
+ "@types/node": "20.12.7",
35
+ "@types/uuid": "10.0.0"
36
+ },
37
+ "scripts": {
38
+ "build": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --minify --dts --sourcemap",
39
+ "build-no-minify": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --dts --sourcemap",
40
+ "dev": "tsup src/index.ts --clean --format esm,cjs --outDir ./dist --dts --sourcemap --watch",
41
+ "link:common-sdk-base": "yalc add @crossmint/common-sdk-base && yalc link @crossmint/common-sdk-base && pnpm i && pnpm build && yalc push",
42
+ "test": "cross-env NODE_ENV=test jest",
43
+ "test-coverage": "cross-env NODE_ENV=test jest --coverage",
44
+ "test:starter": "pnpm run build && pnpm --filter @crossmint/client-sdk-smart-wallet-react-starter exec playwright test",
45
+ "unlink:common-sdk-base": "yalc remove @crossmint/common-sdk-base && pnpm i"
46
+ }
47
+ }
@@ -1,8 +1,9 @@
1
1
  import { stringify } from "viem";
2
2
 
3
- import { EVMBlockchainIncludingTestnet, validateAPIKey } from "@crossmint/common-sdk-base";
3
+ import { validateAPIKey } from "@crossmint/common-sdk-base";
4
4
 
5
5
  import { CrossmintWalletService } from "./api/CrossmintWalletService";
6
+ import { SmartWalletChain } from "./blockchain/chains";
6
7
  import type { EVMSmartWallet } from "./blockchain/wallets";
7
8
  import { ClientDecorator } from "./blockchain/wallets/clientDecorator";
8
9
  import { SmartWalletService } from "./blockchain/wallets/service";
@@ -54,7 +55,7 @@ export class SmartWalletSDK extends LoggerWrapper {
54
55
  */
55
56
  async getOrCreateWallet(
56
57
  user: UserParams,
57
- chain: EVMBlockchainIncludingTestnet,
58
+ chain: SmartWalletChain,
58
59
  walletParams: WalletParams = { signer: { type: "PASSKEY" } }
59
60
  ): Promise<EVMSmartWallet> {
60
61
  return logPerformance(
@@ -64,6 +64,9 @@ export class APIErrorService {
64
64
  throw new CrossmintServiceError(body.message, response.status);
65
65
  }
66
66
  } catch (e) {
67
+ if (e instanceof SmartWalletSDKError) {
68
+ throw e;
69
+ }
67
70
  console.error("Error parsing response", e);
68
71
  }
69
72
 
@@ -1,13 +1,10 @@
1
+ import { SmartWalletChain } from "@/blockchain/chains";
1
2
  import { SignerData, StoreSmartWalletParams } from "@/types/API";
2
3
  import type { UserParams } from "@/types/Config";
3
4
  import { API_VERSION } from "@/utils/constants";
4
5
 
5
- import type { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
6
-
7
6
  import { BaseCrossmintService } from "./BaseCrossmintService";
8
7
 
9
- export { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
10
-
11
8
  export class CrossmintWalletService extends BaseCrossmintService {
12
9
  async idempotentCreateSmartWallet(user: UserParams, input: StoreSmartWalletParams) {
13
10
  return this.fetchCrossmintAPI(
@@ -20,7 +17,7 @@ export class CrossmintWalletService extends BaseCrossmintService {
20
17
 
21
18
  async getSmartWalletConfig(
22
19
  user: UserParams,
23
- chain: EVMBlockchainIncludingTestnet
20
+ chain: SmartWalletChain
24
21
  ): Promise<{
25
22
  kernelVersion: string;
26
23
  entryPointVersion: string;
@@ -36,7 +33,7 @@ export class CrossmintWalletService extends BaseCrossmintService {
36
33
  );
37
34
  }
38
35
 
39
- async fetchNFTs(address: string, chain: EVMBlockchainIncludingTestnet) {
36
+ async fetchNFTs(address: string, chain: SmartWalletChain) {
40
37
  return this.fetchCrossmintAPI(
41
38
  `v1-alpha1/wallets/${chain}:${address}/nfts`,
42
39
  { method: "GET" },
@@ -0,0 +1,43 @@
1
+ import { BUNDLER_RPC } from "@/utils/constants";
2
+ import { Chain, base, baseSepolia, polygon, polygonAmoy } from "viem/chains";
3
+
4
+ import { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from "@crossmint/common-sdk-base";
5
+
6
+ export const SmartWalletTestnet = {
7
+ BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,
8
+ POLYGON_AMOY: Blockchain.POLYGON_AMOY,
9
+ } as const;
10
+ export type SmartWalletTestnet = ObjectValues<typeof SmartWalletTestnet>;
11
+ export const SMART_WALLET_TESTNETS = objectValues(SmartWalletTestnet);
12
+
13
+ export const SmartWalletMainnet = {
14
+ BASE: Blockchain.BASE,
15
+ POLYGON: Blockchain.POLYGON,
16
+ } as const;
17
+ export type SmartWalletMainnet = ObjectValues<typeof SmartWalletMainnet>;
18
+ export const SMART_WALLET_MAINNETS = objectValues(SmartWalletMainnet);
19
+
20
+ export const SmartWalletChain = {
21
+ ...SmartWalletTestnet,
22
+ ...SmartWalletMainnet,
23
+ } as const;
24
+ export type SmartWalletChain = ObjectValues<typeof SmartWalletChain>;
25
+ export const SMART_WALLET_CHAINS = objectValues(SmartWalletChain);
26
+
27
+ export const zerodevProjects: Record<SmartWalletChain, string> = {
28
+ polygon: "5c9f4865-ca8e-44bb-9b9e-3810b2b46f9f",
29
+ "polygon-amoy": "3deef404-ca06-4a5d-9a58-907c99e7ef00",
30
+ "base-sepolia": "5a127978-6473-4784-9dfb-f74395b220a6",
31
+ base: "e8b3020f-4dde-4176-8a7d-be8102527a5c",
32
+ };
33
+
34
+ export const viemNetworks: Record<SmartWalletChain, Chain> = {
35
+ polygon: polygon,
36
+ "polygon-amoy": polygonAmoy,
37
+ base: base,
38
+ "base-sepolia": baseSepolia,
39
+ };
40
+
41
+ export const getBundlerRPC = (chain: SmartWalletChain) => {
42
+ return BUNDLER_RPC + zerodevProjects[chain];
43
+ };
@@ -1,14 +1,13 @@
1
1
  import { logError } from "@/services/logging";
2
2
  import { type HttpTransport, type PublicClient, isAddress, publicActions } from "viem";
3
3
 
4
- import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
5
-
6
4
  import type { CrossmintWalletService } from "../../api/CrossmintWalletService";
7
5
  import { TransferError } from "../../error";
8
6
  import type { TransferType } from "../../types/Tokens";
9
7
  import { SmartWalletClient } from "../../types/internal";
10
8
  import { SCW_SERVICE } from "../../utils/constants";
11
9
  import { LoggerWrapper, errorToJSON } from "../../utils/log";
10
+ import { SmartWalletChain } from "../chains";
12
11
  import { transferParams } from "../transfer";
13
12
 
14
13
  /**
@@ -16,7 +15,7 @@ import { transferParams } from "../transfer";
16
15
  * Core functionality is exposed via [viem](https://viem.sh/) clients within the `client` property of the class.
17
16
  */
18
17
  export class EVMSmartWallet extends LoggerWrapper {
19
- public readonly chain: EVMBlockchainIncludingTestnet;
18
+ public readonly chain: SmartWalletChain;
20
19
 
21
20
  /**
22
21
  * [viem](https://viem.sh/) clients that provide an interface for core wallet functionality.
@@ -37,7 +36,7 @@ export class EVMSmartWallet extends LoggerWrapper {
37
36
  private readonly crossmintService: CrossmintWalletService,
38
37
  private readonly accountClient: SmartWalletClient,
39
38
  publicClient: PublicClient<HttpTransport>,
40
- chain: EVMBlockchainIncludingTestnet
39
+ chain: SmartWalletChain
41
40
  ) {
42
41
  super("EVMSmartWallet", { chain, address: accountClient.account.address });
43
42
  this.chain = chain;
@@ -7,7 +7,7 @@ import type { SmartAccountClient } from "permissionless";
7
7
  import type { EntryPoint } from "permissionless/types/entrypoint";
8
8
  import { stringify } from "viem";
9
9
 
10
- import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
10
+ import { SmartWalletChain } from "../chains";
11
11
 
12
12
  const transactionMethods = [
13
13
  "sendTransaction",
@@ -44,7 +44,7 @@ export class ClientDecorator {
44
44
  crossmintChain,
45
45
  smartAccountClient,
46
46
  }: {
47
- crossmintChain: EVMBlockchainIncludingTestnet;
47
+ crossmintChain: SmartWalletChain;
48
48
  smartAccountClient: Client;
49
49
  }): Client {
50
50
  return new Proxy(smartAccountClient, {
@@ -73,7 +73,7 @@ export class ClientDecorator {
73
73
  // eslint-disable-next-line @typescript-eslint/ban-types
74
74
  originalMethod: Function,
75
75
  args: any[],
76
- crossmintChain: EVMBlockchainIncludingTestnet
76
+ crossmintChain: SmartWalletChain
77
77
  ) {
78
78
  try {
79
79
  logInfo(`[CrossmintSmartWallet.${prop}] - params: ${stringify(args)}`);
@@ -88,7 +88,7 @@ export class ClientDecorator {
88
88
  }
89
89
  }
90
90
 
91
- private processTxnArgs(prop: TxnMethod, crossmintChain: EVMBlockchainIncludingTestnet, args: any[]): any[] {
91
+ private processTxnArgs(prop: TxnMethod, crossmintChain: SmartWalletChain, args: any[]): any[] {
92
92
  if (prop === "sendUserOperation") {
93
93
  const [{ userOperation, middleware, account }] = args as Parameters<
94
94
  SmartAccountClient<EntryPoint>["sendUserOperation"]
@@ -115,7 +115,7 @@ export class ClientDecorator {
115
115
  * https://docs.zerodev.app/sdk/faqs/use-with-gelato#transaction-configuration
116
116
  */
117
117
  private addGelatoBundlerProperties(
118
- crossmintChain: EVMBlockchainIncludingTestnet,
118
+ crossmintChain: SmartWalletChain,
119
119
  txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }
120
120
  ) {
121
121
  if (usesGelatoBundler(crossmintChain)) {
@@ -3,11 +3,17 @@ import { type PasskeySignerData, displayPasskey } from "@/types/API";
3
3
  import type { PasskeySigner, UserParams, WalletParams } from "@/types/Config";
4
4
  import type { AccountAndSigner, PasskeyValidatorSerializedData, WalletCreationParams } from "@/types/internal";
5
5
  import { PasskeyValidatorContractVersion, WebAuthnMode, toPasskeyValidator } from "@zerodev/passkey-validator";
6
- import { type KernelValidator, createKernelAccount } from "@zerodev/sdk";
7
- import { WebAuthnKey, toWebAuthnKey } from "@zerodev/webauthn-key";
6
+ import { type KernelSmartAccount, type KernelValidator, createKernelAccount } from "@zerodev/sdk";
7
+ import { type WebAuthnKey, toWebAuthnKey } from "@zerodev/webauthn-key";
8
+ import type { SmartAccount } from "permissionless/accounts";
8
9
  import type { EntryPoint } from "permissionless/types/entrypoint";
9
10
 
10
- import { PasskeyMismatchError } from "../../error";
11
+ import {
12
+ PasskeyIncompatibleAuthenticatorError,
13
+ PasskeyMismatchError,
14
+ PasskeyPromptError,
15
+ PasskeyRegistrationError,
16
+ } from "../../error";
11
17
 
12
18
  export interface PasskeyWalletParams extends WalletCreationParams {
13
19
  walletParams: WalletParams & { signer: PasskeySigner };
@@ -20,7 +26,6 @@ export function isPasskeyParams(params: WalletCreationParams): params is Passkey
20
26
  type PasskeyValidator = KernelValidator<EntryPoint, "WebAuthnValidator"> & {
21
27
  getSerializedData: () => string;
22
28
  };
23
-
24
29
  export class PasskeyAccountService {
25
30
  constructor(private readonly crossmintService: CrossmintWalletService) {}
26
31
 
@@ -36,28 +41,32 @@ export class PasskeyAccountService {
36
41
  );
37
42
  }
38
43
 
39
- const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig);
40
-
41
- const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;
42
- const validatorContractVersion =
43
- existingSignerConfig == null ? latestValidatorVersion : existingSignerConfig.validatorContractVersion;
44
- const validator = await toPasskeyValidator(publicClient, {
45
- webAuthnKey: passkey,
46
- entryPoint: entryPoint.address,
47
- validatorContractVersion,
48
- kernelVersion,
49
- });
44
+ try {
45
+ const passkey = await this.getPasskey(user, inputPasskeyName, existingSignerConfig);
46
+
47
+ const latestValidatorVersion = PasskeyValidatorContractVersion.V0_0_2;
48
+ const validatorContractVersion =
49
+ existingSignerConfig == null ? latestValidatorVersion : existingSignerConfig.validatorContractVersion;
50
+ const validator = await toPasskeyValidator(publicClient, {
51
+ webAuthnKey: passkey,
52
+ entryPoint: entryPoint.address,
53
+ validatorContractVersion,
54
+ kernelVersion,
55
+ });
56
+
57
+ const kernelAccount = await createKernelAccount(publicClient, {
58
+ plugins: { sudo: validator },
59
+ entryPoint: entryPoint.address,
60
+ kernelVersion,
61
+ });
50
62
 
51
- const kernelAccount = await createKernelAccount(publicClient, {
52
- plugins: { sudo: validator },
53
- entryPoint: entryPoint.address,
54
- kernelVersion,
55
- });
56
-
57
- return {
58
- signerData: this.getSignerData(validator, validatorContractVersion, inputPasskeyName),
59
- account: kernelAccount,
60
- };
63
+ return {
64
+ signerData: this.getSignerData(validator, validatorContractVersion, inputPasskeyName),
65
+ account: this.decorate(kernelAccount, inputPasskeyName),
66
+ };
67
+ } catch (error) {
68
+ throw this.mapError(error, inputPasskeyName);
69
+ }
61
70
  }
62
71
 
63
72
  private async getPasskey(
@@ -102,6 +111,52 @@ export class PasskeyAccountService {
102
111
  Authorization: `Bearer ${user.jwt}`,
103
112
  };
104
113
  }
114
+
115
+ private mapError(error: any, passkeyName: string) {
116
+ if (error.code === 0 && error.name === "DataError") {
117
+ return new PasskeyIncompatibleAuthenticatorError(passkeyName);
118
+ }
119
+
120
+ if (error.message === "Registration not verified") {
121
+ return new PasskeyRegistrationError(passkeyName);
122
+ }
123
+
124
+ if (error.code === "ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY" && error.name === "NotAllowedError") {
125
+ return new PasskeyPromptError(passkeyName);
126
+ }
127
+
128
+ return error;
129
+ }
130
+
131
+ private decorate<Account extends KernelSmartAccount<EntryPoint>>(account: Account, passkeyName: string): Account {
132
+ return new Proxy(account, {
133
+ get: (target, prop, receiver) => {
134
+ const original = Reflect.get(target, prop, receiver);
135
+ if (typeof original !== "function" || typeof prop !== "string" || !isAccountSigningMethod(prop)) {
136
+ return original;
137
+ }
138
+
139
+ return async (...args: any[]) => {
140
+ try {
141
+ return await original.call(target, ...args);
142
+ } catch (error) {
143
+ throw this.mapError(error, passkeyName);
144
+ }
145
+ };
146
+ },
147
+ });
148
+ }
149
+ }
150
+
151
+ const accountSigningMethods = [
152
+ "signMessage",
153
+ "signTypedData",
154
+ "signUserOperation",
155
+ "signTransaction",
156
+ ] as const satisfies readonly (keyof SmartAccount<EntryPoint>)[];
157
+
158
+ function isAccountSigningMethod(method: string): method is (typeof accountSigningMethods)[number] {
159
+ return accountSigningMethods.includes(method as any);
105
160
  }
106
161
 
107
162
  const deserializePasskeyValidatorData = (params: string) => {
@@ -1,27 +1,18 @@
1
- import { PAYMASTER_RPC, PM_BASE_RPC, PM_BASE_SEPOLIA_RPC } from "@/utils/constants";
1
+ import { PAYMASTER_RPC } from "@/utils/constants";
2
2
  import { createZeroDevPaymasterClient } from "@zerodev/sdk";
3
3
  import { Middleware } from "permissionless/actions/smartAccount";
4
4
  import { EntryPoint } from "permissionless/types/entrypoint";
5
5
  import { http } from "viem";
6
6
 
7
- import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
8
-
9
7
  import { usesGelatoBundler } from "../../utils/blockchain";
10
- import { getViemNetwork, getZeroDevProjectIdByBlockchain } from "../BlockchainNetworks";
8
+ import { SmartWalletChain, viemNetworks, zerodevProjects } from "../chains";
11
9
 
12
- export function usePaymaster(chain: EVMBlockchainIncludingTestnet) {
10
+ export function usePaymaster(chain: SmartWalletChain) {
13
11
  return !usesGelatoBundler(chain);
14
12
  }
15
13
 
16
- const getPaymasterRPC = (chain: EVMBlockchainIncludingTestnet) => {
17
- switch (chain) {
18
- case EVMBlockchainIncludingTestnet.BASE_SEPOLIA:
19
- return PM_BASE_SEPOLIA_RPC;
20
- case EVMBlockchainIncludingTestnet.BASE:
21
- return PM_BASE_RPC;
22
- default:
23
- return PAYMASTER_RPC + getZeroDevProjectIdByBlockchain(chain) + "?paymasterProvider=STACKUP";
24
- }
14
+ const getPaymasterRPC = (chain: SmartWalletChain) => {
15
+ return PAYMASTER_RPC + zerodevProjects[chain];
25
16
  };
26
17
 
27
18
  export function paymasterMiddleware({
@@ -29,13 +20,13 @@ export function paymasterMiddleware({
29
20
  chain,
30
21
  }: {
31
22
  entryPoint: EntryPoint;
32
- chain: EVMBlockchainIncludingTestnet;
23
+ chain: SmartWalletChain;
33
24
  }): Middleware<EntryPoint> {
34
25
  return {
35
26
  middleware: {
36
27
  sponsorUserOperation: async ({ userOperation }) => {
37
28
  const paymasterClient = createZeroDevPaymasterClient({
38
- chain: getViemNetwork(chain),
29
+ chain: viemNetworks[chain],
39
30
  transport: http(getPaymasterRPC(chain)),
40
31
  entryPoint,
41
32
  });
@@ -7,7 +7,7 @@ import { Address, type HttpTransport, createPublicClient, getAddress, http } fro
7
7
 
8
8
  import { blockchainToChainId } from "@crossmint/common-sdk-base";
9
9
 
10
- import type { CrossmintWalletService, EVMBlockchainIncludingTestnet } from "../../api/CrossmintWalletService";
10
+ import type { CrossmintWalletService } from "../../api/CrossmintWalletService";
11
11
  import {
12
12
  AdminMismatchError,
13
13
  CrossmintServiceError,
@@ -25,7 +25,7 @@ import {
25
25
  isSupportedKernelVersion,
26
26
  } from "../../types/internal";
27
27
  import { CURRENT_VERSION, ZERO_DEV_TYPE } from "../../utils/constants";
28
- import { getBundlerRPC, getViemNetwork } from "../BlockchainNetworks";
28
+ import { SmartWalletChain, getBundlerRPC, viemNetworks } from "../chains";
29
29
  import { EVMSmartWallet } from "./EVMSmartWallet";
30
30
  import { ClientDecorator } from "./clientDecorator";
31
31
  import { EOAAccountService, type EOAWalletParams } from "./eoa";
@@ -44,7 +44,7 @@ export class SmartWalletService {
44
44
 
45
45
  public async getOrCreate(
46
46
  user: UserParams,
47
- chain: EVMBlockchainIncludingTestnet,
47
+ chain: SmartWalletChain,
48
48
  walletParams: WalletParams
49
49
  ): Promise<EVMSmartWallet> {
50
50
  const { entryPoint, kernelVersion, existingSignerConfig, smartContractWalletAddress, userId } =
@@ -82,7 +82,7 @@ export class SmartWalletService {
82
82
 
83
83
  const kernelAccountClient: SmartWalletClient = createKernelAccountClient({
84
84
  account,
85
- chain: getViemNetwork(chain),
85
+ chain: viemNetworks[chain],
86
86
  entryPoint: account.entryPoint,
87
87
  bundlerTransport: http(getBundlerRPC(chain)),
88
88
  ...(usePaymaster(chain) && paymasterMiddleware({ entryPoint: account.entryPoint, chain })),
@@ -98,7 +98,7 @@ export class SmartWalletService {
98
98
 
99
99
  private async fetchConfig(
100
100
  user: UserParams,
101
- chain: EVMBlockchainIncludingTestnet
101
+ chain: SmartWalletChain
102
102
  ): Promise<{
103
103
  entryPoint: EntryPointDetails;
104
104
  kernelVersion: SupportedKernelVersion;
@@ -13,7 +13,11 @@ export const SmartWalletErrors = {
13
13
  ERROR_WALLET_CONFIG: "smart-wallet:wallet-config.error",
14
14
  ERROR_ADMIN_MISMATCH: "smart-wallet:wallet-config.admin-mismatch",
15
15
  ERROR_PASSKEY_MISMATCH: "smart-wallet:wallet-config.passkey-mismatch",
16
+ ERROR_PASSKEY_PROMPT: "smart-wallet:passkey.prompt",
17
+ ERROR_PASSKEY_INCOMPATIBLE_AUTHENTICATOR: "smart-wallet.passkey.incompatible-authenticator",
18
+ ERROR_PASSKEY_REGISTRATION: "smart-wallet:passkey.registration",
16
19
  ERROR_ADMIN_SIGNER_ALREADY_USED: "smart-wallet:wallet-config.admin-signer-already-used",
20
+ ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: "smart-wallet:wallet-config.non-custodial-wallets-not-enabled",
17
21
  UNCATEGORIZED: "smart-wallet:uncategorized", // catch-all error code
18
22
  } as const;
19
23
  export type SmartWalletErrorCode = (typeof SmartWalletErrors)[keyof typeof SmartWalletErrors];
@@ -118,6 +122,45 @@ export class UserWalletAlreadyCreatedError extends SmartWalletSDKError {
118
122
  }
119
123
  }
120
124
 
125
+ export class PasskeyPromptError extends SmartWalletSDKError {
126
+ public passkeyName: string;
127
+
128
+ constructor(passkeyName: string) {
129
+ super(
130
+ `Prompt was either cancelled or timed out for passkey ${passkeyName}`,
131
+ undefined,
132
+ SmartWalletErrors.ERROR_PASSKEY_PROMPT
133
+ );
134
+ this.passkeyName = passkeyName;
135
+ }
136
+ }
137
+
138
+ export class PasskeyRegistrationError extends SmartWalletSDKError {
139
+ public passkeyName: string;
140
+
141
+ constructor(passkeyName: string) {
142
+ super(
143
+ `Registration for passkey ${passkeyName} failed, either the registration took too long, or passkey signature vaildation failed.`,
144
+ undefined,
145
+ SmartWalletErrors.ERROR_PASSKEY_REGISTRATION
146
+ );
147
+ this.passkeyName = passkeyName;
148
+ }
149
+ }
150
+
151
+ export class PasskeyIncompatibleAuthenticatorError extends SmartWalletSDKError {
152
+ public passkeyName: string;
153
+
154
+ constructor(passkeyName: string) {
155
+ super(
156
+ `User selected authenticator for passkey ${passkeyName} is not compatible with Crossmint's Smart Wallets.`,
157
+ undefined,
158
+ SmartWalletErrors.ERROR_PASSKEY_INCOMPATIBLE_AUTHENTICATOR
159
+ );
160
+ this.passkeyName = passkeyName;
161
+ }
162
+ }
163
+
121
164
  export class OutOfCreditsError extends SmartWalletSDKError {
122
165
  constructor(message?: string) {
123
166
  super(
@@ -142,6 +185,7 @@ export class AdminAlreadyUsedError extends ConfigError {
142
185
  }
143
186
 
144
187
  export class NonCustodialWalletsNotEnabledError extends ConfigError {
188
+ public readonly code = SmartWalletErrors.ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED;
145
189
  constructor() {
146
190
  super("Non-custodial wallets are not enabled for this project");
147
191
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { EVMBlockchainIncludingTestnet as Blockchain, blockchainToChainId } from "@crossmint/common-sdk-base";
1
+ export { blockchainToChainId, EVMBlockchainIncludingTestnet as Chain } from "@crossmint/common-sdk-base";
2
2
 
3
3
  export { EVMSmartWallet } from "./blockchain/wallets/EVMSmartWallet";
4
4
 
@@ -27,6 +27,9 @@ export {
27
27
  AdminAlreadyUsedError,
28
28
  AdminMismatchError,
29
29
  PasskeyMismatchError,
30
+ PasskeyPromptError,
31
+ PasskeyRegistrationError,
32
+ PasskeyIncompatibleAuthenticatorError,
30
33
  ConfigError,
31
34
  NonCustodialWalletsNotEnabledError,
32
35
  } from "./error";
@@ -1,7 +1,7 @@
1
- import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
1
+ import type { SmartWalletChain } from "../blockchain/chains";
2
2
 
3
3
  export interface EVMToken {
4
- chain: EVMBlockchainIncludingTestnet;
4
+ chain: SmartWalletChain;
5
5
  contractAddress: string;
6
6
  }
7
7
 
@@ -4,8 +4,7 @@ import type { SmartAccount } from "permissionless/accounts";
4
4
  import type { EntryPoint } from "permissionless/types/entrypoint";
5
5
  import type { Chain, Hex, HttpTransport, PublicClient } from "viem";
6
6
 
7
- import type { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
8
-
7
+ import type { SmartWalletChain } from "../blockchain/chains";
9
8
  import type { SignerData } from "./API";
10
9
  import type { EntryPointDetails, UserParams, WalletParams } from "./Config";
11
10
 
@@ -25,7 +24,7 @@ export function isSupportedEntryPointVersion(version: string): version is Suppor
25
24
 
26
25
  export interface WalletCreationParams {
27
26
  user: UserParams & { id: string };
28
- chain: EVMBlockchainIncludingTestnet;
27
+ chain: SmartWalletChain;
29
28
  publicClient: PublicClient<HttpTransport>;
30
29
  walletParams: WalletParams;
31
30
  entryPoint: EntryPointDetails;
@@ -1,15 +1,5 @@
1
- import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
1
+ import { SmartWalletChain } from "../blockchain/chains";
2
2
 
3
- function isPolygonCDK(chain: EVMBlockchainIncludingTestnet) {
4
- const polygonCDKchains: EVMBlockchainIncludingTestnet[] = [
5
- EVMBlockchainIncludingTestnet.ZKYOTO,
6
- EVMBlockchainIncludingTestnet.ZKATANA,
7
- EVMBlockchainIncludingTestnet.ASTAR_ZKEVM,
8
- EVMBlockchainIncludingTestnet.HYPERSONIC_TESTNET,
9
- ];
10
- return polygonCDKchains.includes(chain);
11
- }
12
-
13
- export function usesGelatoBundler(chain: EVMBlockchainIncludingTestnet) {
14
- return isPolygonCDK(chain);
3
+ export function usesGelatoBundler(chain: SmartWalletChain) {
4
+ return false;
15
5
  }