Skip to content

Commit c1a7fed

Browse files
committed
Add optionalU64ToPtr
1 parent 26ff52f commit c1a7fed

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

internal/api/lib.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,12 @@ func AnalyzeCode(cache Cache, checksum []byte) (*types.AnalysisReport, error) {
161161
}
162162
requiredCapabilities := string(copyAndDestroyUnmanagedVector(report.required_capabilities))
163163
entrypoints := string(copyAndDestroyUnmanagedVector(report.entrypoints))
164-
var contract_migrate_version *uint64
165-
if report.contract_migrate_version.is_some {
166-
contract_migrate_version = (*uint64)(&report.contract_migrate_version.value)
167-
}
164+
168165
res := types.AnalysisReport{
169166
HasIBCEntryPoints: bool(report.has_ibc_entry_points),
170167
RequiredCapabilities: requiredCapabilities,
171168
Entrypoints: strings.Split(entrypoints, ","),
172-
ContractMigrateVersion: contract_migrate_version,
169+
ContractMigrateVersion: optionalU64ToPtr(report.contract_migrate_version),
173170
}
174171
return &res, nil
175172
}

internal/api/memory.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ func copyAndDestroyUnmanagedVector(v C.UnmanagedVector) []byte {
7575
return out
7676
}
7777

78+
func optionalU64ToPtr(val C.OptionalU64) *uint64 {
79+
if val.is_some {
80+
return (*uint64)(&val.value)
81+
}
82+
return nil
83+
}
84+
7885
// copyU8Slice copies the contents of an Option<&[u8]> that was allocated on the Rust side.
7986
// Returns nil if and only if the source is None.
8087
func copyU8Slice(view C.U8SliceView) []byte {

0 commit comments

Comments
 (0)