Skip to content

Commit

Permalink
Merge branch 'x' into OK-35288
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming authored Jan 22, 2025
2 parents ace9a7b + dda5948 commit 23a6972
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/core/src/types/coreTypesTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export type IUnsignedTxPro = IUnsignedTx & {
rawTxUnsigned?: string;
uuid?: string;
isInternalSwap?: boolean;
isInternalTransfer?: boolean;
};
export type ISignedTx = {
txid: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/kit-bg/src/services/ServiceSend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ class ServiceSend extends ServiceBase {
prevNonce,
feeInfo,
isInternalSwap,
isInternalTransfer,
} = params;

let newUnsignedTx = unsignedTx;
Expand All @@ -560,6 +561,7 @@ class ServiceSend extends ServiceBase {
}

newUnsignedTx.isInternalSwap = isInternalSwap;
newUnsignedTx.isInternalTransfer = isInternalTransfer;

if (swapInfo) {
newUnsignedTx.swapInfo = swapInfo;
Expand Down
1 change: 1 addition & 0 deletions packages/kit-bg/src/vaults/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ export interface IBuildUnsignedTxParams {
feeInfo?: IFeeInfoUnit;
transferPayload?: ITransferPayload;
isInternalSwap?: boolean;
isInternalTransfer?: boolean;
}

export type ITokenApproveInfo = { allowance: string; isUnlimited: boolean };
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/hooks/useSignatureConfirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type IBuildUnsignedTxParams = {
feeInfoEditable?: boolean;
feeInfo?: IFeeInfoUnit;
isInternalSwap?: boolean;
isInternalTransfer?: boolean;
};

function useSignatureConfirm(params: IParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function SendDataInputContainer() {
paymentId: paymentIdValue,
note: noteValue,
},
isInternalTransfer: true,
});
setIsSubmitting(false);
} catch (e: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ type IProps = {
useFeeInTx?: boolean;
feeInfoEditable?: boolean;
popStack?: boolean;
fromAddress?: string;
toAddress?: string;
};

function TxConfirmActions(props: IProps) {
Expand All @@ -76,8 +74,6 @@ function TxConfirmActions(props: IProps) {
transferPayload,
useFeeInTx,
feeInfoEditable,
fromAddress,
toAddress,
popStack = true,
} = props;
const intl = useIntl();
Expand All @@ -100,6 +96,9 @@ function TxConfirmActions(props: IProps) {
const successfullySentTxs = useRef<string[]>([]);
const { bottom } = useSafeAreaInsets();

const toAddress = transferPayload?.originalRecipient;
const unsignedTx = unsignedTxs[0];

const dappApprove = useDappApproveAction({
id: sourceInfo?.id ?? '',
closeWindowAfterResolved: true,
Expand All @@ -125,11 +124,22 @@ function TxConfirmActions(props: IProps) {
updateSendTxStatus({ isSubmitting: true });
isSubmitted.current = true;
// Pre-check before submit

const accountAddress =
await backgroundApiProxy.serviceAccount.getAccountAddressForApi({
accountId,
networkId,
});
try {
if (networkId && fromAddress && toAddress) {
if (
unsignedTx.isInternalTransfer &&
networkId &&
accountAddress &&
toAddress
) {
await serviceSend.checkAddressBeforeSending({
networkId,
fromAddress,
fromAddress: accountAddress,
toAddress,
});
}
Expand Down Expand Up @@ -286,11 +296,11 @@ function TxConfirmActions(props: IProps) {
}
}, [
updateSendTxStatus,
sendSelectedFeeInfo,
accountId,
networkId,
fromAddress,
sendSelectedFeeInfo,
unsignedTx.isInternalTransfer,
toAddress,
accountId,
unsignedTxs,
nativeTokenTransferAmountToUpdate.isMaxSend,
nativeTokenTransferAmountToUpdate.amountToUpdate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ function formatTagValue(value: string | string[]) {

function Address(props: IProps) {
const intl = useIntl();
const { accountId, networkId, component, showAddressLocalTags } = props;
const {
accountId,
networkId: currentNetworkId,
component,
showAddressLocalTags,
} = props;

const networkId = component.networkId || currentNetworkId;

return (
<SignatureConfirmItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ function TxConfirm() {
},
);

const fromAddress = decodedTxs?.[0]?.owner;
const toAddress = decodedTxs?.[0]?.to;
usePromiseResult(async () => {
if (txConfirmParamsInit.current) return;
updateNativeTokenInfo({
Expand Down Expand Up @@ -272,11 +270,7 @@ function TxConfirm() {
<Page.Body testID="tx-confirmation-body" px="$5">
{renderTxConfirmContent()}
</Page.Body>
<TxConfirmActions
fromAddress={fromAddress}
toAddress={toAddress}
{...route.params}
/>
<TxConfirmActions {...route.params} />
</Page>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/utils/txActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ function convertAssetTransferActionToSignatureConfirmComponent({
}),
address: unsignedTx.swapInfo.receivingAddress,
tags: [],
networkId: unsignedTx.swapInfo.receiver.accountInfo.networkId,
};

components.push(receiveAddressComponent);
Expand Down
1 change: 1 addition & 0 deletions packages/shared/types/signatureConfirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface IDisplayComponentAddress {
iconURL?: string;
}[];
isNavigable?: boolean;
networkId?: string;
}

export interface IDisplayComponentAmount {
Expand Down

0 comments on commit 23a6972

Please sign in to comment.