I am trying to send the transection while I wait for transection due to getJsonRpcClient is deprecated since i tried to do it with getgrpcClient still facing error the code is.
function _wait(provider, txnHash, res, rej) {
setTimeout(() => {
provider
// .getJsonRpcClient()
.getGrpcClient()
.getTransactionStatus(txnHash)
.then(txnStatus => {
if (!txnStatus) {
return rej(“Transaction Status is null”);
}
}, 1000);
}
with using getGrpcClient if a face this error
typeError:A.getGrpc(…).getTransactionStatus is not a function
If i use the getJsonRpcClient() i face this error
typeerror:A.getJsonRpcClient is not a function
I am calling it in this while I getting the Provider and txnhash
function waitForTransaction(provider, txnHash) {
return new Promise((res, rej) => {
_wait(provider, txnHash, res, rej);
});
}
The JSON RPC client has been removed from the wallet API after being deprecated for a long while, so the only way to communicate with a Concordium node is through GRPC.
The recommended way to do this with the our Concordium wallet for web is described at the bottom of the documentation for @concordium/browser-wallet-api-helpers, which also documents the interface of the Concordium Wallet API. Please note that the latest version of this has @concordium/web-sdk@7 is a peer dependency here, meaning you need to have this installed in your project as well.
Since you have a reference to a provider in your code, I assume you’re using @concordium/browser-wallet-api-helpers in your project. Which version of this package are you using?
If you get your dependencies up to date by doing the following:
npm install --save @concordium/browser-wallet-api-helpers @concordium/web-sdk # or yarn if you use that
You should be able to do the following (which I think is what you’re trying to achieve):
import { detectConcordiumProvider } from '@concordium/browser-wallet-api-helpers';
import { ConcordiumGRPCClient } from '@concordium/web-sdk';
...
const provider = await detectConcordiumProvider();
const client = new ConcordiumGRPCClient(provider.grpcTransport);
const transactionHash = await provider.sendTransaction(...); // wait for user approval in wallet
const status = await client.waitForTransactionFinalization(transactionHash); // wait for transaction to finalize
Please let me know if that works for you, or if you face any other issues while trying to do this.
thanks for your consideration in this matter I have done that thanks for your support if you can look at this function I am facing a problem like I don’t get the txnstatus receiving [Object,Object] how can i get the status in console.info in my code the code is.
function _wait(provider, txnHash, res, rej) {
console.log(provider, txnHash, “params fro wait”);
setTimeout(() => {
provider
.getGrpcClient()
.waitForTransactionFinalization(txnHash)
.then(txnStatus => {
if (!txnStatus) {
return rej(“Transaction Status is null”);
}
The type returned by waitForTransactionFinalization is an object that has a status property on it. Have a look here at the function signature: ConcordiumGRPCClient | Concordium JS-SDK
I really appreciate your effort and helping. I am know don’t using my custom wait function for wait transection know I am simply just doing this at the end of the Update contract function.