-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: ➕ Add MoonPay react and nodejs libraries * feat: 🍱 Add MoonPay branding * feat: Add MoonPay url signing endpoint * feat: 💄 Add MoonPay buy widget * docs: 🔧 Add MoonPay env placeholders * chore: 🌐 Add missing translation for MoonPay subtitle * fix: 🌐 Fix wrong localization key in moonpay onramp * chore: update lockfile * feat: update copy to "Buy crypto" * feat: update moonpay widget border * feat: improve modals layout with hideDefaultBackButton * feat: add more margin between header and list * feat: add onRequestBack handler * feat: add custom header * feat: add system-based moonpay theme * feat: add payment methods assets * feat: update Moonpay selection UI * feat: localize moonpay country support * refactor: use useMedia instead of window.matchMedia --------- Co-authored-by: Enrico Barbieri <[email protected]> Co-authored-by: fabryscript <[email protected]>
- Loading branch information
1 parent
348b889
commit 4d91181
Showing
35 changed files
with
366 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { apiClient } from "@osmosis-labs/utils"; | ||
import { observer } from "mobx-react-lite"; | ||
import dynamic from "next/dynamic"; | ||
import { FunctionComponent } from "react"; | ||
import { useMedia } from "react-use"; | ||
|
||
import { MoonpaySignUrlResponse } from "~/integrations/moonpay/types"; | ||
import { ModalBaseProps } from "~/modals"; | ||
import { useStore } from "~/stores"; | ||
|
||
const MoonPayBuyWidget = dynamic( | ||
() => import("@moonpay/moonpay-react").then((mod) => mod.MoonPayBuyWidget), | ||
{ ssr: false } | ||
); | ||
|
||
async function generateMoonpayUrlSignature(url: string): Promise<string> { | ||
return ( | ||
await apiClient<MoonpaySignUrlResponse>( | ||
"/api/integrations/moonpay/sign-url", | ||
{ | ||
method: "POST", | ||
data: { | ||
url, | ||
}, | ||
} | ||
) | ||
).signature; | ||
} | ||
|
||
export const Moonpay: FunctionComponent< | ||
{ assetKey: string } & Pick<ModalBaseProps, "isOpen" | "onRequestClose"> | ||
> = observer(({ assetKey, isOpen }) => { | ||
const { chainStore, accountStore } = useStore(); | ||
|
||
const prefersDark = useMedia("(prefers-color-scheme: dark)"); | ||
|
||
const account = accountStore.getWallet(chainStore.osmosis.chainId); | ||
|
||
let walletAddress = account?.address; | ||
|
||
return ( | ||
<MoonPayBuyWidget | ||
className="!m-0 !border-[0px]" | ||
variant="embedded" | ||
baseCurrencyCode={assetKey} | ||
defaultCurrencyCode="OSMO" | ||
visible={isOpen} | ||
walletAddress={walletAddress} | ||
onUrlSignatureRequested={generateMoonpayUrlSignature} | ||
theme={prefersDark ? "dark" : "light"} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface MoonpaySignUrlResponse { | ||
readonly signature: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.