Skip to content

Commit

Permalink
Merge pull request #362 from airgap-it/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AndreasGassmann authored Jun 30, 2022
2 parents 3d8814c + 7a608a1 commit cef5d2c
Show file tree
Hide file tree
Showing 51 changed files with 732 additions and 207 deletions.
23 changes: 5 additions & 18 deletions assets/alert/alert-pair.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
#beacon--qr__copy {
display: none;
position: relative;
top: -190px;
left: 138px;
margin: 0;
margin-top: auto;
margin-left: auto;
margin-right: auto;
}
#beacon--qr__container {
margin-left: auto;
Expand All @@ -73,26 +73,13 @@
#beacon--qr__container:hover #beacon--qr__copy {
display: block;
}
.disabled {
cursor: initial;
}
.disabled span,
.disabled img {
opacity: 0.48;
}

.disabled p {
text-align: left;
margin: 0;
font-size: 10px;
font-weight: 300;
}
.disabled img {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
filter: gray;
opacity: 0.48;
}

#beacon--disclaimer {
Expand Down
44 changes: 42 additions & 2 deletions examples/dapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

<style>
/* To test if our UI is affected by global styles */
div {
/* div {
background-color: red;
}
span {
background-color: orange;
}
} */
</style>
</head>

Expand Down Expand Up @@ -105,10 +105,50 @@
---
<br /><br />
<button id="reset">Reset and Refresh</button>
<br /><br />

<div id="logger-output"></div>

<br /><br />
<p style="margin-top: 1000px">End of page</p>

<script>
class MyLogger {
constructor() {}

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

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)
}

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)
}

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)
}
}

const x = new MyLogger()

beacon.setLogger(x)

