Skip to content

Commit 2a45ef9

Browse files
committed
feat: refactor WithdrawFee to use value and expo for amount calculation
1 parent 08ac8eb commit 2a45ef9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

governance/xc_admin/packages/xc_admin_common/src/__tests__/GovernancePayload.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,15 @@ function governanceActionArb(): Arbitrary<PythGovernanceAction> {
436436
return fc
437437
.record({
438438
targetAddress: hexBytesArb({ minLength: 20, maxLength: 20 }),
439-
amount: fc.bigUintN(256),
439+
value: fc.bigUintN(64),
440+
expo: fc.bigUintN(64),
440441
})
441-
.map(({ targetAddress, amount }) => {
442+
.map(({ targetAddress, value, expo }) => {
442443
return new WithdrawFee(
443444
header.targetChainId,
444445
Buffer.from(targetAddress, "hex"),
445-
amount,
446+
value,
447+
expo,
446448
);
447449
});
448450
} else {

governance/xc_admin/packages/xc_admin_common/src/governance_payload/WithdrawFee.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ import { ChainName } from "../chains";
99
/** Withdraw fees from the target chain to the specified address */
1010
export class WithdrawFee extends PythGovernanceActionImpl {
1111
static layout: BufferLayout.Structure<
12-
Readonly<{ targetAddress: string; amount: bigint }>
12+
Readonly<{ targetAddress: string; value: bigint; expo: bigint }>
1313
> = BufferLayout.struct([
1414
BufferLayoutExt.hexBytes(20, "targetAddress"), // Ethereum address as hex string
15-
BufferLayoutExt.u256be("amount"), // uint256 for amount in wei
15+
BufferLayoutExt.u64be("value"), // uint64 for value
16+
BufferLayoutExt.u64be("expo"), // uint64 for exponent
1617
]);
1718

1819
constructor(
1920
targetChainId: ChainName,
2021
readonly targetAddress: Buffer,
21-
readonly amount: bigint,
22+
readonly value: bigint,
23+
readonly expo: bigint,
2224
) {
2325
super(targetChainId, "WithdrawFee");
2426
}
@@ -34,14 +36,16 @@ export class WithdrawFee extends PythGovernanceActionImpl {
3436
return new WithdrawFee(
3537
decoded[0].targetChainId,
3638
Buffer.from(decoded[1].targetAddress, "hex"),
37-
decoded[1].amount,
39+
decoded[1].value,
40+
decoded[1].expo,
3841
);
3942
}
4043

4144
encode(): Buffer {
4245
return super.encodeWithPayload(WithdrawFee.layout, {
4346
targetAddress: this.targetAddress.toString("hex"),
44-
amount: this.amount,
47+
value: this.value,
48+
expo: this.expo,
4549
});
4650
}
4751
}

0 commit comments

Comments
 (0)