Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add xrpl #202

Merged
merged 38 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
10dbed3
feat: add xrpl
Polybius93 Oct 1, 2024
f073de6
feat: modify vault query
Polybius93 Oct 2, 2024
82cb209
feat: modify use nft hook to make it more stable
Polybius93 Oct 3, 2024
49591c0
wip: adding xrpl conditions
Polybius93 Oct 8, 2024
c850a07
feat: modfiy isConnected conditions
Polybius93 Oct 9, 2024
e3c6075
wip: modify flow
Polybius93 Oct 10, 2024
e324bab
feat: remove ethereum observer, modify vault fetching
Polybius93 Oct 11, 2024
4d9a5f3
feat: modify balance fetching
Polybius93 Oct 11, 2024
7a2052a
feat: add ledger support
Polybius93 Oct 14, 2024
07215b7
feat: add working ledger wallet for xrpl
Polybius93 Oct 15, 2024
ca81126
feat: add gem wallet as xrp wallet option
Polybius93 Oct 16, 2024
c31c722
fix: modify value handling in form
Polybius93 Oct 17, 2024
39fa672
chore: change dlc-btc-lib package version
Polybius93 Oct 17, 2024
b023bc8
feat: modify xrpl related texts and lib version
Polybius93 Oct 18, 2024
a5e8265
fix: modify xrpl issuer address
Polybius93 Oct 18, 2024
8ac4d54
feat: modify loading states of xrpl wallets and abstract functions
Polybius93 Oct 21, 2024
bd056d0
chore: modify dlc-btc-lib version
Polybius93 Oct 21, 2024
402fd15
feat: modify form value validation, modify button navigation
Polybius93 Oct 22, 2024
6061294
chore: merge branch 'dev' into feat/xrpl-extended
Polybius93 Oct 23, 2024
0bb0f02
feat: modify devnet config
Polybius93 Oct 23, 2024
e21a79e
feat: modify dlc-btc-lib version, and related functions
Polybius93 Oct 23, 2024
d0ed713
feat: import attestor request functions from dlc-btc-lib
Polybius93 Oct 24, 2024
fb56040
chore: revert "feat: import attestor request functions from dlc-btc-lib"
Polybius93 Oct 24, 2024
f796e0a
feat: modify dlc-btc-lib and update related function arguments
Polybius93 Oct 24, 2024
0d18f11
chore: merge branch 'dev' into feat/multi-chain
Polybius93 Oct 24, 2024
3da007d
feat: add network connection context provider
Polybius93 Oct 24, 2024
012c759
feat: add enums for network, mint, redeem and tabs
Polybius93 Oct 30, 2024
5aa1195
feat: modify issuer address
Polybius93 Oct 30, 2024
2baa634
chore: merge branch 'dev' into feat/multi-chain
Polybius93 Nov 4, 2024
fcc7e1f
chore: merge branch 'dev' into feat/multi-chain
Polybius93 Nov 11, 2024
a93e851
feat: modify mainnet config for xrpl support
Polybius93 Nov 11, 2024
bf0d1f1
chore: update dlc-btc-lib package
Polybius93 Nov 12, 2024
5009f1e
chore: merge branch 'dev' into feat/multi-chain
Polybius93 Nov 19, 2024
8383fc5
feat: removing unnecessary logs
Polybius93 Nov 19, 2024
4d33dbc
feat: revert non xrpl related utility changes
Polybius93 Nov 20, 2024
803088a
chore: merge branch 'dev' into feat/multi-chain
Polybius93 Nov 20, 2024
1b5cf82
feat: add addtional vaultState argument for vault group container
Polybius93 Nov 20, 2024
62bff84
feat: add ts lint ignore line for expected
Polybius93 Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"appEnvironment": "devnet",
"coordinatorURL": "https://devnet.dlc.link/attestor-1",
"enabledEthereumNetworkIDs": ["421614", "84532", "11155111"],
"enabledRippleNetworkIDs": ["1"],
"bitcoinNetwork": "regtest",
"bitcoinNetworkIndex": 1,
"bitcoinNetworkPreFix": "bcrt1",
"bitcoinBlockchainURL": "https://devnet.dlc.link/electrs",
"bitcoinBlockchainExplorerURL": "https://devnet.dlc.link/electrs",
"bitcoinBlockchainFeeEstimateURL": "https://devnet.dlc.link/electrs/fee-estimates",
"rippleIssuerAddress": "rLTBw1MEy45uE5qmkWseinbj7h4zmdQuR8",
"xrplWebsocket": "wss://s.altnet.rippletest.net:51233",
"ledgerApp": "Bitcoin Test",
"merchants": [
{
Expand Down
3 changes: 3 additions & 0 deletions config.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"appEnvironment": "mainnet",
"coordinatorURL": "https://mainnet.dlc.link/attestor-1",
"enabledEthereumNetworkIDs": ["42161", "8453"],
"enabledRippleNetworkIDs": ["0"],
"bitcoinNetwork": "mainnet",
"bitcoinNetworkIndex": 0,
"bitcoinNetworkPreFix": "bc1",
"bitcoinBlockchainURL": "https://mainnet.dlc.link/electrs",
"bitcoinBlockchainExplorerURL": "https://mempool.space",
"bitcoinBlockchainFeeEstimateURL": "https://mempool.space/api/v1/fees/recommended",
"rippleIssuerAddress": "rGcyRGrZPaJAZbZDi4NqRFLA5GQH63iFpD",
"xrplWebsocket": "wss://xrpl.ws/",
"ledgerApp": "Bitcoin",
"merchants": [
{
Expand Down
3 changes: 3 additions & 0 deletions config.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"appEnvironment": "testnet",
"coordinatorURL": "https://testnet.dlc.link/attestor-1",
"enabledEthereumNetworkIDs": ["421614", "84532", "11155111"],
"enabledRippleNetworkIDs": ["1"],
"bitcoinNetwork": "testnet",
"bitcoinNetworkIndex": 1,
"bitcoinNetworkPreFix": "tb1",
"bitcoinBlockchainURL": "https://testnet.dlc.link/electrs",
"bitcoinBlockchainExplorerURL": "https://mempool.space/testnet",
"bitcoinBlockchainFeeEstimateURL": "https://mempool.space/testnet/api/v1/fees/recommended",
"rippleIssuerAddress": "ra3oyRVfy4yD4NJPrVcewvDtisZ3FhkcYL",
"xrplWebsocket": "wss://testnet.xrpl-labs.com/",
sosaucily marked this conversation as resolved.
Show resolved Hide resolved
"ledgerApp": "Bitcoin Test",
"merchants": [
{
Expand Down
42 changes: 42 additions & 0 deletions netlify/functions/fetch-attestor-group-public-key.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Handler, HandlerEvent } from '@netlify/functions';
import { getAttestorExtendedGroupPublicKey } from 'dlc-btc-lib/attestor-request-functions';

const handler: Handler = async (event: HandlerEvent) => {
try {
if (!event.queryStringParameters) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No Parameters were provided',
}),
};
}

if (!event.queryStringParameters.coordinatorURL) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No Coordinator URL was provided',
}),
};
}

