Skip to content

Commit

Permalink
mobile: release nits draft (#1256)
Browse files Browse the repository at this point in the history
* release nits

* wip

* rebase

* revert history op
  • Loading branch information
kayleegeorge authored Aug 10, 2024
1 parent 072e57d commit 1620e6c
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
amountToDollars,
getAccountName,
getChainDisplayName,
getDAv2Chain,
getDisplayFromTo,
getSynthesizedMemo,
getDAv2Chain,
tryOrNull,
} from "@daimo/common";
import { ChainConfig, daimoChainFromId } from "@daimo/contract";
Expand Down
20 changes: 4 additions & 16 deletions apps/daimo-mobile/src/view/screen/send/CoinDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import {
ForeignToken,
arbitrum,
arbitrumSepolia,
arbitrumUSDC,
base,
baseSepolia,
baseUSDC,
getChainDisplayName,
optimism,
optimismSepolia,
optimismUSDC,
polygon,
polygonAmoy,
polygonUSDC,
getSupportedSendPairs,
SendPair,
} from "@daimo/common";
import {
Image,
Expand All @@ -32,12 +31,8 @@ import IconPolygon from "../../../../assets/logos/poly-logo.png";
import { useAccount } from "../../../logic/accountManager";
import { color, ss } from "../../shared/style";

type SendPair = {
chain: DAv2Chain;
coin: ForeignToken;
};

// Get the logo for the chain
// TODO: move elsewhere
const getChainUri = (chain: DAv2Chain) => {
switch (chain) {
case base:
Expand Down Expand Up @@ -78,14 +73,7 @@ export function SendCoinButton({

const homeCoin = baseUSDC; // TODO: add home coin to account
const chainUri = getChainUri(toChain);

// TODO
const supportedSendPairs: SendPair[] = [
{ chain: base, coin: baseUSDC },
{ chain: optimism, coin: optimismUSDC },
{ chain: polygon, coin: polygonUSDC },
{ chain: arbitrum, coin: arbitrumUSDC },
];
const supportedSendPairs = getSupportedSendPairs(toChain.chainId);

return (
<SelectDropdown
Expand Down
13 changes: 6 additions & 7 deletions apps/daimo-mobile/src/view/screen/send/SendTransferScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
assert,
assertNotNull,
baseUSDC,
daimoChainToId,
dollarsToAmount,
getAccountName,
isTestnetChain,
now,
DAv2Chain,
getDAv2Chain,
Expand Down Expand Up @@ -225,9 +223,8 @@ function SendChooseAmount({
const result = rpcHook.validateMemo.useQuery({ memo });
const memoStatus = result.data;

// Token swapping is not supported on testnet
const isTestnet = isTestnetChain(daimoChainToId(daimoChain));
const isFixed = recipient.name != null || isTestnet;
// If sending to another DAv2, will be same chain, same coin
const sendCoinIsFixed = recipient.name != null;

return (
<View>
Expand All @@ -245,15 +242,17 @@ function SendChooseAmount({
<Spacer h={16} />
<View style={styles.detailsRow}>
<View style={styles.detail}>
{!isFixed && <TextMeta color={color.gray3}>{i18.memo()}</TextMeta>}
{!sendCoinIsFixed && (
<TextMeta color={color.gray3}>{i18.memo()}</TextMeta>
)}
<SendMemoButton
memo={memo}
memoStatus={memoStatus}
setMemo={setMemo}
/>
</View>

{!isFixed && (
{!sendCoinIsFixed && (
<View style={styles.detail}>
<TextMeta color={color.gray3}>{i18.sendAs()}</TextMeta>
<SendCoinButton
Expand Down
2 changes: 1 addition & 1 deletion packages/daimo-common/src/i18n/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function displayAddrLabel(type: AddrLabel): string {
case AddrLabel.Binance:
return `binance`;
case AddrLabel.FastCCTP:
return `instant cross-chain`;
return `cross-chain`;
default:
return `unknown`;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/daimo-common/src/i18n/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function displayAddrLabel(type: AddrLabel): string {
case AddrLabel.Binance:
return `binance`;
case AddrLabel.FastCCTP:
return `cross-chain instantáneo`;
return `cross-chain`;
default:
throw new Error(`Invalid AddrLabel: ${type}`);
}
Expand Down
1 change: 1 addition & 0 deletions packages/daimo-common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export * from "./foreignToken";
export * from "./chain";
export * from "./retryBackoff";
export * from "./cctp";
export * from "./sendPair";
2 changes: 1 addition & 1 deletion packages/daimo-common/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export enum AddrLabel {
LiFi = "li.fi bridge",
UniswapETHPool = "swapped ETH",
Binance = "binance",
FastCCTP = "instant cross-chain",
FastCCTP = "cross-chain",
}

/** Subset of EAccount for Daimo accounts, which always have a name. */
Expand Down
10 changes: 8 additions & 2 deletions packages/daimo-common/src/op.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ export type PendingOp = {
inviteCode?: string;
};

/** Original (non-home-coin) inbound transfer, for an inbound swap. */
/**
* Original (non-home-coin) inbound transfer, for an inbound swap or inbound
* cross-chain transfer.
*/
export type PreSwapTransfer = {
coin: ForeignToken;
amount: BigIntStr; // in native unit of the token
from: Address;
};

/** Non-home-coin outbound transfer, for an outbound swap. */
/**
* Non-home-coin outbound transfer, for an outbound swap or outbound
* cross-chain transfer.
*/
export type PostSwapTransfer = {
coin: ForeignToken;
amount: BigIntStr; // in native unit of the token
Expand Down
43 changes: 43 additions & 0 deletions packages/daimo-common/src/sendPair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {
DAv2Chain,
arbitrum,
base,
baseSepolia,
ethereumSepolia,
isTestnetChain,
optimism,
polygon,
} from "./chain";
import {
ForeignToken,
arbitrumUSDC,
baseSepoliaUSDC,
baseUSDC,
ethereumSepoliaUSDC,
optimismUSDC,
polygonUSDC,
} from "./foreignToken";

// Supported Chain <> Coin send pair (any coin, any chain)
export type SendPair = {
chain: DAv2Chain;
coin: ForeignToken;
};

const supportedSendPairsMainnet: SendPair[] = [
{ chain: base, coin: baseUSDC },
{ chain: optimism, coin: optimismUSDC },
{ chain: polygon, coin: polygonUSDC },
{ chain: arbitrum, coin: arbitrumUSDC },
];

const supportedSendPairsTestnet: SendPair[] = [
{ chain: baseSepolia, coin: baseSepoliaUSDC },
{ chain: ethereumSepolia, coin: ethereumSepoliaUSDC },
];

export const getSupportedSendPairs = (chainId: number): SendPair[] => {
return isTestnetChain(chainId)
? supportedSendPairsTestnet
: supportedSendPairsMainnet;
};

0 comments on commit 1620e6c

Please sign in to comment.