UNPKG

ox

Version:

Ethereum Standard Library

81 lines (76 loc) 2.64 kB
import { TxEnvelopeEip7702 } from 'ox' import { expectTypeOf, test } from 'vp/test' test('default', () => { { const envelope = TxEnvelopeEip7702.from({ authorizationList: [], chainId: 1, to: '0x0000000000000000000000000000000000000000', value: 69n, }) expectTypeOf(envelope).toEqualTypeOf<{ readonly authorizationList: readonly [] readonly chainId: 1 readonly to: '0x0000000000000000000000000000000000000000' readonly value: 69n readonly type: 'eip7702' }>() expectTypeOf(envelope).toMatchTypeOf<TxEnvelopeEip7702.TxEnvelopeEip7702>() } { const envelope = TxEnvelopeEip7702.from( '0x123' as TxEnvelopeEip7702.Serialized, ) expectTypeOf(envelope).toMatchTypeOf<TxEnvelopeEip7702.TxEnvelopeEip7702>() } { const envelope = TxEnvelopeEip7702.from({ authorizationList: [], chainId: 1, to: '0x0000000000000000000000000000000000000000', value: 69n, r: '0x0000000000000000000000000000000000000000000000000000000000000000', s: '0x0000000000000000000000000000000000000000000000000000000000000001', yParity: 0, }) expectTypeOf(envelope).toEqualTypeOf<{ readonly authorizationList: readonly [] readonly chainId: 1 readonly to: '0x0000000000000000000000000000000000000000' readonly value: 69n readonly r: '0x0000000000000000000000000000000000000000000000000000000000000000' readonly s: '0x0000000000000000000000000000000000000000000000000000000000000001' readonly yParity: 0 readonly type: 'eip7702' }>() expectTypeOf(envelope).toMatchTypeOf<TxEnvelopeEip7702.TxEnvelopeEip7702>() } }) test('options: signature', () => { const envelope = TxEnvelopeEip7702.from( { authorizationList: [], chainId: 1, to: '0x0000000000000000000000000000000000000000', value: 69n, }, { signature: { r: '0x0000000000000000000000000000000000000000000000000000000000000000', s: '0x0000000000000000000000000000000000000000000000000000000000000001', yParity: 0, }, }, ) expectTypeOf(envelope).toEqualTypeOf<{ readonly authorizationList: readonly [] readonly chainId: 1 readonly to: '0x0000000000000000000000000000000000000000' readonly value: 69n readonly r: '0x0000000000000000000000000000000000000000000000000000000000000000' readonly s: '0x0000000000000000000000000000000000000000000000000000000000000001' readonly yParity: 0 readonly type: 'eip7702' }>() expectTypeOf(envelope).toMatchTypeOf<TxEnvelopeEip7702.TxEnvelopeEip7702>() })