|
1 | | -import 'should'; |
| 1 | +import * as should from 'should'; |
2 | 2 |
|
3 | 3 | import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; |
4 | 4 | import { BitGoAPI } from '@bitgo/sdk-api'; |
5 | 5 |
|
6 | 6 | import { Wemix, Twemix } from '../../src/index'; |
| 7 | +import { UnsignedSweepTxMPCv2 } from '@bitgo/abstract-eth'; |
| 8 | +import { mockDataUnsignedSweep } from '../resources'; |
| 9 | +import nock from 'nock'; |
| 10 | +import { common } from '@bitgo/sdk-core'; |
7 | 11 |
|
8 | 12 | const bitgo: TestBitGoAPI = TestBitGo.decorate(BitGoAPI, { env: 'test' }); |
9 | 13 |
|
@@ -40,3 +44,55 @@ describe('wemix', function () { |
40 | 44 | }); |
41 | 45 | }); |
42 | 46 | }); |
| 47 | + |
| 48 | +describe('Build Unsigned Sweep for Self-Custody Cold Wallets (MPCv2)', function () { |
| 49 | + const bitgo = TestBitGo.decorate(BitGoAPI, { env: 'test' }); |
| 50 | + const explorerUrl = common.Environments[bitgo.getEnv()].wemixExplorerBaseUrl as string; |
| 51 | + |
| 52 | + it('should generate an unsigned sweep without derivation path', async () => { |
| 53 | + nock(explorerUrl) |
| 54 | + .get('/api') |
| 55 | + .twice() |
| 56 | + .query(mockDataUnsignedSweep.getTxListRequest) |
| 57 | + .reply(200, mockDataUnsignedSweep.getTxListResponse); |
| 58 | + nock(explorerUrl) |
| 59 | + .get('/api') |
| 60 | + .query(mockDataUnsignedSweep.getBalanceRequest) |
| 61 | + .reply(200, mockDataUnsignedSweep.getBalanceResponse); |
| 62 | + |
| 63 | + const baseCoin: any = bitgo.coin('twemix'); |
| 64 | + const transaction = (await baseCoin.recover({ |
| 65 | + userKey: mockDataUnsignedSweep.userKey, |
| 66 | + backupKey: mockDataUnsignedSweep.backupKey, |
| 67 | + walletContractAddress: mockDataUnsignedSweep.walletBaseAddress, |
| 68 | + recoveryDestination: mockDataUnsignedSweep.recoveryDestination, |
| 69 | + isTss: true, |
| 70 | + eip1559: { maxFeePerGas: 20000000000, maxPriorityFeePerGas: 10000000000 }, |
| 71 | + gasLimit: 500000, |
| 72 | + replayProtectionOptions: { |
| 73 | + chain: 1112, |
| 74 | + hardfork: 'london', |
| 75 | + }, |
| 76 | + })) as UnsignedSweepTxMPCv2; |
| 77 | + should.exist(transaction); |
| 78 | + transaction.should.have.property('txRequests'); |
| 79 | + transaction.txRequests.length.should.equal(1); |
| 80 | + const txRequest = transaction.txRequests[0]; |
| 81 | + txRequest.should.have.property('walletCoin'); |
| 82 | + txRequest.walletCoin.should.equal('twemix'); |
| 83 | + txRequest.should.have.property('transactions'); |
| 84 | + txRequest.transactions.length.should.equal(1); |
| 85 | + const tx = txRequest.transactions[0]; |
| 86 | + tx.should.have.property('nonce'); |
| 87 | + tx.should.have.property('unsignedTx'); |
| 88 | + tx.unsignedTx.should.have.property('serializedTxHex'); |
| 89 | + tx.unsignedTx.should.have.property('signableHex'); |
| 90 | + tx.unsignedTx.should.have.property('derivationPath'); |
| 91 | + tx.unsignedTx.should.have.property('feeInfo'); |
| 92 | + tx.unsignedTx.feeInfo?.should.have.property('fee'); |
| 93 | + tx.unsignedTx.feeInfo?.should.have.property('feeString'); |
| 94 | + tx.unsignedTx.should.have.property('parsedTx'); |
| 95 | + tx.unsignedTx.parsedTx?.should.have.property('spendAmount'); |
| 96 | + tx.unsignedTx.parsedTx?.should.have.property('outputs'); |
| 97 | + }); |
| 98 | +}); |
0 commit comments