@phantom/browser-injected-sdk 0.0.10 → 1.0.0-beta.0
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/dist/auto-confirm/index.d.ts +6 -6
- package/dist/auto-confirm/index.js +22 -6
- package/dist/auto-confirm/index.mjs +22 -6
- package/dist/{chunk-QNVIOBKG.mjs → chunk-IHSV7HFD.mjs} +8 -0
- package/dist/ethereum/index.d.ts +1 -1
- package/dist/ethereum/index.js +8 -0
- package/dist/ethereum/index.mjs +1 -1
- package/dist/{index-2f448acb.d.ts → index-ecfd5526.d.ts} +39 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -0
- package/dist/index.mjs +1 -1
- package/dist/solana/index.d.ts +8 -8
- package/dist/solana/index.js +26 -3
- package/dist/solana/index.mjs +26 -3
- package/package.json +2 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { P as Plugin } from '../index-
|
|
1
|
+
import { P as Plugin } from '../index-ecfd5526.js';
|
|
2
|
+
import { NetworkId } from '@phantom/constants';
|
|
2
3
|
|
|
3
|
-
type NetworkID = "bip122:000000000019d6689c085ae165831e93" | "bip122:000000000933ea01ad0ee984209779ba" | "solana:101" | "solana:102" | "solana:103" | "solana:localnet" | "eip155:1" | "eip155:11155111" | "eip155:137" | "eip155:80002" | "eip155:8453" | "eip155:84532" | "eip155:143" | "eip155:10143" | "eip155:41454" | "eip155:42161" | "eip155:421614" | "hypercore:mainnet" | "hypercore:testnet" | "sui:mainnet" | "sui:testnet";
|
|
4
4
|
type AutoConfirmEnableParams = {
|
|
5
|
-
chains?:
|
|
5
|
+
chains?: NetworkId[];
|
|
6
6
|
};
|
|
7
7
|
type AutoConfirmResult = {
|
|
8
8
|
enabled: boolean;
|
|
9
|
-
chains:
|
|
9
|
+
chains: NetworkId[];
|
|
10
10
|
};
|
|
11
11
|
type AutoConfirmSupportedChainsResult = {
|
|
12
|
-
chains:
|
|
12
|
+
chains: NetworkId[];
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
declare function autoConfirmEnable(params?: AutoConfirmEnableParams): Promise<AutoConfirmResult>;
|
|
@@ -34,4 +34,4 @@ declare module "../index" {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export { AutoConfirmEnableParams, AutoConfirmResult, AutoConfirmSupportedChainsResult,
|
|
37
|
+
export { AutoConfirmEnableParams, AutoConfirmPlugin, AutoConfirmResult, AutoConfirmSupportedChainsResult, createAutoConfirmPlugin };
|
|
@@ -37,19 +37,25 @@ function getProvider() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// src/auto-confirm/autoConfirmEnable.ts
|
|
40
|
+
var import_constants = require("@phantom/constants");
|
|
40
41
|
async function autoConfirmEnable(params) {
|
|
41
42
|
const provider = await getProvider();
|
|
42
43
|
if (!provider) {
|
|
43
44
|
throw new Error("Provider not found.");
|
|
44
45
|
}
|
|
46
|
+
const transformedParams = params?.chains ? { chains: params.chains.map(import_constants.networkIdToInternalCaip) } : {};
|
|
45
47
|
const result = await provider.request({
|
|
46
48
|
method: "phantom_auto_confirm_enable",
|
|
47
|
-
params:
|
|
49
|
+
params: transformedParams
|
|
48
50
|
});
|
|
49
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
...result,
|
|
53
|
+
chains: result.chains.map(import_constants.internalCaipToNetworkId)
|
|
54
|
+
};
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
// src/auto-confirm/autoConfirmDisable.ts
|
|
58
|
+
var import_constants2 = require("@phantom/constants");
|
|
53
59
|
async function autoConfirmDisable() {
|
|
54
60
|
const provider = await getProvider();
|
|
55
61
|
if (!provider) {
|
|
@@ -59,10 +65,14 @@ async function autoConfirmDisable() {
|
|
|
59
65
|
method: "phantom_auto_confirm_disable",
|
|
60
66
|
params: {}
|
|
61
67
|
});
|
|
62
|
-
return
|
|
68
|
+
return {
|
|
69
|
+
...result,
|
|
70
|
+
chains: result.chains.map(import_constants2.internalCaipToNetworkId)
|
|
71
|
+
};
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
// src/auto-confirm/autoConfirmStatus.ts
|
|
75
|
+
var import_constants3 = require("@phantom/constants");
|
|
66
76
|
async function autoConfirmStatus() {
|
|
67
77
|
const provider = await getProvider();
|
|
68
78
|
if (!provider) {
|
|
@@ -72,12 +82,16 @@ async function autoConfirmStatus() {
|
|
|
72
82
|
method: "phantom_auto_confirm_status",
|
|
73
83
|
params: {}
|
|
74
84
|
});
|
|
75
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
...result,
|
|
87
|
+
chains: result.chains.map(import_constants3.internalCaipToNetworkId)
|
|
88
|
+
};
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
// src/auto-confirm/autoConfirmSupportedChains.ts
|
|
92
|
+
var import_constants4 = require("@phantom/constants");
|
|
79
93
|
async function autoConfirmSupportedChains() {
|
|
80
|
-
const provider = getProvider();
|
|
94
|
+
const provider = await getProvider();
|
|
81
95
|
if (!provider) {
|
|
82
96
|
throw new Error("Provider not found.");
|
|
83
97
|
}
|
|
@@ -85,7 +99,9 @@ async function autoConfirmSupportedChains() {
|
|
|
85
99
|
method: "phantom_auto_confirm_supported_chains",
|
|
86
100
|
params: {}
|
|
87
101
|
});
|
|
88
|
-
return
|
|
102
|
+
return {
|
|
103
|
+
chains: result.chains.map(import_constants4.internalCaipToNetworkId)
|
|
104
|
+
};
|
|
89
105
|
}
|
|
90
106
|
|
|
91
107
|
// src/auto-confirm/plugin.ts
|
|
@@ -13,19 +13,25 @@ function getProvider() {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// src/auto-confirm/autoConfirmEnable.ts
|
|
16
|
+
import { networkIdToInternalCaip, internalCaipToNetworkId } from "@phantom/constants";
|
|
16
17
|
async function autoConfirmEnable(params) {
|
|
17
18
|
const provider = await getProvider();
|
|
18
19
|
if (!provider) {
|
|
19
20
|
throw new Error("Provider not found.");
|
|
20
21
|
}
|
|
22
|
+
const transformedParams = params?.chains ? { chains: params.chains.map(networkIdToInternalCaip) } : {};
|
|
21
23
|
const result = await provider.request({
|
|
22
24
|
method: "phantom_auto_confirm_enable",
|
|
23
|
-
params:
|
|
25
|
+
params: transformedParams
|
|
24
26
|
});
|
|
25
|
-
return
|
|
27
|
+
return {
|
|
28
|
+
...result,
|
|
29
|
+
chains: result.chains.map(internalCaipToNetworkId)
|
|
30
|
+
};
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
// src/auto-confirm/autoConfirmDisable.ts
|
|
34
|
+
import { internalCaipToNetworkId as internalCaipToNetworkId2 } from "@phantom/constants";
|
|
29
35
|
async function autoConfirmDisable() {
|
|
30
36
|
const provider = await getProvider();
|
|
31
37
|
if (!provider) {
|
|
@@ -35,10 +41,14 @@ async function autoConfirmDisable() {
|
|
|
35
41
|
method: "phantom_auto_confirm_disable",
|
|
36
42
|
params: {}
|
|
37
43
|
});
|
|
38
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
...result,
|
|
46
|
+
chains: result.chains.map(internalCaipToNetworkId2)
|
|
47
|
+
};
|
|
39
48
|
}
|
|
40
49
|
|
|
41
50
|
// src/auto-confirm/autoConfirmStatus.ts
|
|
51
|
+
import { internalCaipToNetworkId as internalCaipToNetworkId3 } from "@phantom/constants";
|
|
42
52
|
async function autoConfirmStatus() {
|
|
43
53
|
const provider = await getProvider();
|
|
44
54
|
if (!provider) {
|
|
@@ -48,12 +58,16 @@ async function autoConfirmStatus() {
|
|
|
48
58
|
method: "phantom_auto_confirm_status",
|
|
49
59
|
params: {}
|
|
50
60
|
});
|
|
51
|
-
return
|
|
61
|
+
return {
|
|
62
|
+
...result,
|
|
63
|
+
chains: result.chains.map(internalCaipToNetworkId3)
|
|
64
|
+
};
|
|
52
65
|
}
|
|
53
66
|
|
|
54
67
|
// src/auto-confirm/autoConfirmSupportedChains.ts
|
|
68
|
+
import { internalCaipToNetworkId as internalCaipToNetworkId4 } from "@phantom/constants";
|
|
55
69
|
async function autoConfirmSupportedChains() {
|
|
56
|
-
const provider = getProvider();
|
|
70
|
+
const provider = await getProvider();
|
|
57
71
|
if (!provider) {
|
|
58
72
|
throw new Error("Provider not found.");
|
|
59
73
|
}
|
|
@@ -61,7 +75,9 @@ async function autoConfirmSupportedChains() {
|
|
|
61
75
|
method: "phantom_auto_confirm_supported_chains",
|
|
62
76
|
params: {}
|
|
63
77
|
});
|
|
64
|
-
return
|
|
78
|
+
return {
|
|
79
|
+
chains: result.chains.map(internalCaipToNetworkId4)
|
|
80
|
+
};
|
|
65
81
|
}
|
|
66
82
|
|
|
67
83
|
// src/auto-confirm/plugin.ts
|
|
@@ -174,6 +174,13 @@ var InjectedEthereumStrategy = class {
|
|
|
174
174
|
params: [{ chainId }]
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
+
async request(args) {
|
|
178
|
+
const provider = __privateMethod(this, _getProvider, getProvider_fn).call(this);
|
|
179
|
+
if (!provider) {
|
|
180
|
+
throw new Error("Provider not found.");
|
|
181
|
+
}
|
|
182
|
+
return await provider.request(args);
|
|
183
|
+
}
|
|
177
184
|
};
|
|
178
185
|
_getProvider = new WeakSet();
|
|
179
186
|
getProvider_fn = function() {
|
|
@@ -367,6 +374,7 @@ var ethereum = {
|
|
|
367
374
|
signTransaction,
|
|
368
375
|
getChainId,
|
|
369
376
|
switchChain,
|
|
377
|
+
getProvider,
|
|
370
378
|
addEventListener,
|
|
371
379
|
removeEventListener
|
|
372
380
|
};
|
package/dist/ethereum/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { E as Ethereum, e as EthereumEventType, d as EthereumSignInData, b as EthereumTransaction, a as PhantomEthereumProvider, c as createEthereumPlugin } from '../index-ecfd5526.js';
|
package/dist/ethereum/index.js
CHANGED
|
@@ -208,6 +208,13 @@ var InjectedEthereumStrategy = class {
|
|
|
208
208
|
params: [{ chainId }]
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
+
async request(args) {
|
|
212
|
+
const provider = __privateMethod(this, _getProvider, getProvider_fn).call(this);
|
|
213
|
+
if (!provider) {
|
|
214
|
+
throw new Error("Provider not found.");
|
|
215
|
+
}
|
|
216
|
+
return await provider.request(args);
|
|
217
|
+
}
|
|
211
218
|
};
|
|
212
219
|
_getProvider = new WeakSet();
|
|
213
220
|
getProvider_fn = function() {
|
|
@@ -401,6 +408,7 @@ var ethereum = {
|
|
|
401
408
|
signTransaction,
|
|
402
409
|
getChainId,
|
|
403
410
|
switchChain,
|
|
411
|
+
getProvider,
|
|
404
412
|
addEventListener,
|
|
405
413
|
removeEventListener
|
|
406
414
|
};
|
package/dist/ethereum/index.mjs
CHANGED
|
@@ -127,6 +127,43 @@ declare function getChainId(): Promise<string>;
|
|
|
127
127
|
*/
|
|
128
128
|
declare function switchChain(chainId: string): Promise<void>;
|
|
129
129
|
|
|
130
|
+
declare enum ProviderStrategy {
|
|
131
|
+
INJECTED = "injected",
|
|
132
|
+
DEEPLINK = "deeplink"
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface EthereumStrategy {
|
|
136
|
+
readonly type: ProviderStrategy;
|
|
137
|
+
isConnected: boolean;
|
|
138
|
+
connect: ({ onlyIfTrusted }: {
|
|
139
|
+
onlyIfTrusted: boolean;
|
|
140
|
+
}) => Promise<string[] | undefined>;
|
|
141
|
+
disconnect: () => Promise<void>;
|
|
142
|
+
getAccounts: () => Promise<string[]>;
|
|
143
|
+
signMessage: (message: string, address: string) => Promise<string>;
|
|
144
|
+
signPersonalMessage: (message: string, address: string) => Promise<string>;
|
|
145
|
+
signTypedData: (typedData: any, address: string) => Promise<string>;
|
|
146
|
+
signIn: (signInData: EthereumSignInData) => Promise<{
|
|
147
|
+
address: string;
|
|
148
|
+
signature: string;
|
|
149
|
+
signedMessage: string;
|
|
150
|
+
}>;
|
|
151
|
+
sendTransaction: (transaction: EthereumTransaction) => Promise<string>;
|
|
152
|
+
signTransaction: (transaction: EthereumTransaction) => Promise<string>;
|
|
153
|
+
getChainId: () => Promise<string>;
|
|
154
|
+
switchChain: (chainId: string) => Promise<void>;
|
|
155
|
+
request: <T = any>(args: {
|
|
156
|
+
method: string;
|
|
157
|
+
params?: unknown[];
|
|
158
|
+
}) => Promise<T>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves Phantom Ethereum provider and returns it if it exists.
|
|
163
|
+
* @returns Phantom Ethereum provider or throws error if it doesn't exist.
|
|
164
|
+
*/
|
|
165
|
+
declare function getProvider(strategy?: ProviderStrategy): Promise<EthereumStrategy>;
|
|
166
|
+
|
|
130
167
|
type Ethereum = {
|
|
131
168
|
connect: typeof connect;
|
|
132
169
|
disconnect: typeof disconnect;
|
|
@@ -139,6 +176,7 @@ type Ethereum = {
|
|
|
139
176
|
signTransaction: typeof signTransaction;
|
|
140
177
|
getChainId: typeof getChainId;
|
|
141
178
|
switchChain: typeof switchChain;
|
|
179
|
+
getProvider: typeof getProvider;
|
|
142
180
|
addEventListener: (event: EthereumEventType, callback: PhantomEthereumEventCallback) => () => void;
|
|
143
181
|
removeEventListener: (event: EthereumEventType, callback: PhantomEthereumEventCallback) => void;
|
|
144
182
|
};
|
|
@@ -165,4 +203,4 @@ interface Phantom {
|
|
|
165
203
|
*/
|
|
166
204
|
declare function createPhantom({ plugins }: CreatePhantomConfig): Phantom;
|
|
167
205
|
|
|
168
|
-
export { CreatePhantomConfig as C,
|
|
206
|
+
export { CreatePhantomConfig as C, Ethereum as E, Plugin as P, PhantomEthereumProvider as a, EthereumTransaction as b, createEthereumPlugin as c, EthereumSignInData as d, EthereumEventType as e, Phantom as f, createPhantom as g, createExtensionPlugin as h, Extension as i, isInstalled as j };
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CreatePhantomConfig,
|
|
1
|
+
export { C as CreatePhantomConfig, i as Extension, f as Phantom, P as Plugin, c as createEthereumPlugin, h as createExtensionPlugin, g as createPhantom, j as isPhantomExtensionInstalled } from './index-ecfd5526.js';
|
package/dist/index.js
CHANGED
|
@@ -232,6 +232,13 @@ var InjectedEthereumStrategy = class {
|
|
|
232
232
|
params: [{ chainId }]
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
+
async request(args) {
|
|
236
|
+
const provider = __privateMethod(this, _getProvider, getProvider_fn).call(this);
|
|
237
|
+
if (!provider) {
|
|
238
|
+
throw new Error("Provider not found.");
|
|
239
|
+
}
|
|
240
|
+
return await provider.request(args);
|
|
241
|
+
}
|
|
235
242
|
};
|
|
236
243
|
_getProvider = new WeakSet();
|
|
237
244
|
getProvider_fn = function() {
|
|
@@ -425,6 +432,7 @@ var ethereum = {
|
|
|
425
432
|
signTransaction,
|
|
426
433
|
getChainId,
|
|
427
434
|
switchChain,
|
|
435
|
+
getProvider,
|
|
428
436
|
addEventListener,
|
|
429
437
|
removeEventListener
|
|
430
438
|
};
|
package/dist/index.mjs
CHANGED
package/dist/solana/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Plugin } from '../index-
|
|
2
|
-
import {
|
|
1
|
+
import { P as Plugin } from '../index-ecfd5526.js';
|
|
2
|
+
import { VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
3
3
|
|
|
4
4
|
declare function connect(): Promise<string | undefined>;
|
|
5
5
|
|
|
@@ -50,12 +50,12 @@ interface PhantomSolanaProvider {
|
|
|
50
50
|
signature: Uint8Array;
|
|
51
51
|
signedMessage: Uint8Array;
|
|
52
52
|
}>;
|
|
53
|
-
signAndSendTransaction: (transaction:
|
|
53
|
+
signAndSendTransaction: (transaction: any, options?: SendOptions) => Promise<{
|
|
54
54
|
signature: string;
|
|
55
55
|
publicKey?: string;
|
|
56
56
|
}>;
|
|
57
|
-
signAllTransactions: (transactions:
|
|
58
|
-
signTransaction: (transaction:
|
|
57
|
+
signAllTransactions: (transactions: any[]) => Promise<any[]>;
|
|
58
|
+
signTransaction: (transaction: any) => Promise<any>;
|
|
59
59
|
on: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
60
60
|
off: (event: "connect" | "disconnect" | "accountChanged", handler: (publicKey?: PublicKey) => void) => void;
|
|
61
61
|
}
|
|
@@ -69,11 +69,11 @@ declare function getAccount(): Promise<string | undefined>;
|
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Signs and sends a transaction using the Phantom provider.
|
|
72
|
-
* @param transaction The transaction to sign and send.
|
|
72
|
+
* @param transaction The transaction to sign and send (Web3.js format).
|
|
73
73
|
* @returns A promise that resolves with the transaction signature and optionally the public key.
|
|
74
74
|
* @throws Error if Phantom provider is not found or if the operation fails.
|
|
75
75
|
*/
|
|
76
|
-
declare function signAndSendTransaction(transaction:
|
|
76
|
+
declare function signAndSendTransaction(transaction: VersionedTransaction | Transaction): Promise<{
|
|
77
77
|
signature: string;
|
|
78
78
|
address?: string;
|
|
79
79
|
}>;
|
|
@@ -120,4 +120,4 @@ declare module "../index" {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
export { PhantomSolanaProvider, SolanaSignInData, createSolanaPlugin };
|
|
123
|
+
export { PhantomSolanaProvider, Solana, SolanaSignInData, createSolanaPlugin };
|
package/dist/solana/index.js
CHANGED
|
@@ -213,7 +213,14 @@ var DeepLinkSolanaStrategy = class {
|
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
async signAndSendTransaction(transaction) {
|
|
216
|
-
|
|
216
|
+
let serialized;
|
|
217
|
+
if ("serialize" in transaction && typeof transaction.serialize === "function") {
|
|
218
|
+
serialized = transaction.serialize();
|
|
219
|
+
} else {
|
|
220
|
+
serialized = transaction.serializeMessage?.() || new Uint8Array();
|
|
221
|
+
}
|
|
222
|
+
const encoded = Buffer.from(serialized).toString("base64");
|
|
223
|
+
const deeplink = `phantom://sign-and-send-transaction?transaction=${encoded}`;
|
|
217
224
|
window.location.href = deeplink;
|
|
218
225
|
return Promise.resolve({
|
|
219
226
|
signature: "",
|
|
@@ -221,12 +228,28 @@ var DeepLinkSolanaStrategy = class {
|
|
|
221
228
|
});
|
|
222
229
|
}
|
|
223
230
|
async signTransaction(transaction) {
|
|
224
|
-
|
|
231
|
+
let serialized;
|
|
232
|
+
if ("serialize" in transaction && typeof transaction.serialize === "function") {
|
|
233
|
+
serialized = transaction.serialize();
|
|
234
|
+
} else {
|
|
235
|
+
serialized = transaction.serializeMessage?.() || new Uint8Array();
|
|
236
|
+
}
|
|
237
|
+
const encoded = Buffer.from(serialized).toString("base64");
|
|
238
|
+
const deeplink = `phantom://sign-transaction?transaction=${encoded}`;
|
|
225
239
|
window.location.href = deeplink;
|
|
226
240
|
return Promise.resolve(transaction);
|
|
227
241
|
}
|
|
228
242
|
async signAllTransactions(transactions) {
|
|
229
|
-
const
|
|
243
|
+
const serializedTxs = transactions.map((tx) => {
|
|
244
|
+
let serialized;
|
|
245
|
+
if ("serialize" in tx && typeof tx.serialize === "function") {
|
|
246
|
+
serialized = tx.serialize();
|
|
247
|
+
} else {
|
|
248
|
+
serialized = tx.serializeMessage?.() || new Uint8Array();
|
|
249
|
+
}
|
|
250
|
+
return Buffer.from(serialized).toString("base64");
|
|
251
|
+
});
|
|
252
|
+
const deeplink = `phantom://sign-all-transactions?transactions=${JSON.stringify(serializedTxs)}`;
|
|
230
253
|
window.location.href = deeplink;
|
|
231
254
|
return Promise.resolve(transactions);
|
|
232
255
|
}
|
package/dist/solana/index.mjs
CHANGED
|
@@ -180,7 +180,14 @@ var DeepLinkSolanaStrategy = class {
|
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
async signAndSendTransaction(transaction) {
|
|
183
|
-
|
|
183
|
+
let serialized;
|
|
184
|
+
if ("serialize" in transaction && typeof transaction.serialize === "function") {
|
|
185
|
+
serialized = transaction.serialize();
|
|
186
|
+
} else {
|
|
187
|
+
serialized = transaction.serializeMessage?.() || new Uint8Array();
|
|
188
|
+
}
|
|
189
|
+
const encoded = Buffer.from(serialized).toString("base64");
|
|
190
|
+
const deeplink = `phantom://sign-and-send-transaction?transaction=${encoded}`;
|
|
184
191
|
window.location.href = deeplink;
|
|
185
192
|
return Promise.resolve({
|
|
186
193
|
signature: "",
|
|
@@ -188,12 +195,28 @@ var DeepLinkSolanaStrategy = class {
|
|
|
188
195
|
});
|
|
189
196
|
}
|
|
190
197
|
async signTransaction(transaction) {
|
|
191
|
-
|
|
198
|
+
let serialized;
|
|
199
|
+
if ("serialize" in transaction && typeof transaction.serialize === "function") {
|
|
200
|
+
serialized = transaction.serialize();
|
|
201
|
+
} else {
|
|
202
|
+
serialized = transaction.serializeMessage?.() || new Uint8Array();
|
|
203
|
+
}
|
|
204
|
+
const encoded = Buffer.from(serialized).toString("base64");
|
|
205
|
+
const deeplink = `phantom://sign-transaction?transaction=${encoded}`;
|
|
192
206
|
window.location.href = deeplink;
|
|
193
207
|
return Promise.resolve(transaction);
|
|
194
208
|
}
|
|
195
209
|
async signAllTransactions(transactions) {
|
|
196
|
-
const
|
|
210
|
+
const serializedTxs = transactions.map((tx) => {
|
|
211
|
+
let serialized;
|
|
212
|
+
if ("serialize" in tx && typeof tx.serialize === "function") {
|
|
213
|
+
serialized = tx.serialize();
|
|
214
|
+
} else {
|
|
215
|
+
serialized = tx.serializeMessage?.() || new Uint8Array();
|
|
216
|
+
}
|
|
217
|
+
return Buffer.from(serialized).toString("base64");
|
|
218
|
+
});
|
|
219
|
+
const deeplink = `phantom://sign-all-transactions?transactions=${JSON.stringify(serializedTxs)}`;
|
|
197
220
|
window.location.href = deeplink;
|
|
198
221
|
return Promise.resolve(transactions);
|
|
199
222
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/browser-injected-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\""
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@phantom/constants": "^1.0.0-beta.0",
|
|
45
46
|
"@solana/web3.js": "^1.98.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|