1
1
import { Extension } from '@magic-sdk/commons' ;
2
2
3
3
/* eslint-disable no-param-reassign, array-callback-return */
4
+ import { Transaction , VersionedTransaction } from '@solana/web3.js' ;
4
5
import { SolanaConfig , SolanaPayloadMethod , SerializeConfig } from './type' ;
5
6
6
7
export class SolanaExtension extends Extension . Internal < 'solana' , any > {
@@ -16,31 +17,18 @@ export class SolanaExtension extends Extension.Internal<'solana', any> {
16
17
} ;
17
18
}
18
19
19
- public signTransaction = ( transaction : any , serializeConfig ?: SerializeConfig ) => {
20
- const { instructions } = transaction ;
21
-
22
- const magicInstructions = instructions . map ( ( i : any ) => {
23
- return {
24
- ...i ,
25
- keys : i . keys . map ( ( k : any ) => {
26
- return { ...k , pubkey : k . pubkey . toBase58 ( ) } ;
27
- } ) ,
28
- programId : i . programId . toBase58 ( ) ,
29
- } ;
30
- } ) ;
31
-
32
- const params = {
33
- feePayer : transaction . feePayer . toBase58 ( ) ,
34
- instructions : magicInstructions ,
35
- recentBlockhash : transaction . recentBlockhash ,
36
- serializeConfig,
37
- } ;
38
-
20
+ public signTransaction = ( transaction : Transaction | VersionedTransaction ) => {
39
21
return this . request ( {
40
22
id : 42 ,
41
23
jsonrpc : '2.0' ,
42
24
method : SolanaPayloadMethod . SignTransaction ,
43
- params,
25
+ params : {
26
+ type : transaction instanceof Transaction ? 'legacy' : 0 ,
27
+ serialized : transaction . serialize ( {
28
+ requireAllSignatures : false ,
29
+ verifySignatures : false ,
30
+ } ) ,
31
+ } ,
44
32
} ) ;
45
33
} ;
46
34
0 commit comments