mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-06-23 18:51:07 +00:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/apps-routing authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { Route, TFunction } from './types.js';
|
|
|
|
import Component, { useCounter } from '@pezkuwi/app-claims';
|
|
import { hasBuffer, u8aToBuffer } from '@pezkuwi/util';
|
|
|
|
// See https://github.com/pezkuwichain/pezkuwi-apps/issues/10115 - this may not work,
|
|
// if not we will have to disable it all (no way of testing)
|
|
function needsApiCheck (): boolean {
|
|
try {
|
|
if (!Buffer.from([1, 2, 3])?.length) {
|
|
console.error('ERROR: Unable to construct Buffer object for claims module');
|
|
|
|
return false;
|
|
} else if (!hasBuffer || !Buffer.isBuffer(u8aToBuffer(new Uint8Array([1, 2, 3])))) {
|
|
console.error('ERROR: Unable to use u8aToBuffer for claims module');
|
|
|
|
return false;
|
|
}
|
|
} catch {
|
|
console.error('ERROR: Fatal error in working with Buffer module');
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
export default function create (t: TFunction): Route {
|
|
return {
|
|
Component,
|
|
display: {
|
|
needsAccounts: true,
|
|
needsApi: [
|
|
'tx.claims.mintClaim'
|
|
],
|
|
needsApiCheck
|
|
},
|
|
group: 'accounts',
|
|
icon: 'star',
|
|
name: 'claims',
|
|
text: t('nav.claims', 'Claim Tokens', { ns: 'apps-routing' }),
|
|
useCounter
|
|
};
|
|
}
|