You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
The Concordium provider that you get from detectConcordiumProvider has a nice interface for contract init and update where it automatically serializes the parameters using a provided schema. But when you want to invoke a contract, you have to go down one level of abstraction and use jsonRpcClient.
It would be great if we could add a helper method for invoking contracts at the same level of abstraction as init and update.
Current
With contract updates, we can provide a JSON parameter and a module schema as a string
But for invocations, you have to use the json rpc client directly, which is at a lower level of abstraction.
Here, you have to serialize the parameter and deserialize the return value manually.
You also have to specify contract and entrypoint as two separate parameters, instead of a receive name (<contract_name>.<entrypoint_name>).
const inputParams = serializeUpdateContractParameters("voting.view", { my: "JSON parameter"}, rawModuleSchema);
client.getJsonRpcClient().invokeContract({ // Using json rpc client
contract: { index: BigInt(contractIndex), subindex: BigInt(0) },
method: 'voting.view',
parameter: inputParams
})
.then((viewResult) => {
let returnValue = concordiumSDK.deserializeReceiveReturnValue(
concordiumSDK.toBuffer(viewResult.returnValue, 'hex'),
concordiumSDK.toBuffer(rawModuleSchema, 'base64'),
"voting",
"view", // NOTE: Here it is just the entrypoint name, i.e. the contract name is not prepended.
concordiumSDK.SchemaVersion.V2
);
})
.catch(alert);
Suggestion
client.invokeContract({ // <-- Helper function directly on client
contract: { index: BigInt(contractIndex), subindex: BigInt(0) },
method: 'voting.view',
parameter: { my: "JSON parameter" }, // <-- Directly provide json schema
rawModuleSchema // <-- And schema
})
.then((viewResult) => {
// The viewResult is the deserialized return value.
let field_a = viewResult.a;
})
.catch(alert);
The text was updated successfully, but these errors were encountered:
Can I add to this that it would also be nice to expose CIS2 functionality for querying balance and metadata directly. Like the cis2Client we have in the Rust SDK.
Description
The Concordium provider that you get from
detectConcordiumProvider
has a nice interface for contract init and update where it automatically serializes the parameters using a provided schema. But when you want to invoke a contract, you have to go down one level of abstraction and use jsonRpcClient.It would be great if we could add a helper method for invoking contracts at the same level of abstraction as init and update.
Current
With contract updates, we can provide a JSON parameter and a module schema as a string
But for invocations, you have to use the json rpc client directly, which is at a lower level of abstraction.
Here, you have to serialize the parameter and deserialize the return value manually.
You also have to specify contract and entrypoint as two separate parameters, instead of a receive name (
<contract_name>.<entrypoint_name>
).Suggestion
The text was updated successfully, but these errors were encountered: