-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpending-approval-workaround.js
More file actions
35 lines (25 loc) · 938 Bytes
/
pending-approval-workaround.js
File metadata and controls
35 lines (25 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const BitGoJS = require('bitgo');
const bitgo = new BitGoJS.BitGo({ env: 'prod' });
const Promise = require('bluebird');
const coin = 'btc';
const basecoin = bitgo.coin(coin);
// wallet
const walletId = '';
// pull from localStorage > Session Storage > BG.Tokens.token in the UI
const accessToken = "";
// tap OTP here
const otp = '';
// this is the pending approval for the tx - can pull this from UI network tab
const pendingApprovalId = '';
Promise.coroutine(function *() {
bitgo.authenticateWithAccessToken({ accessToken });
const walletInstance = yield basecoin.wallets()
.get({ id: walletId });
// assume one pending approval
const rgrPendingApproval = walletInstance.pendingApprovals()[0];
console.dir(rgrPendingApproval, { depth: 4 });
if (rgrPendingApproval._pendingApproval.id === pendingApprovalId) {
const approve = yield rgrPendingApproval.approve({ otp });
console.log(approve);
}
})();