Skip to content

Commit

Permalink
fix: display stargate message correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
quanpt239 committed Jan 10, 2025
1 parent d89c2a7 commit 08c7e47
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
},
"dependencies": {
"@codemirror/lang-json": "^6.0.1",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@rjsf/core": "^5.1.0",
"@rjsf/utils": "^5.1.0",
"@rjsf/validator-ajv8": "^5.6.2",
Expand All @@ -19,9 +21,7 @@
"next": "^14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-select": "^5.7.5",
"@cosmjs/cosmwasm-stargate": "^0.32.4",
"@cosmjs/stargate": "^0.32.4"
"react-select": "^5.7.5"
},
"devDependencies": {
"@oraichain/common-contracts-sdk": "^1.0.31",
Expand Down
19 changes: 17 additions & 2 deletions util/conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,21 @@ export const decodeProto = (
const typeUrl = value.type_url || value.typeUrl;
if (typeUrl) {
// decode proto
return decodeProto(customRegistry.decode({ typeUrl, value: value.value }));
if (typeof value.value === 'object' && !Array.isArray(value.value)) {
return value;
}
if (typeof value.value === 'string') {
try {
value.value = fromBinary(value.value);
} catch {
value.value = Buffer.from(value.value, 'base64');
}
}
const decodedValue = customRegistry.decode({ typeUrl, value: value.value });
return {
type_url: typeUrl,
value: decodeProto(decodedValue),
};
}
for (const k in value) {
if (
Expand All @@ -110,8 +124,9 @@ export const decodeProto = (
value[k] = fromBinary(value[k]);
} catch {}
}
if (typeof value[k] === 'object')
if (typeof value[k] === 'object') {
value[k] = decodeProto(value[k], decodeBase64Recursive, path + '.' + k);
}
}
if (value.msg instanceof Uint8Array)
value.msg = JSON.parse(fromAscii(value.msg));
Expand Down

0 comments on commit 08c7e47

Please sign in to comment.