@alchemy/wallet-apis 5.0.0-beta.8 → 5.0.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/README.md +2 -0
- package/dist/esm/actions/prepareCalls.d.ts +8 -3
- package/dist/esm/actions/prepareCalls.js +8 -0
- package/dist/esm/actions/prepareCalls.js.map +1 -1
- package/dist/esm/actions/requestAccount.d.ts +4 -3
- package/dist/esm/actions/requestAccount.js.map +1 -1
- package/dist/esm/actions/sendCalls.d.ts +5 -2
- package/dist/esm/actions/sendCalls.js +5 -2
- package/dist/esm/actions/sendCalls.js.map +1 -1
- package/dist/esm/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signPreparedCalls.d.ts +2 -0
- package/dist/esm/actions/signPreparedCalls.js +14 -1
- package/dist/esm/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signSignatureRequest.d.ts +4 -4
- package/dist/esm/actions/signSignatureRequest.js +1 -1
- package/dist/esm/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/actions/signTypedData.d.ts +14 -4
- package/dist/esm/actions/signTypedData.js.map +1 -1
- package/dist/esm/actions/solana/getCallsStatus.d.ts +24 -0
- package/dist/esm/actions/solana/getCallsStatus.js +44 -0
- package/dist/esm/actions/solana/getCallsStatus.js.map +1 -0
- package/dist/esm/actions/solana/prepareCalls.d.ts +46 -0
- package/dist/esm/actions/solana/prepareCalls.js +70 -0
- package/dist/esm/actions/solana/prepareCalls.js.map +1 -0
- package/dist/esm/actions/solana/sendCalls.d.ts +34 -0
- package/dist/esm/actions/solana/sendCalls.js +44 -0
- package/dist/esm/actions/solana/sendCalls.js.map +1 -0
- package/dist/esm/actions/solana/sendPreparedCalls.d.ts +24 -0
- package/dist/esm/actions/solana/sendPreparedCalls.js +32 -0
- package/dist/esm/actions/solana/sendPreparedCalls.js.map +1 -0
- package/dist/esm/actions/solana/signPreparedCalls.d.ts +23 -0
- package/dist/esm/actions/solana/signPreparedCalls.js +24 -0
- package/dist/esm/actions/solana/signPreparedCalls.js.map +1 -0
- package/dist/esm/actions/solana/signSignatureRequest.d.ts +10 -0
- package/dist/esm/actions/solana/signSignatureRequest.js +33 -0
- package/dist/esm/actions/solana/signSignatureRequest.js.map +1 -0
- package/dist/esm/actions/solana/waitForCallsStatus.d.ts +24 -0
- package/dist/esm/actions/solana/waitForCallsStatus.js +46 -0
- package/dist/esm/actions/solana/waitForCallsStatus.js.map +1 -0
- package/dist/esm/actions/undelegateAccount.d.ts +37 -0
- package/dist/esm/actions/undelegateAccount.js +49 -0
- package/dist/esm/actions/undelegateAccount.js.map +1 -0
- package/dist/esm/adapters/SolanaSignerError.d.ts +4 -0
- package/dist/esm/adapters/SolanaSignerError.js +13 -0
- package/dist/esm/adapters/SolanaSignerError.js.map +1 -0
- package/dist/esm/adapters/fromKeypair.d.ts +21 -0
- package/dist/esm/adapters/fromKeypair.js +46 -0
- package/dist/esm/adapters/fromKeypair.js.map +1 -0
- package/dist/esm/adapters/fromKitSigner.d.ts +21 -0
- package/dist/esm/adapters/fromKitSigner.js +61 -0
- package/dist/esm/adapters/fromKitSigner.js.map +1 -0
- package/dist/esm/adapters/fromWalletAdapter.d.ts +26 -0
- package/dist/esm/adapters/fromWalletAdapter.js +45 -0
- package/dist/esm/adapters/fromWalletAdapter.js.map +1 -0
- package/dist/esm/adapters/fromWalletStandard.d.ts +31 -0
- package/dist/esm/adapters/fromWalletStandard.js +53 -0
- package/dist/esm/adapters/fromWalletStandard.js.map +1 -0
- package/dist/esm/adapters/resolveSignerSlot.d.ts +10 -0
- package/dist/esm/adapters/resolveSignerSlot.js +39 -0
- package/dist/esm/adapters/resolveSignerSlot.js.map +1 -0
- package/dist/esm/client.d.ts +29 -14
- package/dist/esm/client.js +63 -19
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/decorators/smartWalletActions.d.ts +2 -0
- package/dist/esm/decorators/smartWalletActions.js +4 -2
- package/dist/esm/decorators/smartWalletActions.js.map +1 -1
- package/dist/esm/decorators/solanaSmartWalletActions.d.ts +16 -0
- package/dist/esm/decorators/solanaSmartWalletActions.js +16 -0
- package/dist/esm/decorators/solanaSmartWalletActions.js.map +1 -0
- package/dist/esm/experimental/actions/requestQuoteV0.d.ts +48 -11
- package/dist/esm/experimental/actions/requestQuoteV0.js +8 -4
- package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
- package/dist/esm/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/esm/experimental/swapActionsDecorator.js.map +1 -1
- package/dist/esm/exports/index.d.ts +5 -3
- package/dist/esm/exports/index.js +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/solana.d.ts +24 -0
- package/dist/esm/exports/solana.js +15 -0
- package/dist/esm/exports/solana.js.map +1 -0
- package/dist/esm/types.d.ts +28 -4
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/assertions.d.ts +4 -2
- package/dist/esm/utils/assertions.js +6 -0
- package/dist/esm/utils/assertions.js.map +1 -1
- package/dist/esm/utils/capabilities.d.ts +22 -6
- package/dist/esm/utils/capabilities.js +19 -2
- package/dist/esm/utils/capabilities.js.map +1 -1
- package/dist/esm/utils/format.d.ts +2 -2
- package/dist/esm/utils/format.js +4 -3
- package/dist/esm/utils/format.js.map +1 -1
- package/dist/esm/utils/schema.d.ts +14 -14
- package/dist/esm/utils/schema.js +35 -39
- package/dist/esm/utils/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/actions/prepareCalls.d.ts +8 -3
- package/dist/types/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/actions/requestAccount.d.ts +4 -3
- package/dist/types/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/actions/sendCalls.d.ts +5 -2
- package/dist/types/actions/sendCalls.d.ts.map +1 -1
- package/dist/types/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/types/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/actions/signPreparedCalls.d.ts +2 -0
- package/dist/types/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/actions/signSignatureRequest.d.ts +4 -4
- package/dist/types/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/actions/signTypedData.d.ts +14 -4
- package/dist/types/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/solana/getCallsStatus.d.ts +25 -0
- package/dist/types/actions/solana/getCallsStatus.d.ts.map +1 -0
- package/dist/types/actions/solana/prepareCalls.d.ts +47 -0
- package/dist/types/actions/solana/prepareCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/sendCalls.d.ts +35 -0
- package/dist/types/actions/solana/sendCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/sendPreparedCalls.d.ts +25 -0
- package/dist/types/actions/solana/sendPreparedCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/signPreparedCalls.d.ts +24 -0
- package/dist/types/actions/solana/signPreparedCalls.d.ts.map +1 -0
- package/dist/types/actions/solana/signSignatureRequest.d.ts +11 -0
- package/dist/types/actions/solana/signSignatureRequest.d.ts.map +1 -0
- package/dist/types/actions/solana/waitForCallsStatus.d.ts +25 -0
- package/dist/types/actions/solana/waitForCallsStatus.d.ts.map +1 -0
- package/dist/types/actions/undelegateAccount.d.ts +38 -0
- package/dist/types/actions/undelegateAccount.d.ts.map +1 -0
- package/dist/types/adapters/SolanaSignerError.d.ts +5 -0
- package/dist/types/adapters/SolanaSignerError.d.ts.map +1 -0
- package/dist/types/adapters/fromKeypair.d.ts +22 -0
- package/dist/types/adapters/fromKeypair.d.ts.map +1 -0
- package/dist/types/adapters/fromKitSigner.d.ts +22 -0
- package/dist/types/adapters/fromKitSigner.d.ts.map +1 -0
- package/dist/types/adapters/fromWalletAdapter.d.ts +27 -0
- package/dist/types/adapters/fromWalletAdapter.d.ts.map +1 -0
- package/dist/types/adapters/fromWalletStandard.d.ts +32 -0
- package/dist/types/adapters/fromWalletStandard.d.ts.map +1 -0
- package/dist/types/adapters/resolveSignerSlot.d.ts +11 -0
- package/dist/types/adapters/resolveSignerSlot.d.ts.map +1 -0
- package/dist/types/client.d.ts +29 -14
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/decorators/smartWalletActions.d.ts +2 -0
- package/dist/types/decorators/smartWalletActions.d.ts.map +1 -1
- package/dist/types/decorators/solanaSmartWalletActions.d.ts +17 -0
- package/dist/types/decorators/solanaSmartWalletActions.d.ts.map +1 -0
- package/dist/types/experimental/actions/requestQuoteV0.d.ts +48 -11
- package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
- package/dist/types/experimental/swapActionsDecorator.d.ts +3 -0
- package/dist/types/experimental/swapActionsDecorator.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +5 -3
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/solana.d.ts +25 -0
- package/dist/types/exports/solana.d.ts.map +1 -0
- package/dist/types/types.d.ts +28 -4
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/assertions.d.ts +4 -2
- package/dist/types/utils/assertions.d.ts.map +1 -1
- package/dist/types/utils/capabilities.d.ts +22 -6
- package/dist/types/utils/capabilities.d.ts.map +1 -1
- package/dist/types/utils/format.d.ts +2 -2
- package/dist/types/utils/format.d.ts.map +1 -1
- package/dist/types/utils/schema.d.ts +14 -14
- package/dist/types/utils/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 +26 -9
- package/src/actions/prepareCalls.ts +21 -3
- package/src/actions/requestAccount.ts +7 -5
- package/src/actions/sendCalls.ts +5 -2
- package/src/actions/sendPreparedCalls.ts +4 -1
- package/src/actions/signPreparedCalls.ts +15 -2
- package/src/actions/signSignatureRequest.ts +8 -8
- package/src/actions/signTypedData.ts +15 -7
- package/src/actions/solana/getCallsStatus.ts +79 -0
- package/src/actions/solana/prepareCalls.ts +120 -0
- package/src/actions/solana/sendCalls.ts +66 -0
- package/src/actions/solana/sendPreparedCalls.ts +65 -0
- package/src/actions/solana/signPreparedCalls.ts +50 -0
- package/src/actions/solana/signSignatureRequest.ts +63 -0
- package/src/actions/solana/waitForCallsStatus.ts +84 -0
- package/src/actions/undelegateAccount.ts +68 -0
- package/src/adapters/SolanaSignerError.ts +5 -0
- package/src/adapters/fromKeypair.ts +58 -0
- package/src/adapters/fromKitSigner.ts +82 -0
- package/src/adapters/fromWalletAdapter.ts +58 -0
- package/src/adapters/fromWalletStandard.ts +100 -0
- package/src/adapters/resolveSignerSlot.ts +46 -0
- package/src/client.ts +131 -18
- package/src/decorators/smartWalletActions.ts +11 -2
- package/src/decorators/solanaSmartWalletActions.ts +62 -0
- package/src/experimental/actions/requestQuoteV0.ts +40 -15
- package/src/experimental/swapActionsDecorator.ts +3 -0
- package/src/exports/index.ts +10 -4
- package/src/exports/solana.ts +36 -0
- package/src/types.ts +38 -7
- package/src/utils/assertions.ts +17 -2
- package/src/utils/capabilities.ts +40 -8
- package/src/utils/format.ts +8 -3
- package/src/utils/schema.ts +58 -69
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../../src/utils/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,IAAI,8BAA8B,EAC1D,6BAA6B,IAAI,mCAAmC,GACrE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../../src/utils/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,IAAI,8BAA8B,EAC1D,6BAA6B,IAAI,mCAAmC,GACrE,MAAM,wCAAwC,CAAC;AA8ChD,SAAS,mBAAmB,CAC1B,KAAa;IAEb,OAAO,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,0BAA0B,CACjC,KAAa;IA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H,CAAC,CAAC,SAAS;KAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n PrepareCallsCapabilities as PrepareCallsCapabilitiesSchema,\n SendPreparedCallsCapabilities as SendPreparedCallsCapabilitiesSchema,\n} from \"@alchemy/wallet-api-types/capabilities\";\nimport type { z } from \"zod\";\nimport type {\n InnerWalletApiClient,\n InnerSolanaWalletApiClient,\n} from \"../types.js\";\n\n/**\n * Decoded capabilities matching the schema shape (uses `paymasterService` key).\n * `ResolveCapabilities` renames this to `paymaster` for client-facing types.\n */\ntype DecodedPrepareCallsCaps = z.output<typeof PrepareCallsCapabilitiesSchema>;\ntype DecodedSendPreparedCallsCaps = z.output<\n typeof SendPreparedCallsCapabilitiesSchema\n>;\n\n/**\n * Renames `paymasterService` (RPC) to `paymaster` in a capabilities type. This\n * is because our RPC schema's paymasterService capability does not exactly match\n * the shape of the new spec, so we want to use a different name in our client\n * types to avoid confusion and be compatible with Viem's types.\n */\ntype ResolveCapabilities<T> = T extends {\n paymasterService?: infer P;\n}\n ? Omit<T, \"paymasterService\"> & { paymaster?: P }\n : T;\n\nexport type PrepareCallsCapabilities =\n ResolveCapabilities<DecodedPrepareCallsCaps>;\n\nexport type SendPreparedCallsCapabilities =\n ResolveCapabilities<DecodedSendPreparedCallsCaps>;\n\n/**\n * Transforms a type so that any `capabilities` field uses `paymaster`\n * instead of `paymasterService` (RPC).\n */\nexport type WithCapabilities<T> = T extends {\n capabilities?: infer C;\n}\n ? Omit<T, \"capabilities\"> & {\n capabilities?: ResolveCapabilities<NonNullable<C>>;\n }\n : T;\n\nfunction hasNoPaymasterField(\n value: object,\n): value is DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps {\n return !(\"paymaster\" in value);\n}\n\nfunction hasNoPaymasterServiceField(\n value: object,\n): value is PrepareCallsCapabilities | SendPreparedCallsCapabilities {\n return !(\"paymasterService\" in value);\n}\n\n/**\n * Converts capabilities (with `paymaster`) to RPC capabilities (with `paymasterService`)\n * for use with `encode` before sending to the RPC.\n *\n * @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field\n * @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined\n */\nexport function toRpcCapabilities(\n capabilities:\n | PrepareCallsCapabilities\n | SendPreparedCallsCapabilities\n | undefined,\n): DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined {\n if (!capabilities) return undefined;\n const { paymaster, ...rest } = capabilities;\n const result =\n paymaster !== undefined\n ? { ...rest, paymasterService: paymaster }\n : { ...rest };\n if (hasNoPaymasterField(result)) return result;\n return undefined;\n}\n\n/**\n * Converts RPC capabilities (with `paymasterService`) from `decode`\n * to capabilities (with `paymaster`).\n *\n * @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field\n * @returns {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} Capabilities with `paymaster`, or undefined if input is undefined\n */\nexport function fromRpcCapabilities(\n capabilities:\n | DecodedPrepareCallsCaps\n | DecodedSendPreparedCallsCaps\n | undefined,\n): PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined {\n if (!capabilities) return undefined;\n if (\"paymasterService\" in capabilities) {\n const { paymasterService, ...rest } = capabilities;\n const result =\n paymasterService !== undefined\n ? { ...rest, paymaster: paymasterService }\n : { ...rest };\n if (hasNoPaymasterServiceField(result)) return result;\n return undefined;\n }\n if (hasNoPaymasterServiceField(capabilities)) return capabilities;\n return undefined;\n}\n\n/**\n * Merges client capabilities with capabilities from the request.\n * Uses policyId (singular) when there's one policy, policyIds (array) when multiple.\n *\n * @param {InnerWalletApiClient} client - The inner wallet API client (potentially including global capabilities like policy IDs)\n * @param {T | undefined} capabilities - Request capabilities to merge with, if any\n * @returns {T | undefined} The merged capabilities object, or original capabilities if no capability configuration exists on the client\n */\nexport const mergeClientCapabilities = <\n T extends PrepareCallsCapabilities | SendPreparedCallsCapabilities,\n>(\n client: InnerWalletApiClient,\n capabilities: T | undefined,\n): T | undefined => {\n if (!client.policyIds?.length || capabilities?.paymaster) {\n return capabilities;\n }\n\n return {\n ...capabilities,\n paymaster:\n client.policyIds.length === 1\n ? { policyId: client.policyIds[0] }\n : { policyIds: client.policyIds },\n } as T;\n};\n\nexport type SolanaPaymasterCapability = {\n policyId: string;\n webhookData?: string;\n};\n\nexport type SolanaPrepareCallsCapabilities = {\n paymaster?: SolanaPaymasterCapability;\n};\n\n/**\n * Merges Solana client-level capabilities (policyId from factory) with\n * request-level capabilities. Request-level takes priority if provided.\n *\n * @param {InnerSolanaWalletApiClient} client - The Solana wallet API client\n * @param {SolanaPrepareCallsCapabilities | undefined} capabilities - Request capabilities to merge with\n * @returns {SolanaPrepareCallsCapabilities | undefined} The merged capabilities\n */\nexport const mergeSolanaClientCapabilities = (\n client: InnerSolanaWalletApiClient,\n capabilities: SolanaPrepareCallsCapabilities | undefined,\n): SolanaPrepareCallsCapabilities | undefined => {\n if (!client.policyIds?.length || capabilities?.paymaster) {\n return capabilities;\n }\n\n return {\n ...capabilities,\n paymaster: { policyId: client.policyIds[0] },\n };\n};\n\n/**\n * Extracts capabilities from prepareCalls that are usable for sendPreparedCalls.\n * Only permissions and paymaster (policyId/policyIds & webhookData) are supported.\n *\n * @param {PrepareCallsCapabilities | undefined} capabilities - The prepareCalls capabilities\n * @returns {SendPreparedCallsCapabilities | undefined} The sendPreparedCalls capabilities, or undefined if no relevant capabilities exist\n */\nexport const extractCapabilitiesForSending = (\n capabilities: PrepareCallsCapabilities | undefined,\n): SendPreparedCallsCapabilities | undefined => {\n if (capabilities?.permissions == null && capabilities?.paymaster == null) {\n return undefined;\n }\n\n const paymaster = capabilities.paymaster;\n\n return {\n permissions: capabilities.permissions,\n paymaster:\n paymaster != null\n ? {\n ...(\"policyId\" in paymaster\n ? { policyId: paymaster.policyId }\n : { policyIds: paymaster.policyIds }),\n webhookData: paymaster.webhookData,\n }\n : undefined,\n };\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Hex, type SignableMessage, type TypedDataDefinition } from "viem";
|
|
1
|
+
import { type Hex, type SignableMessage, type TypedData, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { TypedDataDefinition as WalletServerTypedDataDefinition } from "@alchemy/wallet-api-types";
|
|
3
3
|
export declare const castToHex: (val: string | number | bigint | Hex) => Hex;
|
|
4
4
|
export declare const signableMessageToJsonSafe: (message: SignableMessage) => string | {
|
|
5
5
|
raw: Hex;
|
|
6
6
|
};
|
|
7
|
-
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition) => WalletServerTypedDataDefinition;
|
|
7
|
+
export declare const typedDataToJsonSafe: ({ domain, primaryType, message, types, }: TypedDataDefinition<TypedData | Record<string, unknown>>) => WalletServerTypedDataDefinition;
|
package/dist/esm/utils/format.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, } from "viem";
|
|
1
|
+
import { isHex, toHex, bytesToHex, getTypesForEIP712Domain, validateTypedData, } from "viem";
|
|
2
2
|
export const castToHex = (val) => {
|
|
3
3
|
if (isHex(val)) {
|
|
4
4
|
return val;
|
|
@@ -14,8 +14,9 @@ export const signableMessageToJsonSafe = (message) => {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
// Purposefully not using `formatTypedData` from the wallet server types pkg
|
|
17
|
-
// here, since that would require
|
|
17
|
+
// here, since that would require zod at runtime (which breaks RN).
|
|
18
18
|
export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) => {
|
|
19
|
+
validateTypedData({ domain, primaryType, message, types });
|
|
19
20
|
return {
|
|
20
21
|
domain: {
|
|
21
22
|
...domain,
|
|
@@ -26,7 +27,7 @@ export const typedDataToJsonSafe = ({ domain, primaryType, message, types, }) =>
|
|
|
26
27
|
types: {
|
|
27
28
|
...Object.fromEntries(Object.entries(types).map(([key, value]) => [
|
|
28
29
|
key,
|
|
29
|
-
value ? [...value] : [],
|
|
30
|
+
Array.isArray(value) ? [...value] : [],
|
|
30
31
|
])),
|
|
31
32
|
EIP712Domain: [...getTypesForEIP712Domain({ domain })],
|
|
32
33
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/utils/format.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,KAAK,EAGL,UAAU,EAGV,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,MAAM,CAAC;AAGd,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAmC,EAAO,EAAE;IACpE,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,OAAwB,EACD,EAAE;IACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO;QACL,GAAG,EACD,OAAO,OAAO,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;KAC1E,CAAC;AACJ,CAAC,CAAC;AAEF,4EAA4E;AAC5E,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,MAAM,EACN,WAAW,EACX,OAAO,EACP,KAAK,GAGN,EAAmC,EAAE;IACpC,iBAAiB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO;QACL,MAAM,EAAE;YACN,GAAG,MAAM;YACT,OAAO,EACL,OAAO,MAAM,EAAE,OAAO,KAAK,QAAQ;gBACjC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;gBACxB,CAAC,CAAC,MAAM,EAAE,OAAO;SACtB;QACD,KAAK,EAAE;YACL,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;gBAC1C,GAAG;gBACH,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;aACvC,CAAC,CACH;YACD,YAAY,EAAE,CAAC,GAAG,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;SACvD;QACD,WAAW;QACX,OAAO,EAAE,IAAI,CAAC,KAAK,CACjB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC1E;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n isHex,\n toHex,\n type Hex,\n type SignableMessage,\n bytesToHex,\n type TypedData,\n type TypedDataDefinition,\n getTypesForEIP712Domain,\n validateTypedData,\n} from \"viem\";\nimport type { TypedDataDefinition as WalletServerTypedDataDefinition } from \"@alchemy/wallet-api-types\";\n\nexport const castToHex = (val: string | number | bigint | Hex): Hex => {\n if (isHex(val)) {\n return val;\n }\n return toHex(val);\n};\n\nexport const signableMessageToJsonSafe = (\n message: SignableMessage,\n): string | { raw: Hex } => {\n if (typeof message === \"string\") {\n return message;\n }\n return {\n raw:\n typeof message.raw === \"string\" ? message.raw : bytesToHex(message.raw),\n };\n};\n\n// Purposefully not using `formatTypedData` from the wallet server types pkg\n// here, since that would require zod at runtime (which breaks RN).\nexport const typedDataToJsonSafe = ({\n domain,\n primaryType,\n message,\n types,\n}: TypedDataDefinition<\n TypedData | Record<string, unknown>\n>): WalletServerTypedDataDefinition => {\n validateTypedData({ domain, primaryType, message, types });\n return {\n domain: {\n ...domain,\n chainId:\n typeof domain?.chainId === \"bigint\"\n ? Number(domain.chainId)\n : domain?.chainId,\n },\n types: {\n ...Object.fromEntries(\n Object.entries(types).map(([key, value]) => [\n key,\n Array.isArray(value) ? [...value] : [],\n ]),\n ),\n EIP712Domain: [...getTypesForEIP712Domain({ domain })],\n },\n primaryType,\n message: JSON.parse(\n JSON.stringify(message, (_, v) => (typeof v === \"bigint\" ? toHex(v) : v)),\n ),\n };\n};\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
/** Constraint for RPC method schemas from `@alchemy/wallet-api-types/rpc`. */
|
|
3
|
-
type RpcMethodSchema =
|
|
4
|
-
Request:
|
|
5
|
-
method:
|
|
6
|
-
params:
|
|
3
|
+
type RpcMethodSchema = z.ZodObject<{
|
|
4
|
+
Request: z.ZodObject<{
|
|
5
|
+
method: z.ZodType;
|
|
6
|
+
params: z.ZodTuple<[z.ZodType, ...z.ZodType[]]>;
|
|
7
7
|
}>;
|
|
8
|
-
ReturnType:
|
|
8
|
+
ReturnType: z.ZodType;
|
|
9
9
|
}>;
|
|
10
|
-
export declare function methodSchema<TReq extends
|
|
11
|
-
Request:
|
|
12
|
-
method:
|
|
13
|
-
params:
|
|
10
|
+
export declare function methodSchema<TReq extends z.ZodType, TRes extends z.ZodType>(schema: z.ZodObject<{
|
|
11
|
+
Request: z.ZodObject<{
|
|
12
|
+
method: z.ZodType;
|
|
13
|
+
params: z.ZodTuple<[TReq, ...z.ZodType[]]>;
|
|
14
14
|
}>;
|
|
15
15
|
ReturnType: TRes;
|
|
16
16
|
}>): {
|
|
@@ -18,9 +18,9 @@ export declare function methodSchema<TReq extends TSchema, TRes extends TSchema>
|
|
|
18
18
|
response: TRes;
|
|
19
19
|
};
|
|
20
20
|
/** Extracts the decoded params type from a method schema. */
|
|
21
|
-
export type MethodParams<T extends RpcMethodSchema> =
|
|
21
|
+
export type MethodParams<T extends RpcMethodSchema> = z.output<T["shape"]["Request"]["shape"]["params"]["def"]["items"][0]>;
|
|
22
22
|
/** Extracts the decoded response type from a method schema. */
|
|
23
|
-
export type MethodResponse<T extends RpcMethodSchema> =
|
|
24
|
-
export declare function encode<const T extends
|
|
25
|
-
export declare function decode<const T extends
|
|
23
|
+
export type MethodResponse<T extends RpcMethodSchema> = z.output<T["shape"]["ReturnType"]>;
|
|
24
|
+
export declare function encode<const T extends z.ZodType>(schema: T, value: z.output<T>): z.input<T>;
|
|
25
|
+
export declare function decode<const T extends z.ZodType>(schema: T, value: z.input<T>): z.output<T>;
|
|
26
26
|
export {};
|
package/dist/esm/utils/schema.js
CHANGED
|
@@ -1,63 +1,59 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { BaseError } from "@alchemy/common";
|
|
3
3
|
export function methodSchema(schema) {
|
|
4
4
|
return {
|
|
5
|
-
request: schema.
|
|
6
|
-
response: schema.
|
|
5
|
+
request: schema.shape.Request.shape.params.def.items[0],
|
|
6
|
+
response: schema.shape.ReturnType,
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* @param {EncodeError | DecodeError} error - The error thrown by {@link Value.Encode} or {@link Value.Decode}.
|
|
16
|
-
* @returns {string} A formatted error string prefixed with `"Invalid params"`.
|
|
17
|
-
*/
|
|
18
|
-
function formatCodecError(schema, error) {
|
|
19
|
-
// Use only the first error — it's the most specific. Subsequent errors are
|
|
20
|
-
// typically cascade noise from union/anyOf branches.
|
|
21
|
-
const causeError = error.cause.errors[0];
|
|
22
|
-
// errors is typed as an open array — guard against the (practically
|
|
23
|
-
// impossible) empty case.
|
|
24
|
-
if (!causeError)
|
|
9
|
+
function isUnionIssue(issue) {
|
|
10
|
+
return issue.code === "invalid_union";
|
|
11
|
+
}
|
|
12
|
+
function formatCodecError(error) {
|
|
13
|
+
let issue = error.issues[0];
|
|
14
|
+
if (!issue)
|
|
25
15
|
return "Invalid params";
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
typeof schemaNode.errorMessage === "string") {
|
|
36
|
-
message = schemaNode.errorMessage;
|
|
16
|
+
// For union errors, drill into the branch with the fewest issues (closest match).
|
|
17
|
+
// Accumulate paths as we drill — each union level carries a partial path.
|
|
18
|
+
const pathPrefix = [];
|
|
19
|
+
while (isUnionIssue(issue)) {
|
|
20
|
+
pathPrefix.push(...issue.path);
|
|
21
|
+
let best;
|
|
22
|
+
for (const branch of issue.errors) {
|
|
23
|
+
if (!best || branch.length < best.length)
|
|
24
|
+
best = branch;
|
|
37
25
|
}
|
|
26
|
+
const next = best?.[0];
|
|
27
|
+
if (!next)
|
|
28
|
+
break;
|
|
29
|
+
issue = next;
|
|
38
30
|
}
|
|
39
|
-
|
|
31
|
+
const fullPath = [...pathPrefix, ...issue.path];
|
|
32
|
+
const path = fullPath.length > 0 ? "/" + fullPath.map(String).join("/") + ": " : "";
|
|
33
|
+
return `Invalid params: ${path}${issue.message}`;
|
|
40
34
|
}
|
|
41
|
-
// Type-safe wrapper around `Value.Encode` with human-readable errors.
|
|
42
35
|
export function encode(schema, value) {
|
|
43
36
|
try {
|
|
44
|
-
return
|
|
37
|
+
return schema.encode(value);
|
|
45
38
|
}
|
|
46
39
|
catch (error) {
|
|
47
|
-
if (error instanceof
|
|
48
|
-
throw new BaseError(formatCodecError(
|
|
40
|
+
if (error instanceof z.ZodError) {
|
|
41
|
+
throw new BaseError(formatCodecError(error), {
|
|
42
|
+
cause: error,
|
|
43
|
+
});
|
|
49
44
|
}
|
|
50
45
|
throw error;
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
|
-
// Type-safe wrapper around `Value.Decode` with human-readable errors.
|
|
54
48
|
export function decode(schema, value) {
|
|
55
49
|
try {
|
|
56
|
-
return
|
|
50
|
+
return schema.decode(value);
|
|
57
51
|
}
|
|
58
52
|
catch (error) {
|
|
59
|
-
if (error instanceof
|
|
60
|
-
throw new BaseError(formatCodecError(
|
|
53
|
+
if (error instanceof z.ZodError) {
|
|
54
|
+
throw new BaseError(formatCodecError(error), {
|
|
55
|
+
cause: error,
|
|
56
|
+
});
|
|
61
57
|
}
|
|
62
58
|
throw error;
|
|
63
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,UAAU,YAAY,CAC1B,MAME;IAEF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU;KAClC,CAAC;AACJ,CAAC;AAYD,SAAS,YAAY,CACnB,KAAuB;IAEvB,OAAO,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;AACxC,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAiB;IACzC,IAAI,KAAK,GAAiC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,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CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CACpB,MAAS,EACT,KAAiB;IAEjB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE;gBAC3C,KAAK,EAAE,KAAc;aACtB,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { z } from \"zod\";\nimport { BaseError } from \"@alchemy/common\";\n\n/** Constraint for RPC method schemas from `@alchemy/wallet-api-types/rpc`. */\ntype RpcMethodSchema = z.ZodObject<{\n Request: z.ZodObject<{\n method: z.ZodType;\n params: z.ZodTuple<[z.ZodType, ...z.ZodType[]]>;\n }>;\n ReturnType: z.ZodType;\n}>;\n\nexport function methodSchema<TReq extends z.ZodType, TRes extends z.ZodType>(\n schema: z.ZodObject<{\n Request: z.ZodObject<{\n method: z.ZodType;\n params: z.ZodTuple<[TReq, ...z.ZodType[]]>;\n }>;\n ReturnType: TRes;\n }>,\n): { request: TReq; response: TRes } {\n return {\n request: schema.shape.Request.shape.params.def.items[0],\n response: schema.shape.ReturnType,\n };\n}\n\n/** Extracts the decoded params type from a method schema. */\nexport type MethodParams<T extends RpcMethodSchema> = z.output<\n T[\"shape\"][\"Request\"][\"shape\"][\"params\"][\"def\"][\"items\"][0]\n>;\n\n/** Extracts the decoded response type from a method schema. */\nexport type MethodResponse<T extends RpcMethodSchema> = z.output<\n T[\"shape\"][\"ReturnType\"]\n>;\n\nfunction isUnionIssue(\n issue: z.core.$ZodIssue,\n): issue is z.core.$ZodIssueInvalidUnion {\n return issue.code === \"invalid_union\";\n}\n\nfunction formatCodecError(error: z.ZodError): string {\n let issue: z.core.$ZodIssue | undefined = error.issues[0];\n if (!issue) return \"Invalid params\";\n\n // For union errors, drill into the branch with the fewest issues (closest match).\n // Accumulate paths as we drill — each union level carries a partial path.\n const pathPrefix: PropertyKey[] = [];\n while (isUnionIssue(issue)) {\n pathPrefix.push(...issue.path);\n let best: z.core.$ZodIssue[] | undefined;\n for (const branch of issue.errors) {\n if (!best || branch.length < best.length) best = branch;\n }\n const next = best?.[0];\n if (!next) break;\n issue = next;\n }\n\n const fullPath = [...pathPrefix, ...issue.path];\n const path =\n fullPath.length > 0 ? \"/\" + fullPath.map(String).join(\"/\") + \": \" : \"\";\n\n return `Invalid params: ${path}${issue.message}`;\n}\n\nexport function encode<const T extends z.ZodType>(\n schema: T,\n value: z.output<T>,\n): z.input<T> {\n try {\n return schema.encode(value);\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new BaseError(formatCodecError(error), {\n cause: error as Error,\n });\n }\n throw error;\n }\n}\n\nexport function decode<const T extends z.ZodType>(\n schema: T,\n value: z.input<T>,\n): z.output<T> {\n try {\n return schema.decode(value);\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new BaseError(formatCodecError(error), {\n cause: error as Error,\n });\n }\n throw error;\n }\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "5.0.
|
|
1
|
+
export declare const VERSION = "5.0.1";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.1\";\n"]}
|
|
@@ -2,10 +2,15 @@ import type { Address, Prettify } from "viem";
|
|
|
2
2
|
import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
|
|
3
3
|
import { type PrepareCallsCapabilities, type WithCapabilities } from "../utils/capabilities.js";
|
|
4
4
|
import { type AccountParam } from "../utils/resolve.js";
|
|
5
|
+
import { PrepareCallsParams as EvmPrepareCallsSchema } from "@alchemy/wallet-api-types";
|
|
6
|
+
import type { z } from "zod";
|
|
5
7
|
import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
-
import { type
|
|
7
|
-
type BasePrepareCallsParams =
|
|
8
|
-
type
|
|
8
|
+
import { type MethodResponse } from "../utils/schema.js";
|
|
9
|
+
type BasePrepareCallsParams = z.output<typeof EvmPrepareCallsSchema>;
|
|
10
|
+
type FullPrepareCallsResponse = MethodResponse<typeof MethodSchema>;
|
|
11
|
+
type PrepareCallsResponse = Exclude<FullPrepareCallsResponse, {
|
|
12
|
+
type: "solana-transaction-v0";
|
|
13
|
+
}>;
|
|
9
14
|
export type PrepareCallsParams = Prettify<WithCapabilities<DistributiveOmit<BasePrepareCallsParams, "from" | "chainId"> & {
|
|
10
15
|
account?: AccountParam;
|
|
11
16
|
chainId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,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B,CAAA;CAAE,CAAC,GAC3D,CAAC,IAAI,CACH,OAAO,CAAC,oBAAoB,EAAE;IAAE,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC,EAC3D,iBAAiB,CAClB,GAAG;IACF,eAAe,EAAE,qBAAqB,CAAC;CACxC,CAAC,CAAC;AAEP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAqD7B"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Address } from "abitype";
|
|
2
2
|
import { type JsonRpcAccount, type Prettify } from "viem";
|
|
3
3
|
import { wallet_requestAccount as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
4
|
-
import type {
|
|
4
|
+
import type { InnerWalletApiClient } from "../types";
|
|
5
5
|
import { type MethodParams } from "../utils/schema.js";
|
|
6
6
|
type BaseRequestAccountParams = MethodParams<typeof MethodSchema>;
|
|
7
|
-
|
|
7
|
+
type SignerAddressParams = Extract<BaseRequestAccountParams, {
|
|
8
8
|
signerAddress: Address;
|
|
9
|
-
}
|
|
9
|
+
}>;
|
|
10
|
+
export type RequestAccountParams = Prettify<Pick<SignerAddressParams, "id" | "creationHint"> & ({
|
|
10
11
|
signerAddress?: Address;
|
|
11
12
|
accountAddress?: never;
|
|
12
13
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"requestAccount.d.ts","sourceRoot":"","sources":["../../../src/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,wBAAwB,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,KAAK,mBAAmB,GAAG,OAAO,CAChC,wBAAwB,EACxB;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,CAC3B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,cAAc,CAAC,GAC9C,CACI;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GACnD;IAAE,aAAa,CAAC,EAAE,KAAK,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,CACrD,CACJ,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CA6D/B"}
|
|
@@ -33,8 +33,11 @@ export type SendCallsResult = Prettify<SendPreparedCallsResult>;
|
|
|
33
33
|
* }
|
|
34
34
|
* });
|
|
35
35
|
*
|
|
36
|
-
* //
|
|
37
|
-
*
|
|
36
|
+
* // Wait for the calls to be mined and confirmed.
|
|
37
|
+
* // Polls getCallsStatus until the bundle succeeds, fails, or times out (default 60s).
|
|
38
|
+
* // See: https://viem.sh/docs/actions/wallet/waitForCallsStatus
|
|
39
|
+
* const status = await client.waitForCallsStatus({ id: result.id });
|
|
40
|
+
* console.log(status.status); // "success" | "failure"
|
|
38
41
|
* ```
|
|
39
42
|
* <Note>
|
|
40
43
|
* If using this action with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;IAChD,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;CAC3B,CACF,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AAEhE
|
|
1
|
+
{"version":3,"file":"sendCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAgB,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAKhC,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,GAAG;IAChD,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;CAC3B,CACF,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,uBAAuB,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC,CA2C1B"}
|
|
@@ -3,7 +3,9 @@ import type { DistributiveOmit, InnerWalletApiClient } from "../types.ts";
|
|
|
3
3
|
import { type WithCapabilities } from "../utils/capabilities.js";
|
|
4
4
|
import { wallet_sendPreparedCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
5
5
|
import { type MethodParams, type MethodResponse } from "../utils/schema.js";
|
|
6
|
-
type BaseSendPreparedCallsParams = MethodParams<typeof MethodSchema
|
|
6
|
+
type BaseSendPreparedCallsParams = Exclude<MethodParams<typeof MethodSchema>, {
|
|
7
|
+
type: "solana-transaction-v0";
|
|
8
|
+
}>;
|
|
7
9
|
type SendPreparedCallsResponse = MethodResponse<typeof MethodSchema>;
|
|
8
10
|
export type SendPreparedCallsParams = Prettify<WithCapabilities<DistributiveOmit<BaseSendPreparedCallsParams, "chainId"> & {
|
|
9
11
|
chainId?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE1E,OAA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AC,CA0BlC"}
|
|
@@ -18,6 +18,8 @@ export type SignPreparedCallsResult = {
|
|
|
18
18
|
type: "user-operation-v060";
|
|
19
19
|
}>> | Signed<Extract<PrepareCallsResult, {
|
|
20
20
|
type: "user-operation-v070";
|
|
21
|
+
}>> | Signed<Extract<PrepareCallsResult, {
|
|
22
|
+
type: "authorization";
|
|
21
23
|
}>>;
|
|
22
24
|
/**
|
|
23
25
|
* Signs prepared calls using the provided signer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPreparedCalls.d.ts","sourceRoot":"","sources":["../../../src/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGxD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC;AAEnE,mGAAmG;AACnG,KAAK,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GACrD,QAAQ,CACN,IAAI,CAAC,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAAC,GAAG;IAC3C,SAAS,EAAE,0BAA0B,CAAC;CACvC,CACF,GACD,KAAK,CAAC;AAEV,MAAM,MAAM,uBAAuB,GAC/B;IACE,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,MAAM,CACV,OAAO,CAAC,kBAAkB,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAC/D,EAAE,CAAC;CACL,GACD,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,qBAAqB,CA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AAe,CAAA;CAAE,CAAC,CAAC,CAAC;AAUnE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAsFlC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Hex, type Prettify } from "viem";
|
|
2
|
-
import {
|
|
2
|
+
import { PersonalSignSignatureRequest, TypedDataSignatureRequest, AuthorizationSignatureRequest, Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
|
|
3
3
|
import type { InnerWalletApiClient, WithoutRawPayload } from "../types";
|
|
4
|
-
import type {
|
|
5
|
-
export type SignSignatureRequestParams = Prettify<WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
|
|
6
|
-
data:
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
export type SignSignatureRequestParams = Prettify<WithoutRawPayload<z.output<typeof PersonalSignSignatureRequest> | z.output<typeof TypedDataSignatureRequest> | (z.output<typeof AuthorizationSignatureRequest> & {
|
|
6
|
+
data: z.output<typeof Eip7702UnsignedAuth>;
|
|
7
7
|
})>>;
|
|
8
8
|
export type SignSignatureRequestResult = {
|
|
9
9
|
type: "secp256k1";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signSignatureRequest.d.ts","sourceRoot":"","sources":["../../../src/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAsB,MAAM,MAAM,CAAC;AACnE,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"signSignatureRequest.d.ts","sourceRoot":"","sources":["../../../src/actions/signSignatureRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,QAAQ,EAAsB,MAAM,MAAM,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EACV,oBAAoB,EAEpB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAOlB,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAC/C,iBAAiB,CACb,CAAC,CAAC,MAAM,CAAC,OAAO,4BAA4B,CAAC,GAC7C,CAAC,CAAC,MAAM,CAAC,OAAO,yBAAyB,CAAC,GAC1C,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,6BAA6B,CAAC,GAAG;IAChD,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;CAC5C,CAAC,CACL,CACF,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,GAAG,CAAC;CACX,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAQrC"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Address as ViemAddress, type Hex, type TypedData } from "viem";
|
|
2
2
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
3
3
|
import { type AccountParam } from "../utils/resolve.js";
|
|
4
|
-
export type SignTypedDataParams =
|
|
4
|
+
export type SignTypedDataParams = {
|
|
5
|
+
domain?: {
|
|
6
|
+
name?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
chainId?: number | bigint;
|
|
9
|
+
verifyingContract?: ViemAddress;
|
|
10
|
+
salt?: Hex;
|
|
11
|
+
};
|
|
12
|
+
types: TypedData | Record<string, unknown>;
|
|
13
|
+
primaryType: string;
|
|
14
|
+
message: Record<string, unknown>;
|
|
5
15
|
account?: AccountParam;
|
|
6
|
-
}
|
|
7
|
-
export type SignTypedDataResult =
|
|
16
|
+
};
|
|
17
|
+
export type SignTypedDataResult = Hex;
|
|
8
18
|
/**
|
|
9
19
|
* Signs typed data (EIP-712) using the smart account.
|
|
10
20
|
* This method requests the account associated with the signer and uses it to sign the typed data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"signTypedData.d.ts","sourceRoot":"","sources":["../../../src/actions/signTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,IAAI,WAAW,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,MAAM,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC1B,iBAAiB,CAAC,EAAE,WAAW,CAAC;QAChC,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,CAAC;IACF,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAsB,aAAa,CACjC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,mBAAmB,CAAC,CA4B9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Hex } from "viem";
|
|
2
|
+
import type { InnerSolanaWalletApiClient } from "../../types.js";
|
|
3
|
+
import { wallet_getCallsStatus as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
4
|
+
import { type MethodResponse } from "../../utils/schema.js";
|
|
5
|
+
type GetCallsStatusResponse = MethodResponse<typeof MethodSchema>;
|
|
6
|
+
type SolanaGetCallsStatusResponse = Extract<GetCallsStatusResponse, {
|
|
7
|
+
chainId: `solana:${string}`;
|
|
8
|
+
}>;
|
|
9
|
+
export type SolanaGetCallsStatusParams = {
|
|
10
|
+
id: Hex;
|
|
11
|
+
};
|
|
12
|
+
export type SolanaGetCallsStatusResult = Omit<SolanaGetCallsStatusResponse, "status"> & {
|
|
13
|
+
status: "pending" | "success" | "failure";
|
|
14
|
+
statusCode: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Gets the status of a Solana call bundle.
|
|
18
|
+
*
|
|
19
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
20
|
+
* @param {SolanaGetCallsStatusParams} params - The call ID to check
|
|
21
|
+
* @returns {Promise<SolanaGetCallsStatusResult>} The status of the call
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCallsStatus(client: InnerSolanaWalletApiClient, params: SolanaGetCallsStatusParams): Promise<SolanaGetCallsStatusResult>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=getCallsStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCallsStatus.d.ts","sourceRoot":"","sources":["../../../../src/actions/solana/getCallsStatus.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,qBAAqB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,KAAK,sBAAsB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,KAAK,4BAA4B,GAAG,OAAO,CACzC,sBAAsB,EACtB;IAAE,OAAO,EAAE,UAAU,MAAM,EAAE,CAAA;CAAE,CAChC,CAAC;AAWF,MAAM,MAAM,0BAA0B,GAAG;IACvC,EAAE,EAAE,GAAG,CAAC;CACT,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,4BAA4B,EAC5B,QAAQ,CACT,GAAG;IACF,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CA4BrC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Prettify } from "viem";
|
|
2
|
+
import type { DistributiveOmit, InnerSolanaWalletApiClient } from "../../types.js";
|
|
3
|
+
import type { SolanaChainId } from "@alchemy/wallet-api-types";
|
|
4
|
+
import { SolanaPrepareCallsParams as SolanaPrepareCallsSchema } from "@alchemy/wallet-api-types";
|
|
5
|
+
import { wallet_prepareCalls as MethodSchema } from "@alchemy/wallet-api-types/rpc";
|
|
6
|
+
import type { z } from "zod";
|
|
7
|
+
import { type WithCapabilities } from "../../utils/capabilities.js";
|
|
8
|
+
import { type MethodResponse } from "../../utils/schema.js";
|
|
9
|
+
type PrepareCallsResponse = MethodResponse<typeof MethodSchema>;
|
|
10
|
+
type BaseSolanaPrepareCallsParams = z.output<typeof SolanaPrepareCallsSchema>;
|
|
11
|
+
export type SolanaPrepareCallsParams = Prettify<WithCapabilities<DistributiveOmit<BaseSolanaPrepareCallsParams, "from" | "chainId"> & {
|
|
12
|
+
account?: string;
|
|
13
|
+
chainId?: SolanaChainId;
|
|
14
|
+
}>>;
|
|
15
|
+
type SolanaPrepareCallsResponse = Extract<PrepareCallsResponse, {
|
|
16
|
+
type: "solana-transaction-v0";
|
|
17
|
+
}>;
|
|
18
|
+
export type SolanaPrepareCallsResult = SolanaPrepareCallsResponse;
|
|
19
|
+
/**
|
|
20
|
+
* Prepares Solana instructions for execution by building a versioned transaction.
|
|
21
|
+
* Returns the compiled transaction and a signature request that needs to be signed
|
|
22
|
+
* before submitting to sendPreparedCalls.
|
|
23
|
+
*
|
|
24
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
25
|
+
* @param {SolanaPrepareCallsParams} params - Parameters for preparing Solana calls
|
|
26
|
+
* @param {Array<{programId: string, accounts?: Array, data: Hex}>} params.calls - Array of Solana instructions
|
|
27
|
+
* @param {string} [params.account] - The Solana address to execute from. Defaults to the signer's address.
|
|
28
|
+
* @param {SolanaChainId} [params.chainId] - The Solana chain ID. Defaults to the client's chain.
|
|
29
|
+
* @param {object} [params.capabilities] - Optional capabilities (e.g. paymaster sponsorship)
|
|
30
|
+
* @returns {Promise<SolanaPrepareCallsResult>} The prepared Solana transaction with signature request
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const result = await client.prepareCalls({
|
|
35
|
+
* calls: [{
|
|
36
|
+
* programId: "11111111111111111111111111111111",
|
|
37
|
+
* data: "0x...",
|
|
38
|
+
* }],
|
|
39
|
+
* capabilities: {
|
|
40
|
+
* paymaster: { policyId: "your-policy-id" }
|
|
41
|
+
* }
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function prepareCalls(client: InnerSolanaWalletApiClient, params: SolanaPrepareCallsParams): Promise<SolanaPrepareCallsResult>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=prepareCalls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareCalls.d.ts","sourceRoot":"","sources":["../../../../src/actions/solana/prepareCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,IAAI,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,mBAAmB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAG/B,KAAK,oBAAoB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAEhE,KAAK,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE9E,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,gBAAgB,CACd,gBAAgB,CAAC,4BAA4B,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CACF,CACF,CAAC;AAEF,KAAK,0BAA0B,GAAG,OAAO,CACvC,oBAAoB,EACpB;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CAClC,CAAC;AAQF,MAAM,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,wBAAwB,CAAC,CAwCnC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Prettify } from "viem";
|
|
2
|
+
import type { DistributiveOmit, InnerSolanaWalletApiClient } from "../../types.js";
|
|
3
|
+
import type { SolanaChainId } from "@alchemy/wallet-api-types";
|
|
4
|
+
import { type SolanaPrepareCallsParams } from "./prepareCalls.js";
|
|
5
|
+
import { type SolanaSendPreparedCallsResult } from "./sendPreparedCalls.js";
|
|
6
|
+
export type SolanaSendCallsParams = Prettify<DistributiveOmit<SolanaPrepareCallsParams, "chainId"> & {
|
|
7
|
+
chainId?: SolanaChainId;
|
|
8
|
+
}>;
|
|
9
|
+
export type SolanaSendCallsResult = Prettify<SolanaSendPreparedCallsResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Prepares, signs, and submits Solana instructions in a single call.
|
|
12
|
+
* Internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
|
|
13
|
+
*
|
|
14
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
15
|
+
* @param {SolanaSendCallsParams} params - Parameters for sending Solana calls
|
|
16
|
+
* @param {Array<{programId: string, accounts?: Array, data: Hex}>} params.calls - Array of Solana instructions
|
|
17
|
+
* @param {string} [params.account] - The Solana address to execute from. Defaults to the signer's address.
|
|
18
|
+
* @param {object} [params.capabilities] - Optional capabilities (e.g. paymaster sponsorship)
|
|
19
|
+
* @returns {Promise<SolanaSendCallsResult>} The result containing the call ID
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const result = await client.sendCalls({
|
|
24
|
+
* calls: [{
|
|
25
|
+
* programId: "11111111111111111111111111111111",
|
|
26
|
+
* data: "0x...",
|
|
27
|
+
* }],
|
|
28
|
+
* capabilities: {
|
|
29
|
+
* paymaster: { policyId: "your-policy-id" }
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function sendCalls(client: InnerSolanaWalletApiClient, params: SolanaSendCallsParams): Promise<SolanaSendCallsResult>;
|
|
35
|
+
//# sourceMappingURL=sendCalls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sendCalls.d.ts","sourceRoot":"","sources":["../../../../src/actions/solana/sendCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAgB,KAAK,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAC;AAGhC,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAC1C,gBAAgB,CAAC,wBAAwB,EAAE,SAAS,CAAC,GAAG;IACtD,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC,6BAA6B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,qBAAqB,CAAC,CAgBhC"}
|