Skip to content

Commit

Permalink
Add Petra to the AIP-62 wallet registry (#329)
Browse files Browse the repository at this point in the history
* add petra to the aip-62 wallets registry

* update changeset
  • Loading branch information
0xmaayan authored Jun 21, 2024
1 parent 89bfca9 commit 1580df8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-wombats-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aptos-labs/wallet-adapter-core": minor
---

Add Petra to the AIP-62 wallet registry
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const aptosStandardSupportedWalletList: Array<AptosStandardSupportedWalle
readyState: WalletReadyState.NotDetected,
isAIP62Standard: true,
},
// {
// name: "Petra" as WalletName<"Petra">,
// url: "https://chromewebstore.google.com/detail/petra-aptos-wallet/ejjladinnckdgjemekebdpeokbikhfci?hl=en",
// icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWbSURBVHgB7Z09c9NYFIaPlFSpUqQNK6rQhbSkWJghLZP9BesxfwAqytg1xe7+AY+3go5ACzObBkpwSqrVQkuRCiqkva8UZW1je22wpHPveZ8ZRU6wwwznueee+6FLJCuSdzrb7nZTNjaOJc9/ctdNiaJESPPkeeq+phLH5/L162k0HJ7JikTLvtEFPnFBf+D+0l/dt9tCNJK6xnjmZOg7GdJlPvC/AhQtPo5P3MsHQvwhiobLiLBQABf82y74z4Qt3ldSybKHToLTeW+I5/1B3u2euOD/JQy+zyRowEUs5zAzA1x+oCckJHrRYNCf/uE3AjD4QfONBBMC5PfvY2j3TEi4ZNmd8eHilQDFMK/s8xMhIXPhJLjuJLjAN/8VgRsbPWHwLbAtm5tXRWGRAS5b/99C7FBmgbTMAGXrJ5aIomJir8wA3S5afyLEEkUtEBezfQy+RYpFvdilgmMhNnGxRw2wL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6Pn/ywDHw41DgUwDgRIhVgljSWKzoXYJM+dAFmWCrHKeewsOBViExd71AAjd10IsUYaDYdnsfty4Uz4U4g1zvClHAbm+e9CbJFlfdwKAVwWSJ0EfwixwrCIuYxPBOV5T1gLWCCtWj+4EqCoBbLsFyFhk2UPq9YPJqaCURW6W19IqPRdjCeG/dGsd+Xdbs/dToSERD8aDHrTP4zmvZsSBMXM4INo0afyTudY4vg39zIR4iNFXXfZtc9k4XJw0V9k2R1OFHkIhvVZdn1R8MHCDDDx+zqdxK0c9tz1szAjaKWc1XUTe+OV/iKWFmAcJ8NtJ8Kxe7kvkCGKEiHN45Zz3b/9yN3/uVzUGxXD+RX4F56985hsqA6SAAAAAElFTkSuQmCC",
// readyState: WalletReadyState.NotDetected,
// isAIP62Standard: true,
// },
{
name: "Petra" as WalletName<"Petra">,
url: "https://chromewebstore.google.com/detail/petra-aptos-wallet/ejjladinnckdgjemekebdpeokbikhfci?hl=en",
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAWbSURBVHgB7Z09c9NYFIaPlFSpUqQNK6rQhbSkWJghLZP9BesxfwAqytg1xe7+AY+3go5ACzObBkpwSqrVQkuRCiqkva8UZW1je22wpHPveZ8ZRU6wwwznueee+6FLJCuSdzrb7nZTNjaOJc9/ctdNiaJESPPkeeq+phLH5/L162k0HJ7JikTLvtEFPnFBf+D+0l/dt9tCNJK6xnjmZOg7GdJlPvC/AhQtPo5P3MsHQvwhiobLiLBQABf82y74z4Qt3ldSybKHToLTeW+I5/1B3u2euOD/JQy+zyRowEUs5zAzA1x+oCckJHrRYNCf/uE3AjD4QfONBBMC5PfvY2j3TEi4ZNmd8eHilQDFMK/s8xMhIXPhJLjuJLjAN/8VgRsbPWHwLbAtm5tXRWGRAS5b/99C7FBmgbTMAGXrJ5aIomJir8wA3S5afyLEEk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1Tn/UAAZAWIUXUTHz4IKQn/jCBkB6Pn/ywDHw41DgUwDgRIhVgljSWKzoXYJM+dAFmWCrHKeewsOBViExd71AAjd10IsUYaDYdnsfty4Uz4U4g1zvClHAbm+e9CbJFlfdwKAVwWSJ0EfwixwrCIuYxPBOV5T1gLWCCtWj+4EqCoBbLsFyFhk2UPq9YPJqaCURW6W19IqPRdjCeG/dGsd+Xdbs/dToSERD8aDHrTP4zmvZsSBMXM4INo0afyTudY4vg39zIR4iNFXXfZtc9k4XJw0V9k2R1OFHkIhvVZdn1R8MHCDDDx+zqdxK0c9tz1szAjaKWc1XUTe+OV/iKWFmAcJ8NtJ8Kxe7kvkCGKEiHN45Zz3b/9yN3/uVzUGxXD+RX4F56985hsqA6SAAAAAElFTkSuQmCC",
readyState: WalletReadyState.NotDetected,
isAIP62Standard: true,
},
];
35 changes: 26 additions & 9 deletions packages/wallet-adapter-core/src/WalletCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
this.scopePollingDetectionStrategy();
// Strategy to detect AIP-62 standard compatible wallets (extension + SDK wallets)
this.fetchAptosWallets();
// Append AIP-62 compatible wallets that are not detected on the user machine
this.appendNotDetectedStandardSupportedWallets(this._standard_wallets);
}

