1+ import { Int } from '../serializable/primitives' ;
12import {
23 WarpMessage ,
34 WarpSignature ,
45 WarpUnsignedMessage ,
56} from '../serializable/pvm/warp' ;
7+ import {
8+ AddressedCall ,
9+ L1ValidatorWeightMessage ,
10+ } from '../serializable/pvm/warp/addressedCall' ;
11+ import { L1ValidatorRegistrationMessage } from '../serializable/pvm/warp/addressedCall/messages/l1ValidatorRegistrationMessage' ;
12+ import { RegisterL1ValidatorMessage } from '../serializable/pvm/warp/addressedCall/messages/registerL1ValidatorMessage' ;
13+ import { SubnetToL1ConversionMessage } from '../serializable/pvm/warp/addressedCall/messages/subnetToL1ConversionMessage' ;
14+ import { ConversionData } from '../serializable/pvm/warp/addressedCall/utils/conversionData' ;
15+ import { ValidatorData } from '../serializable/pvm/warp/addressedCall/utils/validatorData' ;
616import { concatBytes } from '../utils' ;
7- import { id , idBytes } from './common' ;
817import {
18+ address ,
19+ addressBytes ,
20+ id ,
21+ idBytes ,
22+ nodeId ,
23+ nodeIdBytes ,
24+ } from './common' ;
25+ import {
26+ bigIntPr ,
27+ bigIntPrBytes ,
28+ blsPublicKey ,
29+ blsPublicKeyBytes ,
930 blsSignature ,
1031 blsSignatureBytes ,
32+ bool ,
33+ boolBytes ,
1134 bytes ,
1235 bytesBytes ,
1336 int ,
1437 intBytes ,
1538} from './primitives' ;
39+ import { pChainOwner , pChainOwnerBytes } from './pvm' ;
1640import { bytesForInt } from './utils/bytesFor' ;
1741
1842export const warpUnsignedMessage = ( ) =>
@@ -31,3 +55,92 @@ export const warpMessage = () =>
3155
3256export const warpMessageBytes = ( ) =>
3357 concatBytes ( warpUnsignedMessageBytes ( ) , bytesForInt ( 0 ) , warpSignatureBytes ( ) ) ;
58+
59+ export const registerL1ValidatorMessage = ( ) =>
60+ new RegisterL1ValidatorMessage (
61+ id ( ) ,
62+ nodeId ( ) ,
63+ blsPublicKey ( ) ,
64+ bigIntPr ( ) ,
65+ pChainOwner ( ) ,
66+ pChainOwner ( ) ,
67+ bigIntPr ( ) ,
68+ ) ;
69+
70+ export const registerL1ValidatorMessageBytes = ( ) =>
71+ concatBytes (
72+ new Int ( 1 ) . toBytes ( ) , // typeId
73+ idBytes ( ) ,
74+ bytesForInt ( nodeIdBytes ( ) . length ) ,
75+ nodeIdBytes ( ) ,
76+ blsPublicKeyBytes ( ) ,
77+ bigIntPrBytes ( ) ,
78+ pChainOwnerBytes ( ) ,
79+ pChainOwnerBytes ( ) ,
80+ bigIntPrBytes ( ) ,
81+ ) ;
82+
83+ export const l1ValidatorWeightMessage = ( ) =>
84+ new L1ValidatorWeightMessage ( id ( ) , bigIntPr ( ) , bigIntPr ( ) ) ;
85+
86+ export const l1ValidatorWeightMessageBytes = ( ) =>
87+ concatBytes (
88+ new Int ( 3 ) . toBytes ( ) , // typeId
89+ idBytes ( ) ,
90+ bigIntPrBytes ( ) ,
91+ bigIntPrBytes ( ) ,
92+ ) ;
93+
94+ export const addressedCall = ( ) => new AddressedCall ( address ( ) , bytes ( ) ) ;
95+
96+ export const addressedCallBytes = ( ) =>
97+ concatBytes (
98+ new Int ( 1 ) . toBytes ( ) , // typeId
99+ bytesForInt ( addressBytes ( ) . length ) ,
100+ addressBytes ( ) ,
101+ bytesBytes ( ) ,
102+ ) ;
103+
104+ export const l1ValidatorRegistrationMessage = ( ) =>
105+ new L1ValidatorRegistrationMessage ( id ( ) , bool ( ) ) ;
106+
107+ export const l1ValidatorRegistrationMessageBytes = ( ) =>
108+ concatBytes (
109+ new Int ( 2 ) . toBytes ( ) , // typeId
110+ idBytes ( ) ,
111+ boolBytes ( ) ,
112+ ) ;
113+
114+ export const subnetToL1ConversionMessage = ( ) =>
115+ new SubnetToL1ConversionMessage ( id ( ) ) ;
116+
117+ export const subnetToL1ConversionMessageBytes = ( ) =>
118+ concatBytes (
119+ new Int ( 0 ) . toBytes ( ) , // typeId
120+ idBytes ( ) ,
121+ ) ;
122+
123+ export const validatorData = ( ) =>
124+ new ValidatorData ( nodeId ( ) , blsPublicKey ( ) , bigIntPr ( ) ) ;
125+
126+ export const validatorDataBytes = ( ) =>
127+ concatBytes (
128+ bytesForInt ( nodeIdBytes ( ) . length ) ,
129+ nodeIdBytes ( ) ,
130+ blsPublicKeyBytes ( ) ,
131+ bigIntPrBytes ( ) ,
132+ ) ;
133+
134+ export const conversionData = ( ) =>
135+ new ConversionData ( id ( ) , id ( ) , address ( ) , [ validatorData ( ) ] ) ;
136+
137+ export const conversionDataBytes = ( ) =>
138+ concatBytes (
139+ idBytes ( ) ,
140+ idBytes ( ) ,
141+ bytesForInt ( addressBytes ( ) . length ) ,
142+ addressBytes ( ) ,
143+ bytesForInt ( validatorDataBytes ( ) . length + 4 ) , // size of validators + length of numValidators
144+ bytesForInt ( 1 ) , // numValidators
145+ validatorDataBytes ( ) ,
146+ ) ;
0 commit comments