Move sortJson into @cosmwasm/sdk

This commit is contained in:
Simon Warta
2020-02-04 12:43:40 +01:00
parent ee2c621fba
commit 8034ae7bc6
5 changed files with 22 additions and 21 deletions
+1 -19
View File
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */
import { marshalTx, unmarshalTx } from "@cosmwasm/sdk";
import { marshalTx, sortJson, unmarshalTx } from "@cosmwasm/sdk";
import {
Address,
ChainId,
@@ -24,24 +24,6 @@ import { nonceToAccountNumber, nonceToSequence, TokenInfos } from "./types";
const { toUtf8 } = Encoding;
function sortJson(json: any): any {
if (typeof json !== "object" || json === null) {
return json;
}
if (Array.isArray(json)) {
return json.map(sortJson);
}
const sortedKeys = Object.keys(json).sort();
const result = sortedKeys.reduce(
(accumulator, key) => ({
...accumulator,
[key]: sortJson(json[key]),
}),
{},
);
return result;
}
export class CosmWasmCodec implements TxCodec {
private readonly prefix: CosmosBech32Prefix;
private readonly tokens: TokenInfos;