ghost-portal/packages/ui-api/src/util/isEqual.ts
Jaco Greeff 19258df2c6
Display transaction fees on signer (#596)
* Move fee display component to ui-signer

* Format fee display

* Cleanup Fees, adjust calls with no params

* WIP

* WIP

* Cleanup derive file naming)

* Fees align with transfer

* Calculate fees (minimum) around proposals

* Apply nonce length correctly
2019-01-14 12:55:36 +01:00

33 lines
743 B
TypeScript

// Copyright 2017-2019 @polkadot/ui-api authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
function flatten (key: string | null, value: any): any {
if (!value) {
return value;
}
if (value.$$typeof) {
return '';
}
if (Array.isArray(value)) {
return value.map((item) =>
flatten(null, item)
);
}
return value;
}
export default function isEqual <T> (a?: T, b?: T, debug: boolean = false): boolean {
const jsonA = JSON.stringify({ test: a }, flatten);
const jsonB = JSON.stringify({ test: b }, flatten);
if (debug) {
console.log('jsonA', jsonA, 'jsonB', jsonB);
}
return jsonA === jsonB;
}