Skip to content

Commit

Permalink
Disable claims (non-working) (#10116)
Browse files Browse the repository at this point in the history
* Disable claims (non-working)

* Disable on no buffer
  • Loading branch information
jacogr authored Dec 19, 2023
1 parent 397ee32 commit bc1d40e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
26 changes: 25 additions & 1 deletion packages/apps-routing/src/claims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -12,7 +35,8 @@ export default function create (t: TFunction): Route {
needsAccounts: true,
needsApi: [
'tx.claims.mintClaim'
]
],
needsApiCheck
},
group: 'accounts',
icon: 'star',
Expand Down
1 change: 1 addition & 0 deletions packages/apps/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 13 additions & 0 deletions packages/apps/src/initBufferHack.ts
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit bc1d40e

Please sign in to comment.