Skip to content

Commit

Permalink
feat: update quoter
Browse files Browse the repository at this point in the history
  • Loading branch information
kwoktung committed Oct 22, 2023
1 parent 1e759b8 commit 352bfc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/engine/src/vaults/impl/btc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type IEncodedTxBtc = {
outputs: Array<{
address: string;
value: string;
payload?: { isCharge?: boolean; bip44Path?: string };
payload?: { isCharge?: boolean; bip44Path?: string; opReturn?: string };
inscriptions?: NFTBTCAssetModel[];
}>;
totalFee: string;
Expand Down
14 changes: 12 additions & 2 deletions packages/kit/src/views/Swap/quoter/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import axios from 'axios';
import BigNumber from 'bignumber.js';
import { th } from 'date-fns/locale';
import * as ethers from 'ethers';

import { getNetworkImpl } from '@onekeyhq/engine/src/managers/network';
import type { Token } from '@onekeyhq/engine/src/types/token';
import type { IEncodedTxAptos } from '@onekeyhq/engine/src/vaults/impl/apt/types';
import type { IEncodedTxBtc } from '@onekeyhq/engine/src/vaults/impl/btc/types';
import type { IEncodedTxEvm } from '@onekeyhq/engine/src/vaults/impl/evm/Vault';
import { IDecodedTxStatus } from '@onekeyhq/engine/src/vaults/types';
import { OnekeyNetwork } from '@onekeyhq/shared/src/config/networkIds';
Expand Down Expand Up @@ -267,6 +266,17 @@ export class SwapQuoter {
opReturn: order.memo,
},
});
if (result) {
const btcResult = result as IEncodedTxBtc;
const isOpReturnEqualOrderMemo = btcResult.outputs.some(
(output) => output.payload?.opReturn === order.memo,
);
if (!isOpReturnEqualOrderMemo) {
throw new Error(
'failed to build transaction due to invalid opReturn',
);
}
}
return result;
}
if (
Expand Down

0 comments on commit 352bfc4

Please sign in to comment.