Skip to content

Commit

Permalink
[BRO-9] Add addCIS2Tokens to the wCCD example
Browse files Browse the repository at this point in the history
Use BrowserWalletConnector instead of detectConcordiumProvider
  • Loading branch information
Ivan-Mahda committed Apr 3, 2024
1 parent c5f76c1 commit 4ea073c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions examples/wCCD/src/wCCD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ import {
import * as leb from '@thi.ng/leb128';
import { multiply, round } from 'mathjs';

import { useGrpcClient, WalletConnectionProps, useConnect, useConnection } from '@concordium/react-components';
import { detectConcordiumProvider } from '@concordium/browser-wallet-api-helpers';
import {
useGrpcClient,
WalletConnectionProps,
useConnect,
useConnection,
BrowserWalletConnector,
} from '@concordium/react-components';
import { wrap, unwrap } from './utils';
import {
CONTRACT_SUB_INDEX,
Expand Down Expand Up @@ -133,14 +138,14 @@ async function updateWCCDBalanceAccount(rpcClient: ConcordiumGRPCClient, account

function addWCDToWallet(
_accountAddress: string,
client: WalletApi,
connection: BrowserWalletConnector,
tokenIds: string[],
contractAddressSource: number | bigint,
contractSubindex: number | bigint
) {
const accountAddress = AccountAddress.fromBase58(_accountAddress);
const contractAddress = ContractAddress.create(contractAddressSource, contractSubindex);
return client.addCIS2Tokens(accountAddress, tokenIds, contractAddress);
return connection.client.addCIS2Tokens(accountAddress, tokenIds, contractAddress);
}

interface ConnectionProps {
Expand Down Expand Up @@ -450,7 +455,7 @@ export default function wCCD(props: ConnectionProps) {
disabled={account === undefined}
onClick={() => {
if (account) {
addWCDToWallet(account, connection.client, [''], wCCDContractIndex, CONTRACT_SUB_INDEX);
addWCDToWallet(account, connection, [''], wCCDContractIndex, CONTRACT_SUB_INDEX);
}
}}
>
Expand Down

0 comments on commit 4ea073c

Please sign in to comment.