@crossmint/client-sdk-smart-wallet 0.1.16 → 0.1.17

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.
@@ -1,15 +1,9 @@
1
1
  import { stringify } from "viem";
2
2
 
3
- import { APIKeyEnvironmentPrefix, validateAPIKey } from "@crossmint/common-sdk-base";
3
+ import { type APIKeyEnvironmentPrefix, validateAPIKey } from "@crossmint/common-sdk-base";
4
4
 
5
5
  import { CrossmintWalletService } from "./api/CrossmintWalletService";
6
- import {
7
- SMART_WALLET_MAINNETS,
8
- SMART_WALLET_TESTNETS,
9
- type SmartWalletChain,
10
- isMainnetChain,
11
- isTestnetChain,
12
- } from "./blockchain/chains";
6
+ import { type SmartWalletChain, isMainnetChain, isTestnetChain } from "./blockchain/chains";
13
7
  import type { EVMSmartWallet } from "./blockchain/wallets";
14
8
  import { AccountConfigCache } from "./blockchain/wallets/account/cache";
15
9
  import { AccountConfigService } from "./blockchain/wallets/account/config";
@@ -80,7 +74,7 @@ export class SmartWalletSDK {
80
74
  }
81
75
  this.assertValidChain(chain);
82
76
 
83
- return this.logger.logPerformance("GET_OR_CREATE_WALLET", async () => {
77
+ return await this.logger.logPerformance("GET_OR_CREATE_WALLET", async () => {
84
78
  try {
85
79
  return await this.smartWalletService.getOrCreate(user, chain, walletParams);
86
80
  } catch (error: any) {
@@ -1,5 +1,5 @@
1
1
  import {
2
- Chain,
2
+ type Chain,
3
3
  arbitrum,
4
4
  arbitrumSepolia,
5
5
  base,
@@ -10,7 +10,7 @@ import {
10
10
  polygonAmoy,
11
11
  } from "viem/chains";
12
12
 
13
- import { BlockchainIncludingTestnet as Blockchain, ObjectValues, objectValues } from "@crossmint/common-sdk-base";
13
+ import { BlockchainIncludingTestnet as Blockchain, type ObjectValues, objectValues } from "@crossmint/common-sdk-base";
14
14
 
15
15
  export const SmartWalletTestnet = {
16
16
  BASE_SEPOLIA: Blockchain.BASE_SEPOLIA,
@@ -1,6 +1,6 @@
1
1
  import { blockchainToChainId } from "@crossmint/common-sdk-base";
2
2
 
3
- import { SmartWalletChain } from "./chains";
3
+ import type { SmartWalletChain } from "./chains";
4
4
 
5
5
  const ALCHEMY_API_KEY = "-7M6vRDBDknwvMxnqah_jbcieWg0qad9";
6
6
  const PIMLICO_API_KEY = "pim_9dKmQPxiTCvtbUNF7XFBbA";
@@ -1,4 +1,4 @@
1
- import { Abi, Account, Address, erc20Abi, erc721Abi } from "viem";
1
+ import { type Abi, type Account, type Address, erc20Abi, erc721Abi } from "viem";
2
2
 
3
3
  import erc1155Abi from "../ABI/ERC1155.json";
4
4
  import type { ERC20TransferType, SFTTransferType, TransferType } from "../types/token";
@@ -15,7 +15,7 @@ import type { SmartWalletClient } from "../../types/internal";
15
15
  import type { TransferType } from "../../types/token";
16
16
  import type { SmartWalletChain } from "../chains";
17
17
  import { transferParams } from "../transfer";
18
- import { SendTransactionOptions, SendTransactionService } from "./SendTransactionService";
18
+ import { type SendTransactionOptions, SendTransactionService } from "./SendTransactionService";
19
19
 
20
20
  /**
21
21
  * Smart wallet interface for EVM chains enhanced with Crossmint capabilities.
@@ -132,7 +132,7 @@ export class EVMSmartWallet {
132
132
  TAbi,
133
133
  "nonpayable" | "payable",
134
134
  TFunctionName
135
- >
135
+ >,
136
136
  >({
137
137
  address,
138
138
  abi,
@@ -1,15 +1,15 @@
1
- import { SmartAccountClient } from "permissionless";
2
- import { SmartAccount } from "permissionless/accounts";
3
- import { EntryPoint } from "permissionless/types";
1
+ import type { SmartAccountClient } from "permissionless";
2
+ import type { SmartAccount } from "permissionless/accounts";
3
+ import type { EntryPoint } from "permissionless/types";
4
4
  import {
5
- Address,
5
+ type Address,
6
6
  BaseError,
7
- Chain,
7
+ type Chain,
8
8
  ContractFunctionRevertedError,
9
- PublicClient,
10
- SimulateContractReturnType,
11
- TransactionReceipt,
12
- Transport,
9
+ type PublicClient,
10
+ type SimulateContractReturnType,
11
+ type TransactionReceipt,
12
+ type Transport,
13
13
  zeroAddress,
14
14
  } from "viem";
15
15
  import { beforeEach, describe, expect, it, vi } from "vitest";
@@ -1,6 +1,6 @@
1
1
  import { beforeEach, describe, expect, it, vi } from "vitest";
2
2
 
3
- import { UserParams } from "../../../types/params";
3
+ import type { UserParams } from "../../../types/params";
4
4
  import { mockConfig } from "../../../utils/test";
5
5
  import { AccountConfigCache } from "./cache";
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { keccak256, toHex } from "viem";
2
2
 
3
- import { UserParams } from "../../../types/params";
3
+ import type { UserParams } from "../../../types/params";
4
4
  import { SmartWalletConfigSchema } from "../../../types/schema";
5
5
  import type { SmartWalletConfig } from "../../../types/service";
6
6
 
@@ -1,11 +1,11 @@
1
1
  import { beforeEach, describe, expect, it } from "vitest";
2
2
  import { mock } from "vitest-mock-extended";
3
3
 
4
- import { CrossmintWalletService } from "../../../api/CrossmintWalletService";
5
- import { SmartWalletConfig } from "../../../types/service";
4
+ import type { CrossmintWalletService } from "../../../api/CrossmintWalletService";
5
+ import type { SmartWalletConfig } from "../../../types/service";
6
6
  import { mockConfig } from "../../../utils/test";
7
7
  import { SmartWalletChain } from "../../chains";
8
- import { AccountConfigCache } from "./cache";
8
+ import type { AccountConfigCache } from "./cache";
9
9
  import { AccountConfigService } from "./config";
10
10
  import { PasskeySignerConfig } from "./signer";
11
11
 
@@ -8,7 +8,7 @@ import type {
8
8
  } from "../../../types/internal";
9
9
  import type { UserParams } from "../../../types/params";
10
10
  import type { SignerData, SmartWalletConfig } from "../../../types/service";
11
- import { AccountConfigCache } from "./cache";
11
+ import type { AccountConfigCache } from "./cache";
12
12
  import { EOASignerConfig, PasskeySignerConfig, type SignerConfig } from "./signer";
13
13
 
14
14
  interface AccountConfig {
@@ -6,8 +6,8 @@ import {
6
6
  isPasskeyCreationContext,
7
7
  isPasskeyWalletParams,
8
8
  } from "../../../types/internal";
9
- import { EOACreationStrategy } from "./eoa";
10
- import { PasskeyCreationStrategy } from "./passkey";
9
+ import type { EOACreationStrategy } from "./eoa";
10
+ import type { PasskeyCreationStrategy } from "./passkey";
11
11
 
12
12
  export class AccountCreator {
13
13
  constructor(
@@ -6,7 +6,7 @@ import type { AccountAndSigner, EOACreationContext } from "../../../types/intern
6
6
  import { equalsIgnoreCase } from "../../../utils/helpers";
7
7
  import { createOwnerSigner } from "../../../utils/signer";
8
8
  import { EOASignerConfig } from "./signer";
9
- import { AccountCreationStrategy } from "./strategy";
9
+ import type { AccountCreationStrategy } from "./strategy";
10
10
 
11
11
  export class EOACreationStrategy implements AccountCreationStrategy {
12
12
  public async create({
@@ -14,13 +14,16 @@ import type { AccountAndSigner, PasskeyCreationContext } from "../../../types/in
14
14
  import type { UserParams } from "../../../types/params";
15
15
  import type { PasskeySignerData, PasskeyValidatorSerializedData } from "../../../types/service";
16
16
  import { PasskeySignerConfig } from "./signer";
17
- import { AccountCreationStrategy } from "./strategy";
17
+ import type { AccountCreationStrategy } from "./strategy";
18
18
 
19
19
  type PasskeyValidator = KernelValidator<EntryPoint, "WebAuthnValidator"> & {
20
20
  getSerializedData: () => string;
21
21
  };
22
22
  export class PasskeyCreationStrategy implements AccountCreationStrategy {
23
- constructor(private readonly passkeyServerUrl: string, private readonly apiKey: string) {}
23
+ constructor(
24
+ private readonly passkeyServerUrl: string,
25
+ private readonly apiKey: string
26
+ ) {}
24
27
 
25
28
  public async create({
26
29
  user,
@@ -1,4 +1,4 @@
1
- import { AccountAndSigner, WalletCreationContext } from "../../../types/internal";
1
+ import type { AccountAndSigner, WalletCreationContext } from "../../../types/internal";
2
2
 
3
3
  export interface AccountCreationStrategy {
4
4
  create(params: WalletCreationContext): Promise<AccountAndSigner>;
@@ -3,10 +3,10 @@ import type { EntryPoint } from "permissionless/types/entrypoint";
3
3
  import { stringify } from "viem";
4
4
 
5
5
  import { SmartWalletError } from "../../error";
6
- import { ErrorProcessor } from "../../error/processor";
6
+ import type { ErrorProcessor } from "../../error/processor";
7
7
  import { scwLogger } from "../../services";
8
8
  import { usesGelatoBundler } from "../../utils/blockchain";
9
- import { SmartWalletChain } from "../chains";
9
+ import type { SmartWalletChain } from "../chains";
10
10
 
11
11
  const transactionMethods = [
12
12
  "sendTransaction",
@@ -37,7 +37,10 @@ function isSignMethod(method: string): method is SignMethod {
37
37
  * - Automatic formatting of transactions for Gelato bundler compatibility.
38
38
  * */
39
39
  export class ClientDecorator {
40
- constructor(private readonly errorProcessor: ErrorProcessor, protected logger = scwLogger) {}
40
+ constructor(
41
+ private readonly errorProcessor: ErrorProcessor,
42
+ protected logger = scwLogger
43
+ ) {}
41
44
 
42
45
  public decorate<Client extends SmartAccountClient<EntryPoint>>({
43
46
  crossmintChain,
@@ -69,7 +72,6 @@ export class ClientDecorator {
69
72
  private async execute<M extends TxnMethod | SignMethod>(
70
73
  target: SmartAccountClient<EntryPoint>,
71
74
  prop: M,
72
- // eslint-disable-next-line @typescript-eslint/ban-types
73
75
  originalMethod: Function,
74
76
  args: any[],
75
77
  crossmintChain: SmartWalletChain
@@ -1,11 +1,11 @@
1
- import { CrossmintWalletService } from "@/api/CrossmintWalletService";
2
- import { Middleware } from "permissionless/actions/smartAccount";
3
- import { PimlicoBundlerClient } from "permissionless/clients/pimlico";
4
- import { EntryPoint } from "permissionless/types/entrypoint";
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
5
 
6
- import { UserParams } from "../../types/params";
6
+ import type { UserParams } from "../../types/params";
7
7
  import { usesGelatoBundler } from "../../utils/blockchain";
8
- import { SmartWalletChain } from "../chains";
8
+ import type { SmartWalletChain } from "../chains";
9
9
 
10
10
  export function usePaymaster(chain: SmartWalletChain) {
11
11
  return !usesGelatoBundler(chain);
@@ -1,8 +1,8 @@
1
- import { KernelSmartAccount } from "@zerodev/sdk";
1
+ import type { KernelSmartAccount } from "@zerodev/sdk";
2
2
  import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07, createSmartAccountClient } from "permissionless";
3
3
  import { createPimlicoBundlerClient } from "permissionless/clients/pimlico";
4
- import { EntryPoint } from "permissionless/types/entrypoint";
5
- import { HttpTransport, createPublicClient, http } from "viem";
4
+ import type { EntryPoint } from "permissionless/types/entrypoint";
5
+ import { type HttpTransport, createPublicClient, http } from "viem";
6
6
 
7
7
  import { blockchainToChainId } from "@crossmint/common-sdk-base";
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { CrossmintSDKError, SmartWalletErrorCode } from "@crossmint/client-sdk-base";
2
2
 
3
- import { PasskeyDisplay, SignerDisplay } from "../types/service";
3
+ import type { PasskeyDisplay, SignerDisplay } from "../types/service";
4
4
 
5
5
  export class SmartWalletError extends CrossmintSDKError {
6
6
  constructor(message: string, details?: string, code: SmartWalletErrorCode = SmartWalletErrorCode.UNCATEGORIZED) {
@@ -1,6 +1,6 @@
1
1
  import { BaseError, stringify } from "viem";
2
2
 
3
- import { SDKLogger } from "@crossmint/client-sdk-base";
3
+ import type { SDKLogger } from "@crossmint/client-sdk-base";
4
4
 
5
5
  import { SmartWalletError } from ".";
6
6
  import { SDK_VERSION } from "../utils/constants";
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import type { z } from "zod";
2
2
 
3
3
  import type { SupportedEntryPointVersion, SupportedKernelVersion } from "./internal";
4
4
  import type {
@@ -1,4 +1,4 @@
1
- import { SmartWalletChain } from "../blockchain/chains";
1
+ import type { SmartWalletChain } from "../blockchain/chains";
2
2
 
3
3
  export function usesGelatoBundler(chain: SmartWalletChain) {
4
4
  return false;
@@ -1,7 +1,9 @@
1
+ import { version } from "../../package.json";
2
+
1
3
  export const ZERO_DEV_TYPE = "ZeroDev";
2
4
  export const CURRENT_VERSION = 0;
3
5
  export const SCW_SERVICE = "SCW_SDK";
4
- export const SDK_VERSION = "0.1.0";
6
+ export const SDK_VERSION = version;
5
7
  export const API_VERSION = "2024-06-09";
6
8
  export const SUPPORTED_KERNEL_VERSIONS = ["0.3.1", "0.3.0", "0.2.4"] as const;
7
9
  export const SUPPORTED_ENTRYPOINT_VERSIONS = ["v0.6", "v0.7"] as const;
@@ -1,10 +1,10 @@
1
1
  import { providerToSmartAccountSigner } from "permissionless";
2
2
  import type { SmartAccountSigner } from "permissionless/accounts";
3
- import { Address, EIP1193Provider } from "viem";
3
+ import type { Address, EIP1193Provider } from "viem";
4
4
 
5
- import { SmartWalletChain } from "../blockchain/chains";
5
+ import type { SmartWalletChain } from "../blockchain/chains";
6
6
  import { SmartWalletError } from "../error";
7
- import { ViemAccount, WalletParams } from "../types/params";
7
+ import type { ViemAccount, WalletParams } from "../types/params";
8
8
 
9
9
  type CreateOwnerSignerInput = {
10
10
  chain: SmartWalletChain;
package/src/utils/test.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SmartWalletConfig } from "../types/service";
1
+ import type { SmartWalletConfig } from "../types/service";
2
2
 
3
3
  export const mockConfig: SmartWalletConfig = {
4
4
  kernelVersion: "0.3.1",