Skip to content

Commit

Permalink
Add AptosConnect (#297)
Browse files Browse the repository at this point in the history
* add aptos connect

* use AC version 0.0.6

* update aptos connect to latest
  • Loading branch information
0xmaayan authored Jun 11, 2024
1 parent 1c6a49f commit 79b1bf8
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .changeset/eleven-cycles-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@aptos-labs/wallet-adapter-core": minor
"@aptos-labs/wallet-adapter-nextjs-example": minor
---

Add AptosConnect
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Account,
AccountAuthenticator,
AnyRawTransaction,
Ed25519Account,
} from "@aptos-labs/ts-sdk";
import { useWallet } from "@aptos-labs/wallet-adapter-react";

Expand All @@ -23,7 +24,7 @@ export default function MultiAgentTransaction({
useWallet();

const [secondarySignerAccount, setSecondarySignerAccount] =
useState<Account>();
useState<Ed25519Account>();
const [transactionToSubmit, setTransactionToSubmit] =
useState<AnyRawTransaction | null>(null);
const { setSuccessAlertHash } = useAlert();
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "next lint"
},
"dependencies": {
"@aptos-labs/ts-sdk": "^1.13.2",
"@aptos-labs/ts-sdk": "^1.18.1",
"@aptos-labs/wallet-adapter-ant-design": "workspace:*",
"@aptos-labs/wallet-adapter-core": "workspace:*",
"@aptos-labs/wallet-adapter-mui-design": "workspace:*",
Expand Down
5 changes: 3 additions & 2 deletions packages/wallet-adapter-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@
"buffer": "^6.0.3",
"eventemitter3": "^4.0.7",
"tweetnacl": "^1.0.3",
"@atomrigslab/aptos-wallet-adapter": "^0.1.12"
"@atomrigslab/aptos-wallet-adapter": "^0.1.12",
"@aptos-connect/wallet-adapter-plugin": "^0.0.11"
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^1.13.2",
"@aptos-labs/ts-sdk": "^1.18.1",
"aptos": "^1.21.0"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { TWallet } from "@atomrigslab/aptos-wallet-adapter";
import { DevTWallet, TWallet } from "@atomrigslab/aptos-wallet-adapter";
import { AptosConnectWallet } from "@aptos-connect/wallet-adapter-plugin";
import { AptosStandardWallet } from "./WalletStandard";
import { Network } from "@aptos-labs/ts-sdk";

const isProd = process.env.NODE_ENV === "production";

const sdkWallets: AptosStandardWallet[] = [];

// TODO twallet uses @aptos-labs/wallet-standard at version 0.0.11 while adapter uses
// a newer version (0.1.0) - this causes type mismatch. We should figure out how to handle it.
sdkWallets.push(new TWallet() as any);
// Push production wallet if env is production, otherwise use dev wallet
if (isProd) {
// TODO twallet uses @aptos-labs/wallet-standard at version 0.0.11 while adapter uses
// a newer version (0.1.0) - this causes type mismatch. We should figure out how to handle it.
sdkWallets.push(new TWallet() as any);
} else {
sdkWallets.push(new DevTWallet() as any);
}

let aptosNetwork = isProd ? Network.MAINNET : Network.TESTNET;
// Need to check window is defined for AptosConnect
if (typeof window !== "undefined") {
sdkWallets.push(new AptosConnectWallet({ network: aptosNetwork }));
}

export default sdkWallets;
2 changes: 2 additions & 0 deletions packages/wallet-adapter-core/src/WalletCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
* @returns
*/
excludeWallet(walletName: string): boolean {
// for now, we always include AptosConnect
if (walletName === "Google (AptosConnect)") return false;
// If _optInWallets is not empty, and does not include the provided wallet,
// return true to exclude the wallet, otherwise return false
if (
Expand Down
Loading

0 comments on commit 79b1bf8

Please sign in to comment.