cosmwasm: Handle other null cases in LCD query

This commit is contained in:
willclarktech 2020-10-08 13:58:21 +02:00
parent 84766217f8
commit 085f29f76c
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7

View File

@ -160,7 +160,7 @@ export function setupWasmExtension(base: LcdClient): WasmExtension {
const path = `/wasm/contract/${address}/raw/${hexKey}?encoding=hex`;
const responseData = (await base.get(path)) as WasmResponse<WasmData[]>;
const data = unwrapWasmResponse(responseData);
return data.length === 0 ? null : fromBase64(data[0].val);
return data === null || data.length === 0 || data[0] === undefined ? null : fromBase64(data[0].val);
},
queryContractSmart: async (address: string, query: Record<string, unknown>) => {
const encoded = toHex(toUtf8(JSON.stringify(query)));