@b3dotfun/sdk 0.0.40-alpha.0 → 0.0.40-alpha.2

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.
@@ -55,9 +55,6 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
55
55
  case "custom":
56
56
  actionText = order.metadata.action || `executed contract`;
57
57
  return `Successfully ${actionText}`;
58
- case "hype_duel":
59
- actionText = `deposited ${formattedActualDstAmount || "--"} HYPE`;
60
- return `Successfully ${actionText} to ${recipient}`;
61
58
  default:
62
59
  throw new Error("Invalid order type");
63
60
  }
@@ -434,7 +431,7 @@ exports.OrderDetails = (0, react_4.memo)(function OrderDetails({ mode = "modal",
434
431
  : null] }) })] }) }), order.errorDetails && ((0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: (0, anyspend_1.getErrorDisplay)(order.errorDetails) }) })), (0, jsx_runtime_1.jsx)("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["Return to Home ", (0, jsx_runtime_1.jsx)(lucide_react_1.Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
435
432
  }
436
433
  if (executeTx) {
437
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: orderStatusPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "order-details-execute-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "order-details-execute-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_3.motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
434
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(OrderStatus_1.OrderStatus, { order: order, selectedCryptoPaymentMethod: orderStatusPaymentMethod }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }), (0, jsx_runtime_1.jsx)(Accordion_1.Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: (0, jsx_runtime_1.jsxs)(Accordion_1.AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [(0, jsx_runtime_1.jsx)(Accordion_1.AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), (0, jsx_runtime_1.jsx)(Accordion_1.AccordionContent, { className: "accordion-content pl-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsx)("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: (0, jsx_runtime_1.jsx)(react_3.motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
438
435
  ? depositTxs.map(dTxs => ((0, jsx_runtime_1.jsx)(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
439
436
  ? `Received payment`
440
437
  : `Received ${(0, number_1.formatTokenAmount)(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
@@ -189,12 +189,19 @@ function useAnyspendFlow({ paymentType = "crypto", recipientAddress, loadOrder,
189
189
  // Handle order completion
190
190
  (0, react_3.useEffect)(() => {
191
191
  if (oat?.data?.order.status === "executed") {
192
- console.log("Order executed successfully");
193
- // just get the payload.amount if available from custompayload
194
- const amount = oat.data.order.payload?.amount;
195
- onTransactionSuccess?.(amount);
192
+ // get the actualDstAmount if available from custompayload
193
+ const amount = oat.data.order.payload?.actualDstAmount;
194
+ const formattedActualDstAmount = amount
195
+ ? (0, number_1.formatTokenAmount)(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
196
+ : undefined;
197
+ onTransactionSuccess?.(formattedActualDstAmount);
196
198
  }
197
- }, [oat?.data?.order.status, oat?.data?.order.payload, onTransactionSuccess]);
199
+ }, [
200
+ oat?.data?.order.status,
201
+ oat?.data?.order.payload,
202
+ onTransactionSuccess,
203
+ oat?.data?.order.metadata.dstToken.decimals,
204
+ ]);
198
205
  return {
199
206
  // State
200
207
  activePanel,
@@ -127,7 +127,7 @@ exports.EVM_MAINNET = {
127
127
  name: chains_1.bsc.name,
128
128
  logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
129
129
  type: chain_1.ChainType.EVM,
130
- nativeRequired: (0, viem_1.parseEther)("0.000025"),
130
+ nativeRequired: (0, viem_1.parseEther)("0.0001"),
131
131
  canDepositNative: true,
132
132
  defaultToken: (0, token_1.getBnbToken)(),
133
133
  nativeToken: (0, token_1.getBnbToken)(),
@@ -130,18 +130,21 @@ function useUnifiedChainSwitchAndExecute() {
130
130
  });
131
131
  }
132
132
  catch (err) {
133
- console.error(err);
133
+ console.error("Create global-accounts-intents error", err);
134
134
  }
135
135
  sonner_1.toast.info("Sending transaction…");
136
+ const start = performance.now();
136
137
  const sendTxResponse = await (0, thirdweb_2.sendTransaction)({
137
138
  account: aaAccount,
138
139
  transaction,
139
140
  });
141
+ const end = performance.now();
142
+ console.log("Time taken to send transaction", end - start);
140
143
  sonner_1.toast.success("Transaction sent successfully");
141
144
  return sendTxResponse.transactionHash;
142
145
  }
143
146
  catch (err) {
144
- console.error(err);
147
+ console.error("Send transaction error", err);
145
148
  sonner_1.toast.error(err?.message ?? "Transaction failed");
146
149
  return undefined;
147
150
  }
@@ -49,9 +49,6 @@ function getOrderSuccessText({ order, tournament, formattedActualDstAmount, form
49
49
  case "custom":
50
50
  actionText = order.metadata.action || `executed contract`;
51
51
  return `Successfully ${actionText}`;
52
- case "hype_duel":
53
- actionText = `deposited ${formattedActualDstAmount || "--"} HYPE`;
54
- return `Successfully ${actionText} to ${recipient}`;
55
52
  default:
56
53
  throw new Error("Invalid order type");
57
54
  }
@@ -428,7 +425,7 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
428
425
  : null] }) })] }) }), order.errorDetails && (_jsx("div", { className: "flex justify-center", children: _jsx("span", { className: "text-as-primary/50 text-center text-sm", style: { maxWidth: "40ch" }, children: getErrorDisplay(order.errorDetails) }) })), _jsx("button", { className: "order-close-button order-details-close-btn bg-as-brand flex w-full items-center justify-center gap-2 rounded-lg p-2 font-semibold text-white", onClick: mode === "page" ? handleBack : handleCloseModal, children: mode === "page" ? (_jsxs(_Fragment, { children: ["Return to Home ", _jsx(Home, { className: "ml-2 h-4 w-4" })] })) : ("Close") })] }));
429
426
  }
430
427
  if (executeTx) {
431
- return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: orderStatusPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [_jsx(AccordionTrigger, { className: "order-details-execute-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "order-details-execute-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
428
+ return (_jsxs(_Fragment, { children: [_jsx(OrderStatus, { order: order, selectedCryptoPaymentMethod: orderStatusPaymentMethod }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount }), _jsx(Accordion, { type: "single", collapsible: true, className: "order-details-accordion w-full", children: _jsxs(AccordionItem, { value: "execute-details", className: "order-details-execute-item", children: [_jsx(AccordionTrigger, { className: "accordion-trigger", children: "Transaction Details" }), _jsx(AccordionContent, { className: "accordion-content pl-2", children: _jsxs("div", { className: "relative flex w-full flex-col gap-4", children: [_jsx("div", { className: "bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2", children: _jsx(motion.div, { className: "bg-as-border-primary absolute left-[2px] top-0 z-10 w-[3px]", initial: { height: "0%" }, animate: { height: "100%" }, transition: { duration: 1.5, ease: "easeInOut" } }) }), depositTxs
432
429
  ? depositTxs.map(dTxs => (_jsx(TransactionDetails, { title: order.onrampMetadata?.vendor === "stripe-web2"
433
430
  ? `Received payment`
434
431
  : `Received ${formatTokenAmount(BigInt(dTxs.amount), srcToken.decimals)} ${srcToken.symbol}`, chainId: order.srcChain, tx: dTxs, isProcessing: false }, dTxs.txHash)))
@@ -185,12 +185,19 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
185
185
  // Handle order completion
186
186
  useEffect(() => {
187
187
  if (oat?.data?.order.status === "executed") {
188
- console.log("Order executed successfully");
189
- // just get the payload.amount if available from custompayload
190
- const amount = oat.data.order.payload?.amount;
191
- onTransactionSuccess?.(amount);
188
+ // get the actualDstAmount if available from custompayload
189
+ const amount = oat.data.order.payload?.actualDstAmount;
190
+ const formattedActualDstAmount = amount
191
+ ? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
192
+ : undefined;
193
+ onTransactionSuccess?.(formattedActualDstAmount);
192
194
  }
193
- }, [oat?.data?.order.status, oat?.data?.order.payload, onTransactionSuccess]);
195
+ }, [
196
+ oat?.data?.order.status,
197
+ oat?.data?.order.payload,
198
+ onTransactionSuccess,
199
+ oat?.data?.order.metadata.dstToken.decimals,
200
+ ]);
194
201
  return {
195
202
  // State
196
203
  activePanel,
@@ -104,7 +104,7 @@ export const EVM_MAINNET = {
104
104
  name: bsc.name,
105
105
  logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
106
106
  type: ChainType.EVM,
107
- nativeRequired: parseEther("0.000025"),
107
+ nativeRequired: parseEther("0.0001"),
108
108
  canDepositNative: true,
109
109
  defaultToken: getBnbToken(),
110
110
  nativeToken: getBnbToken(),
@@ -124,18 +124,21 @@ export function useUnifiedChainSwitchAndExecute() {
124
124
  });
125
125
  }
126
126
  catch (err) {
127
- console.error(err);
127
+ console.error("Create global-accounts-intents error", err);
128
128
  }
129
129
  toast.info("Sending transaction…");
130
+ const start = performance.now();
130
131
  const sendTxResponse = await twSendTransaction({
131
132
  account: aaAccount,
132
133
  transaction,
133
134
  });
135
+ const end = performance.now();
136
+ console.log("Time taken to send transaction", end - start);
134
137
  toast.success("Transaction sent successfully");
135
138
  return sendTxResponse.transactionHash;
136
139
  }
137
140
  catch (err) {
138
- console.error(err);
141
+ console.error("Send transaction error", err);
139
142
  toast.error(err?.message ?? "Transaction failed");
140
143
  return undefined;
141
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b3dotfun/sdk",
3
- "version": "0.0.40-alpha.0",
3
+ "version": "0.0.40-alpha.2",
4
4
  "source": "src/index.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "react-native": "./dist/cjs/index.native.js",
@@ -110,9 +110,6 @@ function getOrderSuccessText({
110
110
  case "custom":
111
111
  actionText = order.metadata.action || `executed contract`;
112
112
  return `Successfully ${actionText}`;
113
- case "hype_duel":
114
- actionText = `deposited ${formattedActualDstAmount || "--"} HYPE`;
115
- return `Successfully ${actionText} to ${recipient}`;
116
113
  default:
117
114
  throw new Error("Invalid order type");
118
115
  }
@@ -667,8 +664,8 @@ export const OrderDetails = memo(function OrderDetails({
667
664
  />
668
665
  <Accordion type="single" collapsible className="order-details-accordion w-full">
669
666
  <AccordionItem value="execute-details" className="order-details-execute-item">
670
- <AccordionTrigger className="order-details-execute-trigger">Transaction Details</AccordionTrigger>
671
- <AccordionContent className="order-details-execute-content pl-2">
667
+ <AccordionTrigger className="accordion-trigger">Transaction Details</AccordionTrigger>
668
+ <AccordionContent className="accordion-content pl-2">
672
669
  <div className="relative flex w-full flex-col gap-4">
673
670
  <div className="bg-as-surface-secondary absolute bottom-2 left-4 top-2 z-[5] w-2">
674
671
  <motion.div
@@ -244,12 +244,19 @@ export function useAnyspendFlow({
244
244
  // Handle order completion
245
245
  useEffect(() => {
246
246
  if (oat?.data?.order.status === "executed") {
247
- console.log("Order executed successfully");
248
- // just get the payload.amount if available from custompayload
249
- const amount = (oat.data.order.payload as { amount?: string })?.amount;
250
- onTransactionSuccess?.(amount);
247
+ // get the actualDstAmount if available from custompayload
248
+ const amount = (oat.data.order.payload as { actualDstAmount?: string })?.actualDstAmount;
249
+ const formattedActualDstAmount = amount
250
+ ? formatTokenAmount(BigInt(amount), oat.data.order.metadata.dstToken.decimals)
251
+ : undefined;
252
+ onTransactionSuccess?.(formattedActualDstAmount);
251
253
  }
252
- }, [oat?.data?.order.status, oat?.data?.order.payload, onTransactionSuccess]);
254
+ }, [
255
+ oat?.data?.order.status,
256
+ oat?.data?.order.payload,
257
+ onTransactionSuccess,
258
+ oat?.data?.order.metadata.dstToken.decimals,
259
+ ]);
253
260
 
254
261
  return {
255
262
  // State
@@ -149,7 +149,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
149
149
  name: bsc.name,
150
150
  logoUrl: "https://avatars.githubusercontent.com/u/45615063?s=280&v=4",
151
151
  type: ChainType.EVM,
152
- nativeRequired: parseEther("0.000025"),
152
+ nativeRequired: parseEther("0.0001"),
153
153
  canDepositNative: true,
154
154
  defaultToken: getBnbToken(),
155
155
  nativeToken: getBnbToken(),
@@ -154,19 +154,22 @@ export function useUnifiedChainSwitchAndExecute() {
154
154
  value: params.value.toString(),
155
155
  });
156
156
  } catch (err: any) {
157
- console.error(err);
157
+ console.error("Create global-accounts-intents error", err);
158
158
  }
159
159
 
160
160
  toast.info("Sending transaction…");
161
+ const start = performance.now();
161
162
  const sendTxResponse = await twSendTransaction({
162
163
  account: aaAccount,
163
164
  transaction,
164
165
  });
166
+ const end = performance.now();
167
+ console.log("Time taken to send transaction", end - start);
165
168
 
166
169
  toast.success("Transaction sent successfully");
167
170
  return sendTxResponse.transactionHash;
168
171
  } catch (err: any) {
169
- console.error(err);
172
+ console.error("Send transaction error", err);
170
173
  toast.error(err?.message ?? "Transaction failed");
171
174
  return undefined;
172
175
  } finally {