|
| 1 | +import { PythGovernanceActionImpl } from "./PythGovernanceAction"; |
| 2 | +import * as BufferLayout from "@solana/buffer-layout"; |
| 3 | +import * as BufferLayoutExt from "./BufferLayoutExt"; |
| 4 | +import { ChainName } from "../chains"; |
| 5 | + |
| 6 | +/** Set the transaction fee on the target chain to newFeeValue * 10^newFeeExpo */ |
| 7 | +export class SetTransactionFee extends PythGovernanceActionImpl { |
| 8 | + static layout: BufferLayout.Structure< |
| 9 | + Readonly<{ newFeeValue: bigint; newFeeExpo: bigint }> |
| 10 | + > = BufferLayout.struct([ |
| 11 | + BufferLayoutExt.u64be("newFeeValue"), |
| 12 | + BufferLayoutExt.u64be("newFeeExpo"), |
| 13 | + ]); |
| 14 | + |
| 15 | + constructor( |
| 16 | + targetChainId: ChainName, |
| 17 | + readonly newFeeValue: bigint, |
| 18 | + readonly newFeeExpo: bigint, |
| 19 | + ) { |
| 20 | + super(targetChainId, "SetTransactionFee"); |
| 21 | + } |
| 22 | + |
| 23 | + static decode(data: Buffer): SetTransactionFee | undefined { |
| 24 | + const decoded = PythGovernanceActionImpl.decodeWithPayload( |
| 25 | + data, |
| 26 | + "SetTransactionFee", |
| 27 | + SetTransactionFee.layout, |
| 28 | + ); |
| 29 | + if (!decoded) return undefined; |
| 30 | + |
| 31 | + return new SetTransactionFee( |
| 32 | + decoded[0].targetChainId, |
| 33 | + decoded[1].newFeeValue, |
| 34 | + decoded[1].newFeeExpo, |
| 35 | + ); |
| 36 | + } |
| 37 | + |
| 38 | + encode(): Buffer { |
| 39 | + return super.encodeWithPayload(SetTransactionFee.layout, { |
| 40 | + newFeeValue: this.newFeeValue, |
| 41 | + newFeeExpo: this.newFeeExpo, |
| 42 | + }); |
| 43 | + } |
| 44 | +} |
0 commit comments