From 8e278bb326dc1d89db848eecefed729fe0f2c181 Mon Sep 17 00:00:00 2001 From: Fawad Ali Date: Tue, 4 Nov 2025 11:34:25 +0100 Subject: [PATCH] Update the CarrotVesting contract handler to include functions in upgrade --- lib/contracts/abis/mainnet/CarrotVesting.ts | 21 +++++++++++++ .../__tests__/carrot-vesting-handler.test.ts | 24 +++++++++++++++ .../handlers/carrot-vesting-handler.ts | 30 +++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/lib/contracts/abis/mainnet/CarrotVesting.ts b/lib/contracts/abis/mainnet/CarrotVesting.ts index 8ae3ff6..100a4e9 100644 --- a/lib/contracts/abis/mainnet/CarrotVesting.ts +++ b/lib/contracts/abis/mainnet/CarrotVesting.ts @@ -68,6 +68,13 @@ export const CarrotVesting = [ outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }], inputs: [], }, + { + type: 'function', + name: 'getNewDuration', + stateMutability: 'view', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + inputs: [], + }, { type: 'function', name: 'startVesting', @@ -82,6 +89,20 @@ export const CarrotVesting = [ outputs: [{ type: 'uint32', name: '', simpleType: 'uint' }], inputs: [], }, + { + inputs: [], + name: 'getNewSteps', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'getUpgradeTimestamp', + outputs: [{ internalType: 'uint48', name: '', type: 'uint48' }], + stateMutability: 'view', + type: 'function', + }, { type: 'function', name: 'EXCHANGE_RATE', diff --git a/lib/contracts/handlers/__tests__/carrot-vesting-handler.test.ts b/lib/contracts/handlers/__tests__/carrot-vesting-handler.test.ts index 2f93d18..f983b85 100644 --- a/lib/contracts/handlers/__tests__/carrot-vesting-handler.test.ts +++ b/lib/contracts/handlers/__tests__/carrot-vesting-handler.test.ts @@ -207,4 +207,28 @@ describe('CarrotVestingHandler', () => { const result = await handler.getDuration(); expect(result).toBe(duration); }); + + it('should get the new duration of the vesting period', async () => { + const newDuration = 365; + contractTestingUtils.mockCall('getNewDuration', [newDuration]); + + const result = await handler.getNewDuration(); + expect(result).toBe(newDuration); + }); + + it('should get the new steps of the vesting period', async () => { + const newSteps = 10; + contractTestingUtils.mockCall('getNewSteps', [newSteps]); + + const result = await handler.getNewSteps(); + expect(result).toBe(newSteps); + }); + + it('should get the upgrade timestamp', async () => { + const upgradeTimestamp = 1234567890; + contractTestingUtils.mockCall('getUpgradeTimestamp', [upgradeTimestamp]); + + const result = await handler.getUpgradeTimestamp(); + expect(result).toBe(upgradeTimestamp); + }); }); diff --git a/lib/contracts/handlers/carrot-vesting-handler.ts b/lib/contracts/handlers/carrot-vesting-handler.ts index 419e6a6..e936259 100644 --- a/lib/contracts/handlers/carrot-vesting-handler.ts +++ b/lib/contracts/handlers/carrot-vesting-handler.ts @@ -231,4 +231,34 @@ export class CarrotVestingHandler { public getDuration() { return this.getContract().read.getDuration(); } + + /** + * Get the new duration of the vesting period. This is a new function + * added after contract upgrade. + * + * @returns The new duration of the vesting period. + */ + public getNewDuration() { + return this.getContract().read.getNewDuration(); + } + + /** + * Get the upgrade timestamp. This is a new function added after + * contract upgrade. + * + * @returns The upgrade timestamp. + */ + public getNewSteps() { + return this.getContract().read.getNewSteps(); + } + + /** + * Get the upgrade timestamp. This is a new function added after + * contract upgrade. + * + * @returns The upgrade timestamp. + */ + public getUpgradeTimestamp() { + return this.getContract().read.getUpgradeTimestamp(); + } }