mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-03 14:06:25 +01:00
65 lines
2.2 KiB
HTML
65 lines
2.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>@trezor/connect example</title>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript" src="https://connect.trezor.io/9/trezor-connect.js"></script>
|
|
<script type="text/javascript">
|
|
window.TrezorConnect.init({
|
|
lazyLoad: true,
|
|
manifest: {
|
|
email: 'developer@xyz.com',
|
|
appName: 'Trezor Connect Example',
|
|
appUrl: 'http://your.application.com',
|
|
},
|
|
});
|
|
|
|
trezorGetAddress = function () {
|
|
window.TrezorConnect.getAddress({
|
|
showOnTrezor: true,
|
|
path: "m/49'/0'/0'/0/0",
|
|
coin: 'btc',
|
|
}).then(res => {
|
|
appendLog('calls', JSON.stringify(res));
|
|
});
|
|
};
|
|
|
|
window.TrezorConnect.on('DEVICE_EVENT', function (event) {
|
|
console.log('event', event);
|
|
appendLog(
|
|
'events',
|
|
JSON.stringify({
|
|
type: event.type,
|
|
device: event.payload.type, // applies for device events
|
|
code: event.payload.code, // applies for button events
|
|
payload: '(...redacted)',
|
|
}),
|
|
);
|
|
});
|
|
|
|
let logNumber = 1;
|
|
appendLog = function (id, log) {
|
|
const record = document.createElement('div');
|
|
record.className = id;
|
|
record.innerText = id + ' ' + logNumber + ' ' + log;
|
|
document.getElementById(id).appendChild(record);
|
|
logNumber++;
|
|
};
|
|
</script>
|
|
|
|
<button onclick="trezorGetAddress()">Get address</button>
|
|
|
|
<div style="display: flex; flex-direction: row; overflow-wrap: anywhere">
|
|
<div style="flex: 1; margin: 10px">
|
|
<div>calls</div>
|
|
<div id="calls"></div>
|
|
</div>
|
|
<div style="flex: 1; margin: 10px">
|
|
<div>events</div>
|
|
<div id="events"></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|