const coordinatorURL = event.queryStringParameters.coordinatorURL;

const attestorGroupPublicKey = await getAttestorExtendedGroupPublicKey(coordinatorURL);

return {
statusCode: 200,
body: attestorGroupPublicKey,
};
} catch (error: any) {
return {
statusCode: 500,
body: JSON.stringify({
message: `Failed to get Attestor Group Public Key: ${error.message}`,
}),
};
}
};

export { handler };
62 changes: 62 additions & 0 deletions netlify/functions/submit-xrpl-vault-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Handler, HandlerEvent } from '@netlify/functions';
import { submitSetupXRPLVaultRequest } from 'dlc-btc-lib/attestor-request-functions';
import { AttestorChainID } from 'dlc-btc-lib/models';

const handler: Handler = async (event: HandlerEvent) => {
try {
if (!event.queryStringParameters) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No Parameters were provided',
}),
};
}

if (!event.queryStringParameters.coordinatorURL) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No Coordinator URL was provided',
}),
};
}

if (!event.queryStringParameters.userXRPLAddress) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No XRPL User Address was provided',
}),
};
}

if (!event.queryStringParameters.attestorChainID) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'No Attestor Chain ID was provided',
}),
};
}

const coordinatorURL = event.queryStringParameters.coordinatorURL;
const userXRPLAddress = event.queryStringParameters.userXRPLAddress;
const attestorChainID = event.queryStringParameters.attestorChainID as AttestorChainID;