private scopePollingDetectionStrategy() {
Expand Down Expand Up @@ -199,20 +201,37 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
});
}

// Append wallets from wallet standard support registry to the `all_wallets` array
// Append wallets from wallet aip-62 standard registry to the `all_wallets` array
private appendNotDetectedStandardSupportedWallets(
aptosStandardWallets: ReadonlyArray<AptosStandardWallet>
) {
// Loop over the registry map
aptosStandardSupportedWalletList.map((supportedWallet) => {
if (this.excludeWallet(supportedWallet.name)) {
return;
}
const existingWalletIndex = aptosStandardWallets.findIndex(
// Check if we already have this wallet as an installed plugin
const existingPluginWalletIndex = this.wallets.findIndex(
(wallet) => wallet.name === supportedWallet.name
);

// If the plugin wallet is installed, dont append and dont show it on the selector modal
// as a not detected wallet
if (existingPluginWalletIndex !== -1) return;

// Check if we already have this wallet as a AIP-62 wallet standard
const existingStandardWallet = aptosStandardWallets.find(
(wallet) => wallet.name == supportedWallet.name
);

// If wallet does not exist, append it from the supported wallets list
if (existingWalletIndex === -1) {
// If AIP-62 wallet detected but it is excluded by the dapp, dont add it to the wallets array
if (
existingStandardWallet &&
this.excludeWallet(existingStandardWallet.name)
) {
return;
}

// If AIP-62 wallet does not exist, append it to the wallet selector modal
// as an undetected wallet
if (!existingStandardWallet) {
this._all_wallets.push(supportedWallet);
this.emit("standardWalletsAdded", supportedWallet);
}
Expand Down Expand Up @@ -248,8 +267,6 @@ export class WalletCore extends EventEmitter<WalletCoreEvents> {
);

this._standard_wallets = aptosStandardWallets;
// Append AIP-62 compatible wallets that are not detected on the user machine
this.appendNotDetectedStandardSupportedWallets(this._standard_wallets);
}

/**
Expand Down

0 comments on commit 1580df8

Please sign in to comment.