diff --git a/packages/protocol/contracts/governance/LockedGold.sol b/packages/protocol/contracts/governance/LockedGold.sol index 32ebb93e43a..3a798d8b9c1 100644 --- a/packages/protocol/contracts/governance/LockedGold.sol +++ b/packages/protocol/contracts/governance/LockedGold.sol @@ -81,7 +81,7 @@ contract LockedGold is * @return The storage, major, minor, and patch version of the contract. */ function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) { - return (1, 1, 1, 2); + return (1, 1, 2, 0); } /** @@ -284,6 +284,25 @@ contract LockedGold is return (values, timestamps); } + /** + * @notice Returns the pending withdrawal at a given index for a given account. + * @param account The address of the account. + * @param index The index of the pending withdrawal. + * @return The value of the pending withdrawal. + * @return The timestamp of the pending withdrawal. + */ + function getPendingWithdrawal(address account, uint256 index) + external + view + returns (uint256, uint256) + { + require(getAccounts().isAccount(account), "Unknown account"); + require(index < balances[account].pendingWithdrawals.length, "Bad pending withdrawal index"); + PendingWithdrawal memory pendingWithdrawal = (balances[account].pendingWithdrawals[index]); + + return (pendingWithdrawal.value, pendingWithdrawal.timestamp); + } + /** * @notice Returns the total amount to withdraw from unlocked gold for an account. * @param account The address of the account. diff --git a/packages/protocol/test/governance/voting/lockedgold.ts b/packages/protocol/test/governance/voting/lockedgold.ts index c10a39e64eb..fa0431bf171 100644 --- a/packages/protocol/test/governance/voting/lockedgold.ts +++ b/packages/protocol/test/governance/voting/lockedgold.ts @@ -203,11 +203,10 @@ contract('LockedGold', (accounts: string[]) => { }) it('should add a pending withdrawal', async () => { - const [values, timestamps] = await lockedGold.getPendingWithdrawals(account) - assert.equal(values.length, 1) - assert.equal(timestamps.length, 1) - assertEqualBN(values[0], value) - assertEqualBN(timestamps[0], availabilityTime) + const [val, timestamp] = await lockedGold.getPendingWithdrawal(account, 0) + assertEqualBN(val, value) + assertEqualBN(timestamp, availabilityTime) + await assertRevert(lockedGold.getPendingWithdrawal(account, 1)) }) it("should decrease the account's nonvoting locked gold balance", async () => {