@phantom/parsers 1.0.0-beta.3 → 1.0.0-beta.5
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 +7 -7
- package/dist/index.js +6 -24
- package/dist/index.mjs +5 -23
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NetworkId } from '@phantom/constants';
|
|
2
|
-
import { Transaction } from '@solana/transactions';
|
|
2
|
+
import { Transaction as Transaction$1 } from '@solana/transactions';
|
|
3
|
+
import { Transaction } from '@solana/web3.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Chain-specific transaction and message response parsing
|
|
@@ -25,11 +26,10 @@ declare function parseSignMessageResponse(base64Response: string, networkId: Net
|
|
|
25
26
|
*/
|
|
26
27
|
declare function parseTransactionResponse(base64RawTransaction: string, networkId: NetworkId, hash?: string): ParsedTransactionResult;
|
|
27
28
|
/**
|
|
28
|
-
* Parse Solana transaction
|
|
29
|
-
* This function extracts the signature from a base64url encoded signed transaction
|
|
29
|
+
* Parse Solana signed transaction from base64url encoded transaction bytes
|
|
30
30
|
*/
|
|
31
|
-
declare function
|
|
32
|
-
|
|
31
|
+
declare function parseSolanaSignedTransaction(base64RawTransaction: string): {
|
|
32
|
+
transaction: Transaction | null;
|
|
33
33
|
fallback: boolean;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -49,6 +49,6 @@ declare function parseMessage(message: string): ParsedMessage;
|
|
|
49
49
|
* Parse a transaction to base64url format based on network type
|
|
50
50
|
*/
|
|
51
51
|
declare function parseTransactionToBase64Url(transaction: any, networkId: NetworkId): Promise<ParsedTransaction>;
|
|
52
|
-
declare function parseSolanaKitTransactionToSolanaWeb3js(transaction: Transaction): any;
|
|
52
|
+
declare function parseSolanaKitTransactionToSolanaWeb3js(transaction: Transaction$1): any;
|
|
53
53
|
|
|
54
|
-
export { ParsedMessage, ParsedSignatureResult, ParsedTransaction, ParsedTransactionResult, parseMessage, parseSignMessageResponse, parseSolanaKitTransactionToSolanaWeb3js,
|
|
54
|
+
export { ParsedMessage, ParsedSignatureResult, ParsedTransaction, ParsedTransactionResult, parseMessage, parseSignMessageResponse, parseSolanaKitTransactionToSolanaWeb3js, parseSolanaSignedTransaction, parseTransactionResponse, parseTransactionToBase64Url };
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
parseMessage: () => parseMessage,
|
|
34
34
|
parseSignMessageResponse: () => parseSignMessageResponse,
|
|
35
35
|
parseSolanaKitTransactionToSolanaWeb3js: () => parseSolanaKitTransactionToSolanaWeb3js,
|
|
36
|
-
|
|
36
|
+
parseSolanaSignedTransaction: () => parseSolanaSignedTransaction,
|
|
37
37
|
parseTransactionResponse: () => parseTransactionResponse,
|
|
38
38
|
parseTransactionToBase64Url: () => parseTransactionToBase64Url
|
|
39
39
|
});
|
|
@@ -143,35 +143,17 @@ function parseBitcoinSignatureResponse(base64Response) {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function parseSolanaSignedTransaction(base64RawTransaction) {
|
|
147
147
|
try {
|
|
148
148
|
const transactionBytes = import_buffer.Buffer.from(base64RawTransaction, "base64url");
|
|
149
149
|
const transaction = import_web3.Transaction.from(transactionBytes);
|
|
150
|
-
let signature = null;
|
|
151
|
-
if (transaction.signature) {
|
|
152
|
-
signature = import_bs58.default.encode(transaction.signature);
|
|
153
|
-
} else if (transaction.signatures && transaction.signatures.length > 0 && transaction.signatures[0].signature) {
|
|
154
|
-
signature = import_bs58.default.encode(transaction.signatures[0].signature);
|
|
155
|
-
}
|
|
156
|
-
if (signature) {
|
|
157
|
-
return {
|
|
158
|
-
signature,
|
|
159
|
-
fallback: false
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
} catch (error) {
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
const transactionBytes = import_buffer.Buffer.from(base64RawTransaction, "base64url");
|
|
166
|
-
const signatureBytes = transactionBytes.slice(0, 64);
|
|
167
|
-
const signature = import_bs58.default.encode(signatureBytes);
|
|
168
150
|
return {
|
|
169
|
-
|
|
170
|
-
fallback:
|
|
151
|
+
transaction,
|
|
152
|
+
fallback: false
|
|
171
153
|
};
|
|
172
154
|
} catch (error) {
|
|
173
155
|
return {
|
|
174
|
-
|
|
156
|
+
transaction: null,
|
|
175
157
|
fallback: true
|
|
176
158
|
};
|
|
177
159
|
}
|
|
@@ -335,7 +317,7 @@ function parseSolanaKitTransactionToSolanaWeb3js(transaction) {
|
|
|
335
317
|
parseMessage,
|
|
336
318
|
parseSignMessageResponse,
|
|
337
319
|
parseSolanaKitTransactionToSolanaWeb3js,
|
|
338
|
-
|
|
320
|
+
parseSolanaSignedTransaction,
|
|
339
321
|
parseTransactionResponse,
|
|
340
322
|
parseTransactionToBase64Url
|
|
341
323
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -104,35 +104,17 @@ function parseBitcoinSignatureResponse(base64Response) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function parseSolanaSignedTransaction(base64RawTransaction) {
|
|
108
108
|
try {
|
|
109
109
|
const transactionBytes = Buffer.from(base64RawTransaction, "base64url");
|
|
110
110
|
const transaction = Transaction.from(transactionBytes);
|
|
111
|
-
let signature = null;
|
|
112
|
-
if (transaction.signature) {
|
|
113
|
-
signature = bs58.encode(transaction.signature);
|
|
114
|
-
} else if (transaction.signatures && transaction.signatures.length > 0 && transaction.signatures[0].signature) {
|
|
115
|
-
signature = bs58.encode(transaction.signatures[0].signature);
|
|
116
|
-
}
|
|
117
|
-
if (signature) {
|
|
118
|
-
return {
|
|
119
|
-
signature,
|
|
120
|
-
fallback: false
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
} catch (error) {
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
const transactionBytes = Buffer.from(base64RawTransaction, "base64url");
|
|
127
|
-
const signatureBytes = transactionBytes.slice(0, 64);
|
|
128
|
-
const signature = bs58.encode(signatureBytes);
|
|
129
111
|
return {
|
|
130
|
-
|
|
131
|
-
fallback:
|
|
112
|
+
transaction,
|
|
113
|
+
fallback: false
|
|
132
114
|
};
|
|
133
115
|
} catch (error) {
|
|
134
116
|
return {
|
|
135
|
-
|
|
117
|
+
transaction: null,
|
|
136
118
|
fallback: true
|
|
137
119
|
};
|
|
138
120
|
}
|
|
@@ -295,7 +277,7 @@ export {
|
|
|
295
277
|
parseMessage,
|
|
296
278
|
parseSignMessageResponse,
|
|
297
279
|
parseSolanaKitTransactionToSolanaWeb3js,
|
|
298
|
-
|
|
280
|
+
parseSolanaSignedTransaction,
|
|
299
281
|
parseTransactionResponse,
|
|
300
282
|
parseTransactionToBase64Url
|
|
301
283
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phantom/parsers",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "Transaction and message parsers for Phantom Wallet SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
"prettier": "prettier --write \"src/**/*.{ts}\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@phantom/base64url": "^1.0.0-beta.
|
|
33
|
-
"@phantom/constants": "^1.0.0-beta.
|
|
32
|
+
"@phantom/base64url": "^1.0.0-beta.5",
|
|
33
|
+
"@phantom/constants": "^1.0.0-beta.5",
|
|
34
|
+
"@phantom/sdk-types": "^1.0.0-beta.5",
|
|
34
35
|
"@solana/transactions": "^2.0.0",
|
|
35
36
|
"@solana/web3.js": "^1.95.0",
|
|
36
37
|
"bs58": "^6.0.0",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@solana/kit": "^2.1.1",
|
|
48
|
+
"@solana/web3.js": "^1.95.0",
|
|
47
49
|
"@types/jest": "^29.5.12",
|
|
48
50
|
"@types/node": "^20.11.0",
|
|
49
51
|
"dotenv": "^16.4.5",
|