fix constract state
This commit is contained in:
parent
cb426251ba
commit
badd7c2c48
@ -1,3 +1,4 @@
|
||||
import { fromAscii, toBase64 } from '@cosmjs/encoding';
|
||||
import type { Timestamp } from 'cosmjs-types/google/protobuf/timestamp';
|
||||
|
||||
export function getLocalObject(name: string) {
|
||||
@ -16,6 +17,19 @@ export const percent = (num: number) => {
|
||||
return parseFloat((num * 100).toFixed(2));
|
||||
};
|
||||
|
||||
export const decodeBuffer = (value: Uint8Array) => {
|
||||
try {
|
||||
const strValue = fromAscii(value);
|
||||
try {
|
||||
return JSON.parse(strValue);
|
||||
} catch {
|
||||
return strValue;
|
||||
}
|
||||
} catch {
|
||||
return toBase64(value);
|
||||
}
|
||||
};
|
||||
|
||||
export function stringToUint8Array(str: string) {
|
||||
const arr = [];
|
||||
for (let i = 0, j = str.length; i < j; ++i) {
|
||||
|
||||
@ -24,6 +24,7 @@ import type { QueryAllContractStateResponse } from 'cosmjs-types/cosmwasm/wasm/v
|
||||
import type { ContractInfo } from 'cosmjs-types/cosmwasm/wasm/v1/types';
|
||||
import { fromAscii } from '@cosmjs/encoding';
|
||||
import type { ExtraTxSearchResponse } from '@/libs/client';
|
||||
import { decodeBuffer } from '@/libs/utils';
|
||||
|
||||
const chainStore = useBlockchain();
|
||||
const baseStore = useBaseStore();
|
||||
@ -308,9 +309,9 @@ const result = ref({});
|
||||
<JsonViewer
|
||||
:value="
|
||||
state.models?.map((v) => ({
|
||||
key: fromAscii(v.key),
|
||||
value: JSON.parse(fromAscii(v.value)),
|
||||
})) || ''
|
||||
key: decodeBuffer(v.key),
|
||||
value: decodeBuffer(v.value),
|
||||
})) || []
|
||||
"
|
||||
:theme="baseStore.theme || 'dark'"
|
||||
style="background: transparent"
|
||||
|
||||
@ -11,6 +11,7 @@ import type {
|
||||
QueryCodesResponse,
|
||||
} from 'cosmjs-types/cosmwasm/wasm/v1/query';
|
||||
import { toBase64 } from '@cosmjs/encoding';
|
||||
import { accessTypeToJSON } from 'cosmjs-types/cosmwasm/wasm/v1/types';
|
||||
|
||||
const props = defineProps(['chain']);
|
||||
|
||||
@ -72,7 +73,7 @@ function myContracts() {
|
||||
</td>
|
||||
<td>{{ v.creator }}</td>
|
||||
<td>
|
||||
{{ v.instantiatePermission?.permission }}
|
||||
{{ accessTypeToJSON(v.instantiatePermission?.permission) }}
|
||||
<span
|
||||
>{{ v.instantiatePermission?.address }}
|
||||
{{ v.instantiatePermission?.addresses.join(', ') }}</span
|
||||
|
||||
Loading…
Reference in New Issue
Block a user