11import { Extension } from '@magic-sdk/commons' ;
22
33/* eslint-disable no-param-reassign, array-callback-return */
4+ import { Transaction , VersionedTransaction } from '@solana/web3.js' ;
45import { SolanaConfig , SolanaPayloadMethod , SerializeConfig } from './type' ;
56
67export class SolanaExtension extends Extension . Internal < 'solana' , any > {
@@ -16,31 +17,18 @@ export class SolanaExtension extends Extension.Internal<'solana', any> {
1617 } ;
1718 }
1819
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 ) => {
3921 return this . request ( {
4022 id : 42 ,
4123 jsonrpc : '2.0' ,
4224 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+ } ,
4432 } ) ;
4533 } ;
4634
0 commit comments