Skip to content

Commit 2120669

Browse files
committed
docs
1 parent 78b8ede commit 2120669

File tree

9 files changed

+167
-0
lines changed

9 files changed

+167
-0
lines changed

interchain/src/chains/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
export type { ChainConfig } from "./types/chainConfig";
12
export { avalancheFuji } from "./avalancheFuji";
23
export { dispatch } from "./dispatch";

interchain/src/warp/addressedCallMessages/conversionData.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { sha256 } from "@noble/hashes/sha2";
44

55
const warpManager = pvmSerial.warp.getWarpManager();
66

7+
/**
8+
* Parses a ConversionData (SubnetToL1Conversion) from a hex string.
9+
*
10+
* @param conversionDataHex - The hex string representing the ConversionData.
11+
* @returns The parsed ConversionData instance. {@link ConversionData}
12+
*/
713
export function parseConversionData(
814
conversionDataHex: string,
915
): ConversionData {
@@ -19,6 +25,18 @@ export function parseConversionData(
1925
);
2026
}
2127

28+
/**
29+
* Creates a new ConversionData from values.
30+
*
31+
* @param subnetId - The subnet ID (base58check encoded).
32+
* @param managerChainId - The manager chain ID (base58check encoded).
33+
* @param managerAddress - The manager address in Bech32 format.
34+
* @param validators - An array of validator data.
35+
* @param validators.nodeId - The node ID (base58check encoded).
36+
* @param validators.blsPublicKey - The BLS public key in hex format.
37+
* @param validators.weight - The weight of the validator as a bigint.
38+
* @returns A new ConversionData instance. {@link ConversionData}
39+
*/
2240
export function newConversionData(
2341
subnetId: string,
2442
managerChainId: string,
@@ -40,6 +58,11 @@ export function newConversionData(
4058
);
4159
}
4260

