@account-kit/infra 4.0.0-beta.0 → 4.0.0-beta.10
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/esm/alchemyTransport.d.ts +69 -0
- package/dist/esm/alchemyTransport.js +139 -0
- package/dist/esm/alchemyTransport.js.map +1 -0
- package/dist/esm/chains.d.ts +1 -0
- package/dist/esm/chains.js +17 -0
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/decorators/alchemyEnhancedApis.d.ts +2 -2
- package/dist/esm/client/decorators/alchemyEnhancedApis.js +3 -7
- package/dist/esm/client/decorators/alchemyEnhancedApis.js.map +1 -1
- package/dist/esm/client/decorators/smartAccount.d.ts +7 -4
- package/dist/esm/client/decorators/smartAccount.js +33 -0
- package/dist/esm/client/decorators/smartAccount.js.map +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.d.ts +1 -1
- package/dist/esm/client/isAlchemySmartAccountClient.js +2 -6
- package/dist/esm/client/isAlchemySmartAccountClient.js.map +1 -1
- package/dist/esm/client/rpcClient.d.ts +9 -10
- package/dist/esm/client/rpcClient.js +9 -33
- package/dist/esm/client/rpcClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.d.ts +12 -9
- package/dist/esm/client/smartAccountClient.js +34 -20
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +8 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -4
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/metrics.d.ts +12 -0
- package/dist/esm/metrics.js +7 -0
- package/dist/esm/metrics.js.map +1 -0
- package/dist/esm/middleware/feeEstimator.d.ts +10 -6
- package/dist/esm/middleware/feeEstimator.js +11 -6
- package/dist/esm/middleware/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/gasManager.d.ts +5 -6
- package/dist/esm/middleware/gasManager.js +5 -6
- package/dist/esm/middleware/gasManager.js.map +1 -1
- package/dist/esm/middleware/userOperationSimulator.d.ts +11 -7
- package/dist/esm/middleware/userOperationSimulator.js +12 -8
- package/dist/esm/middleware/userOperationSimulator.js.map +1 -1
- package/dist/esm/schema.d.ts +0 -391
- package/dist/esm/schema.js +1 -5
- package/dist/esm/schema.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/alchemyTransport.d.ts +70 -0
- package/dist/types/alchemyTransport.d.ts.map +1 -0
- package/dist/types/chains.d.ts +1 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts +2 -2
- package/dist/types/client/decorators/alchemyEnhancedApis.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccount.d.ts +7 -4
- package/dist/types/client/decorators/smartAccount.d.ts.map +1 -1
- package/dist/types/client/isAlchemySmartAccountClient.d.ts +1 -1
- package/dist/types/client/isAlchemySmartAccountClient.d.ts.map +1 -1
- package/dist/types/client/rpcClient.d.ts +9 -10
- package/dist/types/client/rpcClient.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts +12 -9
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +8 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/metrics.d.ts +13 -0
- package/dist/types/metrics.d.ts.map +1 -0
- package/dist/types/middleware/feeEstimator.d.ts +10 -6
- package/dist/types/middleware/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/gasManager.d.ts +5 -6
- package/dist/types/middleware/gasManager.d.ts.map +1 -1
- package/dist/types/middleware/userOperationSimulator.d.ts +11 -7
- package/dist/types/middleware/userOperationSimulator.d.ts.map +1 -1
- package/dist/types/schema.d.ts +0 -391
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +6 -10
- package/src/alchemyTransport.ts +214 -0
- package/src/chains.ts +18 -0
- package/src/client/decorators/alchemyEnhancedApis.ts +9 -16
- package/src/client/decorators/smartAccount.ts +77 -7
- package/src/client/isAlchemySmartAccountClient.ts +4 -9
- package/src/client/rpcClient.ts +14 -47
- package/src/client/smartAccountClient.ts +64 -57
- package/src/client/types.ts +10 -7
- package/src/index.ts +8 -8
- package/src/metrics.ts +19 -0
- package/src/middleware/feeEstimator.ts +15 -10
- package/src/middleware/gasManager.ts +5 -6
- package/src/middleware/userOperationSimulator.ts +13 -10
- package/src/schema.ts +1 -14
- package/src/version.ts +1 -1
- package/dist/esm/client/internal/smartAccountClientFromRpc.d.ts +0 -18
- package/dist/esm/client/internal/smartAccountClientFromRpc.js +0 -56
- package/dist/esm/client/internal/smartAccountClientFromRpc.js.map +0 -1
- package/dist/esm/type.d.ts +0 -3
- package/dist/esm/type.js +0 -2
- package/dist/esm/type.js.map +0 -1
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts +0 -19
- package/dist/types/client/internal/smartAccountClientFromRpc.d.ts.map +0 -1
- package/dist/types/type.d.ts +0 -4
- package/dist/types/type.d.ts.map +0 -1
- package/src/client/internal/smartAccountClientFromRpc.ts +0 -125
- package/src/type.ts +0 -4
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type ConnectionConfig, type NoUndefined } from "@aa-sdk/core";
|
|
2
|
+
import { type EIP1193RequestFn, type HttpTransportConfig, type PublicRpcSchema, type Transport, type TransportConfig } from "viem";
|
|
3
|
+
import type { AlchemyRpcSchema } from "./client/types.js";
|
|
4
|
+
type Never<T> = T extends object ? {
|
|
5
|
+
[K in keyof T]?: never;
|
|
6
|
+
} : never;
|
|
7
|
+
type SplitTransportConfig = {
|
|
8
|
+
alchemyConnection: ConnectionConfig;
|
|
9
|
+
nodeRpcUrl: string;
|
|
10
|
+
};
|
|
11
|
+
export type AlchemyTransportConfig = ((ConnectionConfig & Never<SplitTransportConfig>) | (SplitTransportConfig & Never<ConnectionConfig>)) & {
|
|
12
|
+
/** The max number of times to retry. */
|
|
13
|
+
retryCount?: TransportConfig["retryCount"] | undefined;
|
|
14
|
+
/** The base delay (in ms) between retries. */
|
|
15
|
+
retryDelay?: TransportConfig["retryDelay"] | undefined;
|
|
16
|
+
fetchOptions?: NoUndefined<HttpTransportConfig["fetchOptions"]>;
|
|
17
|
+
};
|
|
18
|
+
type AlchemyTransportBase = Transport<"alchemy", {
|
|
19
|
+
alchemyRpcUrl: string;
|
|
20
|
+
fetchOptions?: AlchemyTransportConfig["fetchOptions"];
|
|
21
|
+
}, EIP1193RequestFn<[...PublicRpcSchema, ...AlchemyRpcSchema]>>;
|
|
22
|
+
export type AlchemyTransport = AlchemyTransportBase & {
|
|
23
|
+
updateHeaders(newHeaders: HeadersInit): void;
|
|
24
|
+
config: AlchemyTransportConfig;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Creates an Alchemy transport with the specified configuration options.
|
|
28
|
+
* When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.
|
|
29
|
+
* If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ### Basic Example
|
|
33
|
+
* If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { alchemy } from "@account-kit/infra";
|
|
36
|
+
*
|
|
37
|
+
* const transport = alchemy({
|
|
38
|
+
* // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt
|
|
39
|
+
* apiKey: "your-api-key",
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* ### AA Only Chains
|
|
44
|
+
* For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only
|
|
45
|
+
* handles the Bundler and Paymaster RPCs for these chains.
|
|
46
|
+
* ```ts
|
|
47
|
+
* import { alchemy } from "@account-kit/infra";
|
|
48
|
+
*
|
|
49
|
+
* const transport = alchemy({
|
|
50
|
+
* alchemyConnection: {
|
|
51
|
+
* apiKey: "your-api-key",
|
|
52
|
+
* },
|
|
53
|
+
* nodeRpcUrl: "https://zora.rpc.url",
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.
|
|
58
|
+
* @param {number} config.retryDelay Optional The delay between retries, in milliseconds.
|
|
59
|
+
* @param {number} config.retryCount Optional The number of retry attempts.
|
|
60
|
+
* @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).
|
|
61
|
+
* @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.
|
|
62
|
+
* @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).
|
|
63
|
+
* @param {string} [config.rpcUrl] Optional RPC URL.
|
|
64
|
+
* @param {string} [config.apiKey] Optional API key for Alchemy.
|
|
65
|
+
* @param {string} [config.jwt] Optional JSON Web Token for authorization.
|
|
66
|
+
* @returns {AlchemyTransport} The configured Alchemy transport object.
|
|
67
|
+
*/
|
|
68
|
+
export declare function alchemy(config: AlchemyTransportConfig): AlchemyTransport;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ChainNotFoundError, ConnectionConfigSchema, split, } from "@aa-sdk/core";
|
|
2
|
+
import { createTransport, http, } from "viem";
|
|
3
|
+
import { AlchemyChainSchema } from "./schema.js";
|
|
4
|
+
import { VERSION } from "./version.js";
|
|
5
|
+
const alchemyMethods = [
|
|
6
|
+
"eth_sendUserOperation",
|
|
7
|
+
"eth_estimateUserOperationGas",
|
|
8
|
+
"eth_getUserOperationReceipt",
|
|
9
|
+
"eth_getUserOperationByHash",
|
|
10
|
+
"eth_supportedEntryPoints",
|
|
11
|
+
"rundler_maxPriorityFeePerGas",
|
|
12
|
+
"pm_getPaymasterData",
|
|
13
|
+
"pm_getPaymasterStubData",
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Creates an Alchemy transport with the specified configuration options.
|
|
17
|
+
* When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.
|
|
18
|
+
* If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ### Basic Example
|
|
22
|
+
* If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { alchemy } from "@account-kit/infra";
|
|
25
|
+
*
|
|
26
|
+
* const transport = alchemy({
|
|
27
|
+
* // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt
|
|
28
|
+
* apiKey: "your-api-key",
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ### AA Only Chains
|
|
33
|
+
* For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only
|
|
34
|
+
* handles the Bundler and Paymaster RPCs for these chains.
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { alchemy } from "@account-kit/infra";
|
|
37
|
+
*
|
|
38
|
+
* const transport = alchemy({
|
|
39
|
+
* alchemyConnection: {
|
|
40
|
+
* apiKey: "your-api-key",
|
|
41
|
+
* },
|
|
42
|
+
* nodeRpcUrl: "https://zora.rpc.url",
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.
|
|
47
|
+
* @param {number} config.retryDelay Optional The delay between retries, in milliseconds.
|
|
48
|
+
* @param {number} config.retryCount Optional The number of retry attempts.
|
|
49
|
+
* @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).
|
|
50
|
+
* @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.
|
|
51
|
+
* @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).
|
|
52
|
+
* @param {string} [config.rpcUrl] Optional RPC URL.
|
|
53
|
+
* @param {string} [config.apiKey] Optional API key for Alchemy.
|
|
54
|
+
* @param {string} [config.jwt] Optional JSON Web Token for authorization.
|
|
55
|
+
* @returns {AlchemyTransport} The configured Alchemy transport object.
|
|
56
|
+
*/
|
|
57
|
+
export function alchemy(config) {
|
|
58
|
+
const { retryDelay, retryCount } = config;
|
|
59
|
+
// we create a copy here in case we create a split transport down below
|
|
60
|
+
// we don't want to add alchemy headers to 3rd party nodes
|
|
61
|
+
const fetchOptions = { ...config.fetchOptions };
|
|
62
|
+
const connectionConfig = ConnectionConfigSchema.parse(config.alchemyConnection ?? config);
|
|
63
|
+
const headersAsObject = convertHeadersToObject(fetchOptions.headers);
|
|
64
|
+
// TODO: we probably should just log these headers during telemetry logging instead of doing this mutable header stuff
|
|
65
|
+
fetchOptions.headers = {
|
|
66
|
+
...headersAsObject,
|
|
67
|
+
"Alchemy-AA-Sdk-Version": VERSION,
|
|
68
|
+
};
|
|
69
|
+
if (connectionConfig.jwt != null) {
|
|
70
|
+
fetchOptions.headers = {
|
|
71
|
+
...fetchOptions.headers,
|
|
72
|
+
Authorization: `Bearer ${connectionConfig.jwt}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const transport = (opts) => {
|
|
76
|
+
const { chain: chain_ } = opts;
|
|
77
|
+
if (!chain_) {
|
|
78
|
+
throw new ChainNotFoundError();
|
|
79
|
+
}
|
|
80
|
+
const chain = AlchemyChainSchema.parse(chain_);
|
|
81
|
+
const rpcUrl = connectionConfig.rpcUrl == null
|
|
82
|
+
? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? ""}`
|
|
83
|
+
: connectionConfig.rpcUrl;
|
|
84
|
+
const innerTransport = (() => {
|
|
85
|
+
if (config.alchemyConnection && config.nodeRpcUrl) {
|
|
86
|
+
return split({
|
|
87
|
+
overrides: [
|
|
88
|
+
{
|
|
89
|
+
methods: alchemyMethods,
|
|
90
|
+
transport: http(rpcUrl, { fetchOptions }),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
fallback: http(config.nodeRpcUrl, {
|
|
94
|
+
fetchOptions: config.fetchOptions,
|
|
95
|
+
}),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return http(rpcUrl, { fetchOptions });
|
|
99
|
+
})();
|
|
100
|
+
return createTransport({
|
|
101
|
+
key: "alchemy",
|
|
102
|
+
name: "Alchemy Transport",
|
|
103
|
+
request: innerTransport(opts).request,
|
|
104
|
+
retryCount: retryCount ?? opts?.retryCount,
|
|
105
|
+
retryDelay,
|
|
106
|
+
type: "alchemy",
|
|
107
|
+
}, { alchemyRpcUrl: rpcUrl, fetchOptions });
|
|
108
|
+
};
|
|
109
|
+
return Object.assign(transport, {
|
|
110
|
+
updateHeaders(newHeaders_) {
|
|
111
|
+
const newHeaders = convertHeadersToObject(newHeaders_);
|
|
112
|
+
fetchOptions.headers = {
|
|
113
|
+
...fetchOptions.headers,
|
|
114
|
+
...newHeaders,
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
config,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const convertHeadersToObject = (headers) => {
|
|
121
|
+
if (!headers) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
if (headers instanceof Headers) {
|
|
125
|
+
const headersObject = {};
|
|
126
|
+
headers.forEach((value, key) => {
|
|
127
|
+
headersObject[key] = value;
|
|
128
|
+
});
|
|
129
|
+
return headersObject;
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(headers)) {
|
|
132
|
+
return headers.reduce((acc, header) => {
|
|
133
|
+
acc[header[0]] = header[1];
|
|
134
|
+
return acc;
|
|
135
|
+
}, {});
|
|
136
|
+
}
|
|
137
|
+
return headers;
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=alchemyTransport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alchemyTransport.js","sourceRoot":"","sources":["../../src/alchemyTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,GAGN,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,IAAI,GAML,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAavC,MAAM,cAAc,GAAG;IACrB,uBAAuB;IACvB,8BAA8B;IAC9B,6BAA6B;IAC7B,4BAA4B;IAC5B,0BAA0B;IAC1B,8BAA8B;IAC9B,qBAAqB;IACrB,yBAAyB;CAC1B,CAAC;AA2BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,OAAO,CAAC,MAA8B;IACpD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1C,uEAAuE;IACvE,0DAA0D;IAC1D,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAEhD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,KAAK,CACnD,MAAM,CAAC,iBAAiB,IAAI,MAAM,CACnC,CAAC;IAEF,MAAM,eAAe,GAAG,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAErE,sHAAsH;IACtH,YAAY,CAAC,OAAO,GAAG;QACrB,GAAG,eAAe;QAClB,wBAAwB,EAAE,OAAO;KAClC,CAAC;IAEF,IAAI,gBAAgB,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QACjC,YAAY,CAAC,OAAO,GAAG;YACrB,GAAG,YAAY,CAAC,OAAO;YACvB,aAAa,EAAE,UAAU,gBAAgB,CAAC,GAAG,E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;SAChB,EACD,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,CACxC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QAC9B,aAAa,CAAC,WAAwB;YACpC,MAAM,UAAU,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAEvD,YAAY,CAAC,OAAO,GAAG;gBACrB,GAAG,YAAY,CAAC,OAAO;gBACvB,GAAG,UAAU;aACd,CAAC;QACJ,CAAC;QACD,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,MAAM,sBAAsB,GAAG,CAC7B,OAAqB,EACG,EAAE;IAC1B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;QAC/B,MAAM,aAAa,GAAG,EAA4B,CAAC;QACnD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3B,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAA4B,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n ConnectionConfigSchema,\n split,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport {\n createTransport,\n http,\n type EIP1193RequestFn,\n type HttpTransportConfig,\n type PublicRpcSchema,\n type Transport,\n type TransportConfig,\n} from \"viem\";\nimport type { AlchemyRpcSchema } from \"./client/types.js\";\nimport { AlchemyChainSchema } from \"./schema.js\";\nimport { VERSION } from \"./version.js\";\n\ntype Never<T> = T extends object\n ? {\n [K in keyof T]?: never;\n }\n : never;\n\ntype SplitTransportConfig = {\n alchemyConnection: ConnectionConfig;\n nodeRpcUrl: string;\n};\n\nconst alchemyMethods = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"rundler_maxPriorityFeePerGas\",\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n];\n\nexport type AlchemyTransportConfig = (\n | (ConnectionConfig & Never<SplitTransportConfig>)\n | (SplitTransportConfig & Never<ConnectionConfig>)\n) & {\n /** The max number of times to retry. */\n retryCount?: TransportConfig[\"retryCount\"] | undefined;\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig[\"retryDelay\"] | undefined;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n};\n\ntype AlchemyTransportBase = Transport<\n \"alchemy\",\n {\n alchemyRpcUrl: string;\n fetchOptions?: AlchemyTransportConfig[\"fetchOptions\"];\n },\n EIP1193RequestFn<[...PublicRpcSchema, ...AlchemyRpcSchema]>\n>;\n\nexport type AlchemyTransport = AlchemyTransportBase & {\n updateHeaders(newHeaders: HeadersInit): void;\n config: AlchemyTransportConfig;\n};\n\n/**\n * Creates an Alchemy transport with the specified configuration options.\n * When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.\n * If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.\n *\n * @example\n * ### Basic Example\n * If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * ### AA Only Chains\n * For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only\n * handles the Bundler and Paymaster RPCs for these chains.\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * alchemyConnection: {\n * apiKey: \"your-api-key\",\n * },\n * nodeRpcUrl: \"https://zora.rpc.url\",\n * });\n * ```\n *\n * @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.\n * @param {number} config.retryDelay Optional The delay between retries, in milliseconds.\n * @param {number} config.retryCount Optional The number of retry attempts.\n * @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).\n * @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.\n * @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).\n * @param {string} [config.rpcUrl] Optional RPC URL.\n * @param {string} [config.apiKey] Optional API key for Alchemy.\n * @param {string} [config.jwt] Optional JSON Web Token for authorization.\n * @returns {AlchemyTransport} The configured Alchemy transport object.\n */\nexport function alchemy(config: AlchemyTransportConfig): AlchemyTransport {\n const { retryDelay, retryCount } = config;\n // we create a copy here in case we create a split transport down below\n // we don't want to add alchemy headers to 3rd party nodes\n const fetchOptions = { ...config.fetchOptions };\n\n const connectionConfig = ConnectionConfigSchema.parse(\n config.alchemyConnection ?? config\n );\n\n const headersAsObject = convertHeadersToObject(fetchOptions.headers);\n\n // TODO: we probably should just log these headers during telemetry logging instead of doing this mutable header stuff\n fetchOptions.headers = {\n ...headersAsObject,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n const transport: AlchemyTransportBase = (opts) => {\n const { chain: chain_ } = opts;\n if (!chain_) {\n throw new ChainNotFoundError();\n }\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n const innerTransport = (() => {\n if (config.alchemyConnection && config.nodeRpcUrl) {\n return split({\n overrides: [\n {\n methods: alchemyMethods,\n transport: http(rpcUrl, { fetchOptions }),\n },\n ],\n fallback: http(config.nodeRpcUrl, {\n fetchOptions: config.fetchOptions,\n }),\n });\n }\n\n return http(rpcUrl, { fetchOptions });\n })();\n\n return createTransport(\n {\n key: \"alchemy\",\n name: \"Alchemy Transport\",\n request: innerTransport(opts).request,\n retryCount: retryCount ?? opts?.retryCount,\n retryDelay,\n type: \"alchemy\",\n },\n { alchemyRpcUrl: rpcUrl, fetchOptions }\n );\n };\n\n return Object.assign(transport, {\n updateHeaders(newHeaders_: HeadersInit) {\n const newHeaders = convertHeadersToObject(newHeaders_);\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n config,\n });\n}\n\nconst convertHeadersToObject = (\n headers?: HeadersInit\n): Record<string, string> => {\n if (!headers) {\n return {};\n }\n\n if (headers instanceof Headers) {\n const headersObject = {} as Record<string, string>;\n headers.forEach((value, key) => {\n headersObject[key] = value;\n });\n return headersObject;\n }\n\n if (Array.isArray(headers)) {\n return headers.reduce((acc, header) => {\n acc[header[0]] = header[1];\n return acc;\n }, {} as Record<string, string>);\n }\n\n return headers;\n};\n"]}
|
package/dist/esm/chains.d.ts
CHANGED
package/dist/esm/chains.js
CHANGED
|
@@ -261,6 +261,23 @@ export const shape = defineChain({
|
|
|
261
261
|
},
|
|
262
262
|
},
|
|
263
263
|
});
|
|
264
|
+
export const beraChainBartio = defineChain({
|
|
265
|
+
id: 80084,
|
|
266
|
+
name: "BeraChain Bartio",
|
|
267
|
+
network: "BeraChain Bartio",
|
|
268
|
+
nativeCurrency: { name: "Bera", symbol: "BERA", decimals: 18 },
|
|
269
|
+
rpcUrls: {
|
|
270
|
+
default: {
|
|
271
|
+
http: ["https://berachain-bartio.g.alchemy.com/v2"],
|
|
272
|
+
},
|
|
273
|
+
public: {
|
|
274
|
+
http: ["https://berachain-bartio.g.alchemy.com/v2"],
|
|
275
|
+
},
|
|
276
|
+
alchemy: {
|
|
277
|
+
http: ["https://berachain-bartio.g.alchemy.com/v2"],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
});
|
|
264
281
|
export const arbitrumNova = {
|
|
265
282
|
...vabn,
|
|
266
283
|
rpcUrls: {
|
package/dist/esm/chains.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EACL,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,IAAI,IAAI,KAAK,EACb,UAAU,IAAI,MAAM,EACpB,WAAW,IAAI,MAAM,EACrB,OAAO,IAAI,KAAK,EAChB,MAAM,IAAI,GAAG,EACb,OAAO,IAAI,KAAK,EAChB,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,OAAO,IAAI,GAAG,EACd,WAAW,IAAI,IAAI,EACnB,aAAa,IAAI,IAAI,EACrB,OAAO,IAAI,IAAI,EACf,YAAY,IAAI,IAAI,EACpB,IAAI,IAAI,KAAK,EACb,WAAW,IAAI,MAAM,GACtB,MAAM,aAAa,CAAC;AAOrB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,KAAK,EACL,UAAU,GAIX,EAAS,EAAE;IACV,OAAO;QACL,GAAG,KAAK;QACR,OAAO,EAAE;YACP,GAAG,KAAK,CAAC,OAAO;YAChB,OAAO,EAAE;gBACP,IAAI,EAAE,CAAC,UA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YACP,IAAI,EAAE,CAAC,wCAAwC,CAAC;SACjD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,wCAAwC,CAAC;SACjD;QACD,OAAO,EAAE;YACP,IAAI,EAAE,CAAC,wCAAwC,CAAC;SACjD;KACF;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,GAAG,IAAI;IACP,OAAO,EAAE;QACP,GAAG,IAAI,CAAC,OAAO;KAChB;CACF,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n arbitrumNova as vabn,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\n */\nexport const defineAlchemyChain = ({\n chain,\n rpcBaseUrl,\n}: {\n chain: Chain;\n rpcBaseUrl: string;\n}): Chain => {\n return {\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n alchemy: {\n http: [rpcBaseUrl],\n },\n },\n };\n};\n\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n\nexport const worldChainSepolia: Chain = defineChain({\n id: 4801,\n name: \"World Chain Sepolia\",\n network: \"World Chain Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const worldChain: Chain = defineChain({\n id: 480,\n name: \"World Chain\",\n network: \"World Chain\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const shapeSepolia: Chain = defineChain({\n id: 11011,\n name: \"Shape Sepolia\",\n network: \"Shape Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const shape: Chain = defineChain({\n id: 360,\n name: \"Shape\",\n network: \"Shape\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const arbitrumNova: Chain = {\n ...vabn,\n rpcUrls: {\n ...vabn.rpcUrls,\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,EACL,QAAQ,IAAI,GAAG,EACf,cAAc,IAAI,IAAI,EACtB,eAAe,IAAI,IAAI,EACvB,IAAI,IAAI,KAAK,EACb,UAAU,IAAI,MAAM,EACpB,WAAW,IAAI,MAAM,EACrB,OAAO,IAAI,K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;IACP,OAAO,EAAE;QACP,GAAG,IAAI,CAAC,OAAO;KAChB;CACF,CAAC","sourcesContent":["import type { Chain } from \"viem\";\n\nimport { defineChain } from \"viem\";\nimport {\n arbitrum as vab,\n arbitrumGoerli as vabg,\n arbitrumSepolia as vabs,\n base as vbase,\n baseGoerli as vbaseg,\n baseSepolia as vbases,\n fraxtal as vfrax,\n goerli as vgo,\n mainnet as vmain,\n optimism as vop,\n optimismGoerli as vopg,\n optimismSepolia as vops,\n polygon as vpg,\n polygonAmoy as vpga,\n polygonMumbai as vpgm,\n sepolia as vsep,\n arbitrumNova as vabn,\n zora as vzora,\n zoraSepolia as vzoras,\n} from \"viem/chains\";\n\nexport type AlchemyChainConfig = {\n chain: Chain;\n rpcBaseUrl: string;\n};\n\n/**\n * Defines an Alchemy chain configuration by adding an Alchemy-specific RPC base URL to the chain's RPC URLs.\n *\n * @example\n * ```ts\n * import { defineAlchemyChain } from \"@account-kit/infra\";\n * import { sepolia } from \"viem/chains\";\n *\n * const chain = defineAlchemyChain({\n * chain: sepolia,\n * rpcBaseUrl: \"https://eth-sepolia.g.alchemy.com/v2\"\n * });\n * ```\n *\n * @param {AlchemyChainConfig} params The parameters for defining the Alchemy chain\n * @param {Chain} params.chain The original chain configuration\n * @param {string} params.rpcBaseUrl The Alchemy-specific RPC base URL\n * @returns {Chain} The updated chain configuration with the Alchemy RPC URL added\n */\nexport const defineAlchemyChain = ({\n chain,\n rpcBaseUrl,\n}: {\n chain: Chain;\n rpcBaseUrl: string;\n}): Chain => {\n return {\n ...chain,\n rpcUrls: {\n ...chain.rpcUrls,\n alchemy: {\n http: [rpcBaseUrl],\n },\n },\n };\n};\n\nexport const arbitrum: Chain = {\n ...vab,\n rpcUrls: {\n ...vab.rpcUrls,\n alchemy: {\n http: [\"https://arb-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumGoerli: Chain = {\n ...vabg,\n rpcUrls: {\n ...vabg.rpcUrls,\n alchemy: {\n http: [\"https://arb-goerli.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const arbitrumSepolia: Chain = {\n ...vabs,\n rpcUrls: {\n ...vabs.rpcUrls,\n alchemy: {\n http: [\"https://arb-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const goerli: Chain = {\n ...vgo,\n rpcUrls: {\n ...vgo.rpcUrls,\n alchemy: {\n http: [\"https://eth-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const mainnet: Chain = {\n ...vmain,\n rpcUrls: {\n ...vmain.rpcUrls,\n alchemy: {\n http: [\"https://eth-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimism: Chain = {\n ...vop,\n rpcUrls: {\n ...vop.rpcUrls,\n alchemy: {\n http: [\"https://opt-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismGoerli: Chain = {\n ...vopg,\n rpcUrls: {\n ...vopg.rpcUrls,\n alchemy: {\n http: [\"https://opt-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const optimismSepolia: Chain = {\n ...vops,\n rpcUrls: {\n ...vops.rpcUrls,\n alchemy: {\n http: [\"https://opt-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const sepolia: Chain = {\n ...vsep,\n rpcUrls: {\n ...vsep.rpcUrls,\n alchemy: {\n http: [\"https://eth-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\nexport const base: Chain = {\n ...vbase,\n rpcUrls: {\n ...vbase.rpcUrls,\n alchemy: {\n http: [\"https://base-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseGoerli: Chain = {\n ...vbaseg,\n rpcUrls: {\n ...vbaseg.rpcUrls,\n alchemy: {\n http: [\"https://base-goerli.g.alchemy.com/v2\"],\n },\n },\n};\nexport const baseSepolia: Chain = {\n ...vbases,\n rpcUrls: {\n ...vbases.rpcUrls,\n alchemy: {\n http: [\"https://base-sepolia.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonMumbai: Chain = {\n ...vpgm,\n rpcUrls: {\n ...vpgm.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mumbai.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygonAmoy: Chain = {\n ...vpga,\n rpcUrls: {\n ...vpga.rpcUrls,\n alchemy: {\n http: [\"https://polygon-amoy.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const polygon: Chain = {\n ...vpg,\n rpcUrls: {\n ...vpg.rpcUrls,\n alchemy: {\n http: [\"https://polygon-mainnet.g.alchemy.com/v2\"],\n },\n },\n};\n\nexport const fraxtal: Chain = {\n ...vfrax,\n rpcUrls: {\n ...vfrax.rpcUrls,\n },\n};\n\nexport const fraxtalSepolia: Chain = defineChain({\n id: 2523,\n name: \"Fraxtal Sepolia\",\n nativeCurrency: { name: \"Frax Ether\", symbol: \"frxETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://rpc.testnet-sepolia.frax.com\"],\n },\n },\n});\n\nexport const zora: Chain = {\n ...vzora,\n rpcUrls: {\n ...vzora.rpcUrls,\n },\n};\n\nexport const zoraSepolia: Chain = {\n ...vzoras,\n rpcUrls: {\n ...vzoras.rpcUrls,\n },\n};\n\nexport const worldChainSepolia: Chain = defineChain({\n id: 4801,\n name: \"World Chain Sepolia\",\n network: \"World Chain Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const worldChain: Chain = defineChain({\n id: 480,\n name: \"World Chain\",\n network: \"World Chain\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://worldchain-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const shapeSepolia: Chain = defineChain({\n id: 11011,\n name: \"Shape Sepolia\",\n network: \"Shape Sepolia\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://shape-sepolia.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const shape: Chain = defineChain({\n id: 360,\n name: \"Shape\",\n network: \"Shape\",\n nativeCurrency: { name: \"Ether\", symbol: \"ETH\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://shape-mainnet.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const beraChainBartio: Chain = defineChain({\n id: 80084,\n name: \"BeraChain Bartio\",\n network: \"BeraChain Bartio\",\n nativeCurrency: { name: \"Bera\", symbol: \"BERA\", decimals: 18 },\n rpcUrls: {\n default: {\n http: [\"https://berachain-bartio.g.alchemy.com/v2\"],\n },\n public: {\n http: [\"https://berachain-bartio.g.alchemy.com/v2\"],\n },\n alchemy: {\n http: [\"https://berachain-bartio.g.alchemy.com/v2\"],\n },\n },\n});\n\nexport const arbitrumNova: Chain = {\n ...vabn,\n rpcUrls: {\n ...vabn.rpcUrls,\n },\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SmartContractAccount } from "@aa-sdk/core";
|
|
2
2
|
import type { Alchemy } from "alchemy-sdk";
|
|
3
|
-
import type { Chain
|
|
3
|
+
import type { Chain } from "viem";
|
|
4
4
|
import type { AlchemySmartAccountClient } from "../smartAccountClient.js";
|
|
5
5
|
export type AlchemyEnhancedApis = {
|
|
6
6
|
core: Alchemy["core"];
|
|
@@ -28,4 +28,4 @@ export type AlchemyEnhancedApis = {
|
|
|
28
28
|
* @param {Alchemy} alchemy The Alchemy instance containing the SDK client
|
|
29
29
|
* @returns {(client: AlchemySmartAccountClient) => AlchemyEnhancedApis} A client decorator for Alchemy Smart Account clients that adds the enhanced API methods
|
|
30
30
|
*/
|
|
31
|
-
export declare function alchemyEnhancedApiActions(alchemy: Alchemy): <
|
|
31
|
+
export declare function alchemyEnhancedApiActions(alchemy: Alchemy): <TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined>(client: AlchemySmartAccountClient<TChain, TAccount>) => AlchemyEnhancedApis;
|
|
@@ -19,13 +19,9 @@ import { AlchemySdkClientSchema } from "../../schema.js";
|
|
|
19
19
|
export function alchemyEnhancedApiActions(alchemy) {
|
|
20
20
|
return (client) => {
|
|
21
21
|
const alchemySdk = AlchemySdkClientSchema.parse(alchemy);
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
alchemy.config.url &&
|
|
26
|
-
alchemy.config.url !== url) {
|
|
27
|
-
throw new Error("Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL");
|
|
28
|
-
}
|
|
22
|
+
if (alchemy.config.url &&
|
|
23
|
+
alchemy.config.url !== client.transport.alchemyRpcUrl) {
|
|
24
|
+
throw new Error("Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL");
|
|
29
25
|
}
|
|
30
26
|
return {
|
|
31
27
|
core: alchemySdk.core,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemyEnhancedApis.js","sourceRoot":"","sources":["../../../../src/client/decorators/alchemyEnhancedApis.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAazD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAgB;
|
|
1
|
+
{"version":3,"file":"alchemyEnhancedApis.js","sourceRoot":"","sources":["../../../../src/client/decorators/alchemyEnhancedApis.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAazD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAgB;IAShB,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEzD,IACE,OAAO,CAAC,MAAM,CAAC,GAAG;YAClB,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC,SAAS,CAAC,aAAa,EACrD,CAAC;YACD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,EAAE,EAAE,UAAU,CAAC,EAAE;YACjB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,MAAM,EAAE,UAAU,CAAC,MAAM;SAC1B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Alchemy } from \"alchemy-sdk\";\nimport type { Chain } from \"viem\";\nimport { AlchemySdkClientSchema } from \"../../schema.js\";\nimport type { AlchemySmartAccountClient } from \"../smartAccountClient.js\";\n\nexport type AlchemyEnhancedApis = {\n core: Alchemy[\"core\"];\n nft: Alchemy[\"nft\"];\n transact: Alchemy[\"transact\"];\n debug: Alchemy[\"debug\"];\n ws: Alchemy[\"ws\"];\n notify: Alchemy[\"notify\"];\n config: Alchemy[\"config\"];\n};\n\n/**\n * Given an instance of the Alchemy SDK, returns a smart account client decorator which contains actions for interacting Alchemy's enhanced APIs.\n *\n * @example\n * ```ts\n * import { Alchemy } from \"alchemy-sdk\";\n * import { alchemyEnhancedApiActions } from \"@account-kit/infra\";\n * import { alchemySCAClient } from \"./client\";\n *\n * const alchemy = new Alchemy(...);\n * const enhancedApiDecorator = alchemyEnhancedApiActions(alchemy);\n * const withEnhancedApis = alchemySCAClient.extend(enhancedApiDecorator);\n * ```\n *\n * @param {Alchemy} alchemy The Alchemy instance containing the SDK client\n * @returns {(client: AlchemySmartAccountClient) => AlchemyEnhancedApis} A client decorator for Alchemy Smart Account clients that adds the enhanced API methods\n */\nexport function alchemyEnhancedApiActions(\n alchemy: Alchemy\n): <\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: AlchemySmartAccountClient<TChain, TAccount>\n) => AlchemyEnhancedApis {\n return (client) => {\n const alchemySdk = AlchemySdkClientSchema.parse(alchemy);\n\n if (\n alchemy.config.url &&\n alchemy.config.url !== client.transport.alchemyRpcUrl\n ) {\n throw new Error(\n \"Alchemy SDK client JSON-RPC URL must match AlchemyProvider JSON-RPC URL\"\n );\n }\n\n return {\n core: alchemySdk.core,\n nft: alchemySdk.nft,\n transact: alchemySdk.transact,\n debug: alchemySdk.debug,\n ws: alchemySdk.ws,\n notify: alchemySdk.notify,\n config: alchemySdk.config,\n };\n };\n}\n"]}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { Chain, Client, Transport } from "viem";
|
|
1
|
+
import { type GetEntryPointFromAccount, type SendTransactionsParameters, type SendUserOperationParameters, type SendUserOperationResult, type SmartContractAccount, type UserOperationContext, type UserOperationOverrides } from "@aa-sdk/core";
|
|
2
|
+
import type { Chain, Client, Hex, SendTransactionParameters, Transport } from "viem";
|
|
3
3
|
import type { SimulateUserOperationAssetChangesResponse } from "../../actions/types.js";
|
|
4
|
-
export type AlchemySmartAccountClientActions<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined> = {
|
|
4
|
+
export type AlchemySmartAccountClientActions<TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TChain extends Chain | undefined = Chain | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>> = {
|
|
5
5
|
simulateUserOperation: (args: SendUserOperationParameters<TAccount, TContext>) => Promise<SimulateUserOperationAssetChangesResponse>;
|
|
6
|
+
sendUserOperation: (args: SendUserOperationParameters<TAccount, TContext, GetEntryPointFromAccount<TAccount>>) => Promise<SendUserOperationResult<TEntryPointVersion>>;
|
|
7
|
+
sendTransaction: <TChainOverride extends Chain | undefined = undefined>(args: SendTransactionParameters<TChain, TAccount, TChainOverride>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext) => Promise<Hex>;
|
|
8
|
+
sendTransactions: (args: SendTransactionsParameters<TAccount, TContext>) => Promise<Hex>;
|
|
6
9
|
};
|
|
7
10
|
/**
|
|
8
11
|
* Provides a set of actions for interacting with the Alchemy Smart Account client, including the ability to simulate user operations.
|
|
@@ -19,4 +22,4 @@ export type AlchemySmartAccountClientActions<TAccount extends SmartContractAccou
|
|
|
19
22
|
* @param {Client<TTransport, TChain, TAccount>} client The client instance used to perform actions
|
|
20
23
|
* @returns {AlchemySmartAccountClientActions<TAccount, TContext>} An object containing Alchemy Smart Account client actions
|
|
21
24
|
*/
|
|
22
|
-
export declare const alchemyActions: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>) => AlchemySmartAccountClientActions<TAccount, TContext>;
|
|
25
|
+
export declare const alchemyActions: <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client: Client<TTransport, TChain, TAccount>) => AlchemySmartAccountClientActions<TAccount, TContext, TChain>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { isSmartAccountWithSigner, sendTransaction, sendTransactions, sendUserOperation, } from "@aa-sdk/core";
|
|
1
2
|
import { simulateUserOperationChanges } from "../../actions/simulateUserOperationChanges.js";
|
|
3
|
+
import { InfraLogger } from "../../metrics.js";
|
|
2
4
|
/**
|
|
3
5
|
* Provides a set of actions for interacting with the Alchemy Smart Account client, including the ability to simulate user operations.
|
|
4
6
|
*
|
|
@@ -16,5 +18,36 @@ import { simulateUserOperationChanges } from "../../actions/simulateUserOperatio
|
|
|
16
18
|
*/
|
|
17
19
|
export const alchemyActions = (client) => ({
|
|
18
20
|
simulateUserOperation: async (args) => simulateUserOperationChanges(client, args),
|
|
21
|
+
sendUserOperation: async (args) => {
|
|
22
|
+
const { account = client.account } = args;
|
|
23
|
+
const result = sendUserOperation(client, args);
|
|
24
|
+
logSendUoEvent(client.chain.id, account);
|
|
25
|
+
return result;
|
|
26
|
+
},
|
|
27
|
+
sendTransaction: async (args, overrides, context) => {
|
|
28
|
+
const { account = client.account } = args;
|
|
29
|
+
const result = await sendTransaction(client, args, overrides, context);
|
|
30
|
+
logSendUoEvent(client.chain.id, account);
|
|
31
|
+
return result;
|
|
32
|
+
},
|
|
33
|
+
async sendTransactions(args) {
|
|
34
|
+
const { account = client.account } = args;
|
|
35
|
+
const result = sendTransactions(client, args);
|
|
36
|
+
logSendUoEvent(client.chain.id, account);
|
|
37
|
+
return result;
|
|
38
|
+
},
|
|
19
39
|
});
|
|
40
|
+
function logSendUoEvent(chainId, account) {
|
|
41
|
+
const signerType = isSmartAccountWithSigner(account)
|
|
42
|
+
? account.getSigner().signerType
|
|
43
|
+
: "unknown";
|
|
44
|
+
InfraLogger.trackEvent({
|
|
45
|
+
name: "client_send_uo",
|
|
46
|
+
data: {
|
|
47
|
+
chainId,
|
|
48
|
+
signerType: signerType,
|
|
49
|
+
entryPoint: account.getEntryPoint().address,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
20
53
|
//# sourceMappingURL=smartAccount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartAccount.js","sourceRoot":"","sources":["../../../../src/client/decorators/smartAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAQlB,MAAM,cAAc,CAAC;AAQtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAgC/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAWyC,CAClE,MAAM,EACN,EAAE,CAAC,CAAC;IACJ,qBAAqB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CACpC,4BAA4B,CAAC,MAAM,EAAE,IAAI,CAAC;IAC5C,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAChC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QAE1C,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC/C,cAAc,CAAC,MAAM,CAAC,KAAM,CAAC,EAAE,EAAE,OAAQ,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QAClD,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACvE,cAAc,CAAC,MAAM,CAAC,KAAM,CAAC,EAAE,EAAE,OAA+B,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,KAAK,CAAC,gBAAgB,CAAC,IAAI;QACzB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;QAE1C,MAAM,MAAM,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC9C,cAAc,CAAC,MAAM,CAAC,KAAM,CAAC,EAAE,EAAE,OAAQ,CAAC,CAAC;QAC3C,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,OAAe,EAAE,OAA6B;IACpE,MAAM,UAAU,GAAG,wBAAwB,CAAC,OAAO,CAAC;QAClD,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU;QAChC,CAAC,CAAC,SAAS,CAAC;IAEd,WAAW,CAAC,UAAU,CAAC;QACrB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE;YACJ,OAAO;YACP,UAAU,EAAE,UAAU;YACtB,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO;SAC5C;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n isSmartAccountWithSigner,\n sendTransaction,\n sendTransactions,\n sendUserOperation,\n type GetEntryPointFromAccount,\n type SendTransactionsParameters,\n type SendUserOperationParameters,\n type SendUserOperationResult,\n type SmartContractAccount,\n type UserOperationContext,\n type UserOperationOverrides,\n} from \"@aa-sdk/core\";\nimport type {\n Chain,\n Client,\n Hex,\n SendTransactionParameters,\n Transport,\n} from \"viem\";\nimport { simulateUserOperationChanges } from \"../../actions/simulateUserOperationChanges.js\";\nimport type { SimulateUserOperationAssetChangesResponse } from \"../../actions/types.js\";\nimport { InfraLogger } from \"../../metrics.js\";\n\nexport type AlchemySmartAccountClientActions<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TChain extends Chain | undefined = Chain | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n simulateUserOperation: (\n args: SendUserOperationParameters<TAccount, TContext>\n ) => Promise<SimulateUserOperationAssetChangesResponse>;\n sendUserOperation: (\n args: SendUserOperationParameters<\n TAccount,\n TContext,\n GetEntryPointFromAccount<TAccount>\n >\n ) => Promise<SendUserOperationResult<TEntryPointVersion>>;\n sendTransaction: <TChainOverride extends Chain | undefined = undefined>(\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n ) => Promise<Hex>;\n sendTransactions: (\n args: SendTransactionsParameters<TAccount, TContext>\n ) => Promise<Hex>;\n};\n\n/**\n * Provides a set of actions for interacting with the Alchemy Smart Account client, including the ability to simulate user operations.\n *\n * @example\n * ```ts\n * import { alchemyActions } from \"@account-kit/infra\";\n * import { createPublicClient } from \"viem\";\n *\n * const client = createPublicClient(...);\n * const clientWithAlchemyActions = client.extend(alchemyActions);\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance used to perform actions\n * @returns {AlchemySmartAccountClientActions<TAccount, TContext>} An object containing Alchemy Smart Account client actions\n */\nexport const alchemyActions: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client: Client<TTransport, TChain, TAccount>\n) => AlchemySmartAccountClientActions<TAccount, TContext, TChain> = (\n client\n) => ({\n simulateUserOperation: async (args) =>\n simulateUserOperationChanges(client, args),\n sendUserOperation: async (args) => {\n const { account = client.account } = args;\n\n const result = sendUserOperation(client, args);\n logSendUoEvent(client.chain!.id, account!);\n return result;\n },\n sendTransaction: async (args, overrides, context) => {\n const { account = client.account } = args;\n\n const result = await sendTransaction(client, args, overrides, context);\n logSendUoEvent(client.chain!.id, account as SmartContractAccount);\n return result;\n },\n async sendTransactions(args) {\n const { account = client.account } = args;\n\n const result = sendTransactions(client, args);\n logSendUoEvent(client.chain!.id, account!);\n return result;\n },\n});\n\nfunction logSendUoEvent(chainId: number, account: SmartContractAccount) {\n const signerType = isSmartAccountWithSigner(account)\n ? account.getSigner().signerType\n : \"unknown\";\n\n InfraLogger.trackEvent({\n name: \"client_send_uo\",\n data: {\n chainId,\n signerType: signerType,\n entryPoint: account.getEntryPoint().address,\n },\n });\n}\n"]}
|
|
@@ -16,4 +16,4 @@ import type { AlchemySmartAccountClient } from "./smartAccountClient";
|
|
|
16
16
|
* @param {Client<TTransport, TChain, TAccount>} client The client instance to be checked
|
|
17
17
|
* @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`
|
|
18
18
|
*/
|
|
19
|
-
export declare function isAlchemySmartAccountClient<
|
|
19
|
+
export declare function isAlchemySmartAccountClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined>(client: Client<Transport, TChain, TAccount>): client is AlchemySmartAccountClient<TChain, TAccount>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from "@aa-sdk/core";
|
|
2
2
|
/**
|
|
3
3
|
* Checks if a given client is an Alchemy Smart Account Client. The goal of this check is to ensure that the client supports certain RPC methods.
|
|
4
4
|
*
|
|
@@ -15,10 +15,6 @@ import { isSmartAccountClient } from "@aa-sdk/core";
|
|
|
15
15
|
* @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`
|
|
16
16
|
*/
|
|
17
17
|
export function isAlchemySmartAccountClient(client) {
|
|
18
|
-
|
|
19
|
-
// we should probably do this by checking the client's transport and configured URL, since alchemy
|
|
20
|
-
// clients have to be RPC clients. this is difficult to do though because the transport might
|
|
21
|
-
// point to a proxy url :/
|
|
22
|
-
return isSmartAccountClient(client);
|
|
18
|
+
return client.transport.type === "alchemy";
|
|
23
19
|
}
|
|
24
20
|
//# sourceMappingURL=isAlchemySmartAccountClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isAlchemySmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isAlchemySmartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"isAlchemySmartAccountClient.js","sourceRoot":"","sources":["../../../src/client/isAlchemySmartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM,cAAc,CAAC;AAIzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,2BAA2B,CAMzC,MAA2C;IAE3C,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["import { type SmartContractAccount } from \"@aa-sdk/core\";\nimport type { Chain, Client, Transport } from \"viem\";\nimport type { AlchemySmartAccountClient } from \"./smartAccountClient\";\n\n/**\n * Checks if a given client is an Alchemy Smart Account Client. The goal of this check is to ensure that the client supports certain RPC methods.\n *\n * @example\n * ```ts\n * import { isAlchemySmartAccountClient } from \"@account-kit/infra\";\n *\n * if (isAlchemySmartAccountClient(client)) {\n * // do things with the client as an Alchemy Smart Account Client\n * }\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client The client instance to be checked\n * @returns {boolean} `true` if the client is an Alchemy Smart Account Client, otherwise `false`\n */\nexport function isAlchemySmartAccountClient<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n>(\n client: Client<Transport, TChain, TAccount>\n): client is AlchemySmartAccountClient<TChain, TAccount> {\n return client.transport.type === \"alchemy\";\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { Chain } from "viem";
|
|
2
|
+
import type { AlchemyTransport } from "../alchemyTransport.js";
|
|
3
3
|
import type { ClientWithAlchemyMethods } from "./types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Creates an Alchemy public RPC client with the provided chain, connection configuration, and optional fetch options. The client has alchemy methods and can dynamically update HTTP headers.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
|
-
* import { createAlchemyPublicRpcClient } from "@account-kit/infra";
|
|
9
|
+
* import { createAlchemyPublicRpcClient, alchemy } from "@account-kit/infra";
|
|
10
10
|
* import { sepolia } from "@account-kit/infra";
|
|
11
11
|
*
|
|
12
12
|
* const client = createAlchemyPublicRpcClient({
|
|
13
|
+
* transport: alchemy({
|
|
14
|
+
* apiKey: "ALCHEMY_API_KEY"
|
|
15
|
+
* }),
|
|
13
16
|
* chain: sepolia,
|
|
14
|
-
* connectionConfig: {
|
|
15
|
-
* apiKey: "your-api-key",
|
|
16
|
-
* }
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*
|
|
@@ -23,8 +23,7 @@ import type { ClientWithAlchemyMethods } from "./types.js";
|
|
|
23
23
|
* @param {NoUndefined<HttpTransportConfig["fetchOptions"]>} [params.fetchOptions] Optional fetch configuration for HTTP transport
|
|
24
24
|
* @returns {ClientWithAlchemyMethods} A client object tailored with Alchemy methods and capabilities to interact with the blockchain
|
|
25
25
|
*/
|
|
26
|
-
export declare const createAlchemyPublicRpcClient: ({
|
|
27
|
-
|
|
28
|
-
chain: Chain;
|
|
29
|
-
fetchOptions?: Omit<RequestInit, "body"> | undefined;
|
|
26
|
+
export declare const createAlchemyPublicRpcClient: ({ transport, chain, }: {
|
|
27
|
+
transport: AlchemyTransport;
|
|
28
|
+
chain: Chain | undefined;
|
|
30
29
|
}) => ClientWithAlchemyMethods;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { createBundlerClient
|
|
2
|
-
import { http } from "viem";
|
|
3
|
-
import { AlchemyChainSchema } from "../schema.js";
|
|
4
|
-
import { VERSION } from "../version.js";
|
|
1
|
+
import { createBundlerClient } from "@aa-sdk/core";
|
|
5
2
|
/**
|
|
6
3
|
* Creates an Alchemy public RPC client with the provided chain, connection configuration, and optional fetch options. The client has alchemy methods and can dynamically update HTTP headers.
|
|
7
4
|
*
|
|
8
5
|
* @example
|
|
9
6
|
* ```ts
|
|
10
|
-
* import { createAlchemyPublicRpcClient } from "@account-kit/infra";
|
|
7
|
+
* import { createAlchemyPublicRpcClient, alchemy } from "@account-kit/infra";
|
|
11
8
|
* import { sepolia } from "@account-kit/infra";
|
|
12
9
|
*
|
|
13
10
|
* const client = createAlchemyPublicRpcClient({
|
|
11
|
+
* transport: alchemy({
|
|
12
|
+
* apiKey: "ALCHEMY_API_KEY"
|
|
13
|
+
* }),
|
|
14
14
|
* chain: sepolia,
|
|
15
|
-
* connectionConfig: {
|
|
16
|
-
* apiKey: "your-api-key",
|
|
17
|
-
* }
|
|
18
15
|
* });
|
|
19
16
|
* ```
|
|
20
17
|
*
|
|
@@ -24,31 +21,10 @@ import { VERSION } from "../version.js";
|
|
|
24
21
|
* @param {NoUndefined<HttpTransportConfig["fetchOptions"]>} [params.fetchOptions] Optional fetch configuration for HTTP transport
|
|
25
22
|
* @returns {ClientWithAlchemyMethods} A client object tailored with Alchemy methods and capabilities to interact with the blockchain
|
|
26
23
|
*/
|
|
27
|
-
export const createAlchemyPublicRpcClient = ({
|
|
28
|
-
const chain = AlchemyChainSchema.parse(chain_);
|
|
29
|
-
const rpcUrl = connectionConfig.rpcUrl == null
|
|
30
|
-
? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? ""}`
|
|
31
|
-
: connectionConfig.rpcUrl;
|
|
32
|
-
fetchOptions.headers = {
|
|
33
|
-
...fetchOptions.headers,
|
|
34
|
-
"Alchemy-AA-Sdk-Version": VERSION,
|
|
35
|
-
};
|
|
36
|
-
if (connectionConfig.jwt != null) {
|
|
37
|
-
fetchOptions.headers = {
|
|
38
|
-
...fetchOptions.headers,
|
|
39
|
-
Authorization: `Bearer ${connectionConfig.jwt}`,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
24
|
+
export const createAlchemyPublicRpcClient = ({ transport, chain, }) => {
|
|
42
25
|
return createBundlerClient({
|
|
43
|
-
chain
|
|
44
|
-
transport
|
|
45
|
-
})
|
|
46
|
-
updateHeaders(newHeaders) {
|
|
47
|
-
fetchOptions.headers = {
|
|
48
|
-
...fetchOptions.headers,
|
|
49
|
-
...newHeaders,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
}));
|
|
26
|
+
chain,
|
|
27
|
+
transport,
|
|
28
|
+
});
|
|
53
29
|
};
|
|
54
30
|
//# sourceMappingURL=rpcClient.js.map
|