Skip to content

Commit c601365

Browse files
committed
feat(add identify function): add the function of jumping to verify the identity page
1 parent abfda1e commit c601365

File tree

6 files changed

+47
-3
lines changed

6 files changed

+47
-3
lines changed

dist/anyweb-js-sdk.umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/anyweb-js-sdk.umd.min.js.map

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

dist/src/provider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ class Provider {
208208
params: params ? JSON.stringify(params) : '',
209209
authType: 'exit_accounts',
210210
}, this);
211+
case 'anyweb_identify':
212+
return yield (0, common_1.callIframe)('pages/user/identify', {
213+
appId: this.appId,
214+
chainId: this.chainId,
215+
params: params ? JSON.stringify(params) : '',
216+
}, this);
211217
default:
212218
return 'Unsupported method';
213219
}

example/basic-dapp/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@
164164
Result: <span id="import_address_result">N/A</span>
165165
</footer>
166166
</article>
167+
<article>
168+
<header>
169+
跳转AnyWeb进行身份验证
170+
</header>
171+
<button id="identify_button" disabled=
172+
"true">跳转
173+
</button>
174+
<footer>
175+
Result: <span id="identify_result">N/A</span>
176+
</footer>
177+
</article>
167178
</div>
168179

169180
<script>

example/basic-dapp/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ async function walletInitialized() {
575575
const transferToAccountInput = getElement('to-account')
576576
const importAddressInput = getElement('import_address_input')
577577
const importAddressNameInput = getElement('import_address_name_input')
578+
const identifyButton = getElement('identify_button')
578579

579580
const deployContract = getElement('deploy_contract')
580581

@@ -596,6 +597,7 @@ async function walletInitialized() {
596597
connectButton.disabled = true
597598
DeauthorizeButton.disabled = false
598599
importAddressButton.disabled = false
600+
identifyButton.disabled = false
599601
}
600602

601603
function unAuthed() {
@@ -611,6 +613,7 @@ async function walletInitialized() {
611613
connectButton.disabled = false
612614
DeauthorizeButton.disabled = true
613615
importAddressButton.disabled = true
616+
identifyButton.disabled = true
614617
}
615618

616619
provider.on('accountsChanged', (accounts) => {
@@ -887,6 +890,19 @@ async function walletInitialized() {
887890
console.log('err', err)
888891
}
889892
}
893+
894+
identifyButton.onclick = async () => {
895+
try {
896+
provider
897+
.request({ method: 'anyweb_identify', params: [] })
898+
.then((result) => {
899+
getElement('identify_result').innerHTML = result
900+
console.log('result', result)
901+
})
902+
} catch (err) {
903+
console.log('err', err)
904+
}
905+
}
890906
}
891907

892908
window.addEventListener('load', async () => {

src/provider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ export class Provider implements IProvider {
230230
},
231231
this
232232
)
233+
case 'anyweb_identify':
234+
return await callIframe(
235+
'pages/user/identify',
236+
{
237+
appId: this.appId,
238+
chainId: this.chainId,
239+
params: params ? JSON.stringify(params) : '',
240+
},
241+
this
242+
)
243+
233244
default:
234245
return 'Unsupported method'
235246
}

0 commit comments

Comments
 (0)