61+
/**
62+
* ConversionData class provides utility methods to build
63+
* and parse ConversionData from hex strings or values, and
64+
* access its properties.
65+
*/
4366
export class ConversionData extends pvmSerial.warp.AddressedCallPayloads.ConversionData {
4467
static fromHex(conversionDataHex: string) {
4568
return parseConversionData(conversionDataHex);

interchain/src/warp/addressedCallMessages/l1ValidatorRegistrationMessage.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { parseAddressedCallPayload } from "../addressedCallPayload";
33

44
const warpManager = pvmSerial.warp.getWarpManager();
55

6+
/**
7+
* Parses a L1ValidatorRegistrationMessage (AddressedCall payload) from a hex string.
8+
*
9+
* @param l1ValidatorRegistrationMessageHex - The hex string representing the L1ValidatorRegistrationMessage.
10+
* @returns The parsed L1ValidatorRegistrationMessage instance. {@link L1ValidatorRegistrationMessage}
11+
*/
612
export function parseL1ValidatorRegistrationMessage(
713
l1ValidatorRegistrationMessageHex: string,
814
): L1ValidatorRegistrationMessage {
@@ -24,6 +30,13 @@ export function parseL1ValidatorRegistrationMessage(
2430
}
2531
}
2632

33+
/**
34+
* Creates a new L1ValidatorRegistrationMessage from values.
35+
*
36+
* @param validationId - The validation ID (base58check encoded).
37+
* @param registered - The registration status as a boolean.
38+
* @returns A new L1ValidatorRegistrationMessage instance. {@link L1ValidatorRegistrationMessage}
39+
*/
2740
export function newL1ValidatorRegistrationMessage(
2841
validationId: string,
2942
registered: boolean,
@@ -35,6 +48,11 @@ export function newL1ValidatorRegistrationMessage(
3548
);
3649
}
3750

51+
/**
52+
* L1ValidatorRegistrationMessage class provides utility methods to build
53+
* and parse L1ValidatorRegistrationMessage from hex strings or values, and
54+
* access its properties.
55+
*/
3856
export class L1ValidatorRegistrationMessage extends pvmSerial.warp.AddressedCallPayloads.L1ValidatorRegistrationMessage {
3957
static fromHex(l1ValidatorRegistrationMessageHex: string) {
4058
return parseL1ValidatorRegistrationMessage(l1ValidatorRegistrationMessageHex);

interchain/src/warp/addressedCallMessages/l1ValidatorWeightMessage.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { parseAddressedCallPayload } from "../addressedCallPayload";
33

44
const warpManager = pvmSerial.warp.getWarpManager();
55

6+
/**
7+
* Parses a L1ValidatorWeightMessage (AddressedCall payload) from a hex string.
8+
*
9+
* @param l1ValidatorWeightMessageHex - The hex string representing the L1ValidatorWeightMessage.
10+
* @returns The parsed L1ValidatorWeightMessage instance. {@link L1ValidatorWeightMessage}
11+
*/
612
export function parseL1ValidatorWeightMessage(
713
l1ValidatorWeightMessageHex: string,
814
): L1ValidatorWeightMessage {
@@ -25,6 +31,14 @@ export function parseL1ValidatorWeightMessage(
2531
}
2632
}
2733

34+
/**
35+
* Creates a new L1ValidatorWeightMessage from values.
36+
*
37+
* @param validationId - The validation ID (base58check encoded).
38+
* @param nonce - The nonce as a bigint.
39+
* @param weight - The weight of the validator as a bigint.
40+
* @returns A new L1ValidatorWeightMessage instance. {@link L1ValidatorWeightMessage}
41+
*/
2842
export function newL1ValidatorWeightMessage(validationId: string, nonce: bigint, weight: bigint) {
2943
const validationIdBytes = utils.base58check.decode(validationId);
3044
return new L1ValidatorWeightMessage(
@@ -34,6 +48,11 @@ export function newL1ValidatorWeightMessage(validationId: string, nonce: bigint,
3448
);
3549
}
3650

51+
/**
52+
* L1ValidatorWeightMessage class provides utility methods to build
53+
* and parse L1ValidatorWeightMessage from hex strings or values, and
54+
* access its properties.
55+
*/
3756
export class L1ValidatorWeightMessage extends pvmSerial.warp.AddressedCallPayloads.L1ValidatorWeightMessage {
3857
static fromHex(l1ValidatorWeightMessageHex: string) {
3958
return parseL1ValidatorWeightMessage(l1ValidatorWeightMessageHex);

interchain/src/warp/addressedCallMessages/registerL1ValidatorMessage.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import type { PChainOwner as PChainOwnerRaw } from "../types";
1414

1515
const warpManager = pvmSerial.warp.getWarpManager();
1616

17+
/**
18+
* Parses a RegisterL1ValidatorMessage (AddressedCall payload) from a hex string.
19+
*
20+
* @param registerL1ValidatorMessageHex - The hex string representing the RegisterL1ValidatorMessage.
21+
* @returns The parsed RegisterL1ValidatorMessage instance. {@link RegisterL1ValidatorMessage}
22+
*/
1723
export function parseRegisterL1ValidatorMessage(
1824
registerL1ValidatorMessageHex: string,
1925
): RegisterL1ValidatorMessage {
@@ -40,6 +46,18 @@ export function parseRegisterL1ValidatorMessage(
4046
}
4147
}
4248

49+
/**
50+
* Creates a new RegisterL1ValidatorMessage from values.
51+
*
52+
* @param subnetId - The subnet ID (base58check encoded).
53+
* @param nodeId - The node ID (base58check encoded).
54+
* @param blsPublicKey - The BLS public key in hex format.
55+
* @param expiry - The expiry time as a bigint.
56+
* @param remainingBalanceOwner - The remaining balance owner details.
57+
* @param disableOwner - The disable owner details.
58+
* @param weight - The weight of the validator as a bigint.
59+
* @returns A new RegisterL1ValidatorMessage instance. {@link RegisterL1ValidatorMessage}
60+
*/
4361
export function newRegisterL1ValidatorMessage(
4462
subnetId: string,
4563
nodeId: string,
@@ -70,6 +88,11 @@ export function newRegisterL1ValidatorMessage(
7088
)
7189
}
7290

91+
/**
92+
* RegisterL1ValidatorMessage class provides utility methods to build
93+
* and parse RegisterL1ValidatorMessage from hex strings or values, and
94+
* access its properties.
95+
*/
7396
export class RegisterL1ValidatorMessage extends pvmSerial.warp.AddressedCallPayloads.RegisterL1ValidatorMessage {
7497
static fromHex(registerL1ValidatorMessageHex: string) {
7598
return parseRegisterL1ValidatorMessage(registerL1ValidatorMessageHex);

interchain/src/warp/addressedCallMessages/subnetToL1ConversionMessage.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { parseAddressedCallPayload } from "../addressedCallPayload";
33

44
const warpManager = pvmSerial.warp.getWarpManager();
55

6+
/**
7+
* Parses a SubnetToL1ConversionMessage (AddressedCall payload) from a hex string.
8+
*
9+
* @param subnetToL1ConversionMessageHex - The hex string representing the SubnetToL1ConversionMessage.
10+
* @returns The parsed SubnetToL1ConversionMessage instance. {@link SubnetToL1ConversionMessage}
11+
*/
612
export function parseSubnetToL1ConversionMessage(
713
subnetToL1ConversionMessageHex: string,
814
): SubnetToL1ConversionMessage {
@@ -23,6 +29,12 @@ export function parseSubnetToL1ConversionMessage(
2329
}
2430
}
2531

32+
/**
33+
* Creates a new SubnetToL1ConversionMessage from a conversion ID.
34+
*
35+
* @param conversionId - The conversion ID (base58check encoded).
36+
* @returns A new SubnetToL1ConversionMessage instance. {@link SubnetToL1ConversionMessage}
37+
*/
2638
export function newSubnetToL1ConversionMessage(
2739
conversionId: string,
2840
) {
@@ -32,6 +44,11 @@ export function newSubnetToL1ConversionMessage(
3244
)
3345
}
3446

47+
/**
48+
* SubnetToL1ConversionMessage class provides utility methods to build
49+
* and parse SubnetToL1ConversionMessage from hex strings or values, and
50+
* access its properties.
51+
*/
3552
export class SubnetToL1ConversionMessage extends pvmSerial.warp.AddressedCallPayloads.SubnetToL1ConversionMessage {
3653
static fromHex(subnetToL1ConversionMessageHex: string) {
3754
return parseSubnetToL1ConversionMessage(subnetToL1ConversionMessageHex);

interchain/src/warp/addressedCallPayload.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { evmOrBech32AddressToBytes } from "./utils";
44

55
const warpManager = pvmSerial.warp.getWarpManager();
66

7+
/**
8+
* Parses a Warp AddressedCall payload from a hex string.
9+
*
10+
* @param addressedCallPayloadHex - The hex string representing the AddressedCall payload.
11+
* @returns The parsed AddressedCall instance. {@link AddressedCall}
12+
*/
713
export function parseAddressedCallPayload(
814
addressedCallPayloadHex: string,
915
): AddressedCall {
@@ -25,12 +31,24 @@ export function parseAddressedCallPayload(
2531
}
2632
}
2733

34+
/**
35+
* Creates a new AddressedCall from values.
36+
*
37+
* @param sourceAddress - The source address (EVM or Bech32 format).
38+
* @param payloadHex - The payload as a hex string.
39+
* @returns A new AddressedCall instance. {@link AddressedCall}
40+
*/
2841
export function newAddressedCallPayload(sourceAddress: string, payloadHex: string) {
2942
const sourceAddressBytes = evmOrBech32AddressToBytes(sourceAddress);
3043
const payloadBytes = utils.hexToBuffer(payloadHex);
3144
return new AddressedCall(new Address(sourceAddressBytes), new Bytes(payloadBytes));
3245
}
3346

47+
/**
48+
* AddressedCall class provides utility methods to build
49+
* and parse AddressedCall payloads from hex strings or values, and
50+
* access its properties.
51+
*/
3452
export class AddressedCall extends pvmSerial.warp.AddressedCallPayloads.AddressedCall {
3553
static fromHex(addressedCallPayloadHex: string): AddressedCall {
3654
return parseAddressedCallPayload(addressedCallPayloadHex);

interchain/src/warp/warpMessage.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { pvmSerial, Short, utils } from "@avalabs/avalanchejs";
22

33
const warpManager = pvmSerial.warp.getWarpManager();
44

5+
/**
6+
* Parses a Warp signed message from a hex string.
7+
*
8+
* @param warpMsgHex - The hex string representing the signed message.
9+
* @returns The parsed WarpSignedMessage instance. {@link WarpMessage}
10+
*/
511
export function parseWarpMessage(warpMsgHex: string): WarpMessage {
612
const parsedWarpMsg = warpManager.unpack(
713
utils.hexToBuffer(warpMsgHex),
@@ -14,6 +20,11 @@ export function parseWarpMessage(warpMsgHex: string): WarpMessage {
1420
);
1521
}
1622

23+
/**
24+
* WarpSignedMessage class provides utility methods to build
25+
* and parse signed warp message from hex strings or values, and
26+
* access its properties.
27+
*/
1728
export class WarpMessage extends pvmSerial.warp.WarpMessage {
1829
static fromHex(warpMsgHex: string) {
1930
return parseWarpMessage(warpMsgHex);

interchain/src/warp/warpUnsignedMessage.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { parseWarpMessage } from "./warpMessage";
33

44
const warpManager = pvmSerial.warp.getWarpManager();
55

6+
/**
7+
* Parses a Warp unsigned or signed message from a hex string.
8+
*
9+
* @param unsignedMsgHex - The hex string representing the unsigned or signed message.
10+
* @returns The parsed WarpUnsignedMessage instance. {@link WarpUnsignedMessage}
11+
*/
612
export function parseWarpUnsignedMessage(unsignedMsgHex: string): WarpUnsignedMessage {
713
try {
814
const parsedWarpUnsignedMsg = warpManager.unpack(
@@ -24,6 +30,14 @@ export function parseWarpUnsignedMessage(unsignedMsgHex: string): WarpUnsignedMe
2430
}
2531
}
2632

33+
/**
34+
* Creates a new WarpUnsignedMessage from values.
35+
*
36+
* @param networkId - The Avalanche network ID.
37+
* @param sourceChainId - The source blockchain ID.
38+
* @param payloadHex - The warp message payload as a hex string.
39+
* @returns A new WarpUnsignedMessage instance. {@link WarpUnsignedMessage}
40+
*/
2741
export function newWarpUnsignedMessage(
2842
networkId: number,
2943
sourceChainId: string,
@@ -36,11 +50,28 @@ export function newWarpUnsignedMessage(
3650
);
3751
}
3852

53+
/**
54+
* WarpUnsignedMessage class provides utility methods to build
55+
* and parse unsigned warp message from hex strings or values, and
56+
* access its properties.
57+
*/
3958
export class WarpUnsignedMessage extends pvmSerial.warp.WarpUnsignedMessage {
59+
/**
60+
* Creates a WarpUnsignedMessage instance from a hex string.
61+
* @param unsignedMsgHex - The hex string representing the unsigned message.
62+
* @returns The parsed WarpUnsignedMessage instance. {@link WarpUnsignedMessage}
63+
*/
4064
static fromHex(unsignedMsgHex: string) {
4165
return parseWarpUnsignedMessage(unsignedMsgHex);
4266
}
4367

68+
/**
69+
* Creates a WarpUnsignedMessage instance from values.
70+
* @param networkId - The Avalanche network ID.
71+
* @param sourceChainId - The source chain ID (base58check encoded).
72+
* @param payloadHex - The payload as a hex string.
73+
* @returns A new WarpUnsignedMessage instance. {@link WarpUnsignedMessage}
74+
*/
4475
static fromValues(
4576
networkId: number,
4677
sourceChainId: string,
@@ -49,6 +80,10 @@ export class WarpUnsignedMessage extends pvmSerial.warp.WarpUnsignedMessage {
4980
return newWarpUnsignedMessage(networkId, sourceChainId, payloadHex);
5081
}
5182

83+
/**
84+
* Serializes the WarpUnsignedMessage to a hex string.
85+
* @returns The hex string representation of the message.
86+
*/
5287
toHex() {
5388
const bytesWithoutCodec = this.toBytes(pvmSerial.warp.codec)
5489
const codecBytes = new Short(0)
@@ -57,6 +92,8 @@ export class WarpUnsignedMessage extends pvmSerial.warp.WarpUnsignedMessage {
5792

5893
/**
5994
* Do not use this method directly.
95+
* Throws an error if called.
96+
* @throws Error
6097
*/
6198
static override fromBytes(
6299
_bytes: never,

0 commit comments

Comments
 (0)