@@ -3,7 +3,6 @@ import { Provider, ProviderInterface } from '../provider';
33import { Signer , SignerInterface } from '../signer' ;
44import {
55 Abi ,
6- AccountInvocationItem ,
76 AccountInvocations ,
87 AccountInvocationsFactoryDetails ,
98 AllowArray ,
@@ -54,6 +53,7 @@ import {
5453 formatSignature ,
5554 randomAddress ,
5655 reduceV2 ,
56+ toETransactionVersions ,
5757 toFeeVersion ,
5858 toTransactionVersion ,
5959 v3Details ,
@@ -805,10 +805,10 @@ export class Account extends Provider implements AccountInterface {
805805 invocations : Invocations ,
806806 details : AccountInvocationsFactoryDetails
807807 ) {
808- const { versions, nonce, blockIdentifier } = details ;
809- // const version = versions[1]; // TODO: ovdje je bilo 0 prije a tribalo bi bit 1 LOL
808+ const { nonce, blockIdentifier } = details ;
810809 const safeNonce = await this . getNonceSafe ( nonce ) ;
811810 const chainId = await this . getChainId ( ) ;
811+ const versions = details . versions . map ( ( it ) => toETransactionVersions ( it ) ) ;
812812
813813 // BULK ACTION FROM NEW ACCOUNT START WITH DEPLOY_ACCOUNT
814814 const tx0Payload : any = 'payload' in invocations [ 0 ] ? invocations [ 0 ] . payload : invocations [ 0 ] ;
@@ -820,72 +820,74 @@ export class Account extends Provider implements AccountInterface {
820820 return Promise . all (
821821 ( [ ] as Invocations ) . concat ( invocations ) . map ( async ( transaction , index : number ) => {
822822 const txPayload : any = 'payload' in transaction ? transaction . payload : transaction ;
823- const signerDetails : InvocationsSignerDetails = {
823+ const signerDetails = {
824824 ...v3Details ( details ) ,
825825 walletAddress : this . address ,
826826 nonce : toBigInt ( Number ( safeNonce ) + index ) ,
827827 maxFee : ZERO ,
828- version : versions [ 1 ] ,
829828 chainId,
830829 cairoVersion,
830+ version : '' as ETransactionVersion ,
831831 } ;
832832 const common = {
833833 type : transaction . type ,
834- version : versions [ 1 ] ,
835834 nonce : toBigInt ( Number ( safeNonce ) + index ) ,
836835 blockIdentifier,
836+ version : '' as ETransactionVersion ,
837837 } ;
838838
839839 if ( transaction . type === TransactionType . INVOKE ) {
840- // todo: moze bit 1 ili 3
841- const versionX = reduceV2 ( versions [ 1 ] as ETransactionVersion ) ;
840+ // 1 or 3
841+ const versionX = reduceV2 ( versions [ 1 ] ) ;
842+ signerDetails . version = versionX ;
843+ common . version = versionX ;
844+
842845 const payload = await this . buildInvocation (
843846 ( [ ] as Call [ ] ) . concat ( txPayload ) ,
844- {
845- ...signerDetails ,
846- version : versionX ,
847- } as InvocationsSignerDetails // TODO: Fix force
847+ signerDetails
848848 ) ;
849849 return {
850- ...{ ... common , version : versionX } ,
850+ ...common ,
851851 ...payload ,
852- } as AccountInvocationItem ;
852+ } ;
853853 }
854854 if ( transaction . type === TransactionType . DEPLOY ) {
855- // todo: moze bit 1 ili 3
856- const versionX = reduceV2 ( versions [ 1 ] as ETransactionVersion ) ;
855+ // 1 or 3
856+ const versionX = reduceV2 ( versions [ 1 ] ) ;
857+ signerDetails . version = versionX ;
858+ common . version = versionX ;
859+
857860 const calls = this . buildUDCContractPayload ( txPayload ) ;
858- const payload = await this . buildInvocation ( calls , {
859- ...signerDetails ,
860- version : versionX ,
861- } as InvocationsSignerDetails ) ; // TODO: Fix force
861+ const payload = await this . buildInvocation ( calls , signerDetails ) ;
862862 return {
863- ...{ ... common , version : versionX } ,
863+ ...common ,
864864 ...payload ,
865865 type : TransactionType . INVOKE ,
866- } as AccountInvocationItem ;
866+ } ;
867867 }
868868 if ( transaction . type === TransactionType . DECLARE ) {
869- // todo: moze bit 1 ili 2,3 OK
870- signerDetails . version = ! isSierra ( txPayload . contract ) ? versions [ 0 ] : versions [ 1 ] ;
869+ // 1 (Cairo0) or 2 or 3
870+ const versionX = ! isSierra ( txPayload . contract ) ? versions [ 0 ] : versions [ 1 ] ;
871+ signerDetails . version = versionX ;
872+ common . version = versionX ;
873+
871874 const payload = await this . buildDeclarePayload ( txPayload , signerDetails ) ;
872875 return {
873876 ...common ,
874877 ...payload ,
875- version : signerDetails . version ,
876- } as AccountInvocationItem ;
878+ } ;
877879 }
878880 if ( transaction . type === TransactionType . DEPLOY_ACCOUNT ) {
879- // todo: moze bit 1 ili 3
880- const versionX = reduceV2 ( versions [ 1 ] as ETransactionVersion ) ;
881- const payload = await this . buildAccountDeployPayload ( txPayload , {
882- ... signerDetails ,
883- version : versionX ,
884- } as InvocationsSignerDetails ) ; // TODO: Fix force
881+ // 1 or 3
882+ const versionX = reduceV2 ( versions [ 1 ] ) ;
883+ signerDetails . version = versionX ;
884+ common . version = versionX ;
885+
886+ const payload = await this . buildAccountDeployPayload ( txPayload , signerDetails ) ;
885887 return {
886- ...{ ... common , version : versionX } ,
888+ ...common ,
887889 ...payload ,
888- } as AccountInvocationItem ;
890+ } ;
889891 }
890892 throw Error ( `accountInvocationsFactory: unsupported transaction type: ${ transaction } ` ) ;
891893 } )
0 commit comments