@b3dotfun/sdk 0.0.51-alpha.2 → 0.0.51-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import { components } from "../../../anyspend/types/api";
2
+ export declare function AnySpendStakeUpside({ loadOrder, mode, beneficiaryAddress, stakeAmount, stakingContractAddress, token, poolType, onSuccess, }: {
3
+ loadOrder?: string;
4
+ mode?: "modal" | "page";
5
+ beneficiaryAddress: string;
6
+ stakeAmount: string;
7
+ stakingContractAddress: string;
8
+ token: components["schemas"]["Token"];
9
+ poolType: "b3" | "weth";
10
+ onSuccess?: () => void;
11
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AnySpendStakeUpside = AnySpendStakeUpside;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("../../../global-account/react");
9
+ const number_1 = require("../../../shared/utils/number");
10
+ const invariant_1 = __importDefault(require("invariant"));
11
+ const viem_1 = require("viem");
12
+ const chains_1 = require("viem/chains");
13
+ const upsideStaking_1 = require("../../abis/upsideStaking");
14
+ const AnySpendCustom_1 = require("./AnySpendCustom");
15
+ function generateEncodedDataForStaking(amount, beneficiary, poolType) {
16
+ (0, invariant_1.default)(BigInt(amount) > 0, "Amount must be greater than zero");
17
+ if (poolType === "weth") {
18
+ return (0, viem_1.encodeFunctionData)({
19
+ abi: upsideStaking_1.WETH_STAKING_CONTRACT,
20
+ functionName: "stakeFor",
21
+ args: [beneficiary, BigInt(amount)],
22
+ });
23
+ }
24
+ else if (poolType === "b3") {
25
+ return (0, viem_1.encodeFunctionData)({
26
+ abi: upsideStaking_1.B3_STAKING_CONTRACT,
27
+ functionName: "stakeFor",
28
+ args: [beneficiary, BigInt(amount)],
29
+ });
30
+ }
31
+ throw new Error("Unsupported pool type");
32
+ }
33
+ function AnySpendStakeUpside({ loadOrder, mode = "modal", beneficiaryAddress, stakeAmount, stakingContractAddress, token, poolType, onSuccess, }) {
34
+ const header = () => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "relative mx-auto size-32", children: (0, jsx_runtime_1.jsx)("img", { alt: "token", className: "size-full", src: token.metadata.logoURI || "https://cdn.b3.fun/b3-coin-3d.png" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "from-b3-react-background to-as-on-surface-1 mt-[-60px] w-full rounded-t-lg bg-gradient-to-t", children: [(0, jsx_runtime_1.jsx)("div", { className: "h-[60px] w-full" }), (0, jsx_runtime_1.jsx)("div", { className: "mb-1 flex w-full flex-col items-center gap-2 p-5", children: (0, jsx_runtime_1.jsxs)("span", { className: "font-sf-rounded text-2xl font-semibold", children: ["Swap & Stake ", stakeAmount ? (0, number_1.formatTokenAmount)(BigInt(stakeAmount), token.decimals) : "", " ", token.symbol] }) })] })] }));
35
+ // Only generate encoded data if we have a valid beneficiary address
36
+ // This is used for the AnySpendCustom swap & stake flow
37
+ if (!beneficiaryAddress || beneficiaryAddress === "") {
38
+ return ((0, jsx_runtime_1.jsx)(react_1.StyleRoot, { children: (0, jsx_runtime_1.jsx)("div", { className: "bg-b3-react-background flex w-full flex-col items-center justify-center p-8", children: (0, jsx_runtime_1.jsx)("p", { className: "font-medium text-yellow-600 dark:text-yellow-400", children: "\u26A0\uFE0F Please connect your wallet to continue." }) }) }));
39
+ }
40
+ const encodedData = generateEncodedDataForStaking(stakeAmount, beneficiaryAddress, poolType);
41
+ return ((0, jsx_runtime_1.jsx)(AnySpendCustom_1.AnySpendCustom, { loadOrder: loadOrder, mode: mode, recipientAddress: beneficiaryAddress, orderType: "custom", dstChainId: chains_1.base.id, dstToken: token, dstAmount: stakeAmount, contractAddress: stakingContractAddress, encodedData: encodedData, metadata: {
42
+ action: `stake ${token.symbol}`,
43
+ }, header: header, onSuccess: onSuccess, showRecipient: true }));
44
+ }
@@ -4,6 +4,7 @@ exports.B3DynamicModal = B3DynamicModal;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("../../../anyspend/react");
6
6
  const AnyspendDepositHype_1 = require("../../../anyspend/react/components/AnyspendDepositHype");
