diff --git a/apps/browser-tests/src/App.tsx b/apps/browser-tests/src/App.tsx index 9301a789..77253a34 100644 --- a/apps/browser-tests/src/App.tsx +++ b/apps/browser-tests/src/App.tsx @@ -1,12 +1,20 @@ import { useCallback, useMemo, useState } from "react"; import { Address, PSBTBuilder, PSBTBuilderOptions } from "@ordzaar/ordit-sdk"; +import * as magiceden from "@ordzaar/ordit-sdk/magiceden"; import * as unisat from "@ordzaar/ordit-sdk/unisat"; import * as xverse from "@ordzaar/ordit-sdk/xverse"; import { RadioInput } from "./components/RadioInput"; import { Select } from "./components/Select"; -type WalletProvider = "unisat" | "xverse"; +type WalletProvider = "unisat" | "xverse" | "magiceden"; + +const TESTNET = "testnet" as const; +// const MAINNET = "mainnet" as const; + +// Change here to use the network you want to use +// MagicEden only supports mainnet +const network = TESTNET; async function createAndPreparePsbt(psbtParams: PSBTBuilderOptions) { const psbt = new PSBTBuilder(psbtParams); @@ -54,7 +62,7 @@ function Transactions({ value: amount, }, ], - network: "testnet" as const, + network, }), [ amount, @@ -87,7 +95,17 @@ function Transactions({ signPsbtResponse = await unisat.signPsbt(psbt.toPSBT()); } else if (provider === "xverse") { signPsbtResponse = await xverse.signPsbt(psbt.toPSBT(), { - network: "testnet", + network, + inputsToSign: [ + { + address: inputAddressInfo.address, + signingIndexes: [0], + }, + ], + }); + } else if (provider === "magiceden") { + signPsbtResponse = await magiceden.signPsbt(psbt.toPSBT(), { + network, inputsToSign: [ { address: inputAddressInfo.address, @@ -118,7 +136,13 @@ function Transactions({ signMessageResponse = await xverse.signMessage( message, inputAddressInfo.address, - "testnet", + network, + ); + } else if (provider === "magiceden") { + signMessageResponse = await magiceden.signMessage( + message, + inputAddressInfo.address, + network, ); } else { throw new Error("Unknown provider"); @@ -218,13 +242,17 @@ function App() { const handleConnect = useCallback(async () => { if (provider === "unisat") { - const addresses = await unisat.getAddresses("testnet"); + const addresses = await unisat.getAddresses(network); console.log("Unisat Connected: ", addresses); setConnectedAddresses(addresses); } else if (provider === "xverse") { - const addresses = await xverse.getAddresses("testnet"); + const addresses = await xverse.getAddresses(network); setConnectedAddresses(addresses); console.log("Xverse Connected: ", addresses); + } else if (provider === "magiceden") { + const addresses = await magiceden.getAddresses(network); + setConnectedAddresses(addresses); + console.log("MagicEden Connected: ", addresses); } else { console.log("Unknown provider", provider); } @@ -248,11 +276,12 @@ function App() { options={[ { name: "Unisat", value: "unisat" }, { name: "Xverse", value: "xverse" }, + { name: "Magic Eden", value: "magiceden" }, ]} value={provider} disabled={!!connectedAddresses} /> -
Network: Testnet
+Network: {network}