@phantom/parsers 1.0.0-beta.9 → 1.0.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.
- package/dist/index.d.ts +6 -1
- package/dist/index.js +18 -11
- package/dist/index.mjs +17 -11
- package/package.json +10 -5
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ declare function parseTransactionResponse(base64RawTransaction: string, networkI
|
|
|
31
31
|
* Supports both legacy Transaction and VersionedTransaction formats
|
|
32
32
|
*/
|
|
33
33
|
declare function parseSolanaSignedTransaction(base64RawTransaction: string): Transaction | VersionedTransaction | null;
|
|
34
|
+
/**
|
|
35
|
+
* Deserialize Solana transaction from Uint8Array bytes
|
|
36
|
+
* Supports both legacy Transaction and VersionedTransaction formats
|
|
37
|
+
*/
|
|
38
|
+
declare function deserializeSolanaTransaction(transactionBytes: Uint8Array): Transaction | VersionedTransaction;
|
|
34
39
|
|
|
35
40
|
interface ParsedTransaction {
|
|
36
41
|
/** The parsed transaction string (base64url for Solana/Sui/Bitcoin, RLP-encoded hex for EVM) */
|
|
@@ -48,4 +53,4 @@ interface ParsedTransaction {
|
|
|
48
53
|
declare function parseToKmsTransaction(transaction: any, networkId: NetworkId): Promise<ParsedTransaction>;
|
|
49
54
|
declare function parseSolanaKitTransactionToSolanaWeb3js(transaction: Transaction$1): any;
|
|
50
55
|
|
|
51
|
-
export { ParsedSignatureResult, ParsedTransaction, ParsedTransactionResult, parseSignMessageResponse, parseSolanaKitTransactionToSolanaWeb3js, parseSolanaSignedTransaction, parseToKmsTransaction, parseTransactionResponse };
|
|
56
|
+
export { ParsedSignatureResult, ParsedTransaction, ParsedTransactionResult, deserializeSolanaTransaction, parseSignMessageResponse, parseSolanaKitTransactionToSolanaWeb3js, parseSolanaSignedTransaction, parseToKmsTransaction, parseTransactionResponse };
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
deserializeSolanaTransaction: () => deserializeSolanaTransaction,
|
|
33
34
|
parseSignMessageResponse: () => parseSignMessageResponse,
|
|
34
35
|
parseSolanaKitTransactionToSolanaWeb3js: () => parseSolanaKitTransactionToSolanaWeb3js,
|
|
35
36
|
parseSolanaSignedTransaction: () => parseSolanaSignedTransaction,
|
|
@@ -147,20 +148,23 @@ function parseBitcoinSignatureResponse(base64Response) {
|
|
|
147
148
|
function parseSolanaSignedTransaction(base64RawTransaction) {
|
|
148
149
|
try {
|
|
149
150
|
const transactionBytes = (0, import_base64url.base64urlDecode)(base64RawTransaction);
|
|
150
|
-
|
|
151
|
-
const transaction = import_web3.Transaction.from(transactionBytes);
|
|
152
|
-
return transaction;
|
|
153
|
-
} catch (legacyError) {
|
|
154
|
-
if (legacyError instanceof Error && legacyError.message.includes("Versioned messages")) {
|
|
155
|
-
const versionedTransaction = import_web3.VersionedTransaction.deserialize(transactionBytes);
|
|
156
|
-
return versionedTransaction;
|
|
157
|
-
}
|
|
158
|
-
throw legacyError;
|
|
159
|
-
}
|
|
151
|
+
return deserializeSolanaTransaction(transactionBytes);
|
|
160
152
|
} catch (error) {
|
|
161
153
|
return null;
|
|
162
154
|
}
|
|
163
155
|
}
|
|
156
|
+
function deserializeSolanaTransaction(transactionBytes) {
|
|
157
|
+
try {
|
|
158
|
+
const transaction = import_web3.Transaction.from(transactionBytes);
|
|
159
|
+
return transaction;
|
|
160
|
+
} catch (legacyError) {
|
|
161
|
+
if (legacyError instanceof Error && legacyError.message.includes("Versioned messages")) {
|
|
162
|
+
const versionedTransaction = import_web3.VersionedTransaction.deserialize(transactionBytes);
|
|
163
|
+
return versionedTransaction;
|
|
164
|
+
}
|
|
165
|
+
throw legacyError;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
164
168
|
|
|
165
169
|
// src/index.ts
|
|
166
170
|
async function parseToKmsTransaction(transaction, networkId) {
|
|
@@ -277,7 +281,9 @@ Please ensure the transaction object includes required fields (to, value, chainI
|
|
|
277
281
|
);
|
|
278
282
|
}
|
|
279
283
|
}
|
|
280
|
-
throw new Error(
|
|
284
|
+
throw new Error(
|
|
285
|
+
"Unsupported EVM transaction format. Expected hex string, bytes, or transaction object with 'to', 'data', or 'from' fields."
|
|
286
|
+
);
|
|
281
287
|
}
|
|
282
288
|
async function parseSuiTransactionToBase64Url(transaction) {
|
|
283
289
|
if (transaction?.serialize && typeof transaction.serialize === "function") {
|
|
@@ -339,6 +345,7 @@ function parseSolanaKitTransactionToSolanaWeb3js(transaction) {
|
|
|
339
345
|
}
|
|
340
346
|
// Annotate the CommonJS export names for ESM import in node:
|
|
341
347
|
0 && (module.exports = {
|
|
348
|
+
deserializeSolanaTransaction,
|
|
342
349
|
parseSignMessageResponse,
|
|
343
350
|
parseSolanaKitTransactionToSolanaWeb3js,
|
|
344
351
|
parseSolanaSignedTransaction,
|
package/dist/index.mjs
CHANGED
|
@@ -109,20 +109,23 @@ function parseBitcoinSignatureResponse(base64Response) {
|
|
|
109
109
|
function parseSolanaSignedTransaction(base64RawTransaction) {
|
|
110
110
|
try {
|
|
111
111
|
const transactionBytes = base64urlDecode(base64RawTransaction);
|
|
112
|
-
|
|
113
|
-
const transaction = Transaction.from(transactionBytes);
|
|
114
|
-
return transaction;
|
|
115
|
-
} catch (legacyError) {
|
|
116
|
-
if (legacyError instanceof Error && legacyError.message.includes("Versioned messages")) {
|
|
117
|
-
const versionedTransaction = VersionedTransaction.deserialize(transactionBytes);
|
|
118
|
-
return versionedTransaction;
|
|
119
|
-
}
|
|
120
|
-
throw legacyError;
|
|
121
|
-
}
|
|
112
|
+
return deserializeSolanaTransaction(transactionBytes);
|
|
122
113
|
} catch (error) {
|
|
123
114
|
return null;
|
|
124
115
|
}
|
|
125
116
|
}
|
|
117
|
+
function deserializeSolanaTransaction(transactionBytes) {
|
|
118
|
+
try {
|
|
119
|
+
const transaction = Transaction.from(transactionBytes);
|
|
120
|
+
return transaction;
|
|
121
|
+
} catch (legacyError) {
|
|
122
|
+
if (legacyError instanceof Error && legacyError.message.includes("Versioned messages")) {
|
|
123
|
+
const versionedTransaction = VersionedTransaction.deserialize(transactionBytes);
|
|
124
|
+
return versionedTransaction;
|
|
125
|
+
}
|
|
126
|
+
throw legacyError;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
126
129
|
|
|
127
130
|
// src/index.ts
|
|
128
131
|
async function parseToKmsTransaction(transaction, networkId) {
|
|
@@ -239,7 +242,9 @@ Please ensure the transaction object includes required fields (to, value, chainI
|
|
|
239
242
|
);
|
|
240
243
|
}
|
|
241
244
|
}
|
|
242
|
-
throw new Error(
|
|
245
|
+
throw new Error(
|
|
246
|
+
"Unsupported EVM transaction format. Expected hex string, bytes, or transaction object with 'to', 'data', or 'from' fields."
|
|
247
|
+
);
|
|
243
248
|
}
|
|
244
249
|
async function parseSuiTransactionToBase64Url(transaction) {
|
|
245
250
|
if (transaction?.serialize && typeof transaction.serialize === "function") {
|
|
@@ -300,6 +305,7 @@ function parseSolanaKitTransactionToSolanaWeb3js(transaction) {
|
|
|
300
305
|
return fakeVersioned;
|
|
301
306
|
}
|
|
302
307
|
export {
|
|
308
|
+
deserializeSolanaTransaction,
|
|
303
309
|
parseSignMessageResponse,
|
|
304
310
|
parseSolanaKitTransactionToSolanaWeb3js,
|
|
305
311
|
parseSolanaSignedTransaction,
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/parsers",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Transaction and message parsers for Phantom Wallet SDK",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/phantom/phantom-connect-sdk",
|
|
8
|
+
"directory": "packages/parsers"
|
|
9
|
+
},
|
|
5
10
|
"main": "dist/index.js",
|
|
6
11
|
"module": "dist/index.mjs",
|
|
7
12
|
"types": "dist/index.d.ts",
|
|
@@ -29,10 +34,10 @@
|
|
|
29
34
|
"prettier": "prettier --write \"src/**/*.{ts}\""
|
|
30
35
|
},
|
|
31
36
|
"dependencies": {
|
|
32
|
-
"@phantom/base64url": "^1.0.
|
|
33
|
-
"@phantom/constants": "^1.0.
|
|
34
|
-
"@phantom/sdk-types": "^1.0.
|
|
35
|
-
"@phantom/utils": "^1.0.
|
|
37
|
+
"@phantom/base64url": "^1.0.2",
|
|
38
|
+
"@phantom/constants": "^1.0.2",
|
|
39
|
+
"@phantom/sdk-types": "^1.0.2",
|
|
40
|
+
"@phantom/utils": "^1.0.2",
|
|
36
41
|
"@solana/transactions": "^2.0.0",
|
|
37
42
|
"@solana/web3.js": "^1.95.0",
|
|
38
43
|
"bs58": "^6.0.0",
|