11import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
2+ import bs58 from "bs58" ;
23import { SolanaWallet } from "./solana" ;
34import type { CreateTransactionSuccessResponse } from "../api" ;
45import { TransactionNotCreatedError } from "../utils/errors" ;
@@ -31,7 +32,7 @@ describe("SolanaWallet - sendTransaction()", () => {
3132 } ) ;
3233
3334 describe ( "success cases" , ( ) => {
34- it ( "sends transaction with serialized transaction string" , async ( ) => {
35+ it ( "sends transaction with a base58 serialized transaction string" , async ( ) => {
3536 const serializedTx = createMockSolanaSerializedTransaction ( ) ;
3637
3738 const mockTransactionResponse = {
@@ -75,9 +76,9 @@ describe("SolanaWallet - sendTransaction()", () => {
7576 ) ;
7677 } ) ;
7778
78- it ( "sends transaction with serialized transaction string " , async ( ) => {
79- const serializedTx =
80- "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgEDBQrKxEIIPWsDwcGCzLQ7FGIHQ38p0dZq6bG2v2wUAUqMx3jV1jZ0" ;
79+ it ( "converts a base64 serialized transaction to base58 " , async ( ) => {
80+ const base58SerializedTx = createMockSolanaSerializedTransaction ( ) ;
81+ const serializedTx = Buffer . from ( bs58 . decode ( base58SerializedTx ) ) . toString ( "base64" ) ;
8182
8283 const mockTransactionResponse = {
8384 id : "txn-sol-456" ,
@@ -90,7 +91,7 @@ describe("SolanaWallet - sendTransaction()", () => {
9091 "https://explorer.solana.com/tx/5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW" ,
9192 } ,
9293 params : {
93- transaction : serializedTx ,
94+ transaction : base58SerializedTx ,
9495 signer : "api-key:test" ,
9596 } ,
9697 createdAt : Date . now ( ) ,
@@ -113,7 +114,7 @@ describe("SolanaWallet - sendTransaction()", () => {
113114 "me:solana:smart" ,
114115 expect . objectContaining ( {
115116 params : expect . objectContaining ( {
116- transaction : serializedTx ,
117+ transaction : base58SerializedTx ,
117118 signer : "api-key" ,
118119 } ) ,
119120 } )
0 commit comments