Disable claims (non-working) (#10116)

* Disable claims (non-working)

* Disable on no buffer
This commit is contained in:
Jaco 2023-12-19 14:28:48 +02:00 committed by GitHub
parent 397ee325e0
commit bc1d40e945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 1 deletions

View File

@ -4,6 +4,29 @@
import type { Route, TFunction } from './types.js';
import Component, { useCounter } from '@polkadot/app-claims';
import { hasBuffer, u8aToBuffer } from '@polkadot/util';
// See https://github.com/polkadot-js/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 {
@ -12,7 +35,8 @@ export default function create (t: TFunction): Route {
needsAccounts: true,
needsApi: [
'tx.claims.mintClaim'
]
],
needsApiCheck
},
group: 'accounts',
icon: 'star',

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// setup these right at front
import './initBufferHack.js';
import './initSettings.js';
import 'semantic-ui-css/semantic.min.css';
import '@polkadot/react-components/i18n';

View File

@ -0,0 +1,13 @@
// Copyright 2017-2023 @polkadot/apps authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { xglobal } from '@polkadot/x-global';
try {
// HACK: Construct a Buffer to ensure that it is actually available in our context
if (Buffer.from([1, 2, 3]).length === 3) {
xglobal.Buffer = Buffer;
}
} catch {
// ignore
}