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