await submitSetupXRPLVaultRequest(coordinatorURL, userXRPLAddress, attestorChainID);

return {
statusCode: 200,
};
} catch (error: any) {
return {
statusCode: 500,
body: JSON.stringify({
message: `Failed to submit Setup XRPL Vault Request: ${error.message}`,
}),
};
}
};

export { handler };
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"@fontsource/inter": "^5.0.18",
"@fontsource/onest": "^5.0.3",
"@fontsource/poppins": "^5.0.8",
"@gemwallet/api": "^3.8.0",
"@ledgerhq/hw-app-xrp": "^6.29.4",
"@ledgerhq/hw-transport-webusb": "^6.28.6",
"@netlify/functions": "^2.8.1",
"@reduxjs/toolkit": "^1.9.7",
Expand All @@ -44,7 +46,7 @@
"concurrently": "^8.2.2",
"d3": "^7.9.0",
"decimal.js": "^10.4.3",
"dlc-btc-lib": "2.2.7",
"dlc-btc-lib": "2.4.12",
"dotenv": "^16.3.1",
"ethers": "5.7.2",
"formik": "^2.4.5",
Expand All @@ -64,7 +66,8 @@
"redux-persist-expire": "^1.1.1",
"viem": "2.x",
"vite-plugin-toml": "^0.7.0",
"wagmi": "^2.12.2"
"wagmi": "^2.12.2",
"xrpl": "^4.0.0"
},
"devDependencies": {
"@ls-lint/ls-lint": "^2.2.2",
Expand Down
1 change: 1 addition & 0 deletions public/images/logos/gem-wallet-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions public/images/logos/xrp-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 37 additions & 28 deletions src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import { BalanceContextProvider } from '@providers/balance-context-provider';
import { BitcoinTransactionConfirmationsProvider } from '@providers/bitcoin-query-provider';
import { BitcoinWalletContextProvider } from '@providers/bitcoin-wallet-context-provider';
import { EthereumNetworkConfigurationContextProvider } from '@providers/ethereum-network-configuration.provider';
import { EthereumObserverProvider } from '@providers/ethereum-observer-provider';
import { NetworkConfigurationContextProvider } from '@providers/network-configuration.provider';
import { NetworkConnectionContextProvider } from '@providers/network-connection.provider';
import { ProofOfReserveContextProvider } from '@providers/proof-of-reserve-context-provider';
import { RippleNetworkConfigurationContextProvider } from '@providers/ripple-network-configuration.provider';
import { XRPWalletContextProvider } from '@providers/xrp-wallet-context-provider';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider } from 'wagmi';

