@@ -925,6 +925,106 @@ describe('SmartTransactionsController', () => {
925
925
] ) ;
926
926
} ) ;
927
927
928
+ it ( 'confirms a smart transaction that was not found in the list of regular transactions' , async ( ) => {
929
+ const { smartTransactionsState } = smartTransactionsController . state ;
930
+ const pendingStx = {
931
+ ...createStateAfterPending ( ) [ 0 ] ,
932
+ history : testHistory ,
933
+ } ;
934
+
935
+ jest
936
+ . spyOn ( smartTransactionsController , 'getRegularTransactions' )
937
+ . mockImplementation ( ( ) => {
938
+ return [ ] ;
939
+ } ) ;
940
+ smartTransactionsController . update ( {
941
+ smartTransactionsState : {
942
+ ...smartTransactionsState ,
943
+ smartTransactions : {
944
+ [ CHAIN_IDS . ETHEREUM ] : [ pendingStx ] as SmartTransaction [ ] ,
945
+ } ,
946
+ } ,
947
+ } ) ;
948
+ const updateTransaction = {
949
+ ...pendingStx ,
950
+ statusMetadata : {
951
+ ...pendingStx . statusMetadata ,
952
+ minedHash : txHash ,
953
+ } ,
954
+ status : SmartTransactionStatuses . SUCCESS ,
955
+ } ;
956
+
957
+ smartTransactionsController . updateSmartTransaction (
958
+ updateTransaction as SmartTransaction ,
959
+ {
960
+ networkClientId : 'mainnet' ,
961
+ } ,
962
+ ) ;
963
+ await flushPromises ( ) ;
964
+ expect (
965
+ smartTransactionsController . confirmExternalTransaction ,
966
+ ) . toHaveBeenCalledTimes ( 1 ) ;
967
+ expect (
968
+ smartTransactionsController . state . smartTransactionsState
969
+ . smartTransactions [ CHAIN_IDS . ETHEREUM ] ,
970
+ ) . toStrictEqual ( [
971
+ {
972
+ ...updateTransaction ,
973
+ confirmed : true ,
974
+ } ,
975
+ ] ) ;
976
+ } ) ;
977
+
978
+ it ( 'confirms a smart transaction that does not have a minedHash' , async ( ) => {
979
+ const { smartTransactionsState } = smartTransactionsController . state ;
980
+ const pendingStx = {
981
+ ...createStateAfterPending ( ) [ 0 ] ,
982
+ history : testHistory ,
983
+ } ;
984
+
985
+ jest
986
+ . spyOn ( smartTransactionsController , 'getRegularTransactions' )
987
+ . mockImplementation ( ( ) => {
988
+ return [ createTransactionMeta ( TransactionStatus . confirmed ) ] ;
989
+ } ) ;
990
+ smartTransactionsController . update ( {
991
+ smartTransactionsState : {
992
+ ...smartTransactionsState ,
993
+ smartTransactions : {
994
+ [ CHAIN_IDS . ETHEREUM ] : [ pendingStx ] as SmartTransaction [ ] ,
995
+ } ,
996
+ } ,
997
+ } ) ;
998
+ const updateTransaction = {
999
+ ...pendingStx ,
1000
+ statusMetadata : {
1001
+ ...pendingStx . statusMetadata ,
1002
+ minedHash : '' ,
1003
+ } ,
1004
+ status : SmartTransactionStatuses . SUCCESS ,
1005
+ } ;
1006
+
1007
+ smartTransactionsController . updateSmartTransaction (
1008
+ updateTransaction as SmartTransaction ,
1009
+ {
1010
+ networkClientId : 'mainnet' ,
1011
+ } ,
1012
+ ) ;
1013
+ await flushPromises ( ) ;
1014
+ expect (
1015
+ smartTransactionsController . confirmExternalTransaction ,
1016
+ ) . toHaveBeenCalledTimes ( 1 ) ;
1017
+ expect (
1018
+ smartTransactionsController . state . smartTransactionsState
1019
+ . smartTransactions [ CHAIN_IDS . ETHEREUM ] ,
1020
+ ) . toStrictEqual ( [
1021
+ {
1022
+ ...updateTransaction ,
1023
+ confirmed : true ,
1024
+ } ,
1025
+ ] ) ;
1026
+ } ) ;
1027
+
928
1028
it ( 'does not call the "confirmExternalTransaction" fn if a tx is already confirmed' , async ( ) => {
929
1029
const { smartTransactionsState } = smartTransactionsController . state ;
930
1030
const pendingStx = {
0 commit comments