Skip to content

Commit

Permalink
feat(etc): add non-bitgo recovery and unsigned sweep support for etc
Browse files Browse the repository at this point in the history
TICKET: COIN-1418
  • Loading branch information
bhupendra11 committed Aug 30, 2024
1 parent f716375 commit 8961b05
Show file tree
Hide file tree
Showing 9 changed files with 7,417 additions and 176 deletions.
2 changes: 1 addition & 1 deletion ETC.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Create a new file called `broadcastETCTransaction.js`
and add the following script:

```js
const axios = require('axios');
import axios from 'axios';
// Replace with your API key
const apiKey = 'your-api-key-here';
Expand Down
3 changes: 3 additions & 0 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Dot, Tdot } from '@bitgo/sdk-coin-dot';
import { Eos, Teos } from '@bitgo/sdk-coin-eos';
import { AbstractEthLikeNewCoins, Erc20Token, Eth, Hteth } from '@bitgo/sdk-coin-eth';
import { Ethw } from '@bitgo/sdk-coin-ethw';
import { Etc, Tetc } from '@bitgo/sdk-coin-etc';
import { Ltc } from '@bitgo/sdk-coin-ltc';
import { Near, TNear } from '@bitgo/sdk-coin-near';
import { Opeth, Topeth, OpethToken } from '@bitgo/sdk-coin-opeth';
Expand Down Expand Up @@ -83,6 +84,8 @@ sdk.register('tbtc', Tbtc.createInstance);
sdk.register('eth', Eth.createInstance);
sdk.register('hteth', Hteth.createInstance);
sdk.register('ethw', Ethw.createInstance);
sdk.register('etc', Etc.createInstance);
sdk.register('tetc', Tetc.createInstance);
sdk.register('eos', Eos.createInstance);
sdk.register('teos', Teos.createInstance);
sdk.register('xlm', Xlm.createInstance);
Expand Down
7,563 changes: 7,395 additions & 168 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@bitgo/sdk-coin-doge": "2.0.32",
"@bitgo/sdk-coin-dot": "4.1.10",
"@bitgo/sdk-coin-eos": "2.1.25",
"@bitgo/sdk-coin-etc": "2.2.0",
"@bitgo/sdk-coin-eth": "24.2.21",
"@bitgo/sdk-coin-ethlike": "1.1.13",
"@bitgo/sdk-coin-ethw": "20.0.32",
Expand Down
1 change: 1 addition & 0 deletions scripts/build-icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const coins = [
'zec',
'btg',
'eth',
'etc',
'trx',
'bsv',
'eos',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNavigate, useParams } from 'react-router-dom';
import { CoinsSelectAutocomplete } from '~/components';
import { useAlertBanner } from '~/contexts';
import {
assert,
assert, getEip1559Params,
getEthLikeRecoveryChainId,
getTokenChain,
includePubsFor,
Expand Down Expand Up @@ -112,6 +112,8 @@ function Form() {
);
case 'eth':
case 'hteth':
case 'etc':
case 'tetc':
case 'arbeth':
case 'tarbeth':
case 'opeth':
Expand All @@ -135,10 +137,7 @@ function Form() {
await updateKeysFromIds(coin, values);
const recoverData = await window.commands.recover(coin, {
...rest,
eip1559: {
maxFeePerGas: toWei(maxFeePerGas),
maxPriorityFeePerGas: toWei(maxPriorityFeePerGas),
},
eip1559: getEip1559Params(coin, maxFeePerGas, maxPriorityFeePerGas),
replayProtectionOptions: {
chain: getEthLikeRecoveryChainId(coin, bitGoEnvironment),
hardfork: 'london',
Expand Down
2 changes: 2 additions & 0 deletions src/containers/NonBitGoRecoveryCoin/NonBitGoRecoveryCoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ function Form() {
);
case 'eth':
case 'hteth':
case 'etc':
case 'tetc':
case 'arbeth':
case 'tarbeth':
case 'opeth':
Expand Down
4 changes: 4 additions & 0 deletions src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ export const buildUnsignedSweepCoins: Record<
allCoinMetas.zec,
allCoinMetas.btg,
allCoinMetas.eth,
allCoinMetas.etc,
allCoinMetas.ethw,
allCoinMetas.erc20,
allCoinMetas.trx,
Expand Down Expand Up @@ -661,6 +662,7 @@ export const buildUnsignedSweepCoins: Record<
allCoinMetas.txrp,
allCoinMetas.txlm,
allCoinMetas.hteth,
allCoinMetas.tetc,
allCoinMetas.hterc20,
allCoinMetas.ttrx,
allCoinMetas.ttrxToken,
Expand Down Expand Up @@ -697,6 +699,7 @@ export const nonBitgoRecoveryCoins: Record<BitgoEnv, readonly CoinMetadata[]> =
allCoinMetas.zec,
allCoinMetas.btg,
allCoinMetas.eth,
allCoinMetas.etc,
allCoinMetas.ethw,
allCoinMetas.erc20,
allCoinMetas.trx,
Expand Down Expand Up @@ -736,6 +739,7 @@ export const nonBitgoRecoveryCoins: Record<BitgoEnv, readonly CoinMetadata[]> =
allCoinMetas.txrp,
allCoinMetas.txlm,
allCoinMetas.hteth,
allCoinMetas.tetc,
allCoinMetas.hterc20,
allCoinMetas.ttrx,
allCoinMetas.ttrxToken,
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,13 @@ export function isBscChain(coin: string) {
return (coin === 'bsc' || coin === 'tbsc')
}

export function isEtcChain(coin: string) {
return (coin === 'etc' || coin === 'tetc')
}

export function getEip1559Params(coin: string, maxFeePerGas: number, maxPriorityFeePerGas: number) {
// bsc and tbsc doesn't support EIP-1559
if (isBscChain(coin)) {
// bsc/tbsc and etc/tetc doesn't support EIP-1559
if (isBscChain(coin) || isEtcChain(coin)) {
return undefined;
}
return {
Expand Down

0 comments on commit 8961b05

Please sign in to comment.