Skip to content

Commit 7e053fd

Browse files
committed
feat: add cancel staking request
https://bitgoinc.atlassian.net/browse/BOS-576
1 parent 0777e9c commit 7e053fd

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

modules/bitgo/test/v2/unit/staking/stakingWalletCommon.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,28 @@ describe('Staking Wallet Common', function () {
119119

120120
});
121121

122+
describe('cancelStakingRequest', function () {
123+
it('should call staking-service to cancel staking request', async function () {
124+
const stakingRequestId = '8638284a-dab2-46b9-b07f-21109a6e7220';
125+
const expected = {
126+
...fixtures.stakingRequest([
127+
fixtures.transaction('REJECTED'),
128+
]),
129+
status: 'REJECTED',
130+
};
131+
const msScope = nock(microservicesUri)
132+
.delete(`/api/staking/v1/${stakingWallet.coin}/wallets/${stakingWallet.walletId}/requests/${stakingRequestId}`)
133+
.reply(200, expected);
134+
135+
const stakingRequest = await stakingWallet.cancelStakingRequest(stakingRequestId);
136+
137+
should.exist(stakingRequest);
138+
139+
stakingRequest.should.deepEqual(expected);
140+
msScope.isDone().should.be.True();
141+
});
142+
});
143+
122144
describe('getStakingRequest', function () {
123145
it('should call staking-service to get staking request', async function () {
124146
const stakingRequestId = '8638284a-dab2-46b9-b07f-21109a6e7220';

modules/sdk-core/src/bitgo/staking/stakingWallet.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export class StakingWallet implements IStakingWallet {
5959
return await this.createStakingRequest(options, 'UNSTAKE');
6060
}
6161

62+
/**
63+
* Cancel staking request
64+
* @param stakingRequestId - id of the staking request to cancel
65+
* @return StakingRequest
66+
*/
67+
async cancelStakingRequest(stakingRequestId: string): Promise<StakingRequest> {
68+
return await this.bitgo.del(this.bitgo.microservicesUrl(this.stakingRequestUrl(stakingRequestId))).result();
69+
}
70+
6271
/**
6372
* Fetch delegations for a specific wallet
6473
* @param options - unstake options

0 commit comments

Comments
 (0)