Skip to content

Commit 4cdcada

Browse files
committed
examples: update examples of verifying signed messages
1 parent dc4d70f commit 4cdcada

9 files changed

Lines changed: 244 additions & 290 deletions

File tree

examples/with-next-app-router/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ export default function Home() {
5959
}
6060

6161
async function handleSignMsg() {
62+
if (!wallet.account) return
6263
try {
6364
const msg = 'Hello world!'
6465
const msgBytes = new TextEncoder().encode(msg)
6566
const result = await wallet.signMessage({
6667
message: msgBytes
6768
})
68-
const verifyResult = wallet.verifySignedMessage(result)
69+
const verifyResult = await wallet.verifySignedMessage(result, wallet.account.publicKey)
6970
console.log('verify signedMessage', verifyResult)
7071
if (!verifyResult) {
7172
alert(`signMessage succeed, but verify signedMessage failed`)

examples/with-next-app-router/package-lock.json

Lines changed: 42 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/with-next-app-router/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@mysten/sui.js": "0.37.1",
13-
"@suiet/wallet-kit": "0.2.16",
12+
"@mysten/sui.js": "0.40.0",
13+
"@suiet/wallet-kit": "0.2.17",
1414
"@types/node": "20.3.1",
1515
"@types/react": "18.2.13",
1616
"@types/react-dom": "18.2.6",

examples/with-next/components/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ function App() {
5252
}
5353

5454
async function handleSignMsg() {
55+
if (!wallet.account) return
5556
try {
5657
const msg = 'Hello world!'
5758
const msgBytes = new TextEncoder().encode(msg)
5859
const result = await wallet.signMessage({
5960
message: msgBytes
6061
})
61-
const verifyResult = wallet.verifySignedMessage(result)
62+
const verifyResult = await wallet.verifySignedMessage(result, wallet.account.publicKey)
6263
console.log('verify signedMessage', verifyResult)
6364
if (!verifyResult) {
6465
alert(`signMessage succeed, but verify signedMessage failed`)

0 commit comments

Comments
 (0)