// Initiate DAppClient
const client = new beacon.DAppClient({
name: 'Example DApp', // Name of the DApp,
Expand Down
6 changes: 2 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"packages": [
"packages/*"
],
"version": "3.1.1"
"packages": ["packages/*"],
"version": "3.1.2"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
'use strict'
import { BeaconMessageType } from '@airgap/beacon-types'
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'

const beaconProtocolSubstrate = require('..')
// use chai-as-promised plugin
chai.use(chaiAsPromised)
const expect = chai.expect

import { SubstrateBlockchain, SubstratePermissionScope } from '../src'

describe('@airgap/beacon-blockchain-substrate', () => {
it('needs tests')
it('should have wallets', async () => {
const blockchain = new SubstrateBlockchain()

const wallets = await blockchain.getWalletLists()

expect(Array.isArray(wallets.desktopList)).to.be.true
expect(Array.isArray(wallets.extensionList)).to.be.true
expect(Array.isArray(wallets.iOSList)).to.be.true
expect(Array.isArray(wallets.webList)).to.be.true
})

it('should handle a permission response', async () => {
const blockchain = new SubstrateBlockchain()

const accountInfos = await blockchain.getAccountInfosFromPermissionResponse({
blockchainIdentifier: 'substrate',
type: BeaconMessageType.PermissionResponse,
blockchainData: {
appMetadata: { senderId: 'sender', name: 'name' },
scopes: [SubstratePermissionScope.transfer],
accounts: [
{
accountId: 'account',
publicKey: 'pubKey',
address: 'address'
}
]
}
})

expect(accountInfos.length).to.equal(1)
expect(accountInfos[0].accountId).to.equal('account')
expect(accountInfos[0].publicKey).to.equal('pubKey')
expect(accountInfos[0].address).to.equal('address')
})
})
6 changes: 3 additions & 3 deletions packages/beacon-blockchain-substrate/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airgap/beacon-blockchain-substrate",
"version": "3.1.1",
"version": "3.1.2",
"description": "> TODO: description",
"author": "Andreas Gassmann <[email protected]>",
"homepage": "https://walletbeacon.io",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/airgap-it/beacon-sdk/issues"
},
"dependencies": {
"@airgap/beacon-types": "^3.1.1",
"@airgap/beacon-ui": "^3.1.1"
"@airgap/beacon-types": "^3.1.2",
"@airgap/beacon-ui": "^3.1.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
'use strict'
import { BeaconMessageType, NetworkType } from '@airgap/beacon-types'
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'

const beaconProtocoTezosSapling = require('..')
// use chai-as-promised plugin
chai.use(chaiAsPromised)
const expect = chai.expect

import { TezosSaplingBlockchain, TezosSaplingPermissionScope } from '../src'

describe('@airgap/beacon-blockchain-tezos-sapling', () => {
it('needs tests')
it('should have wallets', async () => {
const blockchain = new TezosSaplingBlockchain()

const wallets = await blockchain.getWalletLists()

expect(Array.isArray(wallets.desktopList)).to.be.true
expect(Array.isArray(wallets.extensionList)).to.be.true
expect(Array.isArray(wallets.iOSList)).to.be.true
expect(Array.isArray(wallets.webList)).to.be.true
})

it('should handle a permission response', async () => {
const blockchain = new TezosSaplingBlockchain()

const accountInfos = await blockchain.getAccountInfosFromPermissionResponse({
blockchainIdentifier: 'tezos-sapling',
type: BeaconMessageType.PermissionResponse,
blockchainData: {
appMetadata: { senderId: 'sender', name: 'name' },
scopes: [TezosSaplingPermissionScope.transfer],
accounts: [
{
accountId: 'account',
address: 'zet1...',
viewingKey: 'viewingKey...',
network: {
contract: 'KT1...',
type: NetworkType.MAINNET
}
}
]
}
})

expect(accountInfos.length).to.equal(1)
expect(accountInfos[0].accountId).to.equal('account')
expect(accountInfos[0].publicKey).to.equal('viewingKey...')
expect(accountInfos[0].address).to.equal('zet1...')
})
})
6 changes: 3 additions & 3 deletions packages/beacon-blockchain-tezos-sapling/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airgap/beacon-blockchain-tezos-sapling",
"version": "3.1.1",
"version": "3.1.2",
"description": "> TODO: description",
"author": "Andreas Gassmann <[email protected]>",
"homepage": "https://walletbeacon.io",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/airgap-it/beacon-sdk/issues"
},
"dependencies": {
"@airgap/beacon-types": "^3.1.1",
"@airgap/beacon-ui": "^3.1.1"
"@airgap/beacon-types": "^3.1.2",
"@airgap/beacon-ui": "^3.1.2"
}
}
2 changes: 1 addition & 1 deletion packages/beacon-blockchain-tezos-sapling/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class TezosSaplingBlockchain implements Blockchain {
return permissionResponse.blockchainData.accounts.map((account) => ({
accountId: account.accountId,
address: account.address,
publicKey: '' // Public key or viewing key is not shared in permission request for privacy reasons
publicKey: account.viewingKey ?? '' // Public key or viewing key is not shared in permission request for privacy reasons
}))
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export enum TezosSaplingMessageType {
/**
* This message type is used for transfers from one sapling address to another.
*/
'transfer_request' = 'transfer_request'
// shield, transfer, unshield?
// In a later version, support for shield and unshield operations will most likely be added.
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export enum TezosSaplingPermissionScope {
/**
* The "viewing_key" permission is used to signal to the wallet that a dApp requests access to the viewing key. Sharing the viewing key will give up ALL privacy advantages of sapling, so this permission should only be granted in very specific cases.
*/
'viewing_key' = 'viewing_key',
/**
* This permission allows wallets to do normal transfers from one sapling account to another.
*/
'transfer' = 'transfer'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
'use strict'
import { BeaconMessageType } from '@airgap/beacon-types'
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'

const beaconProtocolTezos = require('..')
// use chai-as-promised plugin
chai.use(chaiAsPromised)
const expect = chai.expect

import { TezosBlockchain } from '../src'

describe('@airgap/beacon-blockchain-tezos', () => {
it('needs tests')
it('should have wallets', async () => {
const blockchain = new TezosBlockchain()

const wallets = await blockchain.getWalletLists()

expect(Array.isArray(wallets.desktopList)).to.be.true
expect(Array.isArray(wallets.extensionList)).to.be.true
expect(Array.isArray(wallets.iOSList)).to.be.true
expect(Array.isArray(wallets.webList)).to.be.true
})

it('should handle a permission response', async () => {
const blockchain = new TezosBlockchain()

const accountInfos = await blockchain.getAccountInfosFromPermissionResponse({
blockchainIdentifier: 'tezos',
type: BeaconMessageType.PermissionResponse,
blockchainData: {
appMetadata: { senderId: 'sender', name: 'name' },
scopes: ['test']
}
})

expect(accountInfos.length).to.equal(1)
expect(accountInfos[0].accountId).to.equal('')
expect(accountInfos[0].publicKey).to.equal('')
expect(accountInfos[0].address).to.equal('')
})
})
6 changes: 3 additions & 3 deletions packages/beacon-blockchain-tezos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@airgap/beacon-blockchain-tezos",
"version": "3.1.1",
"version": "3.1.2",
"description": "> TODO: description",
"author": "Andreas Gassmann <[email protected]>",
"homepage": "https://walletbeacon.io",
Expand Down Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/airgap-it/beacon-sdk/issues"
},
"dependencies": {
"@airgap/beacon-types": "^3.1.1",
"@airgap/beacon-ui": "^3.1.1"
"@airgap/beacon-types": "^3.1.2",
"@airgap/beacon-ui": "^3.1.2"
}
}
7 changes: 0 additions & 7 deletions packages/beacon-core/__tests__/beacon-core.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'
import { getAccountIdentifier } from '../src/utils/get-account-identifier'
import { getAccountIdentifier } from '../../src/utils/get-account-identifier'
import { Network, NetworkType } from '@airgap/beacon-types'

// use chai-as-promised plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'

import { FileStorage, writeLocalFile } from '../../../test/test-utils/FileStorage'
import { FileStorage, writeLocalFile } from '../../../../test/test-utils/FileStorage'
import { NetworkType, Origin, Storage, StorageKey } from '@airgap/beacon-types'
import { migrate } from '../src/migrations/migrations'
import { AccountInfoOld, P2PPairingRequestOld } from '../src/migrations/migrate-0.7.0'
import { SDK_VERSION } from '../src'
import { migrate } from '../../src/migrations/migrations'
import { AccountInfoOld, P2PPairingRequestOld } from '../../src/migrations/migrate-0.7.0'
import { SDK_VERSION } from '../../src'

// use chai-as-promised plugin
chai.use(chaiAsPromised)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as chai from 'chai'
import * as chaiAsPromised from 'chai-as-promised'
import 'mocha'

import { Serializer } from '../src/Serializer'
import { Serializer } from '../../src/Serializer'

// use chai-as-promised plugin
chai.use(chaiAsPromised)
Expand Down
Loading

0 comments on commit cef5d2c

Please sign in to comment.