Skip to content

Commit

Permalink
api: release Landline, flag Tronramp
Browse files Browse the repository at this point in the history
  • Loading branch information
dcposch committed Sep 21, 2024
1 parent 4cb0792 commit 70f0390
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions packages/daimo-api/src/api/featureFlag.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EAccount } from "@daimo/common";

export class FeatFlag {
public static landline(account: EAccount & { name: string }) {
public static tronramp(account: EAccount) {
return [
"dcposch",
"klee",
Expand All @@ -10,6 +10,8 @@ export class FeatFlag {
"hanna",
"sfl",
"sbg",
].includes(account.name);
"ansgar",
"liam",
].includes(account.name || "");
}
}
51 changes: 37 additions & 14 deletions packages/daimo-api/src/api/getAccountHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TransferClog,
appStoreLinks,
assert,
assertNotNull,
daimoDomainAddress,
formatDaimoLink,
getLandlineAccountName,
Expand Down Expand Up @@ -164,9 +165,6 @@ export async function getAccountHistory(
// Prefetch info required to send operations > fast at time of sending.
const chainGasConstants = await paymaster.calculateChainGasConstants(eAcc);

// Prefetch info required to deposit to your Daimo account.
const recommendedExchanges = fetchRecommendedExchanges(eAcc, lang);

// Get linked accounts
const linkedAccounts = profileCache.getLinkedAccounts(address);
const inviteLinkStatus = inviteCode
Expand Down Expand Up @@ -205,9 +203,9 @@ export async function getAccountHistory(
let landlineSessionURL = "";
let landlineAccounts: LandlineAccount[] = [];

const showLandline = FeatFlag.landline(eAcc);
if (getEnvApi().LANDLINE_API_URL && showLandline) {
const landlineSessionKey = (await getLandlineSession(address)).key;
let landlineSessionKey: string | undefined;
if (getEnvApi().LANDLINE_API_URL) {
landlineSessionKey = (await getLandlineSession(address)).key;
landlineSessionURL = getLandlineURL(address, landlineSessionKey);
landlineAccounts = await getLandlineAccounts(address);
// Support for displaying landline transfers in the mobile app was added
Expand All @@ -230,6 +228,13 @@ export async function getAccountHistory(
nameReg
);

// Prefetch info required to deposit to your Daimo account.
const recommendedExchanges = await fetchRecommendedExchanges({
account: eAcc,
language: lang,
landlineSessionKey,
});

const ret: AccountHistoryResult = {
address,
sinceBlockNum,
Expand Down Expand Up @@ -357,13 +362,18 @@ function getCoinbaseURL(account: EAccount) {
});
}

function fetchRecommendedExchanges(
account: EAccount,
lang?: string
): RecommendedExchange[] {
const i18 = i18n(lang).recommendedExchange;

return [
function fetchRecommendedExchanges({
account,
language,
landlineSessionKey,
}: {
account: EAccount;
language?: string;
landlineSessionKey?: string;
}): RecommendedExchange[] {
const i18 = i18n(landlineSessionKey).recommendedExchange;

const ret = [
{
cta: i18.bridge.cta(),
title: i18.bridge.title(),
Expand All @@ -384,7 +394,20 @@ function fetchRecommendedExchanges(
cta: i18.ramp.cta(),
url: getRampNetworkURL(account),
logo: `${daimoDomainAddress}/assets/deposit/usdc.png`,
sortId: 3,
sortId: 4,
},
];

if (landlineSessionKey != null && FeatFlag.tronramp(account)) {
const llHost = assertNotNull(getEnvApi().LANDLINE_DOMAIN);
ret.push({
title: `Preview · Tron Deposit`,
cta: `Get a USDT TRC-20 receiving address`,
url: `${llHost}/tron/${account.addr}/${landlineSessionKey}`,
logo: `${daimoDomainAddress}/assets/deposit/usdt-tron.png`,
sortId: 3,
});
}

return ret;
}
2 changes: 1 addition & 1 deletion packages/daimo-api/src/server/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ export class Telemetry {

function getIpCountry(ipAddr: string) {
const ipGeo = geoIP.lookup(ipAddr);
return ipGeo?.country || "Atlantis";
return ipGeo?.country || "Unknown";
}

0 comments on commit 70f0390

Please sign in to comment.