1
1
import { SorobanContextType } from '@soroban-react/core'
2
2
3
3
import { Sign } from 'crypto'
4
- import * as SorobanClient from 'soroban-client'
5
- import { SorobanRpc } from 'soroban-client'
4
+ import * as StellarSdk from 'stellar-sdk'
5
+
6
+ import { SorobanRpc } from 'stellar-sdk'
6
7
7
8
import type { Tx , Transaction , TxResponse } from './types'
8
9
@@ -29,7 +30,7 @@ export async function signAndSendTransaction({
29
30
30
31
// preflight and add the footprint !
31
32
if ( ! skipAddingFootprint ) {
32
- txn = await server . prepareTransaction ( txn , networkPassphrase )
33
+ txn = await server . prepareTransaction ( txn )
33
34
if ( ! txn ) {
34
35
throw new Error ( 'No transaction after adding footprint' )
35
36
}
@@ -42,8 +43,8 @@ export async function signAndSendTransaction({
42
43
// if (auth_len > 1) {
43
44
// throw new NotImplementedError("Multiple auths not yet supported");
44
45
// } else if (auth_len == 1) {
45
- // // TODO: figure out how to fix with new SorobanClient
46
- // // const auth = SorobanClient .xdr.SorobanAuthorizationEntry.fromXDR(auths![0]!, 'base64')
46
+ // // TODO: figure out how to fix with new StellarSdk
47
+ // // const auth = StellarSdk .xdr.SorobanAuthorizationEntry.fromXDR(auths![0]!, 'base64')
47
48
// // if (auth.addressWithNonce() !== undefined) {
48
49
// // throw new NotImplementedError(
49
50
// // `This transaction needs to be signed by ${auth.addressWithNonce()
@@ -55,21 +56,19 @@ export async function signAndSendTransaction({
55
56
let signed = ''
56
57
if ( secretKey ) {
57
58
// User as set a secretKey, txn will be signed using the secretKey
58
- const keypair = SorobanClient . Keypair . fromSecret ( secretKey )
59
+ const keypair = StellarSdk . Keypair . fromSecret ( secretKey )
59
60
txn . sign ( keypair )
60
61
signed = txn . toXDR ( )
61
62
} else if ( sorobanContext . activeConnector ) {
62
63
// User has not set a secretKey, txn will be signed using the Connector (wallet) provided in the sorobanContext
63
- signed = await sorobanContext . activeConnector . signTransaction ( txn . toXDR ( ) , {
64
- networkPassphrase,
65
- } )
64
+ signed = await sorobanContext . activeConnector . signTransaction ( txn . toXDR ( ) )
66
65
} else {
67
66
throw new Error (
68
67
'signAndSendTransaction: no secretKey, neither active Connector'
69
68
)
70
69
}
71
70
72
- const transactionToSubmit = SorobanClient . TransactionBuilder . fromXDR (
71
+ const transactionToSubmit = StellarSdk . TransactionBuilder . fromXDR (
73
72
signed ,
74
73
networkPassphrase
75
74
)
@@ -89,7 +88,7 @@ export async function sendTx({
89
88
} : {
90
89
tx : Tx
91
90
secondsToWait : number
92
- server : SorobanClient . Server
91
+ server : StellarSdk . SorobanRpc . Server
93
92
} ) : Promise < TxResponse > {
94
93
const sendTransactionResponse = await server . sendTransaction ( tx )
95
94
let getTransactionResponse = await server . getTransaction (
@@ -116,7 +115,7 @@ export async function sendTx({
116
115
}
117
116
118
117
if (
119
- getTransactionResponse . status === SorobanRpc . GetTransactionStatus . NOT_FOUND
118
+ getTransactionResponse . status === SorobanRpc . Api . GetTransactionStatus . NOT_FOUND
120
119
) {
121
120
console . error (
122
121
`Waited ${ secondsToWait } seconds for transaction to complete, but it did not. ` +
0 commit comments