Skip to content

Commit dc3698e

Browse files
committed
Update dependencies and enhance documentation:
- Bump versions of @iexec/dataprotector, @iexec/web3mail, and @iexec/web3telegram. - Add ChainSelector component to helloWorld tutorial for network selection. - Improve links in ProtectData and buildIApp tutorials for better clarity. - Implement chain change handling in GrantAccess and ProtectData components.
1 parent 18eb35d commit dc3698e

File tree

8 files changed

+131
-26
lines changed

8 files changed

+131
-26
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"format": "prettier --ignore-path .gitignore --write ."
1010
},
1111
"dependencies": {
12-
"@iexec/dataprotector": "^2.0.0-beta.17",
12+
"@iexec/dataprotector": "^2.0.0-beta.19",
1313
"@iexec/dataprotector-deserializer": "^0.1.1",
14-
"@iexec/web3mail": "^1.2.2",
15-
"@iexec/web3telegram": "^0.1.0-alpha.1",
14+
"@iexec/web3mail": "^1.5.0",
15+
"@iexec/web3telegram": "^0.1.0-alpha.4",
1616
"@reown/appkit": "^1.7.17",
1717
"@reown/appkit-adapter-wagmi": "^1.7.17",
1818
"@tailwindcss/vite": "^4.1.11",

src/components/ChainSelector.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,26 @@ const userStore = useUserStore();
6868
// Data
6969
const supportedChains = getSupportedChains();
7070
71+
// Default initialization: check first if wallet is connected
72+
if (!userStore.chainId) {
73+
if (chainId.value) {
74+
// If wallet is connected, use its chain
75+
const walletChain = getChainById(chainId.value);
76+
if (walletChain) {
77+
userStore.setSelectedChain(walletChain);
78+
}
79+
} else {
80+
// Otherwise, use Bellecour as default
81+
const defaultChain = getChainById(0x86); // Bellecour
82+
if (defaultChain) {
83+
userStore.setSelectedChain(defaultChain);
84+
}
85+
}
86+
}
87+
7188
// Computed
7289
const selectedChain = computed(() => {
90+
// Priority: 1. Connected wallet chain, 2. Selected chain in store
7391
const currentChainId = chainId.value || userStore.chainId;
7492
return currentChainId ? getChainById(currentChainId) : undefined;
7593
});
@@ -91,6 +109,7 @@ const selectedChainId = computed({
91109
},
92110
});
93111
112+
// Watch to synchronize store with wallet chain
94113
watch(chainId, (newChainId) => {
95114
if (newChainId) {
96115
const chain = getChainById(newChainId);

src/documentation/helloWorld.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@ description:
77

88
<script setup>
99
import InfoIcon from '@/components/InfoIcon.vue'
10+
import ChainSelector from '@/components/ChainSelector.vue'
1011
</script>
1112

1213
# 👋 Welcome to iExec
1314

1415
> Reading time 🕒 2 mins
1516
17+
<div class="mb-6 p-4 bg-[var(--vp-c-bg-soft)] rounded-lg border border-[var(--vp-c-divider)]">
18+
<div class="flex items-center gap-3 mb-3">
19+
<span class="text-lg">🌐</span>
20+
<h3 class="m-0 text-lg font-medium">Select Your Network</h3>
21+
</div>
22+
<div class="flex items-center gap-3">
23+
<span class="text-sm font-medium">Network:</span>
24+
<ChainSelector />
25+
</div>
26+
</div>
27+
1628
<div class="bg-gradient-to-r from-[#fcd15a] to-[#ffad4d] rounded-[6px] px-8 pb-4 text-gray-800 max-w-3xl mx-auto mb-6">
1729
<h2 class="text-2xl font-bold mt-0 border-none!">Start Your Web3 Privacy Journey</h2>
1830
<p>And learn how to build Privacy-preserving decentralized applications (dApps) with iExec in this interactive guide.</p>

src/documentation/helloWorld/2-protectData.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ their dApps with these key features:
4646
and user experience.
4747

4848
<div class="bg-gradient-to-r from-fuchsia-400/10 to-fuchsia-400/5 rounded-[6px] p-6 border-l-4 border-fuchsia-700 mb-6">
49-
<p class="m-0!">DataProtector interacts with iExec's <a href="https://chainlist.org/?search=bellecour" target="_blank">Bellecour sidechain</a>, which is gasless, meaning you can use it completely free without needing any tokens!</p>
49+
<p class="m-0!">DataProtector interacts with iExec's <a href="https://chainlist.org/chain/134" target="_blank">Bellecour sidechain</a>, which is gasless, meaning you can use it completely free without needing any tokens!</p>
5050
</div>
5151

5252
## 🧩 Let's Create Protected Data

src/documentation/helloWorld/3-buildIApp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import InfoIcon from '@/components/InfoIcon.vue'
1515

1616
<div class="bg-gradient-to-r from-[#fcd15a] to-[#ffad4d] rounded-[6px] px-8 pb-4 text-gray-800 max-w-3xl mx-auto mb-6">
1717
<h2 class="text-2xl font-bold mt-0 border-none!">Time to build!</h2>
18-
<p>Let's build an iApp that can process protected data in a secure environment using the <a href="/documentation/build-iapp/iapp-generator" target="_blank">iExec iApp generator tool</a>. This tool helps you create, test and deploy iApps with just a few commands.</p>
18+
<p>Let's build an iApp that can process protected data in a secure environment using the <a href="/documentation/build-iapp/iapp-generator" target="_blank" class="!text-gray-900 !font-bold underline hover:!text-black">iExec iApp generator tool</a>. This tool helps you create, test and deploy iApps with just a few commands.</p>
1919
</div>
2020

2121
If you wanna explore and deep dive in the CLI. You can check the

src/modules/helloWorld/GrantAccess.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@
104104
</template>
105105

106106
<script setup>
107-
import { ref } from 'vue';
107+
import { ref, computed, watch } from 'vue';
108108
import { Icon } from '@iconify/vue';
109109
import { IExecDataProtectorCore } from '@iexec/dataprotector';
110110
import Button from '@/components/ui/Button.vue';
111111
import ReownButton from './ReownButton.vue';
112112
import { useAccount } from '@wagmi/vue';
113113
import { useWalletConnection } from '../../hooks/useWalletConnection.vue';
114+
import useUserStore from '@/stores/useUser.store';
114115
115116
const { connector } = useAccount();
116117
const {
@@ -119,12 +120,33 @@ const {
119120
protectedDataAddress,
120121
onWalletConnected,
121122
} = useWalletConnection();
123+
const userStore = useUserStore();
122124
123125
const authorizedApp = ref('');
124126
const isLoadingGrant = ref(false);
125127
const grantError = ref(null);
126128
const grantedAccess = ref(null);
127129
130+
// Watch to clear data when chain changes
131+
watch(
132+
() => userStore.getCurrentChainId(),
133+
(newChainId, oldChainId) => {
134+
if (oldChainId && newChainId && oldChainId !== newChainId) {
135+
console.log(
136+
'Chain changed, clearing grant access data:',
137+
oldChainId,
138+
'->',
139+
newChainId
140+
);
141+
// Clear granted access data
142+
grantedAccess.value = null;
143+
// Reset form
144+
authorizedApp.value = '';
145+
grantError.value = null;
146+
}
147+
}
148+
);
149+
128150
const grantAccess = async () => {
129151
try {
130152
if (!web3Provider.value) {
@@ -141,11 +163,8 @@ const grantAccess = async () => {
141163
}
142164
isLoadingGrant.value = true;
143165
grantError.value = null;
144-
const dataProtectorCore = new IExecDataProtectorCore(web3Provider.value, {
145-
iexecOptions: {
146-
smsURL: 'https://sms.scone-debug.v8-bellecour.iex.ec',
147-
},
148-
});
166+
167+
const dataProtectorCore = new IExecDataProtectorCore(web3Provider.value);
149168
150169
const grantedAccessResult = await dataProtectorCore.grantAccess({
151170
protectedData: protectedDataAddress?.value,

src/modules/helloWorld/ProtectData.vue

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
>
66
Connect Your Wallet
77
<a
8-
href="https://chainlist.org/?search=bellecour"
8+
:href="`https://chainlist.org/chain/${userStore.getCurrentChainId() || 134}`"
99
target="_blank"
1010
class="text-fuchsia-700 underline hover:text-fuchsia-900"
11-
>(iExec network)</a
1211
>
12+
({{ networkName }})
13+
</a>
1314
:
1415
<ReownButton />
1516
</div>
@@ -75,12 +76,16 @@
7576
<p class="mt-4">
7677
You can check it on
7778
<a
78-
:href="`https://explorer.iex.ec/bellecour/dataset/${protectedDataAddress}`"
79+
:href="explorerUrl"
7980
target="_blank"
8081
rel="noopener noreferrer"
8182
class="font-medium text-green-600 underline hover:text-green-800"
8283
>
83-
the iExec explorer
84+
{{
85+
userStore.getCurrentChainId() === 42161
86+
? 'the Arbitrum explorer'
87+
: 'the iExec explorer'
88+
}}
8489
</a>
8590
</p>
8691
<p class="mt-2">
@@ -104,13 +109,14 @@
104109
</template>
105110

106111
<script setup>
107-
import { ref } from 'vue';
112+
import { ref, computed, watch } from 'vue';
108113
import { Icon } from '@iconify/vue';
109114
import { IExecDataProtectorCore } from '@iexec/dataprotector';
110115
import Button from '@/components/ui/Button.vue';
111116
import ReownButton from './ReownButton.vue';
112117
import { useAccount } from '@wagmi/vue';
113118
import { useWalletConnection } from '../../hooks/useWalletConnection.vue';
119+
import useUserStore from '@/stores/useUser.store';
114120
115121
const { connector } = useAccount();
116122
const {
@@ -119,11 +125,50 @@ const {
119125
protectedDataAddress,
120126
protectedDataIpfsAddress,
121127
} = useWalletConnection();
128+
const userStore = useUserStore();
122129
123130
const contentToProtect = ref('');
124131
const isLoadingProtect = ref(false);
125132
const protectError = ref(null);
126133
134+
// Computed property for explorer URL based on selected chain
135+
const explorerUrl = computed(() => {
136+
const currentChainId = userStore.getCurrentChainId();
137+
const networkPath =
138+
currentChainId === 42161 ? 'arbitrum-mainnet' : 'bellecour';
139+
return `https://explorer.iex.ec/${networkPath}/dataset/${protectedDataAddress.value}`;
140+
});
141+
142+
// Computed property for network name
143+
const networkName = computed(() => {
144+
const currentChain = userStore.getCurrentChain();
145+
return currentChain?.name || 'Unknown network';
146+
});
147+
148+
// Watch to clear protected data when chain changes
149+
watch(
150+
() => userStore.getCurrentChainId(),
151+
(newChainId, oldChainId) => {
152+
if (oldChainId && newChainId && oldChainId !== newChainId) {
153+
console.log(
154+
'Chain changed, clearing protected data:',
155+
oldChainId,
156+
'->',
157+
newChainId
158+
);
159+
// Clear protected data
160+
protectedDataAddress.value = '';
161+
protectedDataIpfsAddress.value = '';
162+
// Clear localStorage
163+
localStorage.removeItem('protectedDataAddress');
164+
localStorage.removeItem('protectedDataIpfsAddress');
165+
// Reset form
166+
contentToProtect.value = '';
167+
protectError.value = null;
168+
}
169+
}
170+
);
171+
127172
async function protectData() {
128173
try {
129174
if (!web3Provider.value) {

0 commit comments

Comments
 (0)