Skip to content

Commit

Permalink
fix: using trilitech/tezos-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dianasavvatina committed Nov 26, 2024
1 parent b73baa0 commit fabc881
Show file tree
Hide file tree
Showing 5 changed files with 1,689 additions and 2,094 deletions.
10 changes: 7 additions & 3 deletions dapps/tezos-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
},
"dependencies": {
"@airgap/beacon-types": "^4.3.0",
"@airgap/beacon-types": "^4.3.1",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@solana/web3.js": "^1.78.4",
"@taquito/rpc": "^20.0.1",
"@taquito/taquito": "^20.0.1",
"@taquito/taquito": "^20.1.0",
"@trili/tezos-provider": "^1.0.4",
"@walletconnect/keyvaluestorage": ">=1.1.1",
"@walletconnect/logger": ">=2.1.2",
"@walletconnect/modal": "^2.6.2",
"@walletconnect/universal-provider": "^2.14.0",
"@walletconnect/types": ">=2.17.2",
"@walletconnect/universal-provider": "^2.17.2",
"bs58": "^5.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
47 changes: 22 additions & 25 deletions dapps/tezos-provider/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { WalletConnectModal } from "@walletconnect/modal";
import { useEffect, useState, useCallback } from "react";
import { SAMPLES, SAMPLE_KINDS } from "./utils/samples";
import TezosProvider, {
TezosChainDataMainnet,
TezosChainDataTestnet,
} from "./utils/tezos-provider";
import {
TezosProvider,
TezosChainDataTestnet,
TezosGetAccountResponse,
TezosSendResponse,
TezosSignResponse,
} from "./utils/tezos-provider";
import { ErrorObject } from '@walletconnect/utils';
} from "@trili/tezos-provider";
import { ErrorObject } from "@walletconnect/utils";

const projectId = import.meta.env.VITE_PROJECT_ID;

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

try {
await provider.connect({
chains: [TezosChainDataTestnet, TezosChainDataMainnet],
});
await provider.connect({ chain: TezosChainDataTestnet });
setIsConnected(true);
console.log("Connected to Tezos");
const balance = await provider.getBalance();
Expand Down Expand Up @@ -143,26 +139,26 @@ const App = () => {
let res = null;
switch (kind) {
case SAMPLE_KINDS.GET_ACCOUNTS:
res = await provider.tezosGetAccounts();
res = await provider.getAccounts();
break;
case SAMPLE_KINDS.SIGN:
res = await provider.tezosSign("05010000004254");
res = await provider.sign("05010000004254");
break;
case SAMPLE_KINDS.SEND_TRANSACTION:
res = await provider.tezosSendTransaction(
res = await provider.sendTransaction(
SAMPLES[SAMPLE_KINDS.SEND_TRANSACTION],
);
break;
case SAMPLE_KINDS.SEND_DELEGATION:
res = await provider.tezosSendDelegation(
res = await provider.sendDelegation(
SAMPLES[SAMPLE_KINDS.SEND_DELEGATION],
);
break;
case SAMPLE_KINDS.SEND_UNDELEGATION:
res = await provider.tezosSendUndelegation();
res = await provider.sendUndelegation();
break;
case SAMPLE_KINDS.SEND_ORGINATION:
res = await provider.tezosSendOrigination(
res = await provider.sendOrigination(
SAMPLES[SAMPLE_KINDS.SEND_ORGINATION],
);
for (let attempt = 0; attempt < 10; attempt++) {
Expand All @@ -186,28 +182,26 @@ const App = () => {
}
break;
case SAMPLE_KINDS.SEND_CONTRACT_CALL:
res = await provider.tezosSendContractCall({
res = await provider.sendContractCall({
...SAMPLES[SAMPLE_KINDS.SEND_CONTRACT_CALL],
destination: contractAddress,
});
break;
case SAMPLE_KINDS.SEND_STAKE:
res = await provider.tezosSendStake(
SAMPLES[SAMPLE_KINDS.SEND_STAKE],
);
res = await provider.sendStake(SAMPLES[SAMPLE_KINDS.SEND_STAKE]);
break;
case SAMPLE_KINDS.SEND_UNSTAKE:
res = await provider.tezosSendUnstake(
res = await provider.sendUnstake(
SAMPLES[SAMPLE_KINDS.SEND_UNSTAKE],
);
break;
case SAMPLE_KINDS.SEND_FINALIZE:
res = await provider.tezosSendFinalizeUnstake(
res = await provider.sendFinalizeUnstake(
SAMPLES[SAMPLE_KINDS.SEND_FINALIZE],
);
break;
case SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE:
res = await provider.tezosSendIncreasePaidStorage({
res = await provider.sendIncreasePaidStorage({
...SAMPLES[SAMPLE_KINDS.SEND_INCREASE_PAID_STORAGE],
destination: contractAddress,
});
Expand Down Expand Up @@ -253,13 +247,16 @@ const App = () => {
case SAMPLE_KINDS.SEND_STAKE:
case SAMPLE_KINDS.SEND_UNSTAKE:
case SAMPLE_KINDS.SEND_FINALIZE:
setDescription({ ...SAMPLES[kind], destination: provider?.address });
setDescription({
...SAMPLES[kind],
destination: provider?.connection?.address,
});
break;
default:
setDescription("No description available");
}
},
[contractAddress, provider?.address],
[contractAddress, provider?.connection?.address],
);

const describeClear = useCallback(() => {
Expand All @@ -281,7 +278,7 @@ const App = () => {
<>
<p>
<b>Public Key: </b>
{provider?.address ?? "No account connected"}
{provider?.connection?.address ?? "No account connected"}
</p>
<p>
<b>Balance: </b>
Expand Down
Loading

0 comments on commit fabc881

Please sign in to comment.