Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan committed Feb 14, 2025
1 parent 35f3633 commit 3563cc9
Show file tree
Hide file tree
Showing 7 changed files with 5,187 additions and 10,354 deletions.
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 @@
"format": "prettier --write './**/*.{ts,tsx,js,jsx,json,md,html,css}'"
},
"dependencies": {
"@aptos-labs/ts-sdk": "^1.33.1",
"@aptos-labs/ts-sdk": "^1.35.0",
"@aptos-labs/wallet-adapter-ant-design": "workspace:*",
"@aptos-labs/wallet-adapter-core": "workspace:*",
"@aptos-labs/wallet-adapter-mui-design": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export function SingleSigner() {
data: {
function: "0x1::coin::transfer",
typeArguments: [APTOS_COIN],
functionArguments: [account?.address.toString(), 1], // 1 is in Octas
functionArguments: [account?.address.toString(), 1],
},
};
const response = await signTransaction({
Expand All @@ -132,7 +132,7 @@ export function SingleSigner() {
data: {
function: "0x1::coin::transfer",
typeArguments: [APTOS_COIN],
functionArguments: [account.address.toString(), 1], // 1 is in Octas
functionArguments: [account.address.toString(), 1],
},
});
const response = await signTransaction({
Expand Down
3 changes: 1 addition & 2 deletions packages/wallet-adapter-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
"tweetnacl": "^1.0.3"
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "^1.33.1",
"aptos": "^1.21.0"
"@aptos-labs/ts-sdk": "^1.35.0"
},
"files": [
"dist",
Expand Down
29 changes: 10 additions & 19 deletions packages/wallet-adapter-core/src/WalletCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
AnyPublicKeyVariant,
AnyRawTransaction,
Aptos,
InputGenerateTransactionOptions,
InputSubmitTransactionData,
MultiEd25519PublicKey,
MultiEd25519Signature,
Expand Down Expand Up @@ -172,7 +171,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
super();
this._optInWallets = optInWallets || [];
this._dappConfig = dappConfig;
this._disableTelemetry = disableTelemetry || false;
this._disableTelemetry = disableTelemetry ?? false;
this._sdkWallets = getSDKWallets(this._dappConfig);

// If disableTelemetry set to false (by default), start GA4
Expand All @@ -185,7 +184,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
// We separate the extension and sdk detection process so we dont refetch sdk wallets everytime a new
// extension wallet is detected
this.fetchSDKAIP62AptosWallets();

// Strategy to append not detected AIP-62 standard compatible extension wallets
this.appendNotDetectedStandardSupportedWallets();
}

Expand Down Expand Up @@ -216,13 +215,7 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
private setExtensionAIP62Wallets(
extensionwWallets: readonly AptosWallet[]
): void {
// Twallet SDK fires a register event so the adapter assumes it is an extension wallet
// so filter out t wallet, remove it when twallet fixes it
const wallets = extensionwWallets.filter(
(wallet) => wallet.name !== "Dev T wallet" && wallet.name !== "T wallet"
);

wallets.map((wallet: AdapterWallet) => {
extensionwWallets.map((wallet: AdapterWallet) => {
if (this.excludeWallet(wallet)) {
return;
}
Expand Down Expand Up @@ -269,23 +262,21 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {

// Since we can't discover AIP-62 wallets that are not installed on the user machine,
// we hold a AIP-62 wallets registry to show on the wallet selector modal for the users.
// Append wallets from wallet standard support registry to the `all_wallets` array
// Append wallets from wallet standard support registry to the `_standard_not_detected_wallets` array
// when wallet is not installed on the user machine
private appendNotDetectedStandardSupportedWallets(): void {
// Loop over the registry map
aptosStandardSupportedWalletList.map((supportedWallet) => {
// Check if we already have this wallet as a AIP-62 wallet standard
// Check if we already have this wallet as a detected AIP-62 wallet standard
const existingStandardWallet = this._standard_wallets.find(
(wallet) => wallet.name == supportedWallet.name
);
// If it is detected, it means the user has the wallet installed, so dont add it to the wallets array
if (existingStandardWallet) {
return;
}
// If AIP-62 wallet detected but it is excluded by the dapp, dont add it to the wallets array
if (
existingStandardWallet &&
this.excludeWallet(existingStandardWallet)
) {
if (this.excludeWallet(supportedWallet)) {
return;
}
// If AIP-62 wallet does not exist, append it to the wallet selector modal
Expand All @@ -300,10 +291,10 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
/**
* A function that excludes an AIP-62 compatible wallet the dapp doesnt want to include
*
* @param walletName
* @returns
* @param wallet AdapterWallet | AdapterNotDetectedWallet
* @returns boolean
*/
excludeWallet(wallet: AdapterWallet): boolean {
excludeWallet(wallet: AdapterWallet | AdapterNotDetectedWallet): boolean {
// If _optInWallets is not empty, and does not include the provided wallet,
// return true to exclude the wallet, otherwise return false
if (
Expand Down
6 changes: 3 additions & 3 deletions packages/wallet-adapter-core/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export enum WalletReadyState {
/**
* User-installable wallets can typically be detected by scanning for an API
* that they've injected into the global context. If such an API is present,
* we consider the wallet to have been installed.
* Wallet can only be in one of two states - installed or not installed
* Installed: wallets are detected by the browser event listeners and means they are installed on the user's browser.
* NotDetected: wallets are not detected by the browser event listeners and means they are not installed on the user's browser.
*/
Installed = "Installed",
NotDetected = "NotDetected",
Expand Down
5 changes: 3 additions & 2 deletions packages/wallet-adapter-core/src/sdkWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ export function getSDKWallets(dappConfig?: DappConfig) {
) {
sdkWallets.push(
new MizuWallet({
network: dappConfig.network as any,
// mizo supports only TESTNET and MAINNET and holds a custom type for network
network: dappConfig.network as Network.MAINNET | Network.TESTNET,
manifestURL: dappConfig.mizuwallet.manifestURL,
appId: dappConfig.mizuwallet.appId,
}) as any
})
);
}
}
Expand Down
Loading

0 comments on commit 3563cc9

Please sign in to comment.