@@ -2987,14 +2987,14 @@ describe('PredictController', () => {
29872987 const mockTransactions = [
29882988 {
29892989 params : {
2990- to : '0xToken ' as `0x${string } `,
2991- data : '0xapprove ' as `0x${string } `,
2990+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
2991+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
29922992 } ,
29932993 } ,
29942994 {
29952995 params : {
2996- to : '0xSafe ' as `0x${string } `,
2997- data : '0xdeposit ' as `0x${string } `,
2996+ to : '0x9876543210987654321098765432109876543210 ' as `0x${string } `,
2997+ data : '0xa9059cbb000000000000000000000000 ' as `0x${string } `,
29982998 } ,
29992999 } ,
30003000 ] ;
@@ -3115,8 +3115,8 @@ describe('PredictController', () => {
31153115 transactions : [
31163116 {
31173117 params : {
3118- to : '0xToken ' as `0x${string } `,
3119- data : '0xapprove ' as `0x${string } `,
3118+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3119+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
31203120 } ,
31213121 } ,
31223122 ] ,
@@ -3148,8 +3148,8 @@ describe('PredictController', () => {
31483148 transactions : [
31493149 {
31503150 params : {
3151- to : '0xToken ' as `0x${string } `,
3152- data : '0xapprove ' as `0x${string } `,
3151+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3152+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
31533153 } ,
31543154 } ,
31553155 ] ,
@@ -3190,8 +3190,8 @@ describe('PredictController', () => {
31903190 transactions : [
31913191 {
31923192 params : {
3193- to : '0xToken ' as `0x${string } `,
3194- data : '0xapprove ' as `0x${string } `,
3193+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3194+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
31953195 } ,
31963196 } ,
31973197 ] ,
@@ -3224,8 +3224,8 @@ describe('PredictController', () => {
32243224 transactions : [
32253225 {
32263226 params : {
3227- to : '0xToken ' as `0x${string } `,
3228- data : '0xapprove ' as `0x${string } `,
3227+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3228+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
32293229 } ,
32303230 } ,
32313231 ] ,
@@ -3254,8 +3254,8 @@ describe('PredictController', () => {
32543254 transactions : [
32553255 {
32563256 params : {
3257- to : '0xToken ' as `0x${string } `,
3258- data : '0xapprove ' as `0x${string } `,
3257+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3258+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
32593259 } ,
32603260 } ,
32613261 ] ,
@@ -3328,8 +3328,8 @@ describe('PredictController', () => {
33283328 transactions : [
33293329 {
33303330 params : {
3331- to : '0xToken ' as `0x${string } `,
3332- data : '0xapprove ' as `0x${string } `,
3331+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3332+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
33333333 } ,
33343334 } ,
33353335 ] ,
@@ -3357,8 +3357,8 @@ describe('PredictController', () => {
33573357 transactions : [
33583358 {
33593359 params : {
3360- to : '0xToken ' as `0x${string } `,
3361- data : '0xapprove ' as `0x${string } `,
3360+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3361+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
33623362 } ,
33633363 } ,
33643364 ] ,
@@ -3384,8 +3384,8 @@ describe('PredictController', () => {
33843384 transactions : [
33853385 {
33863386 params : {
3387- to : '0xToken ' as `0x${string } `,
3388- data : '0xapprove ' as `0x${string } `,
3387+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3388+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
33893389 } ,
33903390 } ,
33913391 ] ,
@@ -3406,6 +3406,141 @@ describe('PredictController', () => {
34063406 ) . rejects . toThrow ( 'Value must be a hexadecimal string.' ) ;
34073407 } ) ;
34083408 } ) ;
3409+
3410+ it ( 'throws error when transaction is missing params object' , async ( ) => {
3411+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3412+ transactions : [ { type : 'contractInteraction' } as never ] ,
3413+ chainId : '0x89' ,
3414+ } ) ;
3415+
3416+ await withController ( async ( { controller } ) => {
3417+ await expect (
3418+ controller . depositWithConfirmation ( {
3419+ providerId : 'polymarket' ,
3420+ } ) ,
3421+ ) . rejects . toThrow (
3422+ 'Invalid transaction: transaction at index 0 is missing params object' ,
3423+ ) ;
3424+ } ) ;
3425+ } ) ;
3426+
3427+ it ( 'throws error when transaction is missing to address' , async ( ) => {
3428+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3429+ transactions : [
3430+ {
3431+ params : {
3432+ data : '0x095ea7b3000000000000000000000000' as `0x${string } `,
3433+ } ,
3434+ } as never ,
3435+ ] ,
3436+ chainId : '0x89' ,
3437+ } ) ;
3438+
3439+ await withController ( async ( { controller } ) => {
3440+ await expect (
3441+ controller . depositWithConfirmation ( {
3442+ providerId : 'polymarket' ,
3443+ } ) ,
3444+ ) . rejects . toThrow (
3445+ "Invalid transaction: transaction at index 0 is missing 'to' address" ,
3446+ ) ;
3447+ } ) ;
3448+ } ) ;
3449+
3450+ it ( 'throws error when transaction to address has invalid format' , async ( ) => {
3451+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3452+ transactions : [
3453+ {
3454+ params : {
3455+ to : '0xshort' as `0x${string } `,
3456+ data : '0x095ea7b3000000000000000000000000' as `0x${string } `,
3457+ } ,
3458+ } ,
3459+ ] ,
3460+ chainId : '0x89' ,
3461+ } ) ;
3462+
3463+ await withController ( async ( { controller } ) => {
3464+ await expect (
3465+ controller . depositWithConfirmation ( {
3466+ providerId : 'polymarket' ,
3467+ } ) ,
3468+ ) . rejects . toThrow (
3469+ "Invalid transaction: transaction at index 0 has invalid 'to' address format" ,
3470+ ) ;
3471+ } ) ;
3472+ } ) ;
3473+
3474+ it ( 'throws error when transaction data is missing' , async ( ) => {
3475+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3476+ transactions : [
3477+ {
3478+ params : {
3479+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as `0x${string } `,
3480+ } ,
3481+ } as never ,
3482+ ] ,
3483+ chainId : '0x89' ,
3484+ } ) ;
3485+
3486+ await withController ( async ( { controller } ) => {
3487+ await expect (
3488+ controller . depositWithConfirmation ( {
3489+ providerId : 'polymarket' ,
3490+ } ) ,
3491+ ) . rejects . toThrow (
3492+ 'Invalid transaction: transaction at index 0 is missing data' ,
3493+ ) ;
3494+ } ) ;
3495+ } ) ;
3496+
3497+ it ( 'throws error when transaction data has invalid hex format' , async ( ) => {
3498+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3499+ transactions : [
3500+ {
3501+ params : {
3502+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as `0x${string } `,
3503+ data : 'not-hex-data' as `0x${string } `,
3504+ } ,
3505+ } ,
3506+ ] ,
3507+ chainId : '0x89' ,
3508+ } ) ;
3509+
3510+ await withController ( async ( { controller } ) => {
3511+ await expect (
3512+ controller . depositWithConfirmation ( {
3513+ providerId : 'polymarket' ,
3514+ } ) ,
3515+ ) . rejects . toThrow (
3516+ 'Invalid transaction: transaction at index 0 has invalid data format (must be hex string starting with 0x)' ,
3517+ ) ;
3518+ } ) ;
3519+ } ) ;
3520+
3521+ it ( 'throws error when transaction data is too short' , async ( ) => {
3522+ mockPolymarketProvider . prepareDeposit . mockResolvedValue ( {
3523+ transactions : [
3524+ {
3525+ params : {
3526+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174' as `0x${string } `,
3527+ data : '0x1234' as `0x${string } `,
3528+ } ,
3529+ } ,
3530+ ] ,
3531+ chainId : '0x89' ,
3532+ } ) ;
3533+
3534+ await withController ( async ( { controller } ) => {
3535+ await expect (
3536+ controller . depositWithConfirmation ( {
3537+ providerId : 'polymarket' ,
3538+ } ) ,
3539+ ) . rejects . toThrow (
3540+ 'Invalid transaction: transaction at index 0 has insufficient data (length: 6, minimum: 10)' ,
3541+ ) ;
3542+ } ) ;
3543+ } ) ;
34093544 } ) ;
34103545
34113546 describe ( 'clearDepositTransaction' , ( ) => {
@@ -3488,9 +3623,9 @@ describe('PredictController', () => {
34883623 hash : '0xabc' ,
34893624 status : 'confirmed' ,
34903625 txParams : {
3491- from : '0x1 ' ,
3492- to : '0xToken ' ,
3493- data : '0xapprove ' ,
3626+ from : '0x1234567890123456789012345678901234567890 ' ,
3627+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' ,
3628+ data : '0x095ea7b3000000000000000000000000 ' ,
34943629 value : '0x0' ,
34953630 } ,
34963631 } ;
@@ -3515,8 +3650,8 @@ describe('PredictController', () => {
35153650 transactions : [
35163651 {
35173652 params : {
3518- to : '0xToken ' as `0x${string } `,
3519- data : '0xapprove ' as `0x${string } `,
3653+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3654+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
35203655 } ,
35213656 } ,
35223657 ] ,
@@ -3552,8 +3687,8 @@ describe('PredictController', () => {
35523687 transactions : [
35533688 {
35543689 params : {
3555- to : '0xToken ' as `0x${string } `,
3556- data : '0xapprove ' as `0x${string } `,
3690+ to : '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174 ' as `0x${string } `,
3691+ data : '0x095ea7b3000000000000000000000000 ' as `0x${string } `,
35573692 } ,
35583693 } ,
35593694 ] ,
0 commit comments