@crossmint/client-sdk-smart-wallet 0.1.0 → 0.1.1
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +45 -45
- package/src/SmartWalletSDK.ts +3 -2
- package/src/api/APIErrorService.ts +3 -0
- package/src/api/CrossmintWalletService.ts +3 -6
- package/src/blockchain/chains.ts +43 -0
- package/src/blockchain/wallets/EVMSmartWallet.ts +3 -4
- package/src/blockchain/wallets/clientDecorator.ts +5 -5
- package/src/blockchain/wallets/paymaster.ts +7 -16
- package/src/blockchain/wallets/service.ts +5 -5
- package/src/error/index.ts +2 -0
- package/src/index.ts +2 -1
- package/src/types/Tokens.ts +2 -2
- package/src/types/internal.ts +2 -3
- package/src/utils/blockchain.ts +3 -13
- package/src/utils/constants.ts +0 -20
- package/src/utils/signer.ts +2 -3
- package/src/blockchain/BlockchainNetworks.ts +0 -121
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
2
|
+
"name": "@crossmint/client-sdk-smart-wallet",
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
+
"unlink:common-sdk-base": "yalc remove @crossmint/common-sdk-base && pnpm i"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/SmartWalletSDK.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { stringify } from "viem";
|
|
2
2
|
|
|
3
|
-
import {
|
|
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:
|
|
58
|
+
chain: SmartWalletChain,
|
|
58
59
|
walletParams: WalletParams = { signer: { type: "PASSKEY" } }
|
|
59
60
|
): Promise<EVMSmartWallet> {
|
|
60
61
|
return logPerformance(
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 {
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
118
|
+
crossmintChain: SmartWalletChain,
|
|
119
119
|
txnParams: { maxFeePerGas?: bigint; maxPriorityFeePerGas?: bigint }
|
|
120
120
|
) {
|
|
121
121
|
if (usesGelatoBundler(crossmintChain)) {
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import { PAYMASTER_RPC
|
|
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 {
|
|
8
|
+
import { SmartWalletChain, viemNetworks, zerodevProjects } from "../chains";
|
|
11
9
|
|
|
12
|
-
export function usePaymaster(chain:
|
|
10
|
+
export function usePaymaster(chain: SmartWalletChain) {
|
|
13
11
|
return !usesGelatoBundler(chain);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
const getPaymasterRPC = (chain:
|
|
17
|
-
|
|
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:
|
|
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:
|
|
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
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
101
|
+
chain: SmartWalletChain
|
|
102
102
|
): Promise<{
|
|
103
103
|
entryPoint: EntryPointDetails;
|
|
104
104
|
kernelVersion: SupportedKernelVersion;
|
package/src/error/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export const SmartWalletErrors = {
|
|
|
14
14
|
ERROR_ADMIN_MISMATCH: "smart-wallet:wallet-config.admin-mismatch",
|
|
15
15
|
ERROR_PASSKEY_MISMATCH: "smart-wallet:wallet-config.passkey-mismatch",
|
|
16
16
|
ERROR_ADMIN_SIGNER_ALREADY_USED: "smart-wallet:wallet-config.admin-signer-already-used",
|
|
17
|
+
ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED: "smart-wallet:wallet-config.non-custodial-wallets-not-enabled",
|
|
17
18
|
UNCATEGORIZED: "smart-wallet:uncategorized", // catch-all error code
|
|
18
19
|
} as const;
|
|
19
20
|
export type SmartWalletErrorCode = (typeof SmartWalletErrors)[keyof typeof SmartWalletErrors];
|
|
@@ -142,6 +143,7 @@ export class AdminAlreadyUsedError extends ConfigError {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
export class NonCustodialWalletsNotEnabledError extends ConfigError {
|
|
146
|
+
public readonly code = SmartWalletErrors.ERROR_PROJECT_NONCUSTODIAL_WALLETS_NOT_ENABLED;
|
|
145
147
|
constructor() {
|
|
146
148
|
super("Non-custodial wallets are not enabled for this project");
|
|
147
149
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { blockchainToChainId } from "@crossmint/common-sdk-base";
|
|
2
2
|
|
|
3
3
|
export { EVMSmartWallet } from "./blockchain/wallets/EVMSmartWallet";
|
|
4
4
|
|
|
@@ -12,6 +12,7 @@ export type {
|
|
|
12
12
|
} from "./types/Config";
|
|
13
13
|
|
|
14
14
|
export type { TransferType, ERC20TransferType, NFTTransferType, SFTTransferType } from "./types/Tokens";
|
|
15
|
+
export { SmartWalletChain } from "./blockchain/chains";
|
|
15
16
|
|
|
16
17
|
export {
|
|
17
18
|
TransferError,
|
package/src/types/Tokens.ts
CHANGED
package/src/types/internal.ts
CHANGED
|
@@ -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
|
|
8
|
-
|
|
7
|
+
import { SmartWalletChain } from "..";
|
|
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:
|
|
27
|
+
chain: SmartWalletChain;
|
|
29
28
|
publicClient: PublicClient<HttpTransport>;
|
|
30
29
|
walletParams: WalletParams;
|
|
31
30
|
entryPoint: EntryPointDetails;
|
package/src/utils/blockchain.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SmartWalletChain } from "..";
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
|
|
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
|
}
|
package/src/utils/constants.ts
CHANGED
|
@@ -4,28 +4,8 @@ export const DATADOG_CLIENT_TOKEN = "pub035be8a594b35be1887b6ba76c4029ca";
|
|
|
4
4
|
export const CROSSMINT_DEV_URL = "http://localhost:3000/api";
|
|
5
5
|
export const CROSSMINT_STG_URL = "https://staging.crossmint.com/api";
|
|
6
6
|
export const CROSSMINT_PROD_URL = "https://www.crossmint.com/api";
|
|
7
|
-
export const ZD_ETHEREUM_PROJECT_ID = "9ee29857-8077-404b-9a9a-31eeea996a4a";
|
|
8
|
-
export const ZD_POLYGON_PROJECT_ID = "023d4a21-d801-4450-b629-24439ab1369d";
|
|
9
|
-
export const ZD_BSC_PROJECT_ID = "3d166617-da86-494b-9348-e8a13343bc04";
|
|
10
|
-
export const ZD_OPTIMISM_PROJECT_ID = "e9314f9e-a13d-414f-b965-c591a0248243";
|
|
11
|
-
export const ZD_ARBITRUM_PROJECT_ID = "1641cd99-c1ef-404a-9d26-a9dc67b1ba51";
|
|
12
|
-
export const ZD_GOERLI_PROJECT_ID = "3cfecfb6-9d7d-4ef6-acaa-ac8f79f6cd5a";
|
|
13
|
-
export const ZD_SEPOLIA_PROJECT_ID = "7ff22858-06f0-4f3a-8b46-5b41d8c75d0e";
|
|
14
|
-
export const ZD_AMOY_PROJECT_ID = "3b24773b-d91e-4c01-8ce5-04807463bbca";
|
|
15
|
-
export const ZD_ZKATANA_PROJECT_ID = "d54706a0-304b-419e-8a33-03c26ba3f0e9";
|
|
16
|
-
export const ZD_ZKYOTO_PROJECT_ID = "ce986d52-4f27-4a2b-b429-eb2322f15f32";
|
|
17
|
-
export const ZD_ASTAR_PROJECT_ID = "6204f336-643f-41af-94e1-f8d146c91675";
|
|
18
|
-
export const ZD_BASE_SEPOLIA_PROJECT_ID = "3eb830c5-f91b-48e0-bb7d-dc30103a60b2";
|
|
19
|
-
export const ZD_OPTIMISM_SEPOLIA_PROJECT_ID = "6188b92b-993e-4f39-be22-56e4806416a8";
|
|
20
|
-
export const ZD_ARBITRUM_SEPOLIA_PROJECT_ID = "8b8b6d1a-184c-4198-8f29-c07e63aad595";
|
|
21
|
-
export const ZD_BASE_PROJECT_ID = "5535aa3b-4f9c-45af-9c38-0072369564a3";
|
|
22
|
-
export const ZD_ARBITRUM_NOVA_PROJECT_ID = "b6a6db7c-65de-4f74-9d8f-f70d9c083531";
|
|
23
|
-
export const RELAY_API_KEY = "c8999b7e-8bb7-416d-a854-dac8632f9ee6_crossmint";
|
|
24
7
|
export const SCW_SERVICE = "SCW_SDK";
|
|
25
8
|
export const SDK_VERSION = "0.1.0";
|
|
26
9
|
export const API_VERSION = "2024-06-09";
|
|
27
10
|
export const BUNDLER_RPC = "https://rpc.zerodev.app/api/v2/bundler/";
|
|
28
11
|
export const PAYMASTER_RPC = "https://rpc.zerodev.app/api/v2/paymaster/";
|
|
29
|
-
export const PM_BASE_SEPOLIA_RPC =
|
|
30
|
-
"https://api.developer.coinbase.com/rpc/v1/base-sepolia/6BTAmOQZ0x1YWtI24hIKKqdHWmVP1UXf";
|
|
31
|
-
export const PM_BASE_RPC = "https://api.developer.coinbase.com/rpc/v1/base/6BTAmOQZ0x1YWtI24hIKKqdHWmVP1UXf";
|
package/src/utils/signer.ts
CHANGED
|
@@ -2,14 +2,13 @@ import { providerToSmartAccountSigner } from "permissionless";
|
|
|
2
2
|
import type { SmartAccountSigner } from "permissionless/accounts";
|
|
3
3
|
import { Address, EIP1193Provider } from "viem";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { SmartWalletChain } from "..";
|
|
7
6
|
import { SmartWalletSDKError } from "../error";
|
|
8
7
|
import { ViemAccount, WalletParams } from "../types/Config";
|
|
9
8
|
import { logInputOutput } from "./log";
|
|
10
9
|
|
|
11
10
|
type CreateOwnerSignerInput = {
|
|
12
|
-
chain:
|
|
11
|
+
chain: SmartWalletChain;
|
|
13
12
|
walletParams: WalletParams;
|
|
14
13
|
};
|
|
15
14
|
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BUNDLER_RPC,
|
|
3
|
-
PM_BASE_RPC,
|
|
4
|
-
PM_BASE_SEPOLIA_RPC,
|
|
5
|
-
ZD_AMOY_PROJECT_ID,
|
|
6
|
-
ZD_ARBITRUM_NOVA_PROJECT_ID,
|
|
7
|
-
ZD_ARBITRUM_PROJECT_ID,
|
|
8
|
-
ZD_ARBITRUM_SEPOLIA_PROJECT_ID,
|
|
9
|
-
ZD_ASTAR_PROJECT_ID,
|
|
10
|
-
ZD_BASE_PROJECT_ID,
|
|
11
|
-
ZD_BASE_SEPOLIA_PROJECT_ID,
|
|
12
|
-
ZD_BSC_PROJECT_ID,
|
|
13
|
-
ZD_ETHEREUM_PROJECT_ID,
|
|
14
|
-
ZD_GOERLI_PROJECT_ID,
|
|
15
|
-
ZD_OPTIMISM_PROJECT_ID,
|
|
16
|
-
ZD_OPTIMISM_SEPOLIA_PROJECT_ID,
|
|
17
|
-
ZD_POLYGON_PROJECT_ID,
|
|
18
|
-
ZD_SEPOLIA_PROJECT_ID,
|
|
19
|
-
ZD_ZKATANA_PROJECT_ID,
|
|
20
|
-
ZD_ZKYOTO_PROJECT_ID,
|
|
21
|
-
} from "@/utils/constants";
|
|
22
|
-
import {
|
|
23
|
-
arbitrum,
|
|
24
|
-
arbitrumNova,
|
|
25
|
-
arbitrumSepolia,
|
|
26
|
-
astarZkEVM,
|
|
27
|
-
astarZkyoto,
|
|
28
|
-
base,
|
|
29
|
-
baseSepolia,
|
|
30
|
-
bsc,
|
|
31
|
-
goerli,
|
|
32
|
-
mainnet,
|
|
33
|
-
optimism,
|
|
34
|
-
optimismSepolia,
|
|
35
|
-
polygon,
|
|
36
|
-
polygonAmoy,
|
|
37
|
-
sepolia,
|
|
38
|
-
} from "viem/chains";
|
|
39
|
-
|
|
40
|
-
import { EVMBlockchainIncludingTestnet } from "@crossmint/common-sdk-base";
|
|
41
|
-
|
|
42
|
-
export const getZeroDevProjectIdByBlockchain = (chain: EVMBlockchainIncludingTestnet) => {
|
|
43
|
-
const zeroDevProjectId = new Map<EVMBlockchainIncludingTestnet, string | null>([
|
|
44
|
-
["ethereum", ZD_ETHEREUM_PROJECT_ID],
|
|
45
|
-
["polygon", ZD_POLYGON_PROJECT_ID],
|
|
46
|
-
["bsc", ZD_BSC_PROJECT_ID],
|
|
47
|
-
["optimism", ZD_OPTIMISM_PROJECT_ID],
|
|
48
|
-
["arbitrum", ZD_ARBITRUM_PROJECT_ID],
|
|
49
|
-
["ethereum-goerli", ZD_GOERLI_PROJECT_ID],
|
|
50
|
-
["ethereum-sepolia", ZD_SEPOLIA_PROJECT_ID],
|
|
51
|
-
["polygon-amoy", ZD_AMOY_PROJECT_ID],
|
|
52
|
-
["zkatana", ZD_ZKATANA_PROJECT_ID],
|
|
53
|
-
["zkyoto", ZD_ZKYOTO_PROJECT_ID],
|
|
54
|
-
["arbitrum-sepolia", ZD_ARBITRUM_SEPOLIA_PROJECT_ID],
|
|
55
|
-
["base-goerli", null],
|
|
56
|
-
["base-sepolia", ZD_BASE_SEPOLIA_PROJECT_ID],
|
|
57
|
-
["bsc-testnet", null],
|
|
58
|
-
["optimism-goerli", null],
|
|
59
|
-
["optimism-sepolia", ZD_OPTIMISM_SEPOLIA_PROJECT_ID],
|
|
60
|
-
["zora-goerli", null],
|
|
61
|
-
["zora-sepolia", null],
|
|
62
|
-
["base", ZD_BASE_PROJECT_ID],
|
|
63
|
-
["zora", null],
|
|
64
|
-
["arbitrumnova", ZD_ARBITRUM_NOVA_PROJECT_ID],
|
|
65
|
-
["astar-zkevm", ZD_ASTAR_PROJECT_ID],
|
|
66
|
-
["apex", null],
|
|
67
|
-
]).get(chain)!;
|
|
68
|
-
|
|
69
|
-
if (zeroDevProjectId == null) {
|
|
70
|
-
throw new Error(`ZeroDev project id not found for chain ${chain}`);
|
|
71
|
-
}
|
|
72
|
-
return zeroDevProjectId;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const getViemNetwork = (cmChain: EVMBlockchainIncludingTestnet) => {
|
|
76
|
-
switch (cmChain) {
|
|
77
|
-
case "ethereum":
|
|
78
|
-
return mainnet;
|
|
79
|
-
case "ethereum-goerli":
|
|
80
|
-
return goerli;
|
|
81
|
-
case "ethereum-sepolia":
|
|
82
|
-
return sepolia;
|
|
83
|
-
case "polygon":
|
|
84
|
-
return polygon;
|
|
85
|
-
case "polygon-amoy":
|
|
86
|
-
return polygonAmoy;
|
|
87
|
-
case "optimism":
|
|
88
|
-
return optimism;
|
|
89
|
-
case "optimism-sepolia":
|
|
90
|
-
return optimismSepolia;
|
|
91
|
-
case "arbitrum":
|
|
92
|
-
return arbitrum;
|
|
93
|
-
case "arbitrumnova":
|
|
94
|
-
return arbitrumNova;
|
|
95
|
-
case "arbitrum-sepolia":
|
|
96
|
-
return arbitrumSepolia;
|
|
97
|
-
case "base":
|
|
98
|
-
return base;
|
|
99
|
-
case "base-sepolia":
|
|
100
|
-
return baseSepolia;
|
|
101
|
-
case "zkyoto":
|
|
102
|
-
return astarZkyoto;
|
|
103
|
-
case "astar-zkevm":
|
|
104
|
-
return astarZkEVM;
|
|
105
|
-
case "bsc":
|
|
106
|
-
return bsc;
|
|
107
|
-
default:
|
|
108
|
-
throw new Error(`Unsupported network: ${cmChain}`);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const getBundlerRPC = (chain: EVMBlockchainIncludingTestnet) => {
|
|
113
|
-
switch (chain) {
|
|
114
|
-
case EVMBlockchainIncludingTestnet.BASE_SEPOLIA:
|
|
115
|
-
return PM_BASE_SEPOLIA_RPC;
|
|
116
|
-
case EVMBlockchainIncludingTestnet.BASE:
|
|
117
|
-
return PM_BASE_RPC;
|
|
118
|
-
default:
|
|
119
|
-
return BUNDLER_RPC + getZeroDevProjectIdByBlockchain(chain) + "?bundlerProvider=STACKUP";
|
|
120
|
-
}
|
|
121
|
-
};
|