Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Use standalone modal #14

Merged
merged 30 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3bcb259
Use standalone modal
devceline Nov 16, 2022
d1b84ab
v0.2.3-canary.7
devceline Nov 16, 2022
35ddb8e
Covert deps to be peer deps
devceline Nov 16, 2022
8fcf380
v0.2.3-canary.8
devceline Nov 16, 2022
9b4011a
v0.2.3-canary.9
devceline Nov 16, 2022
cb1178b
v0.2.3-canary.10
devceline Nov 16, 2022
c151db8
v0.2.3-canary.11
devceline Nov 16, 2022
47592c2
v0.2.3-canary.12
devceline Nov 16, 2022
16fd82b
Update dynamic import
devceline Nov 16, 2022
39fb61d
v0.2.3-canary.13
devceline Nov 16, 2022
78141d7
v0.2.3-canary.14
devceline Nov 17, 2022
0ad8c40
v0.2.3-canary.15
devceline Nov 17, 2022
d1d57db
v0.2.3-canary.16
devceline Nov 21, 2022
21dbc36
v0.2.3-canary.17
devceline Nov 21, 2022
3f3734d
v0.2.3-canary.18
devceline Nov 21, 2022
68bbb0b
v0.2.3-canary.19
devceline Nov 21, 2022
b85e1b3
v0.2.3-canary.20
devceline Nov 21, 2022
00bba2e
v0.2.3-canary.21
devceline Nov 22, 2022
f8617fc
v0.2.3-canary.22
devceline Nov 22, 2022
c026891
prep canary 24
devceline Nov 22, 2022
6e432ae
v0.2.3-canary.23
devceline Nov 22, 2022
7818f6f
Fix nextjs errors
devceline Nov 22, 2022
8d12350
v0.2.3-canary.24
devceline Nov 22, 2022
1c6cea2
Use canary in next app
devceline Nov 22, 2022
e400041
Amend docs to mention installation
devceline Nov 22, 2022
45fddb3
v0.2.3-canary.25
devceline Nov 23, 2022
00c8a44
Cleanup code per PR comments
devceline Nov 23, 2022
cdfb12e
Fix projectId
devceline Nov 25, 2022
ebb3f6b
v0.2.3-canary.26
devceline Nov 25, 2022
34ca718
Update next app to use qrcode
devceline Nov 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/docs/Installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,20 @@ npm install --save @walletconnect/solib
```bash
yarn add @walletconnect/solib
```

### Note on QRCodes and Web3Modal's standalone modal
If you plan on setting `qrcode: false` and handling QRCode display yourself when
using `WalletConnectConnector`, be sure to mark the web3modal dependencies as external in the rollup or webpack config.
They are peer dependencies and are not downloaded automatically, and need to be
marked as such to avoid import analysis tools false flagging them.

Example in vite
```json
export default defineConfig({
rollupOptions: {
external: ["@web3modal/core", "@web3modal/ui"]
devceline marked this conversation as resolved.
Show resolved Hide resolved
},
plugins: [react()],
});

```
2 changes: 1 addition & 1 deletion example-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@chakra-ui/react": "^2.3.5",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@walletconnect/solib": "^0.2.3-canary.4",
"@walletconnect/solib": "^0.2.3-canary.24",
"events": "^3.3.0",
"framer-motion": "^7.5.2",
"next": "12.3.1",
Expand Down
2 changes: 1 addition & 1 deletion example-next/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ init(
url: 'http://localhost:3000'
},
autoconnect: true,
qrcode: true
qrcode: false
devceline marked this conversation as resolved.
Show resolved Hide resolved
})
],
chosenCluster: mainnetBetaBlockDaemon
Expand Down
10 changes: 0 additions & 10 deletions example-next/pages/api/hello.ts

This file was deleted.

35 changes: 16 additions & 19 deletions example-next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { NextPage } from 'next'
import {
connect,
signMessage,
Expand All @@ -11,8 +10,6 @@ import {
getFeeForMessage,
getTransaction,
watchTransaction,
getNetwork,
watchNetwork,
fetchName,
fetchAddressFromDomain,
getAccount
Expand All @@ -32,7 +29,7 @@ import {
useToast
} from '@chakra-ui/react'

function Home(): NextPage {
function Home() {
const toast = useToast()
console.log('Phantom is ready', getConnectorIsAvailable(PhantomConnector.connectorName()))
const [address, setAddress] = useState<string | undefined>('')
Expand All @@ -45,17 +42,17 @@ function Home(): NextPage {

useEffect(() => {
console.log('ya hey')
watchAddress(address => {
console.log('Got address', address)
setAddress(address)
watchAddress(address2 => {
console.log('Got address', address2)
setAddress(address2)
})
}, [setAddress])

useEffect(() => {
if (address) {
getBalance().then(value => setBalance((value && value.decimals.toString()) || '0'))
fetchName('FidaeBkZkvDqi1GXNEwB8uWmj9Ngx2HXSS5nyGRuVFcZ').then(name => {
setName(name?.reverse || address!)
getBalance().then(value => setBalance(value?.decimals.toString() ?? '0'))
fetchName('FidaeBkZkvDqi1GXNEwB8uWmj9Ngx2HXSS5nyGRuVFcZ').then(name2 => {
setName(name2?.reverse ?? address)
})
fetchAddressFromDomain('bonfida.sol').then(addr => {
console.log({ addressFromDomain: addr })
Expand All @@ -70,12 +67,11 @@ function Home(): NextPage {
})
}, [])

const onSign = useCallback((message: string | undefined) => {
if (message) {
signMessage(message).then(signature => {
setSignature(signature!)
const onSign = useCallback((message2: string | undefined) => {
if (message2)
signMessage(message2).then(signature2 => {
setSignature(signature2 ?? '')
})
}
}, [])

const onSendTransaction = useCallback(
Expand All @@ -88,22 +84,23 @@ function Home(): NextPage {
feePayer: 'from'
}).then(fee => console.log({ fee }))

if (to && amountInLamports) {
if (to && amountInLamports)
signAndSendTransaction('transfer', {
to,
amountInLamports,
feePayer: 'from'
}).then(async result => {
console.log({ result })
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
devceline marked this conversation as resolved.
Show resolved Hide resolved
await watchTransaction(result!, () => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
getTransaction(result!).then(tra => console.log({ tra }))
toast({
status: 'success',
title: 'Transaction successful'
})
})
})
}
},
[toast]
)
Expand All @@ -121,7 +118,7 @@ function Home(): NextPage {
<Badge fontSize="1em" fontStyle={'italic'}>
Balance: {balance}
</Badge>
<Button onClick={() => disconnect()}>Disconnect</Button>
<Button onClick={async () => disconnect()}>Disconnect</Button>
</Flex>
)}
{address && (
Expand All @@ -148,7 +145,7 @@ function Home(): NextPage {
</NumberInputStepper>
</NumberInput>
</Flex>
<Button onClick={() => onSendTransaction(toAddress!, amount)}>
<Button onClick={() => onSendTransaction(toAddress ?? '', amount)}>
Send Transaction
</Button>
</Flex>
Expand Down
Loading