-
Notifications
You must be signed in to change notification settings - Fork 301
feat(target_chains/ethereum): add WithdrawFee action and implement related functionality in governance payload #2573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
63bbd2d
feat: add WithdrawFee action and implement related functionality in g…
cctdaniel 5dfec3f
style: format WithdrawFee class for improved readability
cctdaniel 7714abb
chore: bump version to 1.4.4-alpha.3 in Pyth contract and package.json
cctdaniel b130e98
feat: update fee withdrawal logic to use value and exponent for amoun…
cctdaniel 2db36c5
Merge branch 'main' into withdraw-fees
cctdaniel 08ac8eb
chore: bump version to 1.4.4-alpha.5 in package.json
cctdaniel 2a45ef9
feat: refactor WithdrawFee to use value and expo for amount calculation
cctdaniel fe8db0c
refactor: rename amount to fee in fee withdrawal logic and related ev…
cctdaniel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
governance/xc_admin/packages/xc_admin_common/src/governance_payload/WithdrawFee.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
PythGovernanceActionImpl, | ||
PythGovernanceHeader, | ||
} from "./PythGovernanceAction"; | ||
import * as BufferLayout from "@solana/buffer-layout"; | ||
import * as BufferLayoutExt from "./BufferLayoutExt"; | ||
import { ChainName } from "../chains"; | ||
|
||
/** Withdraw fees from the target chain to the specified address */ | ||
export class WithdrawFee extends PythGovernanceActionImpl { | ||
static layout: BufferLayout.Structure< | ||
Readonly<{ targetAddress: string; amount: bigint }> | ||
> = BufferLayout.struct([ | ||
BufferLayoutExt.hexBytes(20, "targetAddress"), // Ethereum address as hex string | ||
BufferLayoutExt.u256be("amount"), // uint256 for amount in wei | ||
]); | ||
|
||
constructor( | ||
targetChainId: ChainName, | ||
readonly targetAddress: Buffer, | ||
readonly amount: bigint, | ||
) { | ||
super(targetChainId, "WithdrawFee"); | ||
} | ||
|
||
static decode(data: Buffer): WithdrawFee | undefined { | ||
const decoded = PythGovernanceActionImpl.decodeWithPayload( | ||
data, | ||
"WithdrawFee", | ||
WithdrawFee.layout, | ||
); | ||
if (!decoded) return undefined; | ||
|
||
return new WithdrawFee( | ||
decoded[0].targetChainId, | ||
Buffer.from(decoded[1].targetAddress, "hex"), | ||
decoded[1].amount, | ||
); | ||
} | ||
|
||
encode(): Buffer { | ||
return super.encodeWithPayload(WithdrawFee.layout, { | ||
targetAddress: this.targetAddress.toString("hex"), | ||
amount: this.amount, | ||
}); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.