@phantom/react-sdk 1.0.6 → 1.0.7

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.
package/README.md CHANGED
@@ -1273,6 +1273,48 @@ function EthereumExample() {
1273
1273
  }
1274
1274
  ```
1275
1275
 
1276
+ ## Dapp-Sponsored Transactions (presignTransaction)
1277
+
1278
+ Pass `presignTransaction` directly to `signAndSendTransaction` for calls that need co-signing. Calls without it proceed normally — it is never applied globally.
1279
+
1280
+ > **Important:** Phantom embedded wallets do not accept pre-signed transactions. If your use case requires a second signer (e.g. your app as the fee payer), that signing must happen via this option, after Phantom has constructed and validated the transaction. This restriction does not apply to injected providers (e.g. the Phantom browser extension).
1281
+
1282
+ > **Note:** `presignTransaction` only fires for Solana transactions via the embedded provider. EVM transactions and injected providers are unaffected.
1283
+
1284
+ ```tsx
1285
+ import { useSolana, base64urlDecode, base64urlEncode } from "@phantom/react-sdk";
1286
+ import { VersionedTransaction } from "@solana/web3.js";
1287
+
1288
+ function SendWithFeeSponsor() {
1289
+ const { solana } = useSolana();
1290
+
1291
+ const sendSponsored = async () => {
1292
+ // This call co-signs as fee payer.
1293
+ // presignTransaction should call your backend — never hold a fee payer keypair in frontend code.
1294
+ const result = await solana.signAndSendTransaction(transaction, {
1295
+ presignTransaction: async (tx, context) => {
1296
+ // Send the transaction to your backend for fee payer signing.
1297
+ // Your backend deserializes, partially signs, and returns the modified transaction.
1298
+ const response = await fetch("/api/presign", {
1299
+ method: "POST",
1300
+ body: JSON.stringify({ transaction: tx, networkId: context.networkId }),
1301
+ headers: { "Content-Type": "application/json" },
1302
+ });
1303
+ const { transaction: signedTx } = await response.json();
1304
+ return signedTx; // base64url-encoded, partially signed by the fee payer
1305
+ },
1306
+ });
1307
+ };
1308
+
1309
+ const sendNormal = async () => {
1310
+ // This call has no co-signer
1311
+ const result = await solana.signAndSendTransaction(transaction);
1312
+ };
1313
+ }
1314
+ ```
1315
+
1316
+ > **Never hold a fee payer keypair in frontend code.** The `presignTransaction` callback runs in the browser — use it to call your own backend, which holds the keypair securely and returns the partially-signed transaction.
1317
+
1276
1318
  ## Hooks Reference
1277
1319
 
1278
1320
  Quick reference of all available hooks:
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import * as _phantom_browser_sdk from '@phantom/browser-sdk';
4
4
  import { BrowserSDKConfig, DebugConfig, AuthOptions, BrowserSDK, WalletAddress, ConnectResult, AuthProviderType, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, InjectedWalletInfo, AddressType } from '@phantom/browser-sdk';
5
- export { AddressType, AuthOptions, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, ConnectErrorEventData, ConnectEventData, ConnectStartEventData, DebugLevel, DebugMessage, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, InjectedWalletId, InjectedWalletInfo, NetworkId, SignedTransaction, WalletAddress, debug, isMobileDevice } from '@phantom/browser-sdk';
5
+ export { AddressType, AuthOptions, AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult, ConnectErrorEventData, ConnectEventData, ConnectStartEventData, DebugLevel, DebugMessage, DisconnectEventData, EmbeddedProviderEvent, EmbeddedProviderEventMap, EventCallback, InjectedWalletId, InjectedWalletInfo, NetworkId, SignedTransaction, WalletAddress, base64urlDecode, base64urlEncode, debug, isMobileDevice } from '@phantom/browser-sdk';
6
6
  import { PhantomTheme } from '@phantom/wallet-sdk-ui';
7
7
  export { ComputedPhantomTheme, HexColor, PhantomTheme, darkTheme, lightTheme, mergeTheme, useTheme } from '@phantom/wallet-sdk-ui';
8
8
  import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
package/dist/index.js CHANGED
@@ -36,6 +36,8 @@ __export(src_exports, {
36
36
  DebugLevel: () => import_browser_sdk8.DebugLevel,
37
37
  NetworkId: () => import_browser_sdk8.NetworkId,
38
38
  PhantomProvider: () => PhantomProvider,
39
+ base64urlDecode: () => import_browser_sdk8.base64urlDecode,
40
+ base64urlEncode: () => import_browser_sdk8.base64urlEncode,
39
41
  darkTheme: () => import_wallet_sdk_ui10.darkTheme,
40
42
  debug: () => import_browser_sdk8.debug,
41
43
  isMobileDevice: () => import_browser_sdk8.isMobileDevice,
package/dist/index.mjs CHANGED
@@ -1146,7 +1146,15 @@ function ConnectBox({ maxWidth = "350px", transparent = false, appIcon, appName
1146
1146
 
1147
1147
  // src/index.ts
1148
1148
  import { darkTheme as darkTheme2, lightTheme, mergeTheme as mergeTheme2 } from "@phantom/wallet-sdk-ui";
1149
- import { NetworkId, AddressType as AddressType3, DebugLevel, debug, isMobileDevice as isMobileDevice3 } from "@phantom/browser-sdk";
1149
+ import {
1150
+ NetworkId,
1151
+ AddressType as AddressType3,
1152
+ DebugLevel,
1153
+ debug,
1154
+ isMobileDevice as isMobileDevice3,
1155
+ base64urlEncode,
1156
+ base64urlDecode
1157
+ } from "@phantom/browser-sdk";
1150
1158
  export {
1151
1159
  AddressType3 as AddressType,
1152
1160
  ConnectBox,
@@ -1154,6 +1162,8 @@ export {
1154
1162
  DebugLevel,
1155
1163
  NetworkId,
1156
1164
  PhantomProvider,
1165
+ base64urlDecode,
1166
+ base64urlEncode,
1157
1167
  darkTheme2 as darkTheme,
1158
1168
  debug,
1159
1169
  isMobileDevice3 as isMobileDevice,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phantom/react-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/phantom/phantom-connect-sdk",
@@ -31,10 +31,10 @@
31
31
  "prettier": "prettier --write \"src/**/*.{ts,tsx}\""
32
32
  },
33
33
  "dependencies": {
34
- "@phantom/browser-sdk": "^1.0.6",
35
- "@phantom/chain-interfaces": "^1.0.6",
36
- "@phantom/constants": "^1.0.6",
37
- "@phantom/wallet-sdk-ui": "^1.0.6"
34
+ "@phantom/browser-sdk": "^1.0.7",
35
+ "@phantom/chain-interfaces": "^1.0.7",
36
+ "@phantom/constants": "^1.0.7",
37
+ "@phantom/wallet-sdk-ui": "^1.0.7"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@testing-library/dom": "^10.4.0",