Disable claims (non-working) (#10116)
* Disable claims (non-working) * Disable on no buffer
This commit is contained in:
parent
397ee325e0
commit
bc1d40e945
@ -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',
|
||||
|
||||
@ -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';
|
||||
|
||||
13
packages/apps/src/initBufferHack.ts
Normal file
13
packages/apps/src/initBufferHack.ts
Normal 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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user