Skip to content

Commit

Permalink
refactor(abstract-eth): move methods to abstract-eth
Browse files Browse the repository at this point in the history
  • Loading branch information
gianchandania committed Nov 7, 2023
1 parent 05695da commit 0c0bc80
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 45 deletions.
5 changes: 4 additions & 1 deletion modules/abstract-eth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"ethereumjs-abi": "^0.6.5",
"ethereumjs-util": "7.1.5",
"ethers": "^5.1.3",
"lodash": "4.17.21"
"lodash": "4.17.21",
"keccak": "^3.0.3",
"secp256k1": "5.0.0",
"@bitgo/sdk-lib-mpc": "^8.15.0"
}
}
4 changes: 0 additions & 4 deletions modules/sdk-coin-eth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,11 @@
"dependencies": {
"@bitgo/abstract-eth": "^1.6.0",
"@bitgo/sdk-core": "^8.26.0",
"@bitgo/sdk-lib-mpc": "^8.15.0",
"@bitgo/statics": "^29.0.0",
"@bitgo/utxo-lib": "^9.16.0",
"@ethereumjs/common": "^2.6.5",
"@ethereumjs/tx": "^3.3.0",
"@ethereumjs/util": "8.0.3",
"@metamask/eth-sig-util": "^5.0.2",
"bignumber.js": "^9.0.0",
"bn.js": "^5.2.1",
"ethereumjs-abi": "^0.6.5",
"ethereumjs-util": "7.1.5",
"ethers": "^5.1.3",
Expand Down
37 changes: 0 additions & 37 deletions modules/sdk-coin-ethw/src/ethw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import request from 'superagent';

import BigNumber from 'bignumber.js';
import { BN } from 'ethereumjs-util';

import {
Expand All @@ -10,13 +9,11 @@ import {
KeyPair,
ParsedTransaction,
ParseTransactionOptions,
TransactionExplanation,
VerifyAddressOptions,
VerifyTransactionOptions,
} from '@bitgo/sdk-core';
import { BaseCoin as StaticsBaseCoin, coins } from '@bitgo/statics';
import { Eth, optionalDeps, TransactionBuilder } from '@bitgo/sdk-coin-eth';
import { ExplainTransactionOptions } from '@bitgo/abstract-eth';

type FullNodeResponseBody = {
jsonrpc: string;
Expand Down Expand Up @@ -123,40 +120,6 @@ export class Ethw extends Eth {
return response.body;
}

/**
* Explain a transaction from txHex
* @param params The options with which to explain the transaction
*/
async explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation> {
const txHex = params.txHex || (params.halfSigned && params.halfSigned.txHex);
if (!txHex || !params.feeInfo) {
throw new Error('missing explain tx parameters');
}
const txBuilder = this.getTransactionBuilder();
txBuilder.from(txHex);
const tx = await txBuilder.build();
const outputs = tx.outputs.map((output) => {
return {
address: output.address,
amount: output.value,
};
});

const displayOrder = ['id', 'outputAmount', 'changeAmount', 'outputs', 'changeOutputs', 'fee'];

return {
displayOrder,
id: tx.id,
outputs: outputs,
outputAmount: outputs
.reduce((accumulator, output) => accumulator.plus(output.amount), new BigNumber('0'))
.toFixed(0),
changeOutputs: [], // account based does not use change outputs
changeAmount: '0', // account base does not make change
fee: params.feeInfo,
};
}

/**
* Create a new transaction builder for the current chain
* @return a new transaction builder
Expand Down
3 changes: 0 additions & 3 deletions modules/sdk-coin-polygon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
"@bitgo/statics": "^29.0.0",
"@bitgo/utxo-lib": "^9.16.0",
"@ethereumjs/common": "^2.6.5",
"@ethereumjs/tx": "^3.3.0",
"bignumber.js": "^9.0.0",
"ethereumjs-abi": "^0.6.5",
"lodash": "^4.17.14",
"superagent": "^3.8.3"
},
"devDependencies": {
Expand Down

0 comments on commit 0c0bc80

Please sign in to comment.