1- import type { KeyringPair } from "@polkadot/keyring/types"
2- import type { TxResult as TxResultXcm } from "@substrate/asset-transfer-api"
31import type { PolkadotSigner , TxEvent } from "polkadot-api"
42
53import type { Tx , TxResult } from "../types"
64import type { SubmitAndWatchOptions } from "../types/transaction"
7- import { hasTypeProperty , isTxWithPolkadotSigner , isTxXcmWithKeypair } from "../types/transaction"
5+ import { hasTypeProperty , isTxWithPolkadotSigner } from "../types/transaction"
86
97async function submitAndWatchTx ( options : SubmitAndWatchOptions ) : Promise < TxResult > {
108 return new Promise ( ( resolve , reject ) => {
@@ -51,30 +49,6 @@ async function submitAndWatchTx(options: SubmitAndWatchOptions): Promise<TxResul
5149 } )
5250 }
5351 }
54- // Handle Tx with KeyringPair using signAndSend
55- if ( isTxXcmWithKeypair ( options ) ) {
56- try {
57- options . transaction . tx
58- . signAndSend ( options . signer )
59- . then ( result => {
60- resolve ( {
61- success : true ,
62- transactionHash : result . toString ( )
63- } )
64- } )
65- . catch ( ( error : Error ) => {
66- resolve ( {
67- success : false ,
68- error : `Transaction failed: ${ error . message } `
69- } )
70- } )
71- } catch ( error ) {
72- resolve ( {
73- success : false ,
74- error : `Transaction failed: ${ error instanceof Error ? error . message : String ( error ) } `
75- } )
76- }
77- }
7852 } catch ( error ) {
7953 reject ( error instanceof Error ? error : new Error ( String ( error ) ) )
8054 }
@@ -90,13 +64,3 @@ export async function submitTxWithPolkadotSigner(
9064) : Promise < TxResult > {
9165 return submitAndWatchTx ( { transaction, signer } )
9266}
93-
94- /**
95- * Function to submit a transaction with a KeyringPair
96- */
97- export async function submitXcmTxWithKeypair (
98- transaction : TxResultXcm < "submittable" > ,
99- signer : KeyringPair
100- ) : Promise < TxResult > {
101- return submitAndWatchTx ( { transaction, signer } )
102- }
0 commit comments