Skip to content

Commit

Permalink
Merge c665c9b into fb8a96d
Browse files Browse the repository at this point in the history
  • Loading branch information
pierregee authored Oct 23, 2023
2 parents fb8a96d + c665c9b commit 339819f
Show file tree
Hide file tree
Showing 134 changed files with 31,494 additions and 9,446 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run: .github/workflows/ci/wait-for http://localhost:3001/_actuator/probes/liveness -t 240
- run: .github/workflows/ci/wait-for http://localhost:3002/_actuator/probes/liveness -t 240
- run: .github/workflows/ci/wait-for http://localhost:19551/ping -t 240
- run: .github/workflows/ci/wait-for http://localhost:19550/ping -t 240

- uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2
with:
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = function (api) {
"@shared-api": "./shared/api",
"@shared-contexts": "./shared/contexts",
"@shared-types": "./shared/types",
"@shared-contracts": "./shared/contracts",
"@screens": "./mobile-app/app/screens",
"@store": "./shared/store",
"@translations": "./shared/translations",
Expand Down
16 changes: 11 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ services:
ports:
- "19553:80"
- "19552:8080"
- "19551:8082"
- "19550:8082"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"

defi-blockchain:
image: defi/defichain:master-91a01aea0
image: defi/defichain:HEAD-420563c450
ports:
- "19554:19554"
- "19551:19551"
command: >
defid
-printtoconsole
-rpcallowip=0.0.0.0/0
-rpcbind=0.0.0.0
-ethrpcbind=0.0.0.0
-rpcallowcors=http://localhost:8081
-rpcuser=playground
-rpcpassword=playground
-rpcworkqueue=512
Expand Down Expand Up @@ -55,10 +60,11 @@ services:
-grandcentralheight=16
-grandcentralepilogueheight=17
-nextnetworkupgradeheight=18
-changiintermediateheight=19
environment:
- RUST_LOG=debug

defi-playground:
image: ghcr.io/birthdayresearch/playground-api:3.34.0
image: ghcr.io/birthdayresearch/playground-api:4.0.0-rc.1.2
depends_on:
- defi-blockchain
ports:
Expand All @@ -71,7 +77,7 @@ services:
- "traefik.http.routers.playground.entrypoints=web"

defi-whale:
image: ghcr.io/birthdayresearch/whale-api:3.34.0
image: ghcr.io/birthdayresearch/whale-api:4.0.0-rc.1.2
depends_on:
- defi-blockchain
ports:
Expand Down
41 changes: 28 additions & 13 deletions mobile-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
SecuredStoreAPI,
LanguagePersistence,
ThemePersistence,
DomainPersistence,
Logging,
} from "@api";
import { AppStateContextProvider } from "@contexts/AppStateContext";
Expand All @@ -28,6 +29,7 @@ import {
LanguageProvider,
useLanguage,
} from "@shared-contexts/LanguageProvider";
import { DomainProvider } from "@contexts/DomainContext";
import * as Localization from "expo-localization";
import { useColorScheme } from "react-native";
import { WalletPersistence } from "@api/wallet";
Expand All @@ -45,6 +47,8 @@ import { WalletToast } from "@components/WalletToast";
import { ServiceProviderPersistence } from "@api/wallet/service_provider";
import { FavouritePoolpairProvider } from "@contexts/FavouritePoolpairContext";
import BigNumber from "bignumber.js";
import { EVMProvider } from "@contexts/EVMProvider";
import { CustomServiceProvider } from "@contexts/CustomServiceProvider";

