@@ -5670,7 +5670,7 @@ describe('V2 Wallet:', function () {
5670
5670
solInstructions : [ ] ,
5671
5671
recipients : testRecipients ,
5672
5672
} )
5673
- . should . be . rejectedWith ( `'solInstructions' is a required parameter for customTx intent` ) ;
5673
+ . should . be . rejectedWith ( `'solInstructions' or 'versionedTransactionData' is required for customTx intent` ) ;
5674
5674
} ) ;
5675
5675
5676
5676
it ( 'should support solInstruction for cold wallets' , async function ( ) {
@@ -5708,6 +5708,203 @@ describe('V2 Wallet:', function () {
5708
5708
} ) ;
5709
5709
} ) ;
5710
5710
} ) ;
5711
+
5712
+ describe ( 'prebuildTransaction with versionedTransactionData type' , function ( ) {
5713
+ const testVersionedTransactionData = {
5714
+ versionedInstructions : [
5715
+ {
5716
+ programIdIndex : 10 ,
5717
+ accountKeyIndexes : [ 0 , 1 , 2 ] ,
5718
+ data : '0102030405' ,
5719
+ } ,
5720
+ {
5721
+ programIdIndex : 11 ,
5722
+ accountKeyIndexes : [ 0 , 3 , 4 , 5 ] ,
5723
+ data : '060708090a' ,
5724
+ } ,
5725
+ ] ,
5726
+ addressLookupTables : [
5727
+ {
5728
+ accountKey : '2sk6bVhjN53hz7sqE72eqHvhPfSc1snZzsJR6yA5hF7j' ,
5729
+ writableIndexes : [ 0 , 1 ] ,
5730
+ readonlyIndexes : [ 2 , 3 ] ,
5731
+ } ,
5732
+ ] ,
5733
+ staticAccountKeys : [
5734
+ '5hr5fisPi6DXNuuRpm5XUbzpiEnmdyxXuBDTwzwZj5Pe' ,
5735
+ '2sk6bVhjN53hz7sqE72eqHvhPfSc1snZzsJR6yA5hF7j' ,
5736
+ '11111111111111111111111111111111' ,
5737
+ ] ,
5738
+ messageHeader : {
5739
+ numRequiredSignatures : 1 ,
5740
+ numReadonlySignedAccounts : 0 ,
5741
+ numReadonlyUnsignedAccounts : 1 ,
5742
+ } ,
5743
+ } ;
5744
+
5745
+ it ( 'should call prebuildTxWithIntent with correct parameters for versioned transaction' , async function ( ) {
5746
+ const prebuildTxWithIntent = sandbox . stub ( TssUtils . prototype , 'prebuildTxWithIntent' ) ;
5747
+ prebuildTxWithIntent . resolves ( txRequest ) ;
5748
+ prebuildTxWithIntent . calledOnceWithExactly ( {
5749
+ reqId,
5750
+ intentType : 'customTx' ,
5751
+ versionedTransactionData : testVersionedTransactionData ,
5752
+ recipients : testRecipients ,
5753
+ } ) ;
5754
+
5755
+ const txPrebuild = await tssSolWallet . prebuildTransaction ( {
5756
+ reqId,
5757
+ type : 'customTx' ,
5758
+ versionedTransactionData : testVersionedTransactionData ,
5759
+ recipients : testRecipients ,
5760
+ } ) ;
5761
+
5762
+ txPrebuild . should . deepEqual ( {
5763
+ walletId : tssSolWallet . id ( ) ,
5764
+ wallet : tssSolWallet ,
5765
+ txRequestId : 'id' ,
5766
+ txHex : 'ababcdcd' ,
5767
+ buildParams : {
5768
+ type : 'customTx' ,
5769
+ versionedTransactionData : testVersionedTransactionData ,
5770
+ recipients : testRecipients ,
5771
+ } ,
5772
+ feeInfo : {
5773
+ fee : 5000 ,
5774
+ feeString : '5000' ,
5775
+ } ,
5776
+ } ) ;
5777
+ } ) ;
5778
+
5779
+ it ( 'should handle versionedTransactionData with empty recipients' , async function ( ) {
5780
+ const prebuildTxWithIntent = sandbox . stub ( TssUtils . prototype , 'prebuildTxWithIntent' ) ;
5781
+ prebuildTxWithIntent . resolves ( txRequest ) ;
5782
+ prebuildTxWithIntent . calledOnceWithExactly ( {
5783
+ reqId,
5784
+ intentType : 'customTx' ,
5785
+ versionedTransactionData : testVersionedTransactionData ,
5786
+ recipients : [ ] ,
5787
+ } ) ;
5788
+
5789
+ const txPrebuild = await tssSolWallet . prebuildTransaction ( {
5790
+ reqId,
5791
+ type : 'customTx' ,
5792
+ versionedTransactionData : testVersionedTransactionData ,
5793
+ } ) ;
5794
+
5795
+ txPrebuild . should . deepEqual ( {
5796
+ walletId : tssSolWallet . id ( ) ,
5797
+ wallet : tssSolWallet ,
5798
+ txRequestId : 'id' ,
5799
+ txHex : 'ababcdcd' ,
5800
+ buildParams : {
5801
+ type : 'customTx' ,
5802
+ versionedTransactionData : testVersionedTransactionData ,
5803
+ } ,
5804
+ feeInfo : {
5805
+ fee : 5000 ,
5806
+ feeString : '5000' ,
5807
+ } ,
5808
+ } ) ;
5809
+ } ) ;
5810
+
5811
+ it ( 'should handle versionedTransactionData with memo parameter' , async function ( ) {
5812
+ const prebuildTxWithIntent = sandbox . stub ( TssUtils . prototype , 'prebuildTxWithIntent' ) ;
5813
+ prebuildTxWithIntent . resolves ( txRequest ) ;
5814
+ prebuildTxWithIntent . calledOnceWithExactly ( {
5815
+ reqId,
5816
+ intentType : 'customTx' ,
5817
+ versionedTransactionData : testVersionedTransactionData ,
5818
+ recipients : testRecipients ,
5819
+ memo : {
5820
+ type : 'type' ,
5821
+ value : 'test memo' ,
5822
+ } ,
5823
+ } ) ;
5824
+
5825
+ const txPrebuild = await tssSolWallet . prebuildTransaction ( {
5826
+ reqId,
5827
+ type : 'customTx' ,
5828
+ versionedTransactionData : testVersionedTransactionData ,
5829
+ recipients : testRecipients ,
5830
+ memo : {
5831
+ type : 'type' ,
5832
+ value : 'test memo' ,
5833
+ } ,
5834
+ } ) ;
5835
+
5836
+ txPrebuild . should . deepEqual ( {
5837
+ walletId : tssSolWallet . id ( ) ,
5838
+ wallet : tssSolWallet ,
5839
+ txRequestId : 'id' ,
5840
+ txHex : 'ababcdcd' ,
5841
+ buildParams : {
5842
+ type : 'customTx' ,
5843
+ versionedTransactionData : testVersionedTransactionData ,
5844
+ recipients : testRecipients ,
5845
+ memo : {
5846
+ type : 'type' ,
5847
+ value : 'test memo' ,
5848
+ } ,
5849
+ } ,
5850
+ feeInfo : {
5851
+ fee : 5000 ,
5852
+ feeString : '5000' ,
5853
+ } ,
5854
+ } ) ;
5855
+ } ) ;
5856
+
5857
+ it ( 'should handle versionedTransactionData with pending approval ID' , async function ( ) {
5858
+ const prebuildTxWithIntent = sandbox . stub ( TssUtils . prototype , 'prebuildTxWithIntent' ) ;
5859
+ prebuildTxWithIntent . resolves ( { ...txRequest , state : 'pendingApproval' , pendingApprovalId : 'some-id' } ) ;
5860
+ prebuildTxWithIntent . calledOnceWithExactly ( {
5861
+ reqId,
5862
+ intentType : 'customTx' ,
5863
+ versionedTransactionData : testVersionedTransactionData ,
5864
+ recipients : testRecipients ,
5865
+ } ) ;
5866
+
5867
+ const txPrebuild = await custodialTssSolWallet . prebuildTransaction ( {
5868
+ reqId,
5869
+ type : 'customTx' ,
5870
+ versionedTransactionData : testVersionedTransactionData ,
5871
+ recipients : testRecipients ,
5872
+ } ) ;
5873
+
5874
+ txPrebuild . should . deepEqual ( {
5875
+ walletId : custodialTssSolWallet . id ( ) ,
5876
+ wallet : custodialTssSolWallet ,
5877
+ txRequestId : 'id' ,
5878
+ txHex : 'ababcdcd' ,
5879
+ pendingApprovalId : 'some-id' ,
5880
+ buildParams : {
5881
+ type : 'customTx' ,
5882
+ versionedTransactionData : testVersionedTransactionData ,
5883
+ recipients : testRecipients ,
5884
+ } ,
5885
+ feeInfo : {
5886
+ fee : 5000 ,
5887
+ feeString : '5000' ,
5888
+ } ,
5889
+ } ) ;
5890
+ } ) ;
5891
+
5892
+ it ( 'should throw error for empty versionedInstructions array' , async function ( ) {
5893
+ await tssSolWallet
5894
+ . prebuildTransaction ( {
5895
+ reqId,
5896
+ type : 'customTx' ,
5897
+ versionedTransactionData : {
5898
+ versionedInstructions : [ ] ,
5899
+ addressLookupTables : [ ] ,
5900
+ staticAccountKeys : [ 'test' ] ,
5901
+ messageHeader : { numRequiredSignatures : 1 , numReadonlySignedAccounts : 0 , numReadonlyUnsignedAccounts : 0 } ,
5902
+ } ,
5903
+ recipients : testRecipients ,
5904
+ } )
5905
+ . should . be . rejectedWith ( `'solInstructions' or 'versionedTransactionData' is required for customTx intent` ) ;
5906
+ } ) ;
5907
+ } ) ;
5711
5908
} ) ;
5712
5909
5713
5910
describe ( 'Aptos Custom transaction Flow' , function ( ) {
0 commit comments