Expand All @@ -28,33 +31,39 @@ export function App(): React.JSX.Element {
return (
<WagmiProvider config={wagmiConfiguration}>
<QueryClientProvider client={queryClient}>
<EthereumNetworkConfigurationContextProvider>
<BitcoinWalletContextProvider>
<VaultContextProvider>
<EthereumObserverProvider>
<BitcoinTransactionConfirmationsProvider>
<BalanceContextProvider>
<ProofOfReserveContextProvider>
<AppLayout>
<Route path="/" element={<PointsPage />} />
<Route path="/my-vaults" element={<MyVaults />} />
{/* <Route path="/how-it-works" element={<About />} /> */}
<Route path="/proof-of-reserve" element={<ProofOfReservePage />} />
<Route path="/attestor-details" element={<AttestorDetailsPage />} />
<Route
path="/attestor-details-select"
element={<AttestorDetailsSelectPage />}
/>
<Route path="/merchant-details/:name" element={<MerchantDetails />} />
<Route path="/mint-withdraw" element={<Dashboard />} />
</AppLayout>
</ProofOfReserveContextProvider>
</BalanceContextProvider>
</BitcoinTransactionConfirmationsProvider>
</EthereumObserverProvider>
</VaultContextProvider>
</BitcoinWalletContextProvider>
</EthereumNetworkConfigurationContextProvider>
<NetworkConfigurationContextProvider>
<RippleNetworkConfigurationContextProvider>
<EthereumNetworkConfigurationContextProvider>
<XRPWalletContextProvider>
<BitcoinWalletContextProvider>
<NetworkConnectionContextProvider>
<VaultContextProvider>
<BitcoinTransactionConfirmationsProvider>
<BalanceContextProvider>
<ProofOfReserveContextProvider>
<AppLayout>
<Route path="/" element={<PointsPage />} />
<Route path="/my-vaults" element={<MyVaults />} />
{/* <Route path="/how-it-works" element={<About />} /> */}
<Route path="/proof-of-reserve" element={<ProofOfReservePage />} />
<Route path="/attestor-details" element={<AttestorDetailsPage />} />
<Route
path="/attestor-details-select"
element={<AttestorDetailsSelectPage />}
/>
<Route path="/merchant-details/:name" element={<MerchantDetails />} />
<Route path="/mint-withdraw" element={<Dashboard />} />
</AppLayout>
</ProofOfReserveContextProvider>
</BalanceContextProvider>
</BitcoinTransactionConfirmationsProvider>
</VaultContextProvider>
</NetworkConnectionContextProvider>
</BitcoinWalletContextProvider>
</XRPWalletContextProvider>
</EthereumNetworkConfigurationContextProvider>
</RippleNetworkConfigurationContextProvider>
</NetworkConfigurationContextProvider>
</QueryClientProvider>
</WagmiProvider>
);
Expand Down
52 changes: 46 additions & 6 deletions src/app/components/account/account.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,73 @@
import { useContext } from 'react';
import { useDispatch } from 'react-redux';

import { Button, HStack, useBreakpointValue } from '@chakra-ui/react';
import { AccountMenu } from '@components/account/components/account-menu';
import { XRPWallet, xrpWallets } from '@models/wallet';
import { NetworkConfigurationContext } from '@providers/network-configuration.provider';
import { NetworkConnectionContext } from '@providers/network-connection.provider';
import { XRPWalletContext } from '@providers/xrp-wallet-context-provider';
import { mintUnmintActions } from '@store/slices/mintunmint/mintunmint.actions';
import { modalActions } from '@store/slices/modal/modal.actions';
import { useAccount, useDisconnect } from 'wagmi';
import { Connector, useAccount, useDisconnect } from 'wagmi';

import { NetworkType } from '@shared/constants/network.constants';

export function Account(): React.JSX.Element {
const dispatch = useDispatch();

const { address, connector, isConnected } = useAccount();
const { disconnect } = useDisconnect();
const { isConnected } = useContext(NetworkConnectionContext);
const { networkType } = useContext(NetworkConfigurationContext);

const isMobile = useBreakpointValue({ base: true, md: false });
const { address: ethereumUserAddress, connector: ethereumWallet } = useAccount();
const { disconnect: disconnectEthereumWallet } = useDisconnect();
const {
userAddress: rippleUserAddress,
xrpWalletType,
resetXRPWalletContext,
} = useContext(XRPWalletContext);

function getWalletInformation(): { address: string; wallet: XRPWallet | Connector } | undefined {
switch (networkType) {
case NetworkType.EVM:
if (!ethereumUserAddress || !ethereumWallet) return undefined;
return { address: ethereumUserAddress, wallet: ethereumWallet };
case NetworkType.XRPL:
if (!rippleUserAddress) return undefined;
return {
address: rippleUserAddress,
wallet: xrpWallets.find(xrpWallet => xrpWallet.id === xrpWalletType)!,
};
default:
throw new Error('Invalid Network Type');
}
}

function onConnectWalletClick(): void {
dispatch(modalActions.toggleSelectWalletModalVisibility());
}

function onDisconnectWalletClick(): void {
disconnect();
switch (networkType) {
case NetworkType.EVM:
disconnectEthereumWallet();
break;
case NetworkType.XRPL:
resetXRPWalletContext();
break;
default:
break;
}
dispatch(mintUnmintActions.resetMintUnmintState());
}

return (
<HStack h={isMobile ? '40px' : '50px'}>
{isConnected ? (
<AccountMenu
address={address}
wagmiConnector={connector}
address={getWalletInformation()?.address}
wallet={getWalletInformation()?.wallet}
handleDisconnectWallet={() => onDisconnectWalletClick()}
/>
) : (
Expand Down
Loading
Loading