How to use the @polkadot/extrinsics.timestamp 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 / 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 / api / packages / type-primitives / src / codec / block / decodeRaw.spec.js View on Github external
'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 / codec / block / decodeRaw.spec.js View on Github external
'01000000' +
          '6f000000' +
          // prefix
          'ff' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '00000000' +
          '0300' +
          '7527000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000' +
          '0000000000000000000000000000000000000000000000000000000000000000'
        )
      )
    ).toMatchObject({
      extrinsics: [
        encodeUnchecked(keyring.nobody, 0)(
          extrinsics.timestamp.public.set,
          [10101]
        )
      ]
    });
  });
});
github polkadot-js / client / packages / client-wasm / src / executor / inherentExtrinsics.ts View on Github external
// Copyright 2017-2018 @polkadot/client-wasm authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.

import { UncheckedRaw } from '@polkadot/primitives/extrinsic';
import { ExecutorState } from '../types';

import extrinsics from '@polkadot/extrinsics';
import encodeUnchecked from '@polkadot/extrinsics/codec/encode/unchecked';
import testingKeypairs from '@polkadot/util-keyring/testingPairs';

const keyring = testingKeypairs();
const timestampSet = extrinsics.timestamp.public.set;
const parachainsSet = extrinsics.parachains.public.setHeads;

export default function inherentExtrinsics (self: ExecutorState, timestamp: number, _extrinsics: Array): Array {
  return [
    encodeUnchecked(keyring.nobody, 0)(
      timestampSet,[timestamp]
    ),
    encodeUnchecked(keyring.nobody, 0)(
      parachainsSet, [[]]
    )
  ].concat(_extrinsics);
}
github polkadot-js / common / 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 / 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 / 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(
            '0x4545454545454545454545454545454545454545454545454545454545454545'
          ),
github polkadot-js / common / 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 / executor / inherentExtrinsics.js View on Github external
module.exports = function inherentExtrinsics (self: ExecutorState, timestamp: number, _extrinsics: Array): Array {
  return [
    encodeUnchecked(keyring.nobody, 0)(
      extrinsics.timestamp.public.set,
      [timestamp]
    ),
    encodeUnchecked(keyring.nobody, 0)(
      extrinsics.parachains.public.setHeads,
      [[]]
    )
  ].concat(_extrinsics);
};