Skip to content

Commit

Permalink
#106 wallet connect - allow multiple addresses to be used in single c…
Browse files Browse the repository at this point in the history
…onnection
  • Loading branch information
scholtz committed Jul 19, 2024
1 parent a4620fb commit b9b073f
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 26 deletions.
8 changes: 6 additions & 2 deletions src/locales/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@
"arc14_help": "ARC 14 is 'n verifikasie-standaard wat onderteken transaksies gebruik. Jy kan die verifikasie-token op hierdie bladsy genereer.",
"account_actions": "Rekeningaksies",
"asset_optinArc200": "OptIn na ARC200-bate",
"asset_optinArc200_help": "Jy kan op jou rekening die ARC200-bates sien. ARC200-bates is slimkontrakte met 'n funksie wat enigiemand se rekening kan opt-in om die bate te kan ontvang. ARC200-bates kan gevaarlik wees en jy moet 'n betroubare oudit van die slimkontrak vereis sodat jy dit volledig kan vertrou."
"asset_optinArc200_help": "Jy kan op jou rekening die ARC200-bates sien. ARC200-bates is slimkontrakte met 'n funksie wat enigiemand se rekening kan opt-in om die bate te kan ontvang. ARC200-bates kan gevaarlik wees en jy moet 'n betroubare oudit van die slimkontrak vereis sodat jy dit volledig kan vertrou.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Naam",
Expand Down Expand Up @@ -588,7 +590,9 @@
"session_proposals": "Session proposals",
"toggle_camera": "Toggle camera",
"init_wc": "Initialize connection to Wallet Connect",
"sign_all": "Sign all"
"sign_all": "Sign all",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Add WalletConnect account",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
"arc14_help": "ARC 14 is authentication standard utilizing signed transactions. You can generate the authentication tokens on this page.",
"account_actions": "Account actions",
"asset_optinArc200": "OptIn to ARC200 asset",
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it."
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Name",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Session proposals",
"toggle_camera": "Toggle camera",
"init_wc": "Initialize connection to Wallet Connect",
"sign_all": "Sign all"
"sign_all": "Sign all",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Add WalletConnect account",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,9 @@
"session_proposals": "Session proposals",
"toggle_camera": "Toggle camera",
"init_wc": "Initialize connection to Wallet Connect",
"sign_all": "Sign all"
"sign_all": "Sign all",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Add WalletConnect account",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@
"arc14_help": "ARC 14 is authentication standard utilizing signed transactions. You can generate the authentication tokens on this page.",
"account_actions": "Account actions",
"asset_optinArc200": "OptIn to ARC200 asset",
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it."
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Name",
Expand Down Expand Up @@ -587,7 +589,9 @@
"session_proposals": "Propuestas de sesión",
"toggle_camera": "Cambiar de cámara",
"init_wc": "Inicializar la conexión con WalletConnect",
"sign_all": "Firmar todo"
"sign_all": "Firmar todo",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Añadir cuenta WalletConnect",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
"arc14_help": "Az ARC 14 hitelesítés egy olyan szabvány, amely a hitelesítésre aláírt tranzakciókat használ. A hitelesítési érmék ezen a lapon állíthatól elő.",
"account_actions": "Számla műveletek",
"asset_optinArc200": "Benevezés egy ARC200 pénzeszközbe",
"asset_optinArc200_help": "A számládon megfigyelheted az ARC200 pénzeszközöket. Az ARC200 pénzeszközök olyan okosszerződések, melyekbe bárki benevezhet, ha szeretne ARC200 pénzeszközt fogadni. Az ARC200 pénzeszközök veszélyesek lehetnek, és az okosszerződés alapos vizsgálatára van szükség a teljes bizalom érdekében."
"asset_optinArc200_help": "A számládon megfigyelheted az ARC200 pénzeszközöket. Az ARC200 pénzeszközök olyan okosszerződések, melyekbe bárki benevezhet, ha szeretne ARC200 pénzeszközt fogadni. Az ARC200 pénzeszközök veszélyesek lehetnek, és az okosszerződés alapos vizsgálatára van szükség a teljes bizalom érdekében.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Név",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Munkamenet javaslatok",
"toggle_camera": "Kamera be/kikapcsolás",
"init_wc": "Kapcsolat inicializálása a WalletConnect-hez",
"sign_all": "Az összes aláírása"
"sign_all": "Az összes aláírása",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "WalletConnect számla létrehozása",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
"arc14_help": "ARC 14 is authentication standard utilizing signed transactions. You can generate the authentication tokens on this page.",
"account_actions": "Account actions",
"asset_optinArc200": "OptIn to ARC200 asset",
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it."
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Name",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Session proposals",
"toggle_camera": "Toggle camera",
"init_wc": "Initialize connection to Wallet Connect",
"sign_all": "Sign all"
"sign_all": "Sign all",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Add WalletConnect account",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
"arc14_help": "ARC 14 is authentication standard utilizing signed transactions. You can generate the authentication tokens on this page.",
"account_actions": "Account actions",
"asset_optinArc200": "OptIn to ARC200 asset",
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it."
"asset_optinArc200_help": "You can watch on your account the ARC200 assets. ARC200 assets are smart contracts with feature that anyone can opt in user's account to be able to receive the asset. ARC200 assets may be dangerous and you should require trustworthy audit of the smart contract so that you can fully trust it.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Name",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Session proposals",
"toggle_camera": "Toggle camera",
"init_wc": "Initialize connection to Wallet Connect",
"sign_all": "Sign all"
"sign_all": "Sign all",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Add WalletConnect account",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@
"arc14_help": "ARC 14 — это стандарт аутентификации, использующий подписанные транзакции. На этой странице вы можете сгенерировать токены аутентификации.",
"account_actions": "Действия с аккаунтом",
"asset_optinArc200": "Подключиться к активу ARC200",
"asset_optinArc200_help": "Вы можете наблюдать за активами ARC200 в своей учетной записи. Активы ARC200 — это смарт-контракты с функцией, которую каждый может выбрать в учетной записи пользователя, чтобы получить актив. Активы ARC200 могут быть опасными, и вам следует потребовать заслуживающего доверия аудита смарт-контракт, чтобы вы могли полностью ему доверять."
"asset_optinArc200_help": "Вы можете наблюдать за активами ARC200 в своей учетной записи. Активы ARC200 — это смарт-контракты с функцией, которую каждый может выбрать в учетной записи пользователя, чтобы получить актив. Активы ARC200 могут быть опасными, и вам следует потребовать заслуживающего доверия аудита смарт-контракт, чтобы вы могли полностью ему доверять.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Имя",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Предложения по сеансам",
"toggle_camera": "Переключить камеру",
"init_wc": "Инициализировать подключение к Wallet Connect",
"sign_all": "Подписать все"
"sign_all": "Подписать все",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "Добавить учетную запись WalletConnect",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@
"arc14_help": "ARC 14 je autorizačný štandard ktorý využívat podpísané transakcie. Na tejto stránke si môžete vygenerovať autorizačné tokeny k vášmu účtu a externej službe.",
"account_actions": "Akcie účtu",
"asset_optinArc200": "Pridať ARC200 aktívum",
"asset_optinArc200_help": "Na svojom účte môžete sledovať a robiť prevody ARC200 aktív. ARC200 aktívum je smart kontrakt s výhodou, že otvoriť účet užívateľovi môže ktokoľvek. ARC200 aktívum môže byť nebezpečné a mali by ste vyžadovať bezpečnostný audit smart kontraktu pred tým ako ho začnete používať."
"asset_optinArc200_help": "Na svojom účte môžete sledovať a robiť prevody ARC200 aktív. ARC200 aktívum je smart kontrakt s výhodou, že otvoriť účet užívateľovi môže ktokoľvek. ARC200 aktívum môže byť nebezpečné a mali by ste vyžadovať bezpečnostný audit smart kontraktu pred tým ako ho začnete používať.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Name",
Expand Down Expand Up @@ -586,7 +588,9 @@
"session_proposals": "Návrhy pre reláciu",
"toggle_camera": "Zapnúť/Vypnúť kameru",
"init_wc": "Vytvoriť spojenie na Wallet Connect",
"sign_all": "Podpísať všetky"
"sign_all": "Podpísať všetky",
"proposer": "Navrhovateľ",
"all_accounts": "Použiť všetky účty"
},
"new_account_wc": {
"title": "Pridať WalletConnect účet",
Expand Down
8 changes: 6 additions & 2 deletions src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@
"arc14_help": "ARC 14, imzalı işlemleri kullanan kimlik doğrulama standardıdır. Kimlik doğrulama belirteçlerini bu sayfada oluşturabilirsiniz.",
"account_actions": "Hesap işlemleri",
"asset_optinArc200": "ARC200 varlığını tercih et",
"asset_optinArc200_help": "Hesabınızda ARC200 varlıklarını izleyebilirsiniz. ARC200 varlıkları, herkesin kullanıcının hesabına varlık alabilmeyi seçebileceği özelliğe sahip akıllı sözleşmelerdir. ARC200 varlıkları tehlikeli olabilir ve Akıllı sözleşme böylece ona tamamen güvenebilirsiniz."
"asset_optinArc200_help": "Hesabınızda ARC200 varlıklarını izleyebilirsiniz. ARC200 varlıkları, herkesin kullanıcının hesabına varlık alabilmeyi seçebileceği özelliğe sahip akıllı sözleşmelerdir. ARC200 varlıkları tehlikeli olabilir ve Akıllı sözleşme böylece ona tamamen güvenebilirsiniz.",
"scheduled_payment": "Scheduled payment",
"scheduled_payment_help": "You can setup and manage a scheduled periodic payments to another accounts"
},
"acc_overview_assets": {
"name": "Ad",
Expand Down Expand Up @@ -681,7 +683,9 @@
"session_proposals": "Oturum önerileri",
"toggle_camera": "Kamerayı değiştir",
"init_wc": "Wallet Connect bağlantısını başlat",
"sign_all": "Tümünü imzala"
"sign_all": "Tümünü imzala",
"proposer": "Proposer",
"all_accounts": "Use all wallet accounts"
},
"new_account_wc": {
"title": "WalletConnect hesabını ekleyin",
Expand Down
8 changes: 7 additions & 1 deletion src/pages/Connect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@
</div>
</template>
</Column>
<Column :header="$t('connect.all_accounts')">
<template #body="slotProps">
<Checkbox v-model="allAccounts" :binary="true"></Checkbox>
</template>
</Column>
<Column :header="$t('connect.connected')" :sortable="true">
<template #body="slotProps">
<Button
Expand Down Expand Up @@ -554,6 +559,7 @@ export default {
expandedRequests: [],
expandedTransactions: [],
scan: false,
allAccounts: true,
};
},
computed: {
Expand Down Expand Up @@ -778,7 +784,7 @@ export default {
},
async clickApproveSession(id) {
try {
await this.approveSession({ id });
await this.approveSession({ id, allAccounts: this.allAccounts });
} catch (err) {
const error = err.message ?? err;
this.openError(error);
Expand Down
28 changes: 25 additions & 3 deletions src/store/wc.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,40 @@ const actions = {
await commit("addAlgoSignTxn", algoSignTxn);
});
},
async approveSession({ commit, dispatch }, { id }) {
async approveSession({ commit, dispatch }, { id, allAccounts }) {
const currentChain = await dispatch("publicData/getCurrentChainId", null, {
root: true,
});

const lastActive = this.state.wallet.lastActiveAccount;
const chains = this.state.publicData.genesisList.map((network) => {
return `algorand:${network.CAIP10}`;
});
const accounts = this.state.publicData.genesisList.map((network) => {
return `algorand:${network.CAIP10}:${lastActive}`;
});

if (allAccounts) {
for (const address of this.state.wallet.privateAccounts) {
for (const network of this.state.publicData.genesisList) {
if (address && address.data && address.data[network.network]) {
const add = `algorand:${network.CAIP10}:${address.addr}`;
if (!accounts.includes(add)) {
accounts.push(add);
}
}
}
}
}
console.log("chains,accounts", chains, accounts);

const session = await this.state.wc.web3wallet.approveSession({
id,
namespaces: {
algorand: {
accounts: [`algorand:${currentChain}:${lastActive}`],
accounts: accounts,
methods: ["algo_signTxn"],
chains: [`algorand:${currentChain}`],
chains: chains,
events: ["chainChanged", "accountsChanged"],
},
//skipPairing: true, // optional to skip pairing ( later it can be resumed by invoking .pair())
Expand Down
27 changes: 24 additions & 3 deletions src/store/wcClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,39 @@ const actions = {

return provider;
},
async approveSession({ commit, dispatch }, { id }) {
async approveSession({ commit, dispatch }, { id, allAccounts }) {
const currentChain = await dispatch("publicData/getCurrentChainId", null, {
root: true,
});

const chains = this.state.publicData.genesisList.map((network) => {
return `algorand:${network.CAIP10}`;
});
const lastActive = this.state.wallet.lastActiveAccount;
const accounts = this.state.publicData.genesisList.map((network) => {
return `algorand:${network.CAIP10}:${lastActive}`;
});

if (allAccounts) {
for (const address of this.state.wallet.privateAccounts) {
for (const network of this.state.publicData.genesisList) {
if (address && address.data && address.data[network.network]) {
const add = `algorand:${network.CAIP10}:${address.addr}`;
if (!accounts.includes(add)) {
accounts.push(add);
}
}
}
}
}

const session = await this.state.wc.web3wallet.approveSession({
id,
namespaces: {
algorand: {
accounts: [`algorand:${currentChain}:${lastActive}`],
accounts: accounts,
methods: ["algo_signTxn"],
chains: [`algorand:${currentChain}`],
chains: chains,
events: ["chainChanged", "accountsChanged"],
},
//skipPairing: true, // optional to skip pairing ( later it can be resumed by invoking .pair())
Expand Down

0 comments on commit b9b073f

Please sign in to comment.