Treasure Launcher utilities for the Treasure ecosystem
pnpm add @treasure-dev/launcher
import { getTreasureLauncherAuthToken } from "@treasure-dev/launcher";
const authToken = getTreasureLauncherAuthToken();
import { isUsingTreasureLauncher } from "@treasure-dev/launcher";
const usingLauncher = isUsingTreasureLauncher();
import { startUserSessionViaLauncher } from "@treasure-dev/launcher";
await startUserSessionViaLauncher({
backendWallet: "0x...",
approvedTargets: ["0x..."],
nativeTokenLimitPerTransaction: 100,
sessionDurationSec: 60 * 60 * 24 * 7,
sessionMinDurationLeftSec: 60 * 60 * 24 * 3,
});
import { useTreasure } from "@treasure-dev/react";
const { isUsingTreasureLauncher } = useTreasure();
Use startUserSession
as usual:
import { useTreasure } from "@treasure-dev/react";
const { startUserSession } = useTreasure();
import { getTreasureLauncherAuthToken } from "@treasure-dev/launcher";
ipcMain.on("get-auth-token", (event, _arg) => {
event.returnValue = getTreasureLauncherAuthToken();
});
const getAuthToken = () =>
window.electron.ipcRenderer.sendSync("get-auth-token");
<TreasureProvider
...
launcherOptions={{
getAuthTokenOverride: getAuthToken,
}}
>
Merge changeset-bot's versioning PR to the main
branch to push a new package version to npm.