@polkadot/api/types#ApiOptions TypeScript Examples
The following examples show how to use
@polkadot/api/types#ApiOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From bodhi.js with Apache License 2.0 | 7 votes |
getTestProvider = (urlOverwrite?: string, opts?: ApiOptions): TestProvider => {
const url = urlOverwrite || process.env.ENDPOINT_URL || DEFAULT_URL;
const provider = new TestProvider({
provider: new WsProvider(url),
...opts
});
console.log(`test provider connected to ${url}`);
return provider;
}
Example #2
Source File: chain-api.ts From bodhi.js with Apache License 2.0 | 6 votes |
createApi = (endpoints: string | string[], apiOptions?: ApiOptions): ApiPromise => {
const wsProvider = new WsProvider(endpoints);
return new ApiPromise(
createApiOptions({
types: {
...TYPES,
...apiOptions?.types
},
provider: wsProvider,
...apiOptions
})
);
}
Example #3
Source File: shared.ts From commonwealth with GNU General Public License v3.0 | 6 votes |
public async resetApi(selectedChain: ChainInfo, additionalOptions?): Promise<ApiPromise> {
const provider = await this.createApiProvider(selectedChain.node);
// note that we reuse the same provider and type registry to create both an rxjs
// and a promise-based API -- this avoids creating multiple connections to the node
const options: ApiOptions = {
provider,
...additionalOptions,
};
this._api = await ApiPromise.create(options);
return this._api;
}
Example #4
Source File: index.ts From parity-bridges-ui with GNU General Public License v3.0 | 6 votes |
getProviderInfo = (chainNumber: string, types: ApiOptions['types']) => {
const providedHasher = process.env[`REACT_APP_CHAIN_${chainNumber}_CUSTOM_HASHER`];
const providerUrl = checkEnvVariable(`REACT_APP_CHAIN_${chainNumber}_SUBSTRATE_PROVIDER`);
const hasher = (providedHasher && hashers && hashers[providedHasher]) || null;
const polkadotjsUrl = createPolkadotJsUrl(types!, providerUrl);
return {
hasher,
provider: new WsProvider(providerUrl),
polkadotjsUrl,
types
};
}
Example #5
Source File: Provider.ts From evm-provider.js with Apache License 2.0 | 6 votes |
/**
*
* @param _apiOptions
* @param dataProvider
*/
constructor(_apiOptions: ApiOptions, dataProvider?: AbstractDataProvider) {
const apiOptions = options(_apiOptions);
this.api = new ApiPromise(apiOptions);
this.resolveApi = this.api.isReady;
this._isProvider = true;
this.dataProvider = dataProvider;
this.scanner = new Scanner({
wsProvider: apiOptions.provider as WsProvider,
types: apiOptions.types,
typesAlias: apiOptions.typesAlias,
typesSpec: apiOptions.typesSpec,
typesChain: apiOptions.typesChain,
typesBundle: apiOptions.typesBundle
});
}
Example #6
Source File: TestProvider.ts From bodhi.js with Apache License 2.0 | 5 votes |
constructor(_apiOptions?: ApiOptions) {
const provider = _apiOptions?.provider || new WsProvider('ws://127.0.0.1:9944');
super({ provider, ..._apiOptions });
}
Example #7
Source File: chain-api.ts From bodhi.js with Apache License 2.0 | 5 votes |
defaultOptions: ApiOptions = { types: acalaTypes, rpc: acalaRpc }
Example #8
Source File: chain-api.ts From bodhi.js with Apache License 2.0 | 5 votes |
createApiOptions = ({
types = {},
rpc = {},
typesAlias = {},
typesBundle = {},
signedExtensions,
...otherOptions
}: ApiOptions = {}): ApiOptions => ({
types: {
...types
},
rpc: {
...acalaRpc,
...rpc
},
typesAlias: {
...acalaTypesAlias,
...typesAlias
},
typesBundle: {
...typesBundle,
spec: {
...typesBundle.spec,
acala: {
...acalaTypesBundle?.spec?.acala,
...typesBundle?.spec?.acala
},
mandala: {
...acalaTypesBundle?.spec?.mandala,
...typesBundle?.spec?.mandala
},
karura: {
...acalaTypesBundle?.spec?.karura,
...typesBundle?.spec?.mandala
}
}
},
signedExtensions: {
...acalaSignedExtensions,
...signedExtensions
},
...otherOptions
})
Example #9
Source File: signer-provider.ts From bodhi.js with Apache License 2.0 | 5 votes |
static from(apiOptions: ApiOptions): SignerProvider {
return new SignerProvider(apiOptions);
}
Example #10
Source File: signer-provider.ts From bodhi.js with Apache License 2.0 | 5 votes |
constructor(apiOptions: ApiOptions) {
super();
const api = new ApiPromise(createApiOptions(apiOptions));
this.setApi(api);
}