Skip to content

Commit 3cf8c77

Browse files
authored
Merge pull request #1869 from aeternity/release/13.2.0
Release 13.2.0
2 parents 428ebe6 + eda0f28 commit 3cf8c77

37 files changed

+2710
-1858
lines changed

docs/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [13.2.0](https://github.com/aeternity/aepp-sdk-js/compare/v13.1.0...v13.2.0) (2023-07-28)
6+
7+
8+
### Features
9+
10+
* **account:** add methods to generate delegation signatures ([18bdf5a](https://github.com/aeternity/aepp-sdk-js/commit/18bdf5a113afac2c9a0c99555e2e301f043fa3ab))
11+
* **aepp,wallet:** support delegation signatures ([fd0dc43](https://github.com/aeternity/aepp-sdk-js/commit/fd0dc439418d2b63935bb8bbfb04020ef0884ecc))
12+
13+
14+
### Bug Fixes
15+
16+
* **account:** add implementation of `signTypedData` in AccountBase ([fc6e42f](https://github.com/aeternity/aepp-sdk-js/commit/fc6e42f1229c5bebb0a0802126bd7ea5c8726f3d))
17+
* **wallet:** don't ask to confirm unsubscription ([e2ffc25](https://github.com/aeternity/aepp-sdk-js/commit/e2ffc25021d16b197bba41c88520e0a842b88ba9))
18+
* **wallet:** don't require to be subscribed to request addresses ([36920b4](https://github.com/aeternity/aepp-sdk-js/commit/36920b4234a00be4e3cc2728372e875b361f9409))
19+
* **wallet:** return accounts according to subscription ([fa900c0](https://github.com/aeternity/aepp-sdk-js/commit/fa900c0481cc898211a3d99d22d57d34cac02177))
20+
521
## [13.1.0](https://github.com/aeternity/aepp-sdk-js/compare/v13.0.1...v13.1.0) (2023-07-07)
622

723

examples/browser/aepp/src/App.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
>
3333
Typed data
3434
</a>
35+
<a
36+
href="#"
37+
:class="{ active: view === 'DelegationSignature' }"
38+
@click="view = 'DelegationSignature'"
39+
>
40+
Delegation signature
41+
</a>
3542
</div>
3643

3744
<Component
@@ -41,19 +48,18 @@
4148
</template>
4249

4350
<script>
44-
import { mapState } from 'vuex';
4551
import Connect from './Connect.vue';
4652
import Basic from './Basic.vue';
4753
import Contracts from './Contracts.vue';
4854
import PayForTx from './PayForTx.vue';
4955
import TypedData from './TypedData.vue';
56+
import DelegationSignature from './DelegationSignature.vue';
5057
5158
export default {
5259
components: {
53-
Connect, Basic, Contracts, PayForTx, TypedData,
60+
Connect, Basic, Contracts, PayForTx, TypedData, DelegationSignature,
5461
},
5562
data: () => ({ view: '' }),
56-
computed: mapState(['aeSdk']),
5763
};
5864
</script>
5965

examples/browser/aepp/src/Connect.vue

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,26 @@
1313
</label>
1414
<div><input v-model="reverseIframeWalletUrl"></div>
1515
</div>
16+
17+
<button
18+
v-if="walletConnected"
19+
@click="disconnect"
20+
>
21+
Disconnect
22+
</button>
1623
<button
17-
v-if="connectMethod && !walletConnected"
24+
v-else-if="connectMethod"
1825
:disabled="walletConnecting"
1926
@click="connect"
2027
>
2128
Connect
2229
</button>
30+
2331
<button
24-
v-if="walletConnected"
25-
@click="disconnect"
32+
v-if="cancelWalletDetection"
33+
@click="cancelWalletDetection"
2634
>
27-
Disconnect
35+
Cancel detection
2836
</button>
2937
</div>
3038

@@ -34,6 +42,7 @@
3442
<div>
3543
{{
3644
(walletConnected && 'Wallet connected')
45+
|| (cancelWalletDetection && 'Wallet detection')
3746
|| (walletConnecting && 'Wallet connecting')
3847
|| 'Ready to connect to wallet'
3948
}}
@@ -48,7 +57,7 @@
4857

4958
<script>
5059
import {
51-
walletDetector, BrowserWindowMessageConnection, RpcConnectionDenyError,
60+
walletDetector, BrowserWindowMessageConnection, RpcConnectionDenyError, RpcRejectedByUserError,
5261
} from '@aeternity/aepp-sdk';
5362
import { mapState } from 'vuex';
5463
@@ -60,6 +69,7 @@ export default {
6069
reverseIframe: null,
6170
reverseIframeWalletUrl: process.env.VUE_APP_WALLET_URL ?? 'http://localhost:9000',
6271
walletInfo: null,
72+
cancelWalletDetection: null,
6373
}),
6474
computed: {
6575
...mapState(['aeSdk']),
@@ -69,32 +79,40 @@ export default {
6979
},
7080
},
7181
methods: {
72-
async scanForWallets() {
73-
return new Promise((resolve) => {
74-
let stopScan;
75-
76-
const handleWallets = async ({ wallets, newWallet }) => {
77-
newWallet = newWallet || Object.values(wallets)[0];
82+
async detectWallets() {
83+
if (this.connectMethod === 'reverse-iframe') {
84+
this.reverseIframe = document.createElement('iframe');
85+
this.reverseIframe.src = this.reverseIframeWalletUrl;
86+
this.reverseIframe.style.display = 'none';
87+
document.body.appendChild(this.reverseIframe);
88+
}
89+
const connection = new BrowserWindowMessageConnection();
90+
return new Promise((resolve, reject) => {
91+
const stopDetection = walletDetector(connection, async ({ newWallet }) => {
7892
if (confirm(`Do you want to connect to wallet ${newWallet.info.name} with id ${newWallet.info.id}`)) {
79-
stopScan();
93+
stopDetection();
8094
resolve(newWallet.getConnection());
95+
this.cancelWalletDetection = null;
8196
}
97+
});
98+
this.cancelWalletDetection = () => {
99+
reject(new Error('Wallet detection cancelled'));
100+
stopDetection();
101+
this.cancelWalletDetection = null;
102+
if (this.reverseIframe) this.reverseIframe.remove();
82103
};
83-
84-
const scannerConnection = new BrowserWindowMessageConnection();
85-
stopScan = walletDetector(scannerConnection, handleWallets);
86104
});
87105
},
88106
async connect() {
89107
this.walletConnecting = true;
108+
this.aeSdk.onDisconnect = () => {
109+
this.walletConnected = false;
110+
this.walletInfo = null;
111+
this.$store.commit('setAddress', undefined);
112+
if (this.reverseIframe) this.reverseIframe.remove();
113+
};
90114
try {
91-
if (this.connectMethod === 'reverse-iframe') {
92-
this.reverseIframe = document.createElement('iframe');
93-
this.reverseIframe.src = this.reverseIframeWalletUrl;
94-
this.reverseIframe.style.display = 'none';
95-
document.body.appendChild(this.reverseIframe);
96-
}
97-
const connection = await this.scanForWallets();
115+
const connection = await this.detectWallets();
98116
try {
99117
this.walletInfo = await this.aeSdk.connectToWallet(connection);
100118
} catch (error) {
@@ -104,14 +122,19 @@ export default {
104122
this.walletConnected = true;
105123
const { address: { current } } = await this.aeSdk.subscribeAddress('subscribe', 'connected');
106124
this.$store.commit('setAddress', Object.keys(current)[0]);
125+
} catch (error) {
126+
if (
127+
error.message === 'Wallet detection cancelled'
128+
|| error instanceof RpcConnectionDenyError
129+
|| error instanceof RpcRejectedByUserError
130+
) return;
131+
throw error;
107132
} finally {
108133
this.walletConnecting = false;
109134
}
110135
},
111-
async disconnect() {
112-
await this.aeSdk.disconnectWallet();
113-
this.walletConnected = false;
114-
if (this.reverseIframe) this.reverseIframe.remove();
136+
disconnect() {
137+
this.aeSdk.disconnectWallet();
115138
},
116139
},
117140
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<h2>Sign delegation to contract</h2>
3+
<div class="group">
4+
<div>
5+
<div>Contract address</div>
6+
<div><input v-model="contractAddress"></div>
7+
</div>
8+
<div>
9+
<label>
10+
<input v-model="type" type="radio" value="general">
11+
AENS and oracle
12+
</label>
13+
</div>
14+
<div>
15+
<label>
16+
<input v-model="type" type="radio" value="name">
17+
AENS name
18+
</label>
19+
<div><input v-model="name"></div>
20+
</div>
21+
<div>
22+
<label>
23+
<input v-model="type" type="radio" value="oracle-query">
24+
Oracle query
25+
</label>
26+
<div><input v-model="oracleQueryId"></div>
27+
</div>
28+
<button @click="signPromise = sign()">
29+
Sign
30+
</button>
31+
<div v-if="signPromise">
32+
<div>Signature</div>
33+
<Value :value="signPromise" />
34+
</div>
35+
</div>
36+
</template>
37+
38+
<script>
39+
import { mapState } from 'vuex';
40+
import Value from './components/Value.vue';
41+
42+
export default {
43+
components: { Value },
44+
data: () => ({
45+
type: 'general',
46+
contractAddress: 'ct_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh',
47+
name: 'test.chain',
48+
oracleQueryId: 'oq_6y3N9KqQb74QsvR9NrESyhWeLNiA9aJgJ7ua8CvsTuGot6uzh',
49+
signPromise: null,
50+
}),
51+
computed: mapState(['aeSdk']),
52+
methods: {
53+
sign() {
54+
switch (this.type) {
55+
case 'general':
56+
return this.aeSdk.signDelegationToContract(this.contractAddress);
57+
case 'name':
58+
return this.aeSdk.signNameDelegationToContract(this.contractAddress, this.name);
59+
case 'oracle-query':
60+
return this.aeSdk
61+
.signOracleQueryDelegationToContract(this.contractAddress, this.oracleQueryId);
62+
default:
63+
throw new Error(`Unknown delegation signature type: ${this.type}`)
64+
}
65+
},
66+
},
67+
};
68+
</script>

examples/browser/aepp/src/store.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const store = createStore({
2525
store.commit('setNetworkId', networkId);
2626
},
2727
onAddressChange: ({ current }) => store.commit('setAddress', Object.keys(current)[0]),
28-
onDisconnect: () => alert('Aepp is disconnected'),
2928
})),
3029
},
3130
mutations: {

examples/browser/aepp/src/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ body {
1919
}
2020

2121
button {
22-
@extend .w-32, .p-2, .m-2, .rounded-full, .bg-purple-500, .text-white, .text-xs;
22+
@extend .w-40, .p-2, .m-2, .rounded-full, .bg-purple-500, .text-white, .text-xs;
2323

2424
&:disabled {
2525
@extend .bg-purple-300, .cursor-not-allowed;

0 commit comments

Comments
 (0)