I'm not sure if this is a documentation issue or a nucypher-ts bug.
If we check Conditions.RpcCondition docs, we see there are two ways of creating this condition. But both of them return errors if used as described in docs:
- Using RpcCondition:
const const rpc = new Conditions.RpcCondition({
chain: 1,
method: 'eth_getBalance',
parameters: [
":userAddress",
"latest"
],
returnValueTest: {
comparator: ">=",
value: 10000000000000
}
});
- Using Condition:
const rpcConfig = {
contractAddress: '',
standardContractType: '',
chain: 1,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: 10000000000000,
},
};
const rpc = Conditions.Condition(rpcConfig);
If we use in the code the former one, we get an error:
"returnValueTest.value" must be a string
This error is fixed if we pass the Object key value
as string instead of as number:
returnValueTest: {
comparator: ">=",
value: "10000000000000"
}
However, in the latter option, we can use both, string and number types, for the key value
.
Should we homogenize this behavior by allowing only one type (string or number)?
Another issue is that the latter option returns error:
Error: Request failed with status code 500
It only works if we delete the two first keys of the config object:
const rpcConfig = {
contractAddress: '', // DELETE THIS
standardContractType: '', // DELETE THIS
chain: 1,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: 10000000000000,
},
};
Also, we have the same problems in Conditions.TimelockCondition.