@@ -2,7 +2,7 @@ import type { ThirdwebContract } from "../../../contract/contract.js";
2
2
import { prepareContractCall } from "../../../transaction/prepare-contract-call.js" ;
3
3
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js" ;
4
4
import { readContract } from "../../../transaction/read-contract.js" ;
5
- import { stringToHex } from "../../../utils/encoding/hex.js" ;
5
+ import { isHex , stringToHex } from "../../../utils/encoding/hex.js" ;
6
6
import type { SendTransactionOption } from "../../interfaces/wallet.js" ;
7
7
8
8
/**
@@ -48,11 +48,14 @@ export async function predictAddress(args: {
48
48
"Account address is required to predict the smart wallet address." ,
49
49
) ;
50
50
}
51
- const extraData = stringToHex ( accountSalt ?? "" ) ;
51
+ const saltHex =
52
+ accountSalt && isHex ( accountSalt )
53
+ ? accountSalt
54
+ : stringToHex ( accountSalt ?? "" ) ;
52
55
return readContract ( {
53
56
contract : factoryContract ,
54
57
method : "function getAddress(address, bytes) returns (address)" ,
55
- params : [ adminAddress , extraData ] ,
58
+ params : [ adminAddress , saltHex ] ,
56
59
} ) ;
57
60
}
58
61
@@ -76,10 +79,14 @@ export function prepareCreateAccount(args: {
76
79
if ( createAccount ) {
77
80
return createAccount ( factoryContract ) ;
78
81
}
82
+ const saltHex =
83
+ accountSalt && isHex ( accountSalt )
84
+ ? accountSalt
85
+ : stringToHex ( accountSalt ?? "" ) ;
79
86
return prepareContractCall ( {
80
87
contract : factoryContract ,
81
88
method : "function createAccount(address, bytes) returns (address)" ,
82
- params : [ adminAddress , stringToHex ( accountSalt ?? "" ) ] ,
89
+ params : [ adminAddress , saltHex ] ,
83
90
} ) ;
84
91
}
85
92
0 commit comments