UNPKG

@hyperlane-xyz/sdk

Version:

The official SDK for the Hyperlane Network

326 lines 10.7 kB
import { PublicKey } from '@solana/web3.js'; import { SealevelAccountDataWrapper, SealevelInstructionWrapper, getSealevelAccountDataSchema, getSealevelSimulationReturnDataSchema, } from '../../utils/sealevelSerialization.js'; // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/programs/hyperlane-sealevel-igp/src/accounts.rs#L24 export var SealevelInterchainGasPaymasterType; (function (SealevelInterchainGasPaymasterType) { // An IGP with gas oracles and that receives lamports as payment. SealevelInterchainGasPaymasterType[SealevelInterchainGasPaymasterType["Igp"] = 0] = "Igp"; // An overhead IGP that points to an inner IGP and imposes a gas overhead for each destination domain. SealevelInterchainGasPaymasterType[SealevelInterchainGasPaymasterType["OverheadIgp"] = 1] = "OverheadIgp"; })(SealevelInterchainGasPaymasterType || (SealevelInterchainGasPaymasterType = {})); /** * IGP Config Borsh Schema */ // Config schema, e.g. for use in token data export class SealevelInterchainGasPaymasterConfig { fields; program_id; program_id_pubkey; type; igp_account; igp_account_pub_key; constructor(fields) { this.fields = fields; Object.assign(this, fields); this.program_id_pubkey = new PublicKey(this.program_id); this.igp_account_pub_key = this.igp_account ? new PublicKey(this.igp_account) : undefined; } } export const SealevelInterchainGasPaymasterConfigSchema = { kind: 'struct', fields: [ ['program_id', [32]], ['type', 'u8'], ['igp_account', [32]], ], }; /** * Gas Oracle Borsh Schema */ // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/programs/hyperlane-sealevel-igp/src/accounts.rs#L234 export class SealevelRemoteGasData { fields; token_exchange_rate; gas_price; token_decimals; constructor(fields) { this.fields = fields; Object.assign(this, fields); } } export const SealevelRemoteGasDataSchema = { kind: 'struct', fields: [ ['token_exchange_rate', 'u128'], ['gas_price', 'u128'], ['token_decimals', 'u8'], ], }; // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/programs/hyperlane-sealevel-igp/src/accounts.rs#L45 export var SealevelGasOracleType; (function (SealevelGasOracleType) { SealevelGasOracleType[SealevelGasOracleType["RemoteGasData"] = 0] = "RemoteGasData"; })(SealevelGasOracleType || (SealevelGasOracleType = {})); export class SealevelGasOracle { fields; type; data; constructor(fields) { this.fields = fields; Object.assign(this, fields); } } export const SealevelGasOracleSchema = { kind: 'struct', fields: [ ['type', 'u8'], ['data', SealevelRemoteGasData], ], }; /** * IGP Program Data Borsh Schema */ // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/programs/hyperlane-sealevel-igp/src/accounts.rs#L91 export class SealevelOverheadIgpData { fields; /// The bump seed for this PDA. bump; /// The salt used to derive the overhead IGP PDA. salt; /// The owner of the overhead IGP. owner; owner_pub_key; /// The inner IGP account. inner; inner_pub_key; /// The gas overheads to impose on gas payments to each destination domain. gas_overheads; constructor(fields) { this.fields = fields; Object.assign(this, fields); this.owner_pub_key = this.owner ? new PublicKey(this.owner) : undefined; this.inner_pub_key = new PublicKey(this.inner); } } export const SealevelOverheadIgpDataSchema = new Map([ [ SealevelAccountDataWrapper, getSealevelAccountDataSchema(SealevelOverheadIgpData, [8]), ], [ SealevelOverheadIgpData, { kind: 'struct', fields: [ ['bump', 'u8'], ['salt', [32]], ['owner', { kind: 'option', type: [32] }], ['inner', [32]], ['gas_overheads', { kind: 'map', key: 'u32', value: 'u64' }], ], }, ], ]); // Should match https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/main/rust/sealevel/programs/hyperlane-sealevel-igp/src/accounts.rs#L159 export class SealevelIgpData { /// The bump seed for this PDA. bump_seed; // The salt used to derive the IGP PDA. salt; // 32 bytes /// The owner of the IGP. owner; owner_pub_key; /// The beneficiary of the IGP. beneficiary; // 32 bytes beneficiary_pub_key; gas_oracles; constructor(fields) { Object.assign(this, fields); this.owner_pub_key = this.owner ? new PublicKey(this.owner) : undefined; this.beneficiary_pub_key = new PublicKey(this.beneficiary); } } export const SealevelIgpDataSchema = new Map([ [ SealevelAccountDataWrapper, getSealevelAccountDataSchema(SealevelIgpData, [8]), ], [ SealevelIgpData, { kind: 'struct', fields: [ ['bump_seed', 'u8'], ['salt', [32]], ['owner', { kind: 'option', type: [32] }], ['beneficiary', [32]], ['gas_oracles', { kind: 'map', key: 'u32', value: SealevelGasOracle }], ], }, ], [SealevelGasOracle, SealevelGasOracleSchema], [SealevelRemoteGasData, SealevelRemoteGasDataSchema], ]); /** * IGP instruction Borsh Schema */ // Should match Instruction in https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/8f8853bcd7105a6dd7af3a45c413b137ded6e888/rust/sealevel/programs/hyperlane-sealevel-igp/src/instruction.rs#L19-L42 export var SealevelIgpInstruction; (function (SealevelIgpInstruction) { SealevelIgpInstruction[SealevelIgpInstruction["Init"] = 0] = "Init"; SealevelIgpInstruction[SealevelIgpInstruction["InitIgp"] = 1] = "InitIgp"; SealevelIgpInstruction[SealevelIgpInstruction["InitOverheadIgp"] = 2] = "InitOverheadIgp"; SealevelIgpInstruction[SealevelIgpInstruction["PayForGas"] = 3] = "PayForGas"; SealevelIgpInstruction[SealevelIgpInstruction["QuoteGasPayment"] = 4] = "QuoteGasPayment"; SealevelIgpInstruction[SealevelIgpInstruction["TransferIgpOwnership"] = 5] = "TransferIgpOwnership"; SealevelIgpInstruction[SealevelIgpInstruction["TransferOverheadIgpOwnership"] = 6] = "TransferOverheadIgpOwnership"; SealevelIgpInstruction[SealevelIgpInstruction["SetIgpBeneficiary"] = 7] = "SetIgpBeneficiary"; SealevelIgpInstruction[SealevelIgpInstruction["SetDestinationGasOverheads"] = 8] = "SetDestinationGasOverheads"; SealevelIgpInstruction[SealevelIgpInstruction["SetGasOracleConfigs"] = 9] = "SetGasOracleConfigs"; SealevelIgpInstruction[SealevelIgpInstruction["Claim"] = 10] = "Claim"; })(SealevelIgpInstruction || (SealevelIgpInstruction = {})); export class SealevelIgpQuoteGasPaymentInstruction { fields; destination_domain; gas_amount; constructor(fields) { this.fields = fields; Object.assign(this, fields); } } export const SealevelIgpQuoteGasPaymentSchema = new Map([ [ SealevelInstructionWrapper, { kind: 'struct', fields: [ ['instruction', 'u8'], ['data', SealevelIgpQuoteGasPaymentInstruction], ], }, ], [ SealevelIgpQuoteGasPaymentInstruction, { kind: 'struct', fields: [ ['destination_domain', 'u32'], ['gas_amount', 'u64'], ], }, ], ]); export class SealevelIgpQuoteGasPaymentResponse { fields; payment_quote; constructor(fields) { this.fields = fields; Object.assign(this, fields); } } export const SealevelIgpQuoteGasPaymentResponseSchema = new Map([ [ SealevelAccountDataWrapper, getSealevelSimulationReturnDataSchema(SealevelIgpQuoteGasPaymentResponse), ], [ SealevelIgpQuoteGasPaymentResponse, { kind: 'struct', fields: [['payment_quote', 'u64']], }, ], ]); /** * Gas Oracle Configuration Schemas */ export class SealevelGasOracleConfig { domain; gas_oracle; constructor(domain, gasOracle) { this.domain = domain; this.gas_oracle = gasOracle; } } export const SealevelGasOracleConfigSchema = { kind: 'struct', fields: [ ['domain', 'u32'], ['gas_oracle', { kind: 'option', type: SealevelGasOracle }], ], }; export class SealevelGasOverheadConfig { destination_domain; gas_overhead; constructor(destination_domain, gas_overhead) { this.destination_domain = destination_domain; this.gas_overhead = gas_overhead; } } export const SealevelGasOverheadConfigSchema = { kind: 'struct', fields: [ ['destination_domain', 'u32'], ['gas_overhead', { kind: 'option', type: 'u64' }], ], }; /** * Instruction Schemas */ export class SealevelSetGasOracleConfigsInstruction { configs; constructor(configs) { this.configs = configs; } } export const SealevelSetGasOracleConfigsInstructionSchema = new Map([ [ SealevelInstructionWrapper, { kind: 'struct', fields: [ ['instruction', 'u8'], ['data', SealevelSetGasOracleConfigsInstruction], ], }, ], [ SealevelSetGasOracleConfigsInstruction, { kind: 'struct', fields: [['configs', [SealevelGasOracleConfig]]], }, ], [SealevelGasOracleConfig, SealevelGasOracleConfigSchema], [SealevelGasOracle, SealevelGasOracleSchema], [SealevelRemoteGasData, SealevelRemoteGasDataSchema], ]); export class SealevelSetDestinationGasOverheadsInstruction { configs; constructor(configs) { this.configs = configs; } } export const SealevelSetDestinationGasOverheadsInstructionSchema = new Map([ [ SealevelInstructionWrapper, { kind: 'struct', fields: [ ['instruction', 'u8'], ['data', SealevelSetDestinationGasOverheadsInstruction], ], }, ], [ SealevelSetDestinationGasOverheadsInstruction, { kind: 'struct', fields: [['configs', [SealevelGasOverheadConfig]]], }, ], [SealevelGasOverheadConfig, SealevelGasOverheadConfigSchema], ]); //# sourceMappingURL=serialization.js.map