ghost-portal/packages/page-alliance/src/util.ts
Jaco 4e90ec9663
IPFS compatible text input for alliance CID (#7928)
* IPFS compatible text input for alliance CID

* Adjust detect
2022-07-28 17:18:40 +03:00

23 lines
677 B
TypeScript

// Copyright 2017-2022 @polkadot/app-alliance authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { PalletAllianceCid } from '@polkadot/types/lookup';
import type { Registry } from '@polkadot/types/types';
import type { Cid } from './types';
import { fromIpfsCid, toIpfsCid } from '@polkadot/react-params/util';
export function createPalletCid (registry: Registry, cid: string): PalletAllianceCid | null {
const expanded = fromIpfsCid(cid);
return expanded && registry.createType('PalletAllianceCid', expanded);
}
export function createCid (cid: PalletAllianceCid): Cid {
return {
cid,
ipfs: toIpfsCid(cid),
key: cid.toHex()
};
}