Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getSmartContractSubState(
addr: string,
variableName: string,
indices?: string[],
): Promise> {
const address = validation.isBech32(addr) ? fromBech32Address(addr) : addr;
if (!variableName) {
throw new Error('Variable name required');
}
return this.provider.send(
RPCMethod.GetSmartContractSubState,
address.replace('0x', '').toLowerCase(),
variableName,
indices === undefined ? [] : indices,
);
}
async getSubState(variableName: string, indices?: string[]): Promise {
if (this.status !== ContractStatus.Deployed) {
return Promise.resolve([]);
}
if (!this.address) {
throw new Error('Cannot get state of uninitialised contract');
}
if (!variableName) {
throw new Error('Variable name required');
}
const response = await this.provider.send(
RPCMethod.GetSmartContractSubState,
this.address.replace('0x', '').toLowerCase(),
variableName,
indices === undefined ? [] : indices,
);
return response.result;
}