Skip to content

Commit

Permalink
Merge pull request #741 from airgap-it/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AndreasGassmann authored Mar 25, 2024
2 parents 58cd069 + 8503adc commit 3026e3f
Show file tree
Hide file tree
Showing 101 changed files with 5,372 additions and 2,250 deletions.
6 changes: 6 additions & 0 deletions assets/logos/beacon_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions assets/logos/ios-fireblocks.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions examples/abstracted-account.html
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,6 @@

// Send response back to DApp
client.respond(response)
} else if (message.type === beacon.BeaconMessageType.ProofOfEventChallengeRecorded) {
console.log('Proof of event challenge has been recorded')
} else if (message.type === beacon.BeaconMessageType.ProofOfEventChallengeRequest) {
const isAccepted = window.confirm(
'Do you want to accept the Proof Of Event Challenge ?'
Expand Down
65 changes: 56 additions & 9 deletions examples/dapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@
<br /><br />
<button id="requestPermissionAndSign">Request Permission And Sign Request</button>
<br /><br />

<button id="disconnect" disabled style="opacity: 0.5">Disconnect</button>
<br /><br />
<button id="reset">Reset and Refresh</button>
<br /><br />
<button id="requestProofOfEventChallenge" disabled style="opacity: 0.5">
Request Proof Of Event Challenge
</button>
<br /><br />
<button id="requestSimulatedProofOfEventChallenge" disabled style="opacity: 0.5">
Request Simulated Proof Of Event Challenge
</button>
<br /><br />
<button id="sendToSelf">Send 1 mutez to myself</button>
<br /><br />
<button id="sendToSelfWithPrepare">Send 1 mutez to myself (with 1s prepare delay)</button>
Expand Down Expand Up @@ -147,41 +152,47 @@
el.innerText = `'debug' ${name} ${method} ${args.join(', ')}`
el.setAttribute('style', 'background-color: blue')
document.getElementById('logger-output').appendChild(el)
console.debug('LOGGER', name, method, ...args)
}

log(name, method, ...args) {
const el = document.createElement('div')
el.innerText = `'log' ${name} ${method} ${args.join(', ')}`
el.setAttribute('style', 'background-color: green')
document.getElementById('logger-output').appendChild(el)
console.log('LOGGER', name, method, ...args)
}

warn(name, method, ...args) {
const el = document.createElement('div')
el.innerText = `'warn' ${name} ${method} ${args.join(', ')}`
el.setAttribute('style', 'background-color: orange')
document.getElementById('logger-output').appendChild(el)
console.warn('LOGGER', name, method, ...args)
}

error(name, method, ...args) {
const el = document.createElement('div')
el.innerText = `'error' ${name} ${method} ${args.join(', ')}`
el.setAttribute('style', 'background-color: red')
document.getElementById('logger-output').appendChild(el)
console.error('LOGGER', name, method, ...args)
}

time(start, label) {
const el = document.createElement('div')
el.innerText = `'time' ${start} ${label}`
el.setAttribute('style', 'background-color: grey')
document.getElementById('logger-output').appendChild(el)
console.time(label)
}

timeLog(method, ...args) {
const el = document.createElement('div')
el.innerText = `'timeLog' ${method} ${args.join(', ')}`
el.setAttribute('style', 'background-color: grey')
document.getElementById('logger-output').appendChild(el)
console.timeLog(method, ...args)
}
}

Expand Down Expand Up @@ -224,7 +235,8 @@
featuredWallets: ['kukai', 'metamask', 'airgap'],
network: {
type: beacon.NetworkType.GHOSTNET
}
},
enableMetrics: true
// matrixNodes: ['test.papers.tech', 'test2.papers.tech', 'matrix.papers.tech']
// matrixNodes: ['beacon-node-0.papers.tech:8448']
// matrixNodes: ['matrix.papers.tech']
Expand All @@ -238,14 +250,21 @@
document.getElementById('activeAccount').innerText = activeAccount.address
document.getElementById('activeAccountNetwork').innerText = activeAccount.network.type
document.getElementById('activeAccountTransport').innerText = activeAccount.origin.type
let btn = document.getElementById('disconnect')
btn.style.opacity = '1'
btn.disabled = false

if (
activeAccount.walletType !== 'account_abstracted' &&
activeAccount.verificationType !== 'proof_of_event'
)
return

const btn = document.getElementById('requestProofOfEventChallenge')
btn = document.getElementById('requestProofOfEventChallenge')
btn.style.opacity = '1'
btn.disabled = false

btn = document.getElementById('requestSimulatedProofOfEventChallenge')
btn.style.opacity = '1'
btn.disabled = false
} else {
Expand Down Expand Up @@ -374,14 +393,30 @@
dAppChallengeId: 'my-id',
payload: JSON.stringify({ timestamp: Date.now() })
})
.then(() => {
console.log('ProofOfEventChallenge approved')
.then((response) => {
console.log(`ProofOfEventChallenge ${response.isAccepted ? 'accepted' : 'refused'}`)
})
.catch((error) => {
console.log('error during Proof Of Event Challenge', error)
})
}

const promise = client.getProofOfEventChallenge('my-id')
// disconnect
const disconnect = () => {
client
.disconnect()
.then(() => console.log('disconnected.'))
.catch((err) => console.error(err.message))

promise.then(() => {
alert('Proof of event verified')
})
}

const requestSimulatedProofOfEventChallenge = () => {
client
.requestSimulatedProofOfEventChallenge({
payload: JSON.stringify({ timestamp: Date.now() })
})
.then((response) => {
console.log('SimulatedProofOfEventChallenge response', response)
})
.catch((error) => {
console.log('error during Proof Of Event Challenge', error)
Expand Down Expand Up @@ -419,11 +454,23 @@
requestPermissionAndSign()
})

// Add event listener to the button
document.getElementById('disconnect').addEventListener('click', () => {
disconnect()
})

// Add event listener to the button
document.getElementById('requestProofOfEventChallenge').addEventListener('click', () => {
requestProofOfEventChallenge()
})

// Add event listener to the button
document
.getElementById('requestSimulatedProofOfEventChallenge')
.addEventListener('click', () => {
requestSimulatedProofOfEventChallenge()
})

// Add event listener to the button
document.getElementById('reset').addEventListener('click', () => {
if (document.getElementById('reset').attributes.getNamedItem('disabled') === 'true') {
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "4.1.2",
"version": "4.2.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
Loading

0 comments on commit 3026e3f

Please sign in to comment.