Closed gfusee closed 1 year ago
Workaround:
axios.get('your.abi.json').then((response) => {
const networkProvider = new ProxyNetworkProvider(
'https://devnet-gateway.elrond.com' // or the main/test net
);
const abiRegistry = AbiRegistry.create(response.data);
const abi = new SmartContractAbi(abiRegistry);
const contract = new SmartContract({
address: new Address(yourConfig.contractAddress),
abi: abi
});
// here
const gameStateType = abiRegistry.getEnum('GameState');
const interaction = contract.methodsExplicit.stateToGames([
EnumValue.fromName(gameStateType, "WaitingPlayer")
]);
const query = interaction.buildQuery();
networkProvider.queryContract(query).then((queryResponse) => {
const endpointDefinition = interaction.getEndpoint();
const resultsParser = new ResultsParser();
const { firstValue, secondValue, returnCode } =
resultsParser.parseQueryResponse(queryResponse, endpointDefinition);
});
});
Hi,
It seems convertToTypedValue method from NativeSerializer cannot handle enum, the workaround is to not currently use ABI to call endpoints that require enum
I'm using erdjs 10.2.4
Thank you