/**
* Loads
Expand Down Expand Up @@ -110,19 +114,30 @@ export default function App(): JSX.Element | null {
api={LanguagePersistence}
locale={Localization.locale}
>
<DisplayBalancesProvider>
<ConnectionBoundary>
<GestureHandlerRootView
style={tailwind("flex-1")}
>
<ToastProvider renderType={customToast}>
<FavouritePoolpairProvider>
<Main />
</FavouritePoolpairProvider>
</ToastProvider>
</GestureHandlerRootView>
</ConnectionBoundary>
</DisplayBalancesProvider>
<DomainProvider api={DomainPersistence}>
<CustomServiceProvider
api={ServiceProviderPersistence}
logger={Logging}
>
<DisplayBalancesProvider>
<ConnectionBoundary>
<GestureHandlerRootView
style={tailwind("flex-1")}
>
<ToastProvider
renderType={customToast}
>
<FavouritePoolpairProvider>
<EVMProvider logger={Logging}>
<Main />
</EVMProvider>
</FavouritePoolpairProvider>
</ToastProvider>
</GestureHandlerRootView>
</ConnectionBoundary>
</DisplayBalancesProvider>
</CustomServiceProvider>
</DomainProvider>
</LanguageProvider>
</ThemeProvider>
</FeatureFlagProvider>
Expand Down
1 change: 1 addition & 0 deletions mobile-app/app/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { FeatureFlagPersistence } from "./persistence/feature_flag_storage";
export { SlippageTolerancePersistence } from "./persistence/slippage-tolerance_storage";
export { PortfolioCurrencyPersistence } from "./persistence/portfolio_currency_storage";
export { FavouritePoolpairsPersistence } from "./persistence/favourite_poolpairs_storage";
export { DomainPersistence } from "./persistence/domain_storage";
16 changes: 16 additions & 0 deletions mobile-app/app/api/persistence/domain_storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import AsyncStorage from "@react-native-async-storage/async-storage";

const KEY = "WALLET.EVMDOMAIN";

async function set(domain: NonNullable<string>): Promise<void> {
await AsyncStorage.setItem(KEY, domain);
}

async function get(): Promise<string | null> {
return await AsyncStorage.getItem(KEY);
}

export const DomainPersistence = {
set,
get,
};
51 changes: 29 additions & 22 deletions mobile-app/app/api/transaction/dfi_converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import {
CTransactionSegWit,
TransactionSegWit,
} from "@defichain/jellyfish-transaction";

export type ConversionMode = "utxosToAccount" | "accountToUtxos";
import { ConvertDirection } from "@screens/enum";

export async function dfiConversionSigner(
account: WhaleWalletAccount,
amount: BigNumber,
mode: ConversionMode
mode: ConvertDirection,
): Promise<CTransactionSegWit> {
const script = await account.getScript();
const builder = account.withTransactionBuilder();
Expand All @@ -32,7 +31,7 @@ export async function dfiConversionSigner(
},
],
},
script
script,
);
} else {
signed = await builder.account.accountToUtxos(
Expand All @@ -46,55 +45,63 @@ export async function dfiConversionSigner(
],
mintingOutputsStart: 2, // 0: DfTx, 1: change, 2: minted utxos (mandated by jellyfish-tx)
},
script
script,
);
}
return new CTransactionSegWit(signed);
}

export function dfiConversionCrafter(
amount: BigNumber,
mode: ConversionMode,
convertDirection: ConvertDirection,
onBroadcast: () => any,
onConfirmation: () => void,
submitButtonLabel?: string
submitButtonLabel?: string,
): DfTxSigner {
if (
![
ConvertDirection.accountToUtxos,
ConvertDirection.utxosToAccount,
].includes(convertDirection)
) {
throw new Error("Unexpected DFI conversion");
}

const [symbolA, symbolB] =
mode === "utxosToAccount"
? ["UTXO", translate("screens/OceanInterface", "tokens")]
: [translate("screens/OceanInterface", "tokens"), "UTXO"];
convertDirection === ConvertDirection.utxosToAccount
? ["UTXO", translate("screens/OceanInterface", "DFI")]
: [translate("screens/OceanInterface", "DFI"), "UTXO"];
return {
sign: async (account: WhaleWalletAccount) =>
await dfiConversionSigner(account, amount, mode),
await dfiConversionSigner(account, amount, convertDirection),
title: translate(
"screens/ConvertConfirmScreen",
"Convert {{amount}} DFI to {{target}}",
"Convert {{amount}} {{symbolA}} to {{symbolB}} tokens",
{
amount: amount.toFixed(8),
target:
mode === "utxosToAccount"
? translate("screens/ConvertScreen", "tokens")
: "UTXO",
}
symbolA,
symbolB,
},
),
drawerMessages: {
preparing: translate("screens/OceanInterface", "Preparing to convert…"),
waiting: translate(
"screens/OceanInterface",
"Converting {{amount}} DFI {{symbolA}} to {{symbolB}}",
"Converting {{amount}} {{symbolA}} to {{symbolB}} tokens",
{
symbolA: symbolA,
symbolB: symbolB,
amount: amount.toFixed(8),
}
},
),
complete: translate(
"screens/OceanInterface",
"{{amount}} DFI converted to {{symbolB}}",
"{{amount}} {{symbolA}} converted to {{symbolB}} tokens",
{
symbolB: symbolB,
symbolA,
symbolB,
amount: amount.toFixed(8),
}
},
),
},
onBroadcast,
Expand Down
Loading

0 comments on commit 339819f

Please sign in to comment.