Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop legacy shapeshift MX support #421

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions integration/src/bitcoin/bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,6 @@ export function bitcoinTests(get: () => { wallet: core.HDWallet; info: core.HDWa
TIMEOUT
);

test(
"btcSupportsNativeShapeShift()",
async () => {
if (!wallet) return;
expect(typeof wallet.btcSupportsNativeShapeShift() === typeof true);
if (wallet.btcSupportsNativeShapeShift()) {
expect(info.btcSupportsNativeShapeShift()).toBeTruthy();
}
// TODO: write a testcase that exercises native shapeshift, if the wallet claims to support it.
},
TIMEOUT
);

test(
"btcGetAccountPaths()",
async () => {
Expand Down
10 changes: 0 additions & 10 deletions integration/src/ethereum/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ export function ethereumTests(get: () => { wallet: core.HDWallet; info: core.HDW
TIMEOUT
);

test(
"ethSupportsNativeShapeShift()",
async () => {
if (!wallet) return;
// TODO: add a test that pays a ShapeShift conduit
expect(typeof wallet.ethSupportsNativeShapeShift() === typeof true).toBeTruthy();
},
TIMEOUT
);

test(
"ethSupportsSecureTransfer()",
async () => {
Expand Down
5 changes: 0 additions & 5 deletions integration/src/wallets/keepkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ export function selfTest(get: () => core.HDWallet): void {
await expect(wallet.ethSupportsNetwork(1)).resolves.toEqual(true);
});

it("supports ShapeShift", async () => {
if (!wallet) return;
expect(wallet.ethSupportsNativeShapeShift()).toEqual(true);
});

it("supports Secure Transfer", async () => {
if (!wallet) return;
await expect(wallet.ethSupportsSecureTransfer()).resolves.toEqual(true);
Expand Down
6 changes: 0 additions & 6 deletions integration/src/wallets/ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ export function selfTest(get: () => core.HDWallet): void {
expect(await wallet.ethSupportsNetwork(1)).toEqual(true);
});

it("does not support Native ShapeShift", async () => {
if (!wallet) return;
expect(wallet.ethSupportsNativeShapeShift()).toEqual(false);
expect(wallet.btcSupportsNativeShapeShift()).toEqual(false);
});

it("does not support Secure Transfer", async () => {
if (!wallet) return;
expect(await wallet.ethSupportsSecureTransfer()).toEqual(false);
Expand Down
5 changes: 0 additions & 5 deletions integration/src/wallets/metamask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ export function selfTest(get: () => core.HDWallet): void {
expect(core.supportsBTC(wallet)).toBe(false);
});

it("does not support Native ShapeShift", async () => {
if (!wallet) return;
expect(wallet.ethSupportsNativeShapeShift()).toEqual(false);
});

it("does not support EIP1559", async () => {
if (!wallet) return;
expect(await wallet.ethSupportsEIP1559()).toEqual(false);
Expand Down
6 changes: 0 additions & 6 deletions integration/src/wallets/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ export function selfTest(get: () => core.HDWallet): void {
expect(await wallet.ethSupportsNetwork()).toEqual(true);
});

it("does not support Native ShapeShift", async () => {
if (!wallet) return;
expect(wallet.ethSupportsNativeShapeShift()).toEqual(false);
expect(wallet.btcSupportsNativeShapeShift()).toEqual(false);
});

it("does not support Secure Transfer", async () => {
if (!wallet) return;
expect(await wallet.ethSupportsSecureTransfer()).toEqual(false);
Expand Down
6 changes: 0 additions & 6 deletions integration/src/wallets/trezor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,6 @@ export function selfTest(get: () => core.HDWallet): void {
expect(await wallet.ethSupportsNetwork(1)).toEqual(true);
});

it("does not support Native ShapeShift", async () => {
if (!wallet) return;
expect(wallet.ethSupportsNativeShapeShift()).toEqual(false);
expect(wallet.btcSupportsNativeShapeShift()).toEqual(false);
});

it("does not support Secure Transfer", async () => {
if (!wallet) return;
expect(await wallet.ethSupportsSecureTransfer()).toEqual(false);
Expand Down
18 changes: 1 addition & 17 deletions packages/hdwallet-core/src/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ta from "type-assertions";

import { addressNListToBIP32, slip44ByCoin } from "./utils";
import { BIP32Path, Coin, ExchangeType, HDWallet, HDWalletInfo, PathDescription } from "./wallet";
import { BIP32Path, Coin, HDWallet, HDWalletInfo, PathDescription } from "./wallet";

// GuardedUnion<T> will ensure a static typechecking error if any properties are set that aren't supposed
// to be present on the specific union member being passed in. (This also helps the compiler with type inference.)
Expand Down Expand Up @@ -201,15 +201,6 @@ export type BTCSignTxOutputChange = {
isChange: true;
};

export type BTCSignTxOutputExchange = {
/**
* Device must `btcSupportsNativeShapeShift()`
*/
addressType: BTCOutputAddressType.Exchange;
amount: string;
exchangeType: ExchangeType;
};

export type BTCSignTxOutputMemo = {
addressType?: BTCOutputAddressType.Spend;
amount?: "0";
Expand All @@ -223,7 +214,6 @@ export type BTCSignTxOutput = GuardedUnion<
| BTCSignTxOutputSpendP2WPKH
| BTCSignTxOutputTransfer
| BTCSignTxOutputChange
| BTCSignTxOutputExchange
| BTCSignTxOutputMemo
>;

Expand Down Expand Up @@ -272,7 +262,6 @@ export enum BTCOutputAddressType {
Spend = "spend",
Transfer = "transfer",
Change = "change",
Exchange = "exchange",
}

export interface BTCSignMessage {
Expand Down Expand Up @@ -326,11 +315,6 @@ export interface BTCWalletInfo extends HDWalletInfo {
*/
btcSupportsSecureTransfer(): Promise<boolean>;

/**
* Does the device support `/sendamountProto2` style ShapeShift trades?
*/
btcSupportsNativeShapeShift(): boolean;

/**
* Returns a list of bip32 paths for a given account index in preferred order
* from most to least preferred.
Expand Down
11 changes: 1 addition & 10 deletions packages/hdwallet-core/src/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addressNListToBIP32, slip44ByCoin } from "./utils";
import { ExchangeType, BIP32Path, HDWallet, HDWalletInfo, PathDescription } from "./wallet";
import { BIP32Path, HDWallet, HDWalletInfo, PathDescription } from "./wallet";

export enum ETHTransactionType {
ETH_TX_TYPE_LEGACY = 0,
Expand Down Expand Up @@ -54,10 +54,6 @@ export interface ETHSignTx {
data: string;
/** mainnet: 1, ropsten: 3, kovan: 42 */
chainId: number;
/**
* Device must `ethSupportsNativeShapeShift()`
*/
exchangeType?: ExchangeType;
}

export interface ETHTxHash {
Expand Down Expand Up @@ -105,11 +101,6 @@ export interface ETHWalletInfo extends HDWalletInfo {
*/
ethSupportsSecureTransfer(): Promise<boolean>;

/**
* Does the device support `/sendamountProto2` style ShapeShift trades?
*/
ethSupportsNativeShapeShift(): boolean;

/**
*
* Does the device support transactions with EIP-1559 fee parameters?
Expand Down
16 changes: 0 additions & 16 deletions packages/hdwallet-core/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ export interface LoadDevice {
skipChecksum?: boolean;
}

export interface ExchangeType {
/** `SignedExchangeResponse` from the `/sendamountProto2` ShapeShift endpoint, base64 encoded */
signedExchangeResponse: string;
withdrawalCoinName: string;
withdrawalAddressNList: BIP32Path;
withdrawalScriptType?: BTCInputScriptType;
returnAddressNList: BIP32Path;
returnScriptType?: BTCInputScriptType;
}

export interface DescribePath {
path: BIP32Path;
coin: Coin;
Expand Down Expand Up @@ -246,12 +236,6 @@ export interface HDWalletInfo {
*/
hasOnDeviceRecovery(): boolean;

/**
* Does the device support `/sendamountProto2` style native ShapeShift
* integration for the given pair?
*/
hasNativeShapeShift(srcCoin: Coin, dstCoin: Coin): boolean;

/**
* Will the device allow for transactions to be signed offline to be
* broadcasted separately?
Expand Down
36 changes: 1 addition & 35 deletions packages/hdwallet-keepkey/src/bitcoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as Exchange from "@keepkey/device-protocol/lib/exchange_pb";
import * as Messages from "@keepkey/device-protocol/lib/messages_pb";
import * as Types from "@keepkey/device-protocol/lib/types_pb";
import * as core from "@shapeshiftoss/hdwallet-core";
Expand Down Expand Up @@ -71,36 +70,7 @@ function prepareSignTx(
const output: core.BTCSignTxOutput = o;
const newOutput = new Types.TxOutputType();
newOutput.setAmount(Number(output.amount));
if (output.exchangeType) {
// BTCSignTxOutputExchange
// convert the base64 encoded signedExchangeResponse message into the correct object
const signedHex = core.base64toHEX(output.exchangeType.signedExchangeResponse);
const signedExchange = Exchange.SignedExchangeResponse.deserializeBinary(core.arrayify(signedHex));

// decode the deposit amount from a little-endian Uint8Array into an unsigned uint64
let depAmt = core.mustBeDefined(signedExchange.getResponsev2()).getDepositAmount_asU8();
let val = 0;
for (let jj = depAmt.length - 1; jj >= 0; jj--) {
val += depAmt[jj] * Math.pow(2, 8 * (depAmt.length - jj - 1));
// TODO validate is uint64
}
const outExchangeType = new Types.ExchangeType();
outExchangeType.setSignedExchangeResponse(signedExchange);
outExchangeType.setWithdrawalCoinName(output.exchangeType.withdrawalCoinName);
outExchangeType.setWithdrawalAddressNList(output.exchangeType.withdrawalAddressNList);
outExchangeType.setWithdrawalScriptType(
translateInputScriptType(output.exchangeType.withdrawalScriptType || core.BTCInputScriptType.SpendAddress)
);
outExchangeType.setReturnAddressNList(output.exchangeType.returnAddressNList);
outExchangeType.setReturnScriptType(
translateInputScriptType(output.exchangeType.returnScriptType || core.BTCInputScriptType.SpendAddress)
);
newOutput.setAmount(val);
newOutput.setAddress(core.mustBeDefined(signedExchange.toObject().responsev2?.depositAddress?.address));
newOutput.setScriptType(Types.OutputScriptType.PAYTOADDRESS);
newOutput.setAddressType(Types.OutputAddressType.EXCHANGE);
newOutput.setExchangeType(outExchangeType);
} else if (output.isChange || output.addressType === core.BTCOutputAddressType.Transfer) {
if (output.isChange || output.addressType === core.BTCOutputAddressType.Transfer) {
// BTCSignTxOutputTranfer || BTCSignTxOutputChange
newOutput.setScriptType(translateOutputScriptType(output.scriptType));
newOutput.setAddressNList(output.addressNList);
Expand Down Expand Up @@ -503,10 +473,6 @@ export async function btcSupportsSecureTransfer(): Promise<boolean> {
return true;
}

export function btcSupportsNativeShapeShift(): boolean {
return true;
}

export async function btcSignMessage(
wallet: core.BTCWallet,
transport: Transport,
Expand Down
24 changes: 1 addition & 23 deletions packages/hdwallet-keepkey/src/ethereum.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as Exchange from "@keepkey/device-protocol/lib/exchange_pb";
import * as Messages from "@keepkey/device-protocol/lib/messages_pb";
import * as Types from "@keepkey/device-protocol/lib/types_pb";
import * as core from "@shapeshiftoss/hdwallet-core";
import Common from "@ethereumjs/common";
import { FeeMarketEIP1559Transaction, Transaction } from "@ethereumjs/tx";
import * as eip55 from "eip55";

import { toUTF8Array, translateInputScriptType } from "./utils";
import { toUTF8Array } from "./utils";
import { Transport } from "./transport";

export async function ethSupportsNetwork(chain_id: number): Promise<boolean> {
Expand All @@ -17,10 +16,6 @@ export async function ethSupportsSecureTransfer(): Promise<boolean> {
return true;
}

export function ethSupportsNativeShapeShift(): boolean {
return true;
}

export function ethGetAccountPaths(msg: core.ETHGetAccountPath): Array<core.ETHAccountPath> {
const slip44 = core.slip44ByCoin(msg.coin);
if (slip44 === undefined) return [];
Expand Down Expand Up @@ -63,23 +58,6 @@ export async function ethSignTx(transport: Transport, msg: core.ETHSignTx): Prom
if (msg.toAddressNList) {
est.setAddressType(Types.OutputAddressType.SPEND);
est.setToAddressNList(msg.toAddressNList);
} else if (msg.exchangeType) {
est.setAddressType(Types.OutputAddressType.EXCHANGE);

const signedHex = core.base64toHEX(msg.exchangeType.signedExchangeResponse);
const signedExchangeOut = Exchange.SignedExchangeResponse.deserializeBinary(core.arrayify(signedHex));
const exchangeType = new Types.ExchangeType();
exchangeType.setSignedExchangeResponse(signedExchangeOut);
exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName); // KeepKey firmware will complain if this doesn't match signed exchange response
exchangeType.setWithdrawalAddressNList(msg.exchangeType.withdrawalAddressNList);
exchangeType.setWithdrawalScriptType(
translateInputScriptType(msg.exchangeType.withdrawalScriptType || core.BTCInputScriptType.SpendAddress)
);
exchangeType.setReturnAddressNList(msg.exchangeType.returnAddressNList);
exchangeType.setReturnScriptType(
translateInputScriptType(msg.exchangeType.returnScriptType || core.BTCInputScriptType.SpendAddress)
);
est.setExchangeType(exchangeType);
} else {
est.setAddressType(Types.OutputAddressType.SPEND);
}
Expand Down
24 changes: 0 additions & 24 deletions packages/hdwallet-keepkey/src/keepkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,6 @@ export class KeepKeyHDWalletInfo
return Btc.btcSupportsSecureTransfer();
}

public btcSupportsNativeShapeShift(): boolean {
return Btc.btcSupportsNativeShapeShift();
}

public btcGetAccountPaths(msg: core.BTCGetAccountPaths): Array<core.BTCAccountPath> {
return Btc.btcGetAccountPaths(msg);
}
Expand All @@ -416,10 +412,6 @@ export class KeepKeyHDWalletInfo
return Eth.ethSupportsSecureTransfer();
}

public ethSupportsNativeShapeShift(): boolean {
return Eth.ethSupportsNativeShapeShift();
}

public async ethSupportsEIP1559(): Promise<boolean> {
return true;
}
Expand Down Expand Up @@ -464,10 +456,6 @@ export class KeepKeyHDWalletInfo
return false;
}

public hasNativeShapeShift(srcCoin: core.Coin, dstCoin: core.Coin): boolean {
return true;
}

public supportsOfflineSigning(): boolean {
return true;
}
Expand Down Expand Up @@ -806,10 +794,6 @@ export class KeepKeyHDWallet implements core.HDWallet, core.BTCWallet, core.ETHW
return false;
}

public hasNativeShapeShift(srcCoin: core.Coin, dstCoin: core.Coin): boolean {
return true;
}

public supportsOfflineSigning(): boolean {
return true;
}
Expand Down Expand Up @@ -1149,10 +1133,6 @@ export class KeepKeyHDWallet implements core.HDWallet, core.BTCWallet, core.ETHW
return this.info.btcSupportsSecureTransfer();
}

public btcSupportsNativeShapeShift(): boolean {
return this.info.btcSupportsNativeShapeShift();
}

public async ethSupportsEIP1559(): Promise<boolean> {
// EIP1559 support starts in v7.2.1
return semver.gte(await this.getFirmwareVersion(), "v7.2.1");
Expand Down Expand Up @@ -1203,10 +1183,6 @@ export class KeepKeyHDWallet implements core.HDWallet, core.BTCWallet, core.ETHW
return this.info.ethSupportsSecureTransfer();
}

public ethSupportsNativeShapeShift(): boolean {
return this.info.ethSupportsNativeShapeShift();
}

public ethGetAccountPaths(msg: core.ETHGetAccountPath): Array<core.ETHAccountPath> {
return this.info.ethGetAccountPaths(msg);
}
Expand Down
Loading