@@ -212,15 +212,17 @@ func hostCanonicalizeAddress(ctx context.Context, mod api.Module, addrPtr, addrL
212
212
}
213
213
214
214
// hostValidateAddress implements addr_validate
215
- func hostValidateAddress (ctx context.Context , mod api.Module , addrPtr , addrLen uint32 ) uint32 {
215
+ func hostValidateAddress (ctx context.Context , mod api.Module , addrPtr uint32 ) uint32 {
216
216
env := ctx .Value ("env" ).(* RuntimeEnvironment )
217
217
mem := mod .Memory ()
218
218
219
- addr , err := ReadMemory (mem , addrPtr , addrLen )
219
+ // Read the address bytes directly (no length prefix in Rust)
220
+ addr , err := ReadMemory (mem , addrPtr , 32 ) // Fixed size for addresses
220
221
if err != nil {
221
222
panic (fmt .Sprintf ("failed to read address from memory: %v" , err ))
222
223
}
223
224
225
+ // Convert to string and validate
224
226
_ , err = env .API .ValidateAddress (string (addr ))
225
227
if err != nil {
226
228
return 0 // Return 0 for invalid address
@@ -593,22 +595,22 @@ func RegisterHostFunctions(runtime wazero.Runtime, env *RuntimeEnvironment) (waz
593
595
Export ("api_humanize_address" )
594
596
595
597
builder .NewFunctionBuilder ().
596
- WithFunc (func (ctx context.Context , m api.Module , addrPtr , addrLen uint32 ) ( uint32 , uint32 ) {
598
+ WithFunc (func (ctx context.Context , m api.Module , addrPtr uint32 ) uint32 {
597
599
ctx = context .WithValue (ctx , "env" , env )
598
- return hostCanonicalizeAddress (ctx , m , addrPtr , addrLen )
600
+ return hostValidateAddress (ctx , m , addrPtr )
599
601
}).
600
- WithParameterNames ("addr_ptr" , "addr_len" ).
601
- WithResultNames ("ptr" , "len " ).
602
- Export ("addr_canonicalize " )
602
+ WithParameterNames ("addr_ptr" ).
603
+ WithResultNames ("result " ).
604
+ Export ("addr_validate " )
603
605
604
606
builder .NewFunctionBuilder ().
605
- WithFunc (func (ctx context.Context , m api.Module , addrPtr , addrLen uint32 ) uint32 {
607
+ WithFunc (func (ctx context.Context , m api.Module , addrPtr , addrLen uint32 ) ( uint32 , uint32 ) {
606
608
ctx = context .WithValue (ctx , "env" , env )
607
- return hostValidateAddress (ctx , m , addrPtr , addrLen )
609
+ return hostCanonicalizeAddress (ctx , m , addrPtr , addrLen )
608
610
}).
609
611
WithParameterNames ("addr_ptr" , "addr_len" ).
610
- WithResultNames ("result " ).
611
- Export ("addr_validate " )
612
+ WithResultNames ("ptr" , "len " ).
613
+ Export ("addr_canonicalize " )
612
614
613
615
// Register Query functions
614
616
builder .NewFunctionBuilder ().
0 commit comments