From 218438413d85d0f7b0eedd4ac7ac0d4adcabe78b Mon Sep 17 00:00:00 2001 From: Martian Abhishek <103963489+MartianAbhishek@users.noreply.github.com> Date: Fri, 16 Dec 2022 11:43:02 +0530 Subject: [PATCH] added Martian Wallet plugin (#26) --- README.md | 3 +- apps/nextjs-example/components/AppContext.tsx | 3 +- apps/nextjs-example/package.json | 1 + apps/nextjs-example/wallets/MartianWallet.ts | 195 ------------------ apps/nextjs-example/wallets/index.ts | 1 - pnpm-lock.yaml | 11 + 6 files changed, 16 insertions(+), 198 deletions(-) delete mode 100644 apps/nextjs-example/wallets/MartianWallet.ts diff --git a/README.md b/README.md index d95318e2..33723257 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,5 @@ A monorepo modular wallet adapter developed and maintained by Aptos for wallet a - [Petra](https://www.npmjs.com/package/petra-plugin-wallet-adapter) - [Trust](https://www.npmjs.com/package/@trustwallet/aptos-wallet-adapter) -- [Pontem](https://www.npmjs.com/package/@pontem/wallet-adapter-plugin) \ No newline at end of file +- [Pontem](https://www.npmjs.com/package/@pontem/wallet-adapter-plugin) +- [Martian](https://www.npmjs.com/package/@martianwallet/aptos-wallet-adapter) \ No newline at end of file diff --git a/apps/nextjs-example/components/AppContext.tsx b/apps/nextjs-example/components/AppContext.tsx index 9c9fa622..158c2d1b 100644 --- a/apps/nextjs-example/components/AppContext.tsx +++ b/apps/nextjs-example/components/AppContext.tsx @@ -1,5 +1,6 @@ -import { MartianWallet, RiseWallet } from "../wallets"; +import { RiseWallet } from "../wallets"; import { PetraWallet } from "petra-plugin-wallet-adapter"; +import { MartianWallet } from "@martianwallet/aptos-wallet-adapter"; import { PontemWallet } from "@pontem/wallet-adapter-plugin"; import { TrustWallet } from "@trustwallet/aptos-wallet-adapter"; import { AptosWalletAdapterProvider } from "@aptos-labs/wallet-adapter-react"; diff --git a/apps/nextjs-example/package.json b/apps/nextjs-example/package.json index 5f599822..1acf84f2 100644 --- a/apps/nextjs-example/package.json +++ b/apps/nextjs-example/package.json @@ -15,6 +15,7 @@ "@aptos-labs/wallet-adapter-react": "workspace:*", "@pontem/wallet-adapter-plugin": "^0.1.4", "@trustwallet/aptos-wallet-adapter": "^0.1.4", + "@martianwallet/aptos-wallet-adapter": "^0.0.2", "aptos": "^1.3.17", "next": "13.0.0", "petra-plugin-wallet-adapter": "^0.1.2", diff --git a/apps/nextjs-example/wallets/MartianWallet.ts b/apps/nextjs-example/wallets/MartianWallet.ts deleted file mode 100644 index 12ee8562..00000000 --- a/apps/nextjs-example/wallets/MartianWallet.ts +++ /dev/null @@ -1,195 +0,0 @@ -import { - AptosWalletErrorResult, - NetworkName, - PluginProvider, -} from "@aptos-labs/wallet-adapter-core"; -import type { - AccountInfo, - AdapterPlugin, - NetworkInfo, - SignMessagePayload, - SignMessageResponse, - WalletName, -} from "@aptos-labs/wallet-adapter-core"; -import { MaybeHexString, Types } from "aptos"; -interface MartianProvider - extends Omit { - signTransaction( - transaction: any, - options?: any - ): Promise; - generateTransaction( - sender: MaybeHexString, - payload: any, - options?: any - ): Promise; - signAndSubmitTransaction: ( - transaction: Types.TransactionPayload, - options?: any - ) => Promise; -} - -interface MartianWindow extends Window { - martian?: MartianProvider; -} - -declare const window: MartianWindow; - -export const MartianWalletName = "Martian" as WalletName<"Martian">; - -export class MartianWallet implements AdapterPlugin { - readonly name = MartianWalletName; - readonly url = - "https://chrome.google.com/webstore/detail/martian-wallet/efbglgofoippbgcjepnhiblaibcnclgk"; - readonly icon = - "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAACq1SURBVHgB7Z29mxzJcad/SzrrLeTRU8k7j5BHj03vziLo3VloefIW8u4sNK27swB5R2uG1kkWQIuU1QNLKwtYj143/4Ld9ei1Kqandho9/VEfWVURme/7PO8zEI86VVd1Z1RGRGZ+IYC8ePZg9aAe/tp/9tXB/3z4V2f+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ag4wuxXpKegIAQSGYsXUhfYBhVSXf7baB4z32gcPggb0hgACqXn+4K8f/laCOdnqMTVlQYOAAckggMDYEFCmZav9DMNmF3eilgEjQgCBqam0DySL2p8//Js1Bf2w2cSd9rOLTyIlBRNDAAEPNDMT+/vzg3/DI1vtg8W3B/8mWMCsEEDAKzYreX7wtwkslfKdsVhA2Go/k/jLwb+3IliAQwggEJHj4GJ///bhbyW/dZatHltnfzj6n5t/A4SBAAK50gSTZ2f86uC/9+zM//7hf7498d85/M/+8vD3+wO3R/8zQFb8J7k0wlVpBjE2AAAAAElFTkSuQmCC"; - - provider: MartianProvider | undefined = - typeof window !== "undefined" ? window.martian : undefined; - - async connect(): Promise { - try { - const addressInfo = await this.provider?.connect(); - if (!addressInfo) throw `${MartianWalletName} Address Info Error`; - return addressInfo; - } catch (error: any) { - throw error; - } - } - - async account(): Promise { - const response = await this.provider?.account(); - if (!response) throw `${MartianWalletName} Account Error`; - return response; - } - - async disconnect(): Promise { - try { - await this.provider?.disconnect(); - } catch (error: any) { - throw error; - } - } - - async signAndSubmitTransaction( - transaction: Types.TransactionPayload, - options?: any - ): Promise<{ hash: Types.HexEncodedBytes }> { - try { - const signer = await this.account(); - const tx = await this.provider?.generateTransaction( - signer.address, - transaction, - options - ); - if (!tx) - throw new Error( - "Cannot generate transaction" - ) as AptosWalletErrorResult; - const response = await this.provider?.signAndSubmitTransaction(tx); - - if (!response) { - throw new Error("No response") as AptosWalletErrorResult; - } - return { hash: response } as { hash: Types.HexEncodedBytes }; - } catch (error: any) { - throw error; - } - } - - async signTransaction( - transaction: Types.TransactionPayload, - options?: any - ): Promise { - try { - const signer = await this.account(); - const tx = await this.provider?.generateTransaction( - signer.address, - transaction, - options - ); - if (!tx) - throw new Error( - "Cannot generate transaction" - ) as AptosWalletErrorResult; - const response = await this.provider?.signTransaction(tx); - if (!response) { - throw new Error("No response") as AptosWalletErrorResult; - } - return response; - } catch (error: any) { - throw error; - } - } - - async signMessage(message: SignMessagePayload): Promise { - try { - if (typeof message !== "object" || !message.nonce) { - `${MartianWalletName} Invalid signMessage Payload`; - } - const response = await this.provider?.signMessage(message); - if (response) { - return response; - } else { - throw `${MartianWalletName} Sign Message failed`; - } - } catch (error: any) { - const errMsg = error.message; - throw errMsg; - } - } - - async onNetworkChange(callback: any): Promise { - try { - const handleNetworkChange = async (newNetwork: { - networkName: NetworkInfo; - }): Promise => { - callback({ - name: newNetwork, - chainId: undefined, - api: undefined, - }); - }; - await this.provider?.onNetworkChange(handleNetworkChange); - } catch (error: any) { - const errMsg = error.message; - throw errMsg; - } - } - - async onAccountChange(callback: any): Promise { - try { - const handleAccountChange = async ( - newAccount: AccountInfo - ): Promise => { - if (newAccount?.publicKey) { - callback({ - ...newAccount, - }); - } else { - const response = await this.connect(); - callback({ - ...response, - }); - } - }; - await this.provider?.onAccountChange(handleAccountChange); - } catch (error: any) { - console.log(error); - const errMsg = error.message; - throw errMsg; - } - } - - async network(): Promise { - try { - const response = await this.provider?.network(); - if (!response) throw `${MartianWalletName} Network Error`; - return { - name: response as NetworkName, - }; - } catch (error: any) { - throw error; - } - } -} diff --git a/apps/nextjs-example/wallets/index.ts b/apps/nextjs-example/wallets/index.ts index 2c09179e..91f5ca85 100644 --- a/apps/nextjs-example/wallets/index.ts +++ b/apps/nextjs-example/wallets/index.ts @@ -1,2 +1 @@ -export { MartianWallet } from "./MartianWallet"; export { RiseWallet } from "./RiseWallet"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b7148f92..f8eaf381 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,7 @@ importers: '@aptos-labs/wallet-adapter-core': workspace:* '@aptos-labs/wallet-adapter-react': workspace:* '@babel/core': ^7.0.0 + '@martianwallet/aptos-wallet-adapter': ^0.0.2 '@pontem/wallet-adapter-plugin': ^0.1.4 '@trustwallet/aptos-wallet-adapter': ^0.1.4 '@types/node': ^17.0.12 @@ -37,6 +38,7 @@ importers: dependencies: '@aptos-labs/wallet-adapter-core': link:../../packages/wallet-adapter-core '@aptos-labs/wallet-adapter-react': link:../../packages/wallet-adapter-react + '@martianwallet/aptos-wallet-adapter': 0.0.2 '@pontem/wallet-adapter-plugin': 0.1.4 '@trustwallet/aptos-wallet-adapter': 0.1.4 aptos: 1.3.17 @@ -633,6 +635,15 @@ packages: read-yaml-file: 1.1.0 dev: true + /@martianwallet/aptos-wallet-adapter/0.0.2: + resolution: {integrity: sha512-hKM0zPfw63XRDqeIhaysoR5D9d+oF2oXmN/mkJPQ9oM714MYrx3AhmG1xIJKJe5t6JOrkI8r+wpPgYfTVy8uhg==} + dependencies: + '@aptos-labs/wallet-adapter-core': 0.1.7 + aptos: 1.4.0 + transitivePeerDependencies: + - debug + dev: false + /@next/env/13.0.0: resolution: {integrity: sha512-65v9BVuah2Mplohm4+efsKEnoEuhmlGm8B2w6vD1geeEP2wXtlSJCvR/cCRJ3fD8wzCQBV41VcMBQeYET6MRkg==} dev: false