diff --git a/.changeset/dull-lobsters-approve.md b/.changeset/dull-lobsters-approve.md new file mode 100644 index 00000000..c315bcec --- /dev/null +++ b/.changeset/dull-lobsters-approve.md @@ -0,0 +1,5 @@ +--- +"@aptos-labs/wallet-adapter-core": minor +--- + +Export PluginProvider type diff --git a/apps/nextjs-example/components/AppContext.tsx b/apps/nextjs-example/components/AppContext.tsx index 93cb99c9..19b8dc2c 100644 --- a/apps/nextjs-example/components/AppContext.tsx +++ b/apps/nextjs-example/components/AppContext.tsx @@ -12,8 +12,8 @@ import { TokenPocketWallet } from "@tp-lab/aptos-wallet-adapter"; import { TrustWallet } from "@trustwallet/aptos-wallet-adapter"; import { MSafeWalletAdapter } from "@msafe/aptos-wallet-adapter"; import { WelldoneWallet } from "@welldone-studio/aptos-wallet-adapter"; -import { OKXWallet } from '@okwallet/aptos-wallet-adapter'; -import { OnekeyWallet } from '@onekeyfe/aptos-wallet-adapter'; +import { OKXWallet } from "@okwallet/aptos-wallet-adapter"; +import { OnekeyWallet } from "@onekeyfe/aptos-wallet-adapter"; import { AptosWalletAdapterProvider, NetworkName, diff --git a/packages/wallet-adapter-core/src/WalletCoreV1.ts b/packages/wallet-adapter-core/src/WalletCoreV1.ts index 8d5f1489..5a83a882 100644 --- a/packages/wallet-adapter-core/src/WalletCoreV1.ts +++ b/packages/wallet-adapter-core/src/WalletCoreV1.ts @@ -2,6 +2,7 @@ import { TxnBuilderTypes, Types } from "aptos"; import EventEmitter from "eventemitter3"; import { + WalletNotSupportedMethod, WalletSignAndSubmitMessageError, WalletSignTransactionError, } from "./error"; @@ -45,6 +46,11 @@ export class WalletCoreV1 extends EventEmitter { wallet: Wallet, options?: TransactionOptions ): Promise { + if (!("signAndSubmitBCSTransaction" in wallet)) { + throw new WalletNotSupportedMethod( + `Submit a BCS Transaction is not supported by ${wallet.name}` + ).message; + } try { const response = await (wallet as any).signAndSubmitBCSTransaction( transaction, diff --git a/packages/wallet-adapter-core/src/types.ts b/packages/wallet-adapter-core/src/types.ts index be089f63..472f8bb6 100644 --- a/packages/wallet-adapter-core/src/types.ts +++ b/packages/wallet-adapter-core/src/types.ts @@ -103,7 +103,7 @@ export interface AdapterPluginProps { connect(): Promise; disconnect: () => Promise; network: () => Promise; - signAndSubmitTransaction( + signAndSubmitTransaction( transaction: Types.TransactionPayload | InputGenerateTransactionData, options?: InputGenerateTransactionOptions ): Promise< @@ -134,3 +134,20 @@ export type InputTransactionData = { data: InputGenerateTransactionPayloadData; options?: InputGenerateTransactionOptions; }; + +// To be used by a wallet plugin +export interface PluginProvider { + connect: () => Promise; + account: () => Promise; + disconnect: () => Promise; + signAndSubmitTransaction: ( + transaction: any, + options?: any + ) => Promise<{ hash: Types.HexEncodedBytes } | AptosWalletErrorResult>; + signMessage: (message: SignMessagePayload) => Promise; + network: () => Promise; + onAccountChange: ( + listener: (newAddress: AccountInfo) => Promise + ) => Promise; + onNetworkChange: OnNetworkChange; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3814958..3e1554b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7245,7 +7245,7 @@ packages: resolution: {integrity: sha512-snhhP/qKXLg4foKsDVvy0Jus3H7o46L75aDCXiiSAonty2CnZe1+4cpB8azc7khaMgig+xj9gZbZXKmKtB+HqA==} dependencies: '@aptos-labs/wallet-adapter-core': 2.5.1 - aptos: 1.20.0 + aptos: 1.21.0 transitivePeerDependencies: - debug dev: false