7
+ const AnySpendStakeUpside_1 = require("../../../anyspend/react/components/AnySpendStakeUpside");
7
8
  const react_2 = require("../../../global-account/react");
8
9
  const cn_1 = require("../../../shared/utils/cn");
9
10
  const debug_1 = require("../../../shared/utils/debug");
@@ -27,6 +28,7 @@ function B3DynamicModal() {
27
28
  "anySpendJoinTournament",
28
29
  "anySpendFundTournament",
29
30
  "anySpendStakeB3",
31
+ "anySpendStakeUpside",
30
32
  "anySpendBuySpin",
31
33
  "anySpendOrderHistory",
32
34
  "signInWithB3",
@@ -40,6 +42,7 @@ function B3DynamicModal() {
40
42
  "anySpendJoinTournament",
41
43
  "anySpendFundTournament",
42
44
  "anySpendStakeB3",
45
+ "anySpendStakeUpside",
43
46
  "anySpendBuySpin",
44
47
  "anySpendSignatureMint",
45
48
  "anySpendBondKit",
@@ -75,6 +78,8 @@ function B3DynamicModal() {
75
78
  return (0, jsx_runtime_1.jsx)(react_1.OrderHistory, { onBack: () => { }, mode: "modal" });
76
79
  case "anySpendStakeB3":
77
80
  return (0, jsx_runtime_1.jsx)(react_1.AnySpendStakeB3, { ...contentType, mode: "modal" });
81
+ case "anySpendStakeUpside":
82
+ return (0, jsx_runtime_1.jsx)(AnySpendStakeUpside_1.AnySpendStakeUpside, { ...contentType, mode: "modal" });
78
83
  case "anySpendBuySpin":
79
84
  return (0, jsx_runtime_1.jsx)(react_1.AnySpendBuySpin, { ...contentType, mode: "modal" });
80
85
  case "anySpendSignatureMint":
@@ -210,6 +210,26 @@ export interface AnySpendStakeB3Props extends BaseModalProps {
210
210
  /** Callback function called when the stake is successful */
211
211
  onSuccess?: () => void;
212
212
  }
213
+ /**
214
+ * Props for the AnySpend Stake Contract modal
215
+ * Handles token staking operations to a given contract
216
+ */
217
+ export interface AnySpendStakeUpsideProps extends BaseModalProps {
218
+ /** Modal type identifier */
219
+ type: "anySpendStakeUpside";
220
+ /** Recipient address to stake B3 for */
221
+ beneficiaryAddress: string;
222
+ /** Stake amount */
223
+ stakeAmount: string;
224
+ /** Staking contract address */
225
+ stakingContractAddress: string;
226
+ /** Pool type for staking */
227
+ poolType: "b3" | "weth";
228
+ /** Token address to stake */
229
+ token: components["schemas"]["Token"];
230
+ /** Callback function called when the stake is successful */
231
+ onSuccess?: () => void;
232
+ }
213
233
  /**
214
234
  * Props for the AnySpend Buy Spin modal
215
235
  * Handles spin wheel entry purchases
@@ -302,7 +322,7 @@ export interface AvatarEditorModalProps extends BaseModalProps {
302
322
  /**
303
323
  * Union type of all possible modal content types
304
324
  */
305
- export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps;
325
+ export type ModalContentType = SignInWithB3ModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps;
306
326
  /**
307
327
  * State interface for the modal store
308
328
  */