How to use the @polkadot/extrinsics/fromMetadata function in @polkadot/extrinsics

To help you get started, we’ve selected a few @polkadot/extrinsics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / api / packages / api-observable / src / Base.ts View on Github external
this.isConnected().subscribe(async (isConnected) => {
        if (!isConnected) {
          return;
        }

        try {
          // FIXME This now gets done in api/Base as well, cleanup as soon as we
          // have apis based on api-rx & api-promise (For now a bit of inefficiency)
          const meta = await this._api.state.getMetadata().toPromise();

          this._genesisHash = await this._api.chain.getBlockHash(0).toPromise();

          ApiBase.extrinsics = extrinsicsFromMeta(meta);
          ApiBase.storage = storageFromMeta(meta);

          Event.injectMetadata(meta);
          Method.injectMethods(ApiBase.extrinsics);

          if (!isReady) {
            isReady = true;
            resolveReady(true);
          }
        } catch (error) {
          console.error(error);
        }
      });
    });
github polkadot-js / api / packages / types / src / Metadata / v1 / Metadata.spec.ts View on Github external
describe('storage with default values', () => {
    Method.injectMethods(extrinsicsFromMeta(metadata));

    metadata.asV1.modules
      .filter(({ storage }) => storage.isSome)
      .map((mod) =>
        mod.storage.unwrap().forEach(({ fallback, name, type }) => {
          it(`creates default types for ${mod.prefix}.${name}, type ${type}`, () => {
            expect(
              () => createType(type.toString(), fallback)
            ).not.toThrow();
          });
        })
      );
  });
});