Skip to content

Commit 28cc2b5

Browse files
committed
Merge branch 'master' of https://github.com/ecadlabs/taquito
2 parents cd57994 + 1188bbc commit 28cc2b5

35 files changed

+6308
-948
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Taquito is used by **over 80% of DApps** in the Tezos ecosystem. It is easy to u
2121

2222
## Why should I use Taquito?
2323

24-
Taquito provides convenient abstractions for a multitude of common operations, including wallet interactions (with [WalletConnect2](https://docs.walletconnect.com/2.0) in the works), batching operations, calling into contracts, querying the blockchain, and more. Taquito will isolate your code from subtle - and some not-so-subtle - changes made to the underlying Tezos protocol.
24+
Taquito provides convenient abstractions for a multitude of common operations, including wallet interactions (with [WalletConnect/Reown](https://reown.com/) in the works), batching operations, calling into contracts, querying the blockchain, and more. Taquito will isolate your code from subtle - and some not-so-subtle - changes made to the underlying Tezos protocol.
2525

2626
...Not to mention our thriving, helpful, and welcoming community!
2727

@@ -80,6 +80,8 @@ Taquito is organized as a [monorepo](https://en.wikipedia.org/wiki/Monorepo), an
8080
| [@taquito/contracts-library](packages/taquito-contracts-library) | Provides functionality specify static data related to contracts |
8181
| [@taquito/ledger-signer](packages/taquito-ledger-signer) | Provides functionality for ledger signer provider |
8282
| [@taquito/timelock](packages/taquito-timelock) | Provides functionality to create and open timelocks |
83+
| [@taquito/wallet-connect](packages/taquito-wallet-connect) | WalletConnect class can be injected into the `TezosToolkit` to work with the wallet API. |
84+
8385

8486
## API Documentation
8587

apps/taquito-test-dapp/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"events": "^3.3.0",
1616
"lerna": "^8.1.7",
1717
"prettier-plugin-svelte": "^3.2.6",
18-
"sass": "^1.78.0",
18+
"sass": "^1.80.1",
1919
"svelte": "^4.2.19",
2020
"svelte-check": "^3.8.5",
2121
"svelte-preprocess": "^6.0.2",
@@ -30,7 +30,9 @@
3030
"@taquito/core": "^20.1.0",
3131
"@taquito/taquito": "^20.1.0",
3232
"@taquito/utils": "^20.1.0",
33+
"@taquito/wallet-connect": "^20.1.0",
3334
"buffer": "^6.0.3",
35+
"svelte-modals": "^2.0.0-beta.2",
3436
"svelte-select": "^5.8.3",
3537
"vite-compatible-readable-stream": "^3.6.1"
3638
},

apps/taquito-test-dapp/src/App.svelte

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { NetworkType } from "@airgap/beacon-types";
55
import Select from "svelte-select";
66
import { getRpcUrl } from "./config";
7-
import store from "./store";
7+
import store, { SDK } from "./store";
88
import Layout from "./Layout.svelte";
99
import TestContainer from "./lib/TestContainer.svelte";
1010
@@ -13,7 +13,6 @@
1313
let browser = "";
1414
let availableNetworks = [
1515
{ value: "ghostnet", label: "Ghostnet", group: "current testnets" },
16-
{ value: "oxfordnet", label: "Oxfordnet", group: "current testnets" },
1716
{ value: "parisnet", label: "Parisnet", group: "current testnets" },
1817
{ value: "mainnet", label: "Mainnet", group: "mainnet" },
1918
{ value: "dailynet", label: "Dailynet", group: "other testnets" },
@@ -40,9 +39,6 @@
4039
case "ghostnet":
4140
store.updateNetworkType(NetworkType.GHOSTNET);
4241
break;
43-
case "oxfordnet":
44-
store.updateNetworkType(NetworkType.OXFORDNET);
45-
break;
4642
case "parisnet":
4743
store.updateNetworkType(NetworkType.PARISNET);
4844
break;
@@ -129,6 +125,18 @@
129125
margin: 10px 0px;
130126
}
131127
128+
.sdk {
129+
border: 1px solid;
130+
border-radius: 10px;
131+
display: flex;
132+
flex-direction: column;
133+
align-items: flex-start;
134+
padding: 20px;
135+
grid-row-gap: 10px;
136+
align-items: center;
137+
width: 100%;
138+
}
139+
132140
button {
133141
width: 100%;
134142
justify-content: center;
@@ -175,15 +183,32 @@
175183
<div>(use Chrome for a better experience)</div>
176184
{/if}
177185
<div class="options">
178-
<button
179-
on:click={() => {
180-
const wallet = document.getElementById("wallet-button");
181-
wallet?.click();
182-
}}
183-
>
184-
<span class="material-icons-outlined"> account_balance_wallet </span>
185-
&nbsp; Connect your wallet
186-
</button>
186+
<div class="sdk">
187+
<span><strong>Connect using beacon sdk</strong></span>
188+
<button
189+
on:click={() => {
190+
const wallet = document.getElementById("wallet-button");
191+
store.updateSdk(SDK.BEACON);
192+
wallet.click();
193+
}}
194+
>
195+
<span class="material-icons-outlined"> account_balance_wallet </span>
196+
&nbsp; Connect your wallet
197+
</button>
198+
</div>
199+
<div class="sdk">
200+
<span><strong>Connect using Wallet Connect</strong></span>
201+
<button
202+
on:click={() => {
203+
const walletConnect = document.getElementById("wallet-button");
204+
store.updateSdk(SDK.WC2);
205+
walletConnect.click();
206+
}}
207+
>
208+
<span class="material-icons-outlined"> account_balance_wallet </span>
209+
&nbsp; Connect your wallet
210+
</button>
211+
</div>
187212
<button>
188213
<span class="material-icons-outlined"> usb </span>
189214
&nbsp; Connect your Nano ledger

apps/taquito-test-dapp/src/config.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { NetworkType } from '@airgap/beacon-types';
1+
import { NetworkType as NetworkTypeBeacon } from "@airgap/beacon-sdk";
2+
import { NetworkType as NetworkTypeWc } from "@taquito/wallet-connect";
23

3-
export type SupportedNetworks = NetworkType.PARISNET | NetworkType.OXFORDNET | NetworkType.GHOSTNET | NetworkType.MAINNET | NetworkType.CUSTOM;
4+
export type SupportedNetworks = NetworkTypeBeacon.MAINNET | NetworkTypeBeacon.GHOSTNET | NetworkTypeBeacon.PARISNET | NetworkTypeWc.MAINNET | NetworkTypeWc.GHOSTNET | NetworkTypeWc.PARISNET | NetworkTypeBeacon.CUSTOM;
45

56
const rpcUrls: Record<SupportedNetworks, string> = {
6-
[NetworkType.MAINNET]: "https://mainnet.ecadinfra.com",
7-
[NetworkType.GHOSTNET]: "https://ghostnet.ecadinfra.com/",
8-
[NetworkType.OXFORDNET]: "https://oxfordnet.ecadinfra.com/",
9-
[NetworkType.PARISNET]: "https://rpc.pariscnet.teztnets.com/",
10-
[NetworkType.CUSTOM]: "https://ghostnet.ecadinfra.com/",
7+
[NetworkTypeBeacon.MAINNET]: "https://mainnet.ecadinfra.com",
8+
[NetworkTypeBeacon.GHOSTNET]: "https://ghostnet.ecadinfra.com/",
9+
[NetworkTypeBeacon.PARISNET]: "https://rpc.pariscnet.teztnets.com/",
10+
[NetworkTypeBeacon.CUSTOM]: "https://ghostnet.ecadinfra.com/",
1111
};
1212

1313
export const getRpcUrl = (networkType: SupportedNetworks): string => {
@@ -16,22 +16,23 @@ export const getRpcUrl = (networkType: SupportedNetworks): string => {
1616

1717
export const getTzKtUrl = (networkType: SupportedNetworks): string | undefined => {
1818
switch (networkType) {
19-
case NetworkType.MAINNET:
19+
case NetworkTypeBeacon.MAINNET:
20+
case NetworkTypeWc.MAINNET:
2021
return "https://tzkt.io";
21-
case NetworkType.GHOSTNET:
22+
case NetworkTypeBeacon.GHOSTNET:
23+
case NetworkTypeWc.GHOSTNET:
2224
return "https://ghostnet.tzkt.io";
23-
case NetworkType.OXFORDNET:
24-
return "https://oxfordnet.tzkt.io";
25-
case NetworkType.PARISNET:
25+
case NetworkTypeBeacon.PARISNET:
26+
case NetworkTypeWc.PARISNET:
2627
return "https://parisnet.tzkt.io";
27-
case NetworkType.CUSTOM:
28+
case NetworkTypeBeacon.CUSTOM:
2829
return undefined;
2930
}
3031
}
3132

3233
export const defaultMatrixNode = "beacon-node-1.sky.papers.tech";
3334

34-
export const defaultNetworkType = NetworkType.GHOSTNET;
35+
export const defaultNetworkType = NetworkTypeBeacon.GHOSTNET;
3536

3637
// new protocol updated rpc url in example/data/test-dapp-contract.ts and npm -w example run example:deploy-dapp
3738
export const contractAddress = {
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<script>
2+
import { createModalEventDispatcher } from "svelte-modals";
3+
4+
export let isOpen;
5+
export let title;
6+
export let options;
7+
8+
const dispatch = createModalEventDispatcher();
9+
</script>
10+
11+
<style>
12+
.modal {
13+
position: fixed;
14+
top: 0;
15+
bottom: 0;
16+
right: 0;
17+
left: 0;
18+
display: flex;
19+
justify-content: center;
20+
align-items: center;
21+
color: black;
22+
23+
/* allow click-through to backdrop */
24+
pointer-events: none;
25+
}
26+
27+
.contents {
28+
min-width: 240px;
29+
border-radius: 6px;
30+
padding: 16px;
31+
background: white;
32+
display: flex;
33+
flex-direction: column;
34+
justify-content: space-between;
35+
pointer-events: auto;
36+
}
37+
.button {
38+
color: black;
39+
border-color: black;
40+
}
41+
42+
h2 {
43+
text-align: center;
44+
font-size: 24px;
45+
}
46+
47+
p {
48+
text-align: center;
49+
margin-top: 16px;
50+
}
51+
52+
.actions {
53+
margin-top: 32px;
54+
display: flex;
55+
flex-direction: column;
56+
justify-content: space-between;
57+
gap: 8px;
58+
}
59+
</style>
60+
61+
{#if isOpen}
62+
<div role="dialog" class="modal">
63+
<div class="contents">
64+
<h2>{title}</h2>
65+
<div class="actions">
66+
{#each options as option}
67+
<button class="button" on:click={() => dispatch("select", option)}>
68+
{option.peerMetadata.logo ?? ""}
69+
{option.peerMetadata.name}
70+
</button>
71+
{/each}
72+
<p>or</p>
73+
<button class="button" on:click={() => dispatch("select", "new_pairing")}
74+
>New Pairing</button
75+
>
76+
</div>
77+
</div>
78+
</div>
79+
{/if}

apps/taquito-test-dapp/src/lib/TestContainer.svelte

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@
55
import { shortenHash } from "../utils";
66
import { NetworkType } from "@airgap/beacon-types";
77
import { getTzKtUrl } from "../config";
8+
import { BeaconWallet } from "@taquito/beacon-wallet";
89
910
let test: TestSettings | undefined;
1011
let executionTime = 0;
1112
let loading = false;
1213
let success: boolean | undefined;
1314
let opHash = "";
14-
let input = { text: "", fee: 400, storageLimit: 400, gasLimit: 1320, amount: 0, address: "", delegate: "", stake: 0, unstake: 0 };
15+
let input = {
16+
text: "",
17+
fee: 400,
18+
storageLimit: 400,
19+
gasLimit: 1320,
20+
amount: 0,
21+
address: "",
22+
delegate: "",
23+
stake: 0,
24+
unstake: 0,
25+
};
1526
let testResult: { id: string; title: string; body: any };
27+
let error: Error | undefined;
1628
1729
const run = async () => {
1830
success = undefined;
@@ -68,9 +80,18 @@
6880
title: "Confirmations through observable",
6981
body: result.confirmationObsOutput,
7082
};
83+
} else if (test.id === "show-public-key") {
84+
testResult = {
85+
id: test.id,
86+
title: "Public Key",
87+
body: {
88+
output: result.output
89+
}
90+
}
7191
}
7292
} else {
73-
throw "Error";
93+
error = result.error;
94+
throw result.error;
7495
}
7596
} catch (error) {
7697
console.log(error);
@@ -82,7 +103,9 @@
82103
};
83104
84105
const switchAccount = async () => {
85-
await $store.wallet.clearActiveAccount();
106+
if ($store.wallet instanceof BeaconWallet) {
107+
await $store.wallet.clearActiveAccount();
108+
}
86109
store.updateUserAddress(undefined);
87110
store.updateUserBalance(undefined);
88111
store.updateWallet(undefined);
@@ -306,21 +329,21 @@
306329
bind:value={input.text}
307330
/>
308331
</div>
309-
{:else if test.inputRequired && test.inputType === "delegate"}
332+
{:else if test.inputRequired && test.inputType === "delegate"}
310333
<div class="test-input set-delegate">
311334
<label for="delegate-address">
312335
<span>Delegate address</span>
313336
<input type="delegate" id="delegate-address" bind:value={input.delegate} />
314337
</label>
315338
</div>
316-
{:else if test.inputRequired && test.inputType === "stake"}
339+
{:else if test.inputRequired && test.inputType === "stake"}
317340
<div class="test-input stake">
318341
<label for="stake-amount">
319342
<span>Stake amount</span>
320343
<input type="stake" id="stake-amount" bind:value={input.stake} />
321344
</label>
322345
</div>
323-
{:else if test.inputRequired && test.inputType === "unstake"}
346+
{:else if test.inputRequired && test.inputType === "unstake"}
324347
<div class="test-input unstake">
325348
<label for="unstake-amount">
326349
<span>Unstake amount</span>
@@ -392,6 +415,15 @@
392415
<h4>
393416
Test failed <span class="material-icons-outlined"> sentiment_very_dissatisfied </span>
394417
</h4>
418+
{#if error}
419+
<div style="word-break:break-word; color:#b92a2a">
420+
{#if error instanceof Error}
421+
{error}
422+
{:else}
423+
{JSON.stringify(error)}
424+
{/if}
425+
</div>
426+
{/if}
395427
</div>
396428
{/if}
397429
<div class="test-run">

0 commit comments

Comments
 (0)