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