@phantom/react-native-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 +36 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -2
- package/dist/index.mjs +5 -2
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -489,6 +489,42 @@ The SDK automatically handles deep link redirects. Ensure your app's URL scheme
|
|
|
489
489
|
|
|
490
490
|
**Redirect URL format:** `{scheme}://phantom-auth-callback?wallet_id=...&session_id=...`
|
|
491
491
|
|
|
492
|
+
## Dapp-Sponsored Transactions (presignTransaction)
|
|
493
|
+
|
|
494
|
+
Pass `presignTransaction` directly to `signAndSendTransaction` for calls that need co-signing. Calls without it proceed normally — it is never applied globally.
|
|
495
|
+
|
|
496
|
+
> **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).
|
|
497
|
+
|
|
498
|
+
> **Note:** `presignTransaction` only fires for Solana transactions via the embedded provider. EVM transactions are unaffected.
|
|
499
|
+
|
|
500
|
+
```tsx
|
|
501
|
+
import { useSolana, base64urlDecode, base64urlEncode } from "@phantom/react-native-sdk";
|
|
502
|
+
import { Keypair, VersionedTransaction } from "@solana/web3.js";
|
|
503
|
+
|
|
504
|
+
const feePayerKeypair = Keypair.fromSecretKey(/* your fee payer secret key */);
|
|
505
|
+
|
|
506
|
+
function SendWithFeeSponsor() {
|
|
507
|
+
const { solana } = useSolana();
|
|
508
|
+
|
|
509
|
+
const sendSponsored = async () => {
|
|
510
|
+
// This call co-signs as fee payer
|
|
511
|
+
const result = await solana.signAndSendTransaction(transaction, {
|
|
512
|
+
presignTransaction: async (tx, context) => {
|
|
513
|
+
const txBytes = base64urlDecode(tx);
|
|
514
|
+
const versionedTx = VersionedTransaction.deserialize(txBytes);
|
|
515
|
+
versionedTx.sign([feePayerKeypair]);
|
|
516
|
+
return base64urlEncode(versionedTx.serialize());
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
const sendNormal = async () => {
|
|
522
|
+
// This call has no co-signer
|
|
523
|
+
const result = await solana.signAndSendTransaction(transaction);
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
```
|
|
527
|
+
|
|
492
528
|
## Security Features
|
|
493
529
|
|
|
494
530
|
### Secure Storage
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export { ConnectErrorEventData, ConnectEventData, ConnectResult, ConnectStartEve
|
|
|
6
6
|
import { PhantomTheme } from '@phantom/wallet-sdk-ui';
|
|
7
7
|
export { PhantomTheme, darkTheme, lightTheme } from '@phantom/wallet-sdk-ui';
|
|
8
8
|
import { ISolanaChain, IEthereumChain } from '@phantom/chain-interfaces';
|
|
9
|
-
export {
|
|
9
|
+
export { SignAndSendTransactionOptions } from '@phantom/chain-interfaces';
|
|
10
|
+
export { AddressType, PresignTransactionContext } from '@phantom/client';
|
|
10
11
|
export { NetworkId } from '@phantom/constants';
|
|
12
|
+
export { base64urlDecode, base64urlEncode } from '@phantom/base64url';
|
|
11
13
|
|
|
12
14
|
interface PhantomDebugConfig {
|
|
13
15
|
/** Enable debug logging */
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,8 @@ __export(src_exports, {
|
|
|
33
33
|
AddressType: () => import_client.AddressType,
|
|
34
34
|
NetworkId: () => import_constants5.NetworkId,
|
|
35
35
|
PhantomProvider: () => PhantomProvider,
|
|
36
|
+
base64urlDecode: () => import_base64url3.base64urlDecode,
|
|
37
|
+
base64urlEncode: () => import_base64url3.base64urlEncode,
|
|
36
38
|
darkTheme: () => import_wallet_sdk_ui6.darkTheme,
|
|
37
39
|
lightTheme: () => import_wallet_sdk_ui6.lightTheme,
|
|
38
40
|
useAccounts: () => useAccounts,
|
|
@@ -557,7 +559,7 @@ var ExpoAuthProvider = class {
|
|
|
557
559
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
558
560
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
559
561
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
560
|
-
sdk_version: "1.0.
|
|
562
|
+
sdk_version: "1.0.7",
|
|
561
563
|
sdk_type: "react-native",
|
|
562
564
|
platform: import_react_native5.Platform.OS
|
|
563
565
|
});
|
|
@@ -1277,7 +1279,7 @@ function PhantomProvider({ children, config, debugConfig, theme, appIcon, appNam
|
|
|
1277
1279
|
[import_constants4.ANALYTICS_HEADERS.CLIENT]: import_react_native7.Platform.OS,
|
|
1278
1280
|
[import_constants4.ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1279
1281
|
[import_constants4.ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1280
|
-
[import_constants4.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.
|
|
1282
|
+
[import_constants4.ANALYTICS_HEADERS.SDK_VERSION]: "1.0.7"
|
|
1281
1283
|
// Replaced at build time
|
|
1282
1284
|
}
|
|
1283
1285
|
};
|
|
@@ -1392,12 +1394,15 @@ function useEthereum() {
|
|
|
1392
1394
|
// src/index.ts
|
|
1393
1395
|
var import_client = require("@phantom/client");
|
|
1394
1396
|
var import_constants5 = require("@phantom/constants");
|
|
1397
|
+
var import_base64url3 = require("@phantom/base64url");
|
|
1395
1398
|
var import_wallet_sdk_ui6 = require("@phantom/wallet-sdk-ui");
|
|
1396
1399
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1397
1400
|
0 && (module.exports = {
|
|
1398
1401
|
AddressType,
|
|
1399
1402
|
NetworkId,
|
|
1400
1403
|
PhantomProvider,
|
|
1404
|
+
base64urlDecode,
|
|
1405
|
+
base64urlEncode,
|
|
1401
1406
|
darkTheme,
|
|
1402
1407
|
lightTheme,
|
|
1403
1408
|
useAccounts,
|
package/dist/index.mjs
CHANGED
|
@@ -515,7 +515,7 @@ var ExpoAuthProvider = class {
|
|
|
515
515
|
// OAuth session management - defaults to allow refresh unless explicitly clearing after logout
|
|
516
516
|
clear_previous_session: (phantomOptions.clearPreviousSession ?? false).toString(),
|
|
517
517
|
allow_refresh: (phantomOptions.allowRefresh ?? true).toString(),
|
|
518
|
-
sdk_version: "1.0.
|
|
518
|
+
sdk_version: "1.0.7",
|
|
519
519
|
sdk_type: "react-native",
|
|
520
520
|
platform: Platform.OS
|
|
521
521
|
});
|
|
@@ -1240,7 +1240,7 @@ function PhantomProvider({ children, config, debugConfig, theme, appIcon, appNam
|
|
|
1240
1240
|
[ANALYTICS_HEADERS.CLIENT]: Platform2.OS,
|
|
1241
1241
|
[ANALYTICS_HEADERS.APP_ID]: config.appId,
|
|
1242
1242
|
[ANALYTICS_HEADERS.WALLET_TYPE]: config.embeddedWalletType,
|
|
1243
|
-
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.
|
|
1243
|
+
[ANALYTICS_HEADERS.SDK_VERSION]: "1.0.7"
|
|
1244
1244
|
// Replaced at build time
|
|
1245
1245
|
}
|
|
1246
1246
|
};
|
|
@@ -1355,11 +1355,14 @@ function useEthereum() {
|
|
|
1355
1355
|
// src/index.ts
|
|
1356
1356
|
import { AddressType } from "@phantom/client";
|
|
1357
1357
|
import { NetworkId } from "@phantom/constants";
|
|
1358
|
+
import { base64urlEncode as base64urlEncode3, base64urlDecode } from "@phantom/base64url";
|
|
1358
1359
|
import { darkTheme as darkTheme2, lightTheme } from "@phantom/wallet-sdk-ui";
|
|
1359
1360
|
export {
|
|
1360
1361
|
AddressType,
|
|
1361
1362
|
NetworkId,
|
|
1362
1363
|
PhantomProvider,
|
|
1364
|
+
base64urlDecode,
|
|
1365
|
+
base64urlEncode3 as base64urlEncode,
|
|
1363
1366
|
darkTheme2 as darkTheme,
|
|
1364
1367
|
lightTheme,
|
|
1365
1368
|
useAccounts,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/react-native-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Phantom Wallet SDK for React Native and Expo applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"directory": "packages/react-native-sdk"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@phantom/api-key-stamper": "^1.0.
|
|
48
|
+
"@phantom/api-key-stamper": "^1.0.7",
|
|
49
49
|
"@phantom/auth2": "^1.0.2",
|
|
50
|
-
"@phantom/base64url": "^1.0.
|
|
51
|
-
"@phantom/chain-interfaces": "^1.0.
|
|
52
|
-
"@phantom/client": "^1.0.
|
|
53
|
-
"@phantom/constants": "^1.0.
|
|
54
|
-
"@phantom/crypto": "^1.0.
|
|
55
|
-
"@phantom/embedded-provider-core": "^1.0.
|
|
56
|
-
"@phantom/sdk-types": "^1.0.
|
|
57
|
-
"@phantom/wallet-sdk-ui": "^1.0.
|
|
50
|
+
"@phantom/base64url": "^1.0.7",
|
|
51
|
+
"@phantom/chain-interfaces": "^1.0.7",
|
|
52
|
+
"@phantom/client": "^1.0.7",
|
|
53
|
+
"@phantom/constants": "^1.0.7",
|
|
54
|
+
"@phantom/crypto": "^1.0.7",
|
|
55
|
+
"@phantom/embedded-provider-core": "^1.0.7",
|
|
56
|
+
"@phantom/sdk-types": "^1.0.7",
|
|
57
|
+
"@phantom/wallet-sdk-ui": "^1.0.7",
|
|
58
58
|
"@types/bs58": "^5.0.0",
|
|
59
59
|
"bs58": "^6.0.0",
|
|
60
60
|
"buffer": "^6.0.3"
|