- {assetRows.map(
- ({
- code = "",
- domain,
- image = "",
- issuer = "",
- contractId = "",
- name,
- }) => {
- const isScamAsset = !!blockedDomains.domains[domain];
- const _issuer = contractId || issuer;
- const canonical = getCanonicalFromAsset(code, _issuer);
+ {assetRows.map(({ code = "", domain, image = "", issuer = "" }) => {
+ const isScamAsset = !!blockedDomains.domains[domain];
+ const isContract = isContractId(issuer);
+ const canonical = getCanonicalFromAsset(code, issuer);
- return (
-
{
- if (assetSelect.isSource) {
- dispatch(saveAsset(canonical));
- if (contractId) {
- dispatch(saveIsToken(true));
- } else {
- dispatch(saveIsToken(false));
- }
- history.goBack();
+ return (
+
{
+ if (assetSelect.isSource) {
+ dispatch(saveAsset(canonical));
+ if (isContract) {
+ dispatch(saveIsToken(true));
} else {
- dispatch(saveDestinationAsset(canonical));
- history.goBack();
+ dispatch(saveIsToken(false));
}
- }}
- >
-
-
-
- {contractId ? name : code}
-
-
-
- {formatDomain(domain)}
-
+ history.goBack();
+ } else {
+ dispatch(saveDestinationAsset(canonical));
+ history.goBack();
+ }
+ }}
+ >
+
+
+
+ {code}
+
+
+
+ {formatDomain(domain)}
- {!hideBalances && (
-
- {formatAmount(getAccountBalance(canonical))} {code}
-
- )}
- );
- },
- )}
+ {!hideBalances && (
+
+ {formatAmount(getAccountBalance(canonical))} {code}
+
+ )}
+
+ );
+ })}
);
diff --git a/extension/src/popup/components/sendPayment/SendConfirm/TransactionDetails/index.tsx b/extension/src/popup/components/sendPayment/SendConfirm/TransactionDetails/index.tsx
index f9c7515a8e..545d2a7c00 100644
--- a/extension/src/popup/components/sendPayment/SendConfirm/TransactionDetails/index.tsx
+++ b/extension/src/popup/components/sendPayment/SendConfirm/TransactionDetails/index.tsx
@@ -6,7 +6,6 @@ import {
Asset,
Memo,
Operation,
- SorobanRpc,
TransactionBuilder,
} from "stellar-sdk";
import { Card, Loader, Icon, Button } from "@stellar/design-system";
@@ -271,14 +270,9 @@ export const TransactionDetails = ({ goBack }: { goBack: () => void }) => {
const handleXferTransaction = async () => {
try {
- const preparedTransaction = SorobanRpc.assembleTransaction(
- transactionSimulation.raw!,
- transactionSimulation.response!,
- );
-
const res = await dispatch(
signFreighterSorobanTransaction({
- transactionXDR: preparedTransaction.build().toXDR(),
+ transactionXDR: transactionSimulation.preparedTransaction!,
network: networkDetails.networkPassphrase,
}),
);
diff --git a/extension/src/popup/components/sendPayment/SendSettings/index.tsx b/extension/src/popup/components/sendPayment/SendSettings/index.tsx
index ca2533e9c7..ce8f8e2aba 100644
--- a/extension/src/popup/components/sendPayment/SendSettings/index.tsx
+++ b/extension/src/popup/components/sendPayment/SendSettings/index.tsx
@@ -1,6 +1,5 @@
import React, { useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
-import { Address, XdrLargeInt } from "stellar-sdk";
import { Formik, Form, Field, FieldProps } from "formik";
import { Icon, Textarea, Link, Button } from "@stellar/design-system";
import { useTranslation } from "react-i18next";
@@ -89,11 +88,11 @@ export const SendSettings = ({
Number(assetBalance.decimals),
);
- const params = [
- new Address(publicKey).toScVal(), // from
- new Address(destination).toScVal(), // to
- new XdrLargeInt("i128", parsedAmount.toNumber()).toI128(), // amount
- ];
+ const params = {
+ publicKey,
+ destination,
+ amount: parsedAmount.toNumber(),
+ };
try {
const networkDetails = await getNetworkDetails();
@@ -107,7 +106,7 @@ export const SendSettings = ({
pub_key: publicKey,
memo,
params,
- network_url: networkDetails.networkUrl,
+ network_url: networkDetails.sorobanRpcUrl,
network_passphrase: networkDetails.networkPassphrase,
}),
};
@@ -118,21 +117,22 @@ export const SendSettings = ({
if (!response.ok) {
throw new Error("failed to simluate token transfer");
}
- const { simulationResponse, raw } = await response.json();
+ const {
+ preparedTransaction,
+ simulationResponse,
+ } = await response.json();
- if ("transactionData" in simulationResponse) {
+ if (preparedTransaction) {
dispatch(
saveSimulation({
response: simulationResponse,
- raw,
+ preparedTransaction,
}),
);
navigateTo(next);
return;
}
- throw new Error(
- `Failed to simluate transaction, ID: ${simulationResponse.id}`,
- );
+ throw new Error(`Failed to simluate transaction`);
} catch (error) {
throw new Error(
`Failed to simluate transaction: ${JSON.stringify(error)}`,
diff --git a/extension/src/popup/ducks/transactionSubmission.ts b/extension/src/popup/ducks/transactionSubmission.ts
index 10f7140312..d2edbb437c 100644
--- a/extension/src/popup/ducks/transactionSubmission.ts
+++ b/extension/src/popup/ducks/transactionSubmission.ts
@@ -1,11 +1,7 @@
import {
Horizon,
Keypair,
- Memo,
- MemoType,
- Operation,
SorobanRpc,
- Transaction,
TransactionBuilder,
xdr,
} from "stellar-sdk";
@@ -438,7 +434,7 @@ interface InitialState {
transactionData: TransactionData;
transactionSimulation: {
response: SorobanRpc.Api.SimulateTransactionSuccessResponse | null;
- raw: Transaction
, Operation[]> | null;
+ preparedTransaction: string | null;
};
accountBalances: AccountBalancesInterface;
destinationBalances: AccountBalancesInterface;
@@ -477,7 +473,7 @@ export const initialState: InitialState = {
},
transactionSimulation: {
response: null,
- raw: null,
+ preparedTransaction: null,
},
hardwareWalletData: {
status: ShowOverlayStatus.IDLE,
diff --git a/extension/src/popup/helpers/soroban.ts b/extension/src/popup/helpers/soroban.ts
index 8534038b73..ec3e19204c 100644
--- a/extension/src/popup/helpers/soroban.ts
+++ b/extension/src/popup/helpers/soroban.ts
@@ -203,3 +203,12 @@ export const getAttrsFromSorobanHorizonOp = (
return getRootInvocationArgs(invokeHostFn);
};
+
+export const isContractId = (contractId: string) => {
+ try {
+ StrKey.decodeContract(contractId);
+ return true;
+ } catch (error) {
+ return false;
+ }
+};