Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('custom', (): void => {
const api = new ApiRx({
derives: {
balances: {
fees: (): any => (): Observable => from(['a', 'b'])
},
custom: {
test: (): any => (): Observable => from([1, 2, 3])
}
},
provider: new MockProvider(registry),
registry
});
beforeAll((done): void => {
api.isReady.subscribe((): void => done());
});
// override
testFunction(api)('balances', 'fees', ['a', 'b']);
// new
testFunction(api)('custom' as any, 'test', [1, 2, 3]);
// existing
testFunction(api)('chain', 'bestNumber', []);
});
it('allows for the definition of user RPCs', (): void => {
const rpc = new Rpc(registry, new MockProvider(registry), {
testing: [
{
name: 'foo',
params: [{ name: 'bar', type: 'u32' }],
type: 'Balance'
}
]
});
expect(isFunction((rpc as any).testing.foo)).toBe(true);
expect(rpc.sections.includes('testing')).toBe(true);
expect(rpc.mapping.get('testing_foo')).toEqual({
description: 'User defined',
isDeprecated: false,
isHidden: false,
isOptional: false,
beforeEach((): void => {
rpc = new Rpc(registry, new MockProvider(registry));
});
beforeEach((): void => {
rpc = new Rpc(registry, new MockProvider(registry));
});
import React from 'react';
import ReactDOM from 'react-dom';
import Mock from '@polkadot/rpc-provider/mock';
import Api from './Api';
import Balance from './Balance';
import BestNumber from './BestNumber';
import Chain from './Chain';
import Connected from './Connected';
import NodeName from './NodeName';
import NodeVersion from './NodeVersion';
import Nonce from './Nonce';
import { withApi } from './with/index';
const provider = new Mock();
const ALICE_ADDR = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ';
const ALICE_PUBLIC = '0xd172a74cda4c865912c32ba0a80a57ae69abae410e5ccb59dee84e2f4432db4f';
const element = document.getElementById('demo');
if (!element) {
throw new Error('Unable to find #demo element');
}
const WithApiDebug = withApi(
(apiProps) => (
<pre style="{{"> {JSON.stringify(apiProps, undefined, 2)}
</pre>
)