forked from aptos-labs/aptos-wallet-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
5,038 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,3 @@ | ||
# Turborepo starter | ||
|
||
This is an official pnpm starter turborepo. | ||
|
||
## What's inside? | ||
|
||
This turborepo uses [pnpm](https://pnpm.io) as a package manager. It includes the following packages/apps: | ||
|
||
### Apps and Packages | ||
|
||
- `docs`: a [Next.js](https://nextjs.org/) app | ||
- `web`: another [Next.js](https://nextjs.org/) app | ||
- `ui`: a stub React component library shared by both `web` and `docs` applications | ||
- `eslint-config-custom`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) | ||
- `tsconfig`: `tsconfig.json`s used throughout the monorepo | ||
|
||
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). | ||
|
||
### Utilities | ||
|
||
This turborepo has some additional tools already setup for you: | ||
|
||
- [TypeScript](https://www.typescriptlang.org/) for static type checking | ||
- [ESLint](https://eslint.org/) for code linting | ||
- [Prettier](https://prettier.io) for code formatting | ||
|
||
### Build | ||
|
||
To build all apps and packages, run the following command: | ||
|
||
``` | ||
cd my-turborepo | ||
pnpm run build | ||
``` | ||
|
||
### Develop | ||
|
||
To develop all apps and packages, run the following command: | ||
|
||
``` | ||
cd my-turborepo | ||
pnpm run dev | ||
``` | ||
|
||
### Remote Caching | ||
|
||
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. | ||
|
||
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands: | ||
|
||
``` | ||
cd my-turborepo | ||
pnpm dlx turbo login | ||
``` | ||
|
||
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). | ||
|
||
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your turborepo: | ||
|
||
``` | ||
pnpm dlx turbo link | ||
``` | ||
|
||
## Useful Links | ||
|
||
Learn more about the power of Turborepo: | ||
|
||
- [Pipelines](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) | ||
- [Caching](https://turbo.build/repo/docs/core-concepts/caching) | ||
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) | ||
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) | ||
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration) | ||
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference) | ||
git clone | ||
pnpm i | ||
pnpm turbo run dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
import { Button } from "ui"; | ||
|
||
export default function Docs() { | ||
return ( | ||
<div> | ||
<h1>Docs</h1> | ||
<Button /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "tsconfig/nextjs.json", | ||
"extends": "@aptos/wallet-adapter-tsconfig/nextjs.json", | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { AptosClient, Types } from "aptos"; | ||
import { useWallet, WalletName, Wallet } from "@aptos/wallet-adapter-react/src"; | ||
import { useState } from "react"; | ||
|
||
export const DEVNET_NODE_URL = "https://fullnode.devnet.aptoslabs.com/v1"; | ||
|
||
const aptosClient = new AptosClient(DEVNET_NODE_URL, { | ||
WITH_CREDENTIALS: false, | ||
}); | ||
|
||
type Props = { | ||
wallets: Wallet[]; | ||
}; | ||
|
||
export default function App({ wallets }: Props) { | ||
const { | ||
connect, | ||
disconnect, | ||
account, | ||
network, | ||
getWallet, | ||
signAndSubmitTransaction, | ||
signTransaction, | ||
signMessage, | ||
} = useWallet(); | ||
const [txsLink, setTxsLink] = useState<string>(""); | ||
const [messageResponse, setMessageResponse] = useState(); | ||
|
||
const onConnectClick = (wallet: WalletName) => { | ||
connect(wallet); | ||
}; | ||
|
||
const onSignAndSubmitTransaction = async () => { | ||
const payload: Types.TransactionPayload = { | ||
type: "entry_function_payload", | ||
function: "0x1::coin::transfer", | ||
type_arguments: ["0x1::aptos_coin::AptosCoin"], | ||
arguments: [account?.address, 1], // 1 is in Octas | ||
}; | ||
try { | ||
const response = await signAndSubmitTransaction(payload); | ||
await aptosClient.waitForTransaction(response?.hash || ""); | ||
setTxsLink(`https://explorer.devnet.aptos.dev/txn/${response?.hash}`); | ||
} catch (error: any) { | ||
console.log("error", error); | ||
} | ||
}; | ||
|
||
const onSignTransaction = async () => { | ||
const payload: Types.TransactionPayload = { | ||
type: "entry_function_payload", | ||
function: "0x1::coin::transfer", | ||
type_arguments: ["0x1::aptos_coin::AptosCoin"], | ||
arguments: [account?.address, 1], // 1 is in Octas | ||
}; | ||
try { | ||
const response = await signTransaction(payload); | ||
console.log("response", response); | ||
} catch (error: any) { | ||
console.log("error", error); | ||
} | ||
}; | ||
|
||
const onSignMessage = async () => { | ||
const payload = { | ||
message: "Hello from Aptos Wallet Adapter", | ||
nonce: "random_string", | ||
}; | ||
try { | ||
const response = await signMessage(payload); | ||
setMessageResponse(response as any); | ||
} catch (error: any) { | ||
console.log("error", error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div> | ||
{wallets.map((wallet) => { | ||
return ( | ||
<button | ||
disabled={wallet.readyState !== "Installed"} | ||
key={wallet.name} | ||
onClick={() => onConnectClick(wallet.name)} | ||
> | ||
{wallet.name} | ||
</button> | ||
); | ||
})} | ||
</div> | ||
<div> | ||
<button onClick={disconnect}>Disconnect</button> | ||
</div> | ||
<div> | ||
<button onClick={onSignAndSubmitTransaction}> | ||
Sign and submit transaction | ||
</button> | ||
{txsLink.length > 0 && ( | ||
<p> | ||
<a href={txsLink} target="_blank"> | ||
{txsLink} | ||
</a> | ||
</p> | ||
)} | ||
</div> | ||
<div> | ||
<button onClick={onSignTransaction}>Sign transaction</button> | ||
</div> | ||
|
||
<div> | ||
<button onClick={onSignMessage}>Sign Message</button> | ||
{messageResponse && <p>{JSON.stringify(messageResponse)}</p>} | ||
</div> | ||
|
||
<div> | ||
Wallet Name: <div>{JSON.stringify(getWallet()?.name)}</div> | ||
</div> | ||
<div> | ||
Account: <div>{JSON.stringify(account)}</div> | ||
</div> | ||
<div> | ||
Network: <div>{JSON.stringify(network)}</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
import { Button } from "ui"; | ||
import { | ||
PetraWallet, | ||
MartianWallet, | ||
RiseWallet, | ||
} from "@aptos/wallet-adapter-plugin/src/wallets"; | ||
import { AptosWalletAdapterProvider } from "@aptos/wallet-adapter-react/src"; | ||
import App from "./App"; | ||
|
||
export default function Web() { | ||
const wallets = [new PetraWallet(), new MartianWallet(), new RiseWallet()]; | ||
|
||
return ( | ||
<div> | ||
<h1>Web</h1> | ||
<Button /> | ||
</div> | ||
<AptosWalletAdapterProvider plugins={wallets} autoConnect={true}> | ||
<div> | ||
<h1>Web</h1> | ||
</div> | ||
<App wallets={wallets} /> | ||
</AptosWalletAdapterProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"extends": "tsconfig/nextjs.json", | ||
"extends": "@aptos/wallet-adapter-tsconfig/nextjs.json", | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,17 @@ | |
], | ||
"scripts": { | ||
"build": "turbo run build", | ||
"dev": "turbo run dev --parallel", | ||
"dev": "turbo run dev --no-cache --parallel --continue", | ||
"lint": "turbo run lint", | ||
"format": "prettier --write \"**/*.{ts,tsx,md}\"" | ||
"format": "prettier --write \"**/*.{ts,tsx,md}\"", | ||
"clean": "turbo run clean && rm -rf node_modules", | ||
"changeset": "changeset", | ||
"version-packages": "changeset version", | ||
"release": "turbo run build --filter=docs^... && changeset publish" | ||
}, | ||
"devDependencies": { | ||
"eslint-config-custom": "workspace:*", | ||
"eslint-config-adapter": "workspace:*", | ||
"@changesets/cli": "^2.22.0", | ||
"prettier": "latest", | ||
"turbo": "latest" | ||
}, | ||
|
@@ -22,4 +27,4 @@ | |
}, | ||
"dependencies": {}, | ||
"packageManager": "[email protected]" | ||
} | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/eslint-config-custom/package.json → packages/eslint-config-adapter/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ["adapter"], | ||
}; |
Oops, something went wrong.