Skip to content

Commit fabc881

Browse files
fix: using trilitech/tezos-provider
1 parent b73baa0 commit fabc881

File tree

5 files changed

+1689
-2094
lines changed

5 files changed

+1689
-2094
lines changed

dapps/tezos-provider/package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
1313
},
1414
"dependencies": {
15-
"@airgap/beacon-types": "^4.3.0",
15+
"@airgap/beacon-types": "^4.3.1",
1616
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
1717
"@solana/web3.js": "^1.78.4",
1818
"@taquito/rpc": "^20.0.1",
19-
"@taquito/taquito": "^20.0.1",
19+
"@taquito/taquito": "^20.1.0",
20+
"@trili/tezos-provider": "^1.0.4",
21+
"@walletconnect/keyvaluestorage": ">=1.1.1",
22+
"@walletconnect/logger": ">=2.1.2",
2023
"@walletconnect/modal": "^2.6.2",
21-
"@walletconnect/universal-provider": "^2.14.0",
24+
"@walletconnect/types": ">=2.17.2",
25+
"@walletconnect/universal-provider": "^2.17.2",
2226
"bs58": "^5.0.0",
2327
"react": "^18.2.0",
2428
"react-dom": "^18.2.0",

dapps/tezos-provider/src/App.tsx

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { WalletConnectModal } from "@walletconnect/modal";
22
import { useEffect, useState, useCallback } from "react";
33
import { SAMPLES, SAMPLE_KINDS } from "./utils/samples";
4-
import TezosProvider, {
5-
TezosChainDataMainnet,
6-
TezosChainDataTestnet,
7-
} from "./utils/tezos-provider";
84
import {
5+
TezosProvider,
6+
TezosChainDataTestnet,
97
TezosGetAccountResponse,
108
TezosSendResponse,
119
TezosSignResponse,
12-
} from "./utils/tezos-provider";
13-
import { ErrorObject } from '@walletconnect/utils';
10+
} from "@trili/tezos-provider";
11+
import { ErrorObject } from "@walletconnect/utils";
1412

1513
const projectId = import.meta.env.VITE_PROJECT_ID;
1614

@@ -103,9 +101,7 @@ const App = () => {
103101
if (!provider) return;
104102

105103
try {
106-
await provider.connect({
107-
chains: [TezosChainDataTestnet, TezosChainDataMainnet],
108-
});
104+
await provider.connect({ chain: TezosChainDataTestnet });
109105
setIsConnected(true);
110106
console.log("Connected to Tezos");
111107
const balance = await provider.getBalance();
@@ -143,26 +139,26 @@ const App = () => {
143139
let res = null;
144140
switch (kind) {
145141
case SAMPLE_KINDS.GET_ACCOUNTS:
146-
res = await provider.tezosGetAccounts();
142+
res = await provider.getAccounts();
147143
break;
148144
case SAMPLE_KINDS.SIGN:
149-
res = await provider.tezosSign("05010000004254");
145+
res = await provider.sign("05010000004254");
150146
break;
151147
case SAMPLE_KINDS.SEND_TRANSACTION:
152-
res = await provider.tezosSendTransaction(
148+
res = await provider.sendTransaction(
153149
SAMPLES[SAMPLE_KINDS.SEND_TRANSACTION],
154150
);
155151
break;
156152
case SAMPLE_KINDS.SEND_DELEGATION:
157-
res = await provider.tezosSendDelegation(
153+
res = await provider.sendDelegation(
158154
SAMPLES[SAMPLE_KINDS.SEND_DELEGATION],
159155
);
160156
break;
161157
case SAMPLE_KINDS.SEND_UNDELEGATION:
162-
res = await provider.tezosSendUndelegation();
158+
res = await provider.sendUndelegation();
163159
break;
164160
case SAMPLE_KINDS.SEND_ORGINATION:
165-
res = await provider.tezosSendOrigination(
161+
res = await provider.sendOrigination(
166162
SAMPLES[SAMPLE_KINDS.SEND_ORGINATION],
167163
);
168164
for (let attempt = 0; attempt < 10; attempt++) {
@@ -186,28 +182,26 @@ const App = () => {
186182
}
187183
break;
188184
case SAMPLE_KINDS.SEND_CONTRACT_CALL:
189-
res = await provider.tezosSendContractCall({
185+
res = await provider.sendContractCall({
190186
...SAMPLES[SAMPLE_KINDS.SEND_CONTRACT_CALL],
191187
destination: contractAddress,
192188
});
193189
break;
194190
case SAMPLE_KINDS.SEND_STAKE:
195-
res = await provider.tezosSendStake(
196-
SAMPLES[SAMPLE_KINDS.SEND_STAKE],
197-
);
191+
res = await provider.sendStake(SAMPLES[SAMPLE_KINDS.SEND_STAKE]);
198192
break;
199193
case SAMPLE_KINDS.SEND_UNSTAKE:
200-
res = await provider.tezosSendUnstake(
194+
res = await provider.sendUnstake(
201195
SAMPLES[SAMPLE_KINDS.SEND_UNSTAKE],
202196
);
203197
break;
204198
case SAMPLE_KINDS.SEND_FINALIZE:
205-
res = await provider.tezosSendFinalizeUnstake(
199+
res = await provider.sendFinalizeUnstake(
206200
SAMPLES[SAMPLE_KINDS.SEND_FINALIZE],
207201
);
208202
break;
209203
case SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE:
210-
res = await provider.tezosSendIncreasePaidStorage({
204+
res = await provider.sendIncreasePaidStorage({
211205
...SAMPLES[SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE],
212206
destination: contractAddress,
213207
});
@@ -253,13 +247,16 @@ const App = () => {
253247
case SAMPLE_KINDS.SEND_STAKE:
254248
case SAMPLE_KINDS.SEND_UNSTAKE:
255249
case SAMPLE_KINDS.SEND_FINALIZE:
256-
setDescription({ ...SAMPLES[kind], destination: provider?.address });
250+
setDescription({
251+
...SAMPLES[kind],
252+
destination: provider?.connection?.address,
253+
});
257254
break;
258255
default:
259256
setDescription("No description available");
260257
}
261258
},
262-
[contractAddress, provider?.address],
259+
[contractAddress, provider?.connection?.address],
263260
);
264261

265262
const describeClear = useCallback(() => {
@@ -281,7 +278,7 @@ const App = () => {
281278
<>
282279
<p>
283280
<b>Public Key: </b>
284-
{provider?.address ?? "No account connected"}
281+
{provider?.connection?.address ?? "No account connected"}
285282
</p>
286283
<p>
287284
<b>Balance: </b>

0 commit comments

Comments
 (0)