@alchemy/wallet-apis 5.0.0-beta.27 → 5.0.0-beta.29
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/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/sendPreparedCalls.d.ts +3 -1
- package/dist/esm/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/actions/signPreparedCalls.js +1 -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/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.js +2 -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 +34 -7
- package/dist/esm/experimental/actions/requestQuoteV0.js.map +1 -1
- package/dist/esm/exports/index.d.ts +3 -3
- 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.js +1 -1
- 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/sendPreparedCalls.d.ts +3 -1
- package/dist/types/actions/sendPreparedCalls.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/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/solanaSmartWalletActions.d.ts +17 -0
- package/dist/types/decorators/solanaSmartWalletActions.d.ts.map +1 -0
- package/dist/types/experimental/actions/requestQuoteV0.d.ts +34 -7
- package/dist/types/experimental/actions/requestQuoteV0.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +3 -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/schema.d.ts +14 -14
- package/dist/types/utils/schema.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +26 -9
- package/src/actions/prepareCalls.ts +21 -3
- package/src/actions/requestAccount.ts +7 -5
- package/src/actions/sendPreparedCalls.ts +4 -1
- package/src/actions/signPreparedCalls.ts +1 -1
- package/src/actions/signSignatureRequest.ts +8 -8
- package/src/actions/signTypedData.ts +15 -12
- 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/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 +2 -2
- package/src/decorators/solanaSmartWalletActions.ts +62 -0
- package/src/experimental/actions/requestQuoteV0.ts +26 -11
- package/src/exports/index.ts +8 -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 +1 -1
- package/src/utils/schema.ts +58 -69
- package/src/version.ts +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { prepareCalls } from "../actions/solana/prepareCalls.js";
|
|
2
|
+
export { signPreparedCalls } from "../actions/solana/signPreparedCalls.js";
|
|
3
|
+
export { sendPreparedCalls } from "../actions/solana/sendPreparedCalls.js";
|
|
4
|
+
export { sendCalls } from "../actions/solana/sendCalls.js";
|
|
5
|
+
export { getCallsStatus } from "../actions/solana/getCallsStatus.js";
|
|
6
|
+
export { waitForCallsStatus } from "../actions/solana/waitForCallsStatus.js";
|
|
7
|
+
export { solanaSmartWalletActions } from "../decorators/solanaSmartWalletActions.js";
|
|
8
|
+
// Errors.
|
|
9
|
+
export { SolanaSignerError } from "../adapters/SolanaSignerError.js";
|
|
10
|
+
// Adapters.
|
|
11
|
+
export { fromKeypair } from "../adapters/fromKeypair.js";
|
|
12
|
+
export { fromKitSigner } from "../adapters/fromKitSigner.js";
|
|
13
|
+
export { fromWalletAdapter } from "../adapters/fromWalletAdapter.js";
|
|
14
|
+
export { fromWalletStandard } from "../adapters/fromWalletStandard.js";
|
|
15
|
+
//# sourceMappingURL=solana.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../src/exports/solana.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAI7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAErF,UAAU;AACV,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["// Actions.\nexport type * from \"../actions/solana/prepareCalls.js\";\nexport { prepareCalls } from \"../actions/solana/prepareCalls.js\";\nexport type * from \"../actions/solana/signPreparedCalls.js\";\nexport { signPreparedCalls } from \"../actions/solana/signPreparedCalls.js\";\nexport type * from \"../actions/solana/sendPreparedCalls.js\";\nexport { sendPreparedCalls } from \"../actions/solana/sendPreparedCalls.js\";\nexport type * from \"../actions/solana/sendCalls.js\";\nexport { sendCalls } from \"../actions/solana/sendCalls.js\";\nexport type * from \"../actions/solana/getCallsStatus.js\";\nexport { getCallsStatus } from \"../actions/solana/getCallsStatus.js\";\nexport type * from \"../actions/solana/waitForCallsStatus.js\";\nexport { waitForCallsStatus } from \"../actions/solana/waitForCallsStatus.js\";\n\n// Decorator.\nexport type { SolanaSmartWalletActions } from \"../decorators/solanaSmartWalletActions.js\";\nexport { solanaSmartWalletActions } from \"../decorators/solanaSmartWalletActions.js\";\n\n// Errors.\nexport { SolanaSignerError } from \"../adapters/SolanaSignerError.js\";\n\n// Adapters.\nexport { fromKeypair } from \"../adapters/fromKeypair.js\";\nexport type { SolanaKeypairSigner } from \"../adapters/fromKeypair.js\";\nexport { fromKitSigner } from \"../adapters/fromKitSigner.js\";\nexport type { SolanaTransactionPartialSigner } from \"../adapters/fromKitSigner.js\";\nexport { fromWalletAdapter } from \"../adapters/fromWalletAdapter.js\";\nexport type { WalletAdapterSigner } from \"../adapters/fromWalletAdapter.js\";\nexport { fromWalletStandard } from \"../adapters/fromWalletStandard.js\";\nexport type {\n WalletStandardWallet,\n WalletStandardAccount,\n} from \"../adapters/fromWalletStandard.js\";\n\n// Types.\nexport type { SolanaSigner, SolanaSmartWalletClient } from \"../types.js\";\n"]}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import type { WalletServerViemRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
2
|
+
import type { SolanaChainId } from "@alchemy/wallet-api-types";
|
|
2
3
|
import type { Account, Address, Chain, Client, Hex, JsonRpcAccount, Transport, WalletClient, LocalAccount } from "viem";
|
|
3
4
|
import type { InternalState } from "./internal";
|
|
4
5
|
import type { SmartWalletActions } from "./decorators/smartWalletActions";
|
|
6
|
+
import type { SolanaSmartWalletActions } from "./decorators/solanaSmartWalletActions";
|
|
5
7
|
export type BaseWalletClient<TExtend extends {
|
|
6
8
|
[key: string]: unknown;
|
|
7
9
|
} | undefined = {
|
|
8
10
|
[key: string]: unknown;
|
|
9
|
-
} | undefined
|
|
11
|
+
} | undefined, TAccount extends Account | undefined = JsonRpcAccount<Address>> = Client<Transport<"alchemyHttp">, Chain, TAccount, WalletServerViemRpcSchema, TExtend>;
|
|
12
|
+
export type SignerClient = WalletClient<Transport, Chain | undefined, Account>;
|
|
13
|
+
export type SmartWalletSigner = LocalAccount | SignerClient;
|
|
14
|
+
export type SmartWalletClient = BaseWalletClient<SmartWalletActions>;
|
|
15
|
+
export type SolanaSmartWalletClient = BaseWalletClient<SolanaSmartWalletActions & {
|
|
16
|
+
solanaAccount: string;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
/** Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. */
|
|
19
|
+
export interface SolanaSigner {
|
|
20
|
+
address: string;
|
|
21
|
+
signTransaction(input: {
|
|
22
|
+
transaction: Uint8Array;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
signedTransaction: Uint8Array;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
export interface SolanaChainDef extends Chain {
|
|
29
|
+
solanaChainId: SolanaChainId;
|
|
30
|
+
}
|
|
10
31
|
export type InnerWalletApiClient = BaseWalletClient<{
|
|
11
32
|
internal: InternalState | undefined;
|
|
12
33
|
owner: SmartWalletSigner;
|
|
13
34
|
policyIds?: string[];
|
|
14
35
|
}>;
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
36
|
+
export type InnerSolanaWalletApiClient = BaseWalletClient<{
|
|
37
|
+
internal: InternalState | undefined;
|
|
38
|
+
owner: SolanaSigner;
|
|
39
|
+
solanaAccount: string;
|
|
40
|
+
policyIds?: string[];
|
|
41
|
+
}, undefined>;
|
|
18
42
|
export type OptionalChainId<T> = T extends {
|
|
19
43
|
chainId: number;
|
|
20
44
|
} ? Omit<T, "chainId"> & {
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n JsonRpcAccount,\n Transport,\n WalletClient,\n LocalAccount,\n} from \"viem\";\nimport type { InternalState } from \"./internal\";\nimport type { SmartWalletActions } from \"./decorators/smartWalletActions\";\n\nexport type BaseWalletClient<\n TExtend extends { [key: string]: unknown } | undefined =\n | { [key: string]: unknown }\n | undefined,\n> = Client<\n Transport<\"alchemyHttp\">,\n Chain,\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { WalletServerViemRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport type { SolanaChainId } from \"@alchemy/wallet-api-types\";\nimport type {\n Account,\n Address,\n Chain,\n Client,\n Hex,\n JsonRpcAccount,\n Transport,\n WalletClient,\n LocalAccount,\n} from \"viem\";\nimport type { InternalState } from \"./internal\";\nimport type { SmartWalletActions } from \"./decorators/smartWalletActions\";\nimport type { SolanaSmartWalletActions } from \"./decorators/solanaSmartWalletActions\";\n\nexport type BaseWalletClient<\n TExtend extends { [key: string]: unknown } | undefined =\n | { [key: string]: unknown }\n | undefined,\n TAccount extends Account | undefined = JsonRpcAccount<Address>,\n> = Client<\n Transport<\"alchemyHttp\">,\n Chain,\n TAccount,\n WalletServerViemRpcSchema,\n TExtend\n>;\n\nexport type SignerClient = WalletClient<Transport, Chain | undefined, Account>;\n\nexport type SmartWalletSigner = LocalAccount | SignerClient;\n\nexport type SmartWalletClient = BaseWalletClient<SmartWalletActions>;\n\nexport type SolanaSmartWalletClient = BaseWalletClient<\n SolanaSmartWalletActions & { solanaAccount: string },\n undefined\n>;\n\n/** Solana signer interface. Takes serialized tx bytes, returns signed serialized tx bytes. */\nexport interface SolanaSigner {\n address: string;\n signTransaction(input: {\n transaction: Uint8Array;\n [key: string]: unknown;\n }): Promise<{ signedTransaction: Uint8Array }>;\n}\n\nexport interface SolanaChainDef extends Chain {\n solanaChainId: SolanaChainId;\n}\n\nexport type InnerWalletApiClient = BaseWalletClient<{\n internal: InternalState | undefined;\n owner: SmartWalletSigner;\n policyIds?: string[];\n}>;\n\nexport type InnerSolanaWalletApiClient = BaseWalletClient<\n {\n internal: InternalState | undefined;\n owner: SolanaSigner;\n solanaAccount: string;\n policyIds?: string[];\n },\n undefined\n>;\n\nexport type OptionalChainId<T> = T extends { chainId: number }\n ? Omit<T, \"chainId\"> & { chainId?: number | undefined }\n : T;\n\nexport type OptionalFrom<T> = T extends { from: Address }\n ? Omit<T, \"from\"> & { from?: Address | undefined }\n : T;\n\nexport type WithoutRawPayload<T> = T extends { rawPayload: Hex }\n ? Omit<T, \"rawPayload\">\n : T;\n\nexport type Expect<T extends true> = T;\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends any\n ? Omit<T, K>\n : never;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Client, LocalAccount } from "viem";
|
|
2
|
-
import type { InnerWalletApiClient, SignerClient } from "../types.js";
|
|
1
|
+
import type { Chain, Client, LocalAccount } from "viem";
|
|
2
|
+
import type { InnerWalletApiClient, InnerSolanaWalletApiClient, SignerClient, SolanaChainDef } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Type guard function to check if a client is an Alchemy Smart Wallet Client.
|
|
5
5
|
*
|
|
@@ -7,6 +7,7 @@ import type { InnerWalletApiClient, SignerClient } from "../types.js";
|
|
|
7
7
|
* @returns {boolean} True if the client is an Alchemy Smart Wallet Client
|
|
8
8
|
*/
|
|
9
9
|
export declare function isSmartWalletClient(client: Client): client is InnerWalletApiClient;
|
|
10
|
+
export declare function isSolanaClient(client: Client): client is InnerSolanaWalletApiClient;
|
|
10
11
|
/**
|
|
11
12
|
* Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.
|
|
12
13
|
* After this function returns successfully, TypeScript will narrow the client type.
|
|
@@ -16,5 +17,6 @@ export declare function isSmartWalletClient(client: Client): client is InnerWall
|
|
|
16
17
|
* @throws {Error} Throws an error if the client is not an Alchemy Smart Wallet Client
|
|
17
18
|
*/
|
|
18
19
|
export declare function assertSmartWalletClient(client: Client, message?: string): asserts client is InnerWalletApiClient;
|
|
20
|
+
export declare function isSolanaChain(chain: Chain): chain is SolanaChainDef;
|
|
19
21
|
export declare function isLocalAccount(signer: LocalAccount | SignerClient): signer is LocalAccount;
|
|
20
22
|
export declare function isSignerClient(signer: LocalAccount | SignerClient): signer is SignerClient;
|
|
@@ -8,6 +8,9 @@ import { BaseError } from "@alchemy/common";
|
|
|
8
8
|
export function isSmartWalletClient(client) {
|
|
9
9
|
return client.name === "alchemySmartWalletClient" && "owner" in client;
|
|
10
10
|
}
|
|
11
|
+
export function isSolanaClient(client) {
|
|
12
|
+
return client.name === "alchemySolanaSmartWalletClient" && "owner" in client;
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
15
|
* Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.
|
|
13
16
|
* After this function returns successfully, TypeScript will narrow the client type.
|
|
@@ -21,6 +24,9 @@ export function assertSmartWalletClient(client, message = "Expected an Alchemy S
|
|
|
21
24
|
throw new BaseError(message);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
27
|
+
export function isSolanaChain(chain) {
|
|
28
|
+
return "solanaChainId" in chain;
|
|
29
|
+
}
|
|
24
30
|
export function isLocalAccount(signer) {
|
|
25
31
|
return signer.type === "local";
|
|
26
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/assertions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/utils/assertions.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAc;IAEd,OAAO,MAAM,CAAC,IAAI,KAAK,0BAA0B,IAAI,OAAO,IAAI,MAAM,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAc;IAEd,OAAO,MAAM,CAAC,IAAI,KAAK,gCAAgC,IAAI,OAAO,IAAI,MAAM,CAAC;AAC/E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,MAAc,EACd,OAAO,GAAG,yCAAyC;IAEnD,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAY;IACxC,OAAO,eAAe,IAAI,KAAK,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAmC;IAEnC,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAmC;IAEnC,OAAO,SAAS,IAAI,MAAM,CAAC;AAC7B,CAAC","sourcesContent":["import type { Chain, Client, LocalAccount } from \"viem\";\nimport type {\n InnerWalletApiClient,\n InnerSolanaWalletApiClient,\n SignerClient,\n SolanaChainDef,\n} from \"../types.js\";\nimport { BaseError } from \"@alchemy/common\";\n\n/**\n * Type guard function to check if a client is an Alchemy Smart Wallet Client.\n *\n * @param {Client} client - The client to check\n * @returns {boolean} True if the client is an Alchemy Smart Wallet Client\n */\nexport function isSmartWalletClient(\n client: Client,\n): client is InnerWalletApiClient {\n return client.name === \"alchemySmartWalletClient\" && \"owner\" in client;\n}\n\nexport function isSolanaClient(\n client: Client,\n): client is InnerSolanaWalletApiClient {\n return client.name === \"alchemySolanaSmartWalletClient\" && \"owner\" in client;\n}\n\n/**\n * Assertion function that throws an error if the client is not an Alchemy Smart Wallet Client.\n * After this function returns successfully, TypeScript will narrow the client type.\n *\n * @param {Client} client - The client to assert\n * @param {string} message - Custom error message if assertion fails\n * @throws {Error} Throws an error if the client is not an Alchemy Smart Wallet Client\n */\nexport function assertSmartWalletClient(\n client: Client,\n message = \"Expected an Alchemy Smart Wallet Client\",\n): asserts client is InnerWalletApiClient {\n if (!isSmartWalletClient(client)) {\n throw new BaseError(message);\n }\n}\n\nexport function isSolanaChain(chain: Chain): chain is SolanaChainDef {\n return \"solanaChainId\" in chain;\n}\n\nexport function isLocalAccount(\n signer: LocalAccount | SignerClient,\n): signer is LocalAccount {\n return signer.type === \"local\";\n}\n\nexport function isSignerClient(\n signer: LocalAccount | SignerClient,\n): signer is SignerClient {\n return \"request\" in signer;\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { PrepareCallsCapabilities as PrepareCallsCapabilitiesSchema, SendPreparedCallsCapabilities as SendPreparedCallsCapabilitiesSchema } from "@alchemy/wallet-api-types/capabilities";
|
|
2
|
-
import type {
|
|
3
|
-
import type { InnerWalletApiClient } from "../types.js";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { InnerWalletApiClient, InnerSolanaWalletApiClient } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* Decoded capabilities matching the schema shape (uses `paymasterService` key).
|
|
6
6
|
* `ResolveCapabilities` renames this to `paymaster` for client-facing types.
|
|
7
7
|
*/
|
|
8
|
-
type DecodedPrepareCallsCaps =
|
|
9
|
-
type DecodedSendPreparedCallsCaps =
|
|
8
|
+
type DecodedPrepareCallsCaps = z.output<typeof PrepareCallsCapabilitiesSchema>;
|
|
9
|
+
type DecodedSendPreparedCallsCaps = z.output<typeof SendPreparedCallsCapabilitiesSchema>;
|
|
10
10
|
/**
|
|
11
11
|
* Renames `paymasterService` (RPC) to `paymaster` in a capabilities type. This
|
|
12
12
|
* is because our RPC schema's paymasterService capability does not exactly match
|
|
@@ -31,14 +31,14 @@ export type WithCapabilities<T> = T extends {
|
|
|
31
31
|
} : T;
|
|
32
32
|
/**
|
|
33
33
|
* Converts capabilities (with `paymaster`) to RPC capabilities (with `paymasterService`)
|
|
34
|
-
* for use with
|
|
34
|
+
* for use with `encode` before sending to the RPC.
|
|
35
35
|
*
|
|
36
36
|
* @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
|
|
37
37
|
* @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
|
|
38
38
|
*/
|
|
39
39
|
export declare function toRpcCapabilities(capabilities: PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined): DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined;
|
|
40
40
|
/**
|
|
41
|
-
* Converts RPC capabilities (with `paymasterService`) from
|
|
41
|
+
* Converts RPC capabilities (with `paymasterService`) from `decode`
|
|
42
42
|
* to capabilities (with `paymaster`).
|
|
43
43
|
*
|
|
44
44
|
* @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
|
|
@@ -54,6 +54,22 @@ export declare function fromRpcCapabilities(capabilities: DecodedPrepareCallsCap
|
|
|
54
54
|
* @returns {T | undefined} The merged capabilities object, or original capabilities if no capability configuration exists on the client
|
|
55
55
|
*/
|
|
56
56
|
export declare const mergeClientCapabilities: <T extends PrepareCallsCapabilities | SendPreparedCallsCapabilities>(client: InnerWalletApiClient, capabilities: T | undefined) => T | undefined;
|
|
57
|
+
export type SolanaPaymasterCapability = {
|
|
58
|
+
policyId: string;
|
|
59
|
+
webhookData?: string;
|
|
60
|
+
};
|
|
61
|
+
export type SolanaPrepareCallsCapabilities = {
|
|
62
|
+
paymaster?: SolanaPaymasterCapability;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Merges Solana client-level capabilities (policyId from factory) with
|
|
66
|
+
* request-level capabilities. Request-level takes priority if provided.
|
|
67
|
+
*
|
|
68
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
69
|
+
* @param {SolanaPrepareCallsCapabilities | undefined} capabilities - Request capabilities to merge with
|
|
70
|
+
* @returns {SolanaPrepareCallsCapabilities | undefined} The merged capabilities
|
|
71
|
+
*/
|
|
72
|
+
export declare const mergeSolanaClientCapabilities: (client: InnerSolanaWalletApiClient, capabilities: SolanaPrepareCallsCapabilities | undefined) => SolanaPrepareCallsCapabilities | undefined;
|
|
57
73
|
/**
|
|
58
74
|
* Extracts capabilities from prepareCalls that are usable for sendPreparedCalls.
|
|
59
75
|
* Only permissions and paymaster (policyId/policyIds & webhookData) are supported.
|
|
@@ -7,7 +7,7 @@ function hasNoPaymasterServiceField(value) {
|
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Converts capabilities (with `paymaster`) to RPC capabilities (with `paymasterService`)
|
|
10
|
-
* for use with
|
|
10
|
+
* for use with `encode` before sending to the RPC.
|
|
11
11
|
*
|
|
12
12
|
* @param {PrepareCallsCapabilities | SendPreparedCallsCapabilities | undefined} capabilities - Capabilities object containing a `paymaster` field
|
|
13
13
|
* @returns {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} RPC capabilities with `paymasterService`, or undefined if input is undefined
|
|
@@ -24,7 +24,7 @@ export function toRpcCapabilities(capabilities) {
|
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Converts RPC capabilities (with `paymasterService`) from
|
|
27
|
+
* Converts RPC capabilities (with `paymasterService`) from `decode`
|
|
28
28
|
* to capabilities (with `paymaster`).
|
|
29
29
|
*
|
|
30
30
|
* @param {DecodedPrepareCallsCaps | DecodedSendPreparedCallsCaps | undefined} capabilities - RPC capabilities object containing a `paymasterService` field
|
|
@@ -65,6 +65,23 @@ export const mergeClientCapabilities = (client, capabilities) => {
|
|
|
65
65
|
: { policyIds: client.policyIds },
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Merges Solana client-level capabilities (policyId from factory) with
|
|
70
|
+
* request-level capabilities. Request-level takes priority if provided.
|
|
71
|
+
*
|
|
72
|
+
* @param {InnerSolanaWalletApiClient} client - The Solana wallet API client
|
|
73
|
+
* @param {SolanaPrepareCallsCapabilities | undefined} capabilities - Request capabilities to merge with
|
|
74
|
+
* @returns {SolanaPrepareCallsCapabilities | undefined} The merged capabilities
|
|
75
|
+
*/
|
|
76
|
+
export const mergeSolanaClientCapabilities = (client, capabilities) => {
|
|
77
|
+
if (!client.policyIds?.length || capabilities?.paymaster) {
|
|
78
|
+
return capabilities;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...capabilities,
|
|
82
|
+
paymaster: { policyId: client.policyIds[0] },
|
|
83
|
+
};
|
|
84
|
+
};
|
|
68
85
|
/**
|
|
69
86
|
* Extracts capabilities from prepareCalls that are usable for sendPreparedCalls.
|
|
70
87
|
* Only permissions and paymaster (policyId/policyIds & webhookData) are supported.
|
|
@@ -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,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EAAE,SAAS,CAAC,SAAS,EAAE,CAAC;gBACvC,WAAW,EAAE,SAAS,CAAC,WAAW;aACnC;YACH,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"]}
|
package/dist/esm/utils/format.js
CHANGED
|
@@ -14,7 +14,7 @@ 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
19
|
validateTypedData({ domain, primaryType, message, types });
|
|
20
20
|
return {
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/ut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E,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,CAAC,KAAK;QAAE,OAAO,gBAAgB,CAAC;IAEpC,kFAAkF;IAClF,0EAA0E;IAC1E,MAAM,UAAU,GAAkB,EAAE,CAAC;IACrC,OAAO,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAoC,CAAC;QACzC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,GAAG,IAAI,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tB,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.0-beta.
|
|
1
|
+
export declare const VERSION = "5.0.0-beta.28";
|
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,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.28\";\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,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,EAIL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,E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ChC,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"}
|
|
@@ -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,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,2BAA2B,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;
|
|
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,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,IAAI,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,2BAA2B,GAAG,OAAO,CACxC,YAAY,CAAC,OAAO,YAAY,CAAC,EACjC;IAAE,IAAI,EAAE,uBAAuB,CAAA;CAAE,CAClC,CAAC;AACF,KAAK,yBAAyB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAC;AAEr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