How to use the @polkadot/extrinsics/codec/encode/unchecked 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 / type-primitives / src / codec / block / encode.spec.js View on Github external
it('encodes a block correctly (actual values)', () => {
    expect(
      encodeBlock(
        blockBuilder({
          header: {
            number: 9,
            parentHash: hexToU8a('0x737d699e4e42f78dc2fb098f01bb85389f2c7f0a77bb41918adac6bfa5b3ee46'),
            stateRoot: hexToU8a('0xf707774183723f201b875024069f30e7089b7f83c3c3cdc534b10d15fca91262')
          },
          extrinsics: [
            encodeUnchecked
              (keyring.nobody, 0,
              extrinsics.timestamp.public.set,
              [0x5b13c3a4]
            ),
            encodeUnchecked(
              keyring.nobody, 0,
              extrinsics.parachains.public.setHeads,
              [[]]
            )
          ]
        })
      )
    ).toEqual(
      new Uint8Array([
        115, 125, 105, 158, 78, 66, 247, 141, 194, 251, 9, 143, 1, 187, 133, 56, 159, 44, 127, 10, 119, 187, 65, 145, 138, 218, 198, 191, 165, 179, 238, 70, 9, 0, 0, 0, 0, 0, 0, 0, 247, 7, 119, 65, 131, 114, 63, 32, 27, 135, 80, 36, 6, 159, 48, 231, 8, 155, 127, 131, 195, 195, 205, 197, 52, 177, 13, 21, 252, 169, 18, 98, 140, 102, 133, 98, 214, 123, 73, 173, 122, 252, 247, 48, 181, 86, 77, 188, 213, 161, 17, 19, 73, 96, 158, 181, 249, 69, 97, 15, 186, 12, 45, 157, 0, 0, 0, 0, 2, 0, 0, 0, 111, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 164, 195, 19, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
      ])
      // hexToU8a(
      //   '0x737d699e4e42f78dc2fb098f01bb85389f2c7f0a77bb41918adac6bfa5b3ee460900000000000000f707774183723f201b875024069f30e7089b7f83c3c3cdc534b10d15fca91262ab602f7974bbfb513f021f39777e2195094dc64a2c1b7c82a1781cb9fd4768a800000000020000006e0000000000000000000000000000000000000000000000000000000000000000000000000000000300a4c3135b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006a00000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
      // )
    );
  });
github polkadot-js / api / packages / type-primitives / src / create / extrinsic / rootRaw.spec.js View on Github external
it('calculates the root correctly (actual)', () => {
    expect(
      root([
        encodeUnchecked(
          keyring.nobody, 0,
          extrinsics.timestamp.public.set,
          [0x5b13c3a4]
        ),
        encodeUnchecked(
          keyring.nobody, 0,
          extrinsics.parachains.public.setHeads,
          [[]]
        )
      ])
    ).toEqual(
      new Uint8Array([
        140, 102, 133, 98, 214, 123, 73, 173, 122, 252, 247, 48, 181, 86, 77, 188, 213, 161, 17, 19, 73, 96, 158, 181, 249, 69, 97, 15, 186, 12, 45, 157
      ])
      // hexToU8a(
      //   '0xab602f7974bbfb513f021f39777e2195094dc64a2c1b7c82a1781cb9fd4768a8'
github polkadot-js / common / packages / type-primitives / src / create / extrinsic / rootRaw.spec.js View on Github external
it('calculates the root correctly (actual)', () => {
    expect(
      root([
        encodeUnchecked(keyring.nobody, 0)(
          extrinsics.timestamp.public.set,
          [0x5b13c3a4]
        ),
        encodeUnchecked(keyring.nobody, 0)(
          extrinsics.parachains.public.setHeads,
          [[]]
        )
      ])
    ).toEqual(
      new Uint8Array([
        140, 102, 133, 98, 214, 123, 73, 173, 122, 252, 247, 48, 181, 86, 77, 188, 213, 161, 17, 19, 73, 96, 158, 181, 249, 69, 97, 15, 186, 12, 45, 157
      ])
      // hexToU8a(
      //   '0xab602f7974bbfb513f021f39777e2195094dc64a2c1b7c82a1781cb9fd4768a8'
      // )
    );
github polkadot-js / common / packages / type-primitives / src / codec / block / decodeRaw.spec.js View on Github external
// transactions
          '01000000' +
          '6f000000' +
          // prefix
          'ff' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '00000000' +
          '0300' +
          '7527000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000'
        )
      )
    ).toMatchObject({
      extrinsics: [
        encodeUnchecked(keyring.nobody, 0)(
          extrinsics.timestamp.public.set,
          [10101]
        )
      ]
    });
  });
});
github polkadot-js / api / packages / type-primitives / src / codec / block / decodeRaw.spec.js View on Github external
// transactions
          '01000000' +
          '6f000000' +
          // prefix
          'ff' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '00000000' +
          '0300' +
          '7527000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000'
        )
      )
    ).toMatchObject({
      extrinsics: [
        encodeUnchecked(
          keyring.nobody, 0,
          extrinsics.timestamp.public.set,
          [10101]
        )
      ]
    });
  });
});
github polkadot-js / common / packages / type-primitives / src / create / block.spec.js View on Github external
it('creates a valid block, with defaults submitted', () => {
    const transactions = [
      encodeUnchecked(keyring.nobody, 0)(
        extrinsics.timestamp.public.set,
        [0x5b13c3a4]
      ),
      encodeUnchecked(keyring.nobody, 0)(
        extrinsics.parachains.public.setHeads,
        [[]]
      )
    ];

    expect(
      block({
        header: {
          number: 1,
          parentHash: hexToU8a(
            '0x4545454545454545454545454545454545454545454545454545454545454545'
          ),
          stateRoot: hexToU8a(
            '0x2481853da20b9f4322f34650fea5f240dcbfb266d02db94bfa0153c31f4a29db'
          )
        },
github polkadot-js / api / packages / type-primitives / src / create / header.spec.js View on Github external
it('applies the all transactions (extrinsicsRoot)', () => {
    const transactions = [
      encodeUnchecked(
        keyring.nobody, 0,
        extrinsics.timestamp.public.set,
        [54321]
      ),
      encodeUnchecked(
        keyring.one, 0,
        extrinsics.timestamp.public.set,
        [12345]
      )
    ];

    expect(
      header({}, transactions).extrinsicsRoot
    ).toEqual(
      txRoot(transactions)
    );
github polkadot-js / client / packages / client-wasm / src / generateBlock.spec.js View on Github external
it('generates a basic block (with real externals)', async () => {
    expect(
      await chain.executor.generateBlock([
        encodeUnchecked(keyring.alice, 0,
          methods.staking.public.transfer,
          [keyring.bob.publicKey(), 69]
        )
      ])
    ).not.toBeNull();
  });
github polkadot-js / api / packages / type-primitives / src / create / header.spec.js View on Github external
it('applies the all transactions (extrinsicsRoot)', () => {
    const transactions = [
      encodeUnchecked(
        keyring.nobody, 0,
        extrinsics.timestamp.public.set,
        [54321]
      ),
      encodeUnchecked(
        keyring.one, 0,
        extrinsics.timestamp.public.set,
        [12345]
      )
    ];

    expect(
      header({}, transactions).extrinsicsRoot
    ).toEqual(
      txRoot(transactions)
    );
  });
});
github polkadot-js / api / packages / type-primitives / src / create / block.spec.js View on Github external
it('creates a valid block, with defaults submitted', () => {
    const transactions = [
      encodeUnchecked(
        keyring.nobody, 0,
        extrinsics.timestamp.public.set,
        [0x5b13c3a4]
      ),
      encodeUnchecked(
        keyring.nobody, 0,
        extrinsics.parachains.public.setHeads,
        [[]]
      )
    ];

    expect(
      block({
        header: {
          number: 1,
          parentHash: hexToU8a(