-
Notifications
You must be signed in to change notification settings - Fork 7
chore: port to Motoko core library
#42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Migrated all Motoko import statements from mo:base@0.16.0 to mo:core, preserving functionality across the codebase. Used mo:core/pure for immutable data structures like List as recommended. Changes: - Migrated 48 files including src/, tests/, bench/, and submodules - Updated fringe imports first (Utils, parser combinators, test files) - Then migrated their dependents (parsers, encoders, decoders, etc.) - Changed List imports to mo:core/pure/List for immutability - All other base imports changed to corresponding mo:core modules Files affected: - src/: All Candid, JSON, CBOR, and UrlEncoded modules - tests/: All test files - bench/: Benchmark files - submodules/parser-combinators.mo/src/: Parser library Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Buffer and Prelude modules don't exist in mo:core yet, so keeping these imports from mo:base while using mo:core for all other modules. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added mo:core as a dependency while keeping mo:base for Buffer and Prelude which aren't available in core yet. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace mutable hash-based Map from mo:map@9.0.1 with immutable comparison-based PureMap from mo:core. Key changes: - Replace Map.new() with PureMap.empty() - Convert Map.put() to immutable updates with PureMap.add() - Change hash-based lookups (thash, n32hash) to comparison-based (Text.compare, Nat32.compare, Nat.compare) - Update function signatures to return new maps instead of void - Use var for maps that need updates - Remove create_map utility function from Utils.mo All mo:map@9.0.1/Map imports successfully eliminated. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Clean up remaining TrieMap imports from files that no longer use them after migration to mo:core/pure/Map. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Point core dependency to local development version at /Users/ggreif/motoko-core/src to use latest features. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit completes the migration from mo:map@9.0.1 to mo:core by: 1. Set Migration in Decoder.mo: - Replaced mo:map@9.0.1/Set with mo:core/pure/Set - Changed Set.new() to PureSet.empty() with var declarations - Converted Set.put() to PureSet.add() with immutable updates - Replaced Set.has() with PureSet.contains() - Replaced Set.size() with PureSet.size() - Refactored Set.pop() pattern to save/restore visited set state - Updated function signatures to use closure over mutable sets 2. Dependency Updates: - Removed mo:map@9.0.1 from mops.toml dependencies - Updated cbor from 4.0.0 to 4.1.0 for core@2.0.0 compatibility - Updated candid from 2.0.0 to 2.4.2 for core@2.0.0 compatibility - Updated CBOR lib imports to use cbor@4.1.0 - Updated xtended-numbers imports to use @2.3.0 Note: Some tests still fail due to transitive dependency byte-utils@0.1.2 pulling in incompatible xtended-numbers@2.0.0, but all direct mo:map@9.0.1 usage has been successfully removed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace mo:base/Buffer with mo:core/List across the codebase by creating a ListBuffer wrapper class that provides Buffer-compatible API. Update all Buffer usage to use Runtime.trap instead of Debug.trap for mo:core compatibility. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
In mo:core, mutable array functions have moved to the VarArray module: - Array.init(size, item) -> VarArray.repeat(item, size) - Array.tabulateVar(size, fn) -> VarArray.tabulate(size, fn) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Replace Debug.trap with Runtime.trap throughout - Fix Array.indexOf parameter order (array, equal, element) - Add missing Buffer methods: fromArray, removeLast, last - Fix optional pattern matching syntax Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace PureMap with mutable Map for unique_compound_type_map which is mutated during encoding. Keep renaming_map and recursive_map as PureMap since they are only built once and then read from. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix Float encoding in Encoder and RepIndyHash to use ByteUtils array methods instead of Buffer.LE.addFloat - Fix Array operations: use Array.concat instead of append in RepIndyHash and TypedSerializer - Migrate Set from mo:map@9.0.1 to mo:core/pure/Set in TypedSerializer - Fix PureMap.toArray to use Iter.toArray(PureMap.entries()) pattern - Fix List API in parser-combinators: List.push → List.pushFront with reversed params, List.nil() → List.empty() - Fix List API in Text/Parser/Common: same List changes plus Char.isUppercase → manual range check, Iter.fromList → List.values - Add Runtime.trap import to ICRC3Value and replace all Debug.trap calls Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Complete migration to mo:core API with the following changes: API Replacements: - Iter.fromList() -> List.values() - Iter.toList() -> List.fromIter() - List.pop() -> List.popFront() - List.push(item, list) -> List.pushFront(list, item) - Debug.trap() -> Runtime.trap() throughout codebase - Float.format(#exact, n) -> Float.format(n, #exact) - Array.append() -> Array.flatten() - Iter.range() -> Array.tabulate().vals() - Buffer.last() return type handling Test Results: - 9 out of 12 tests now passing - All compilation errors resolved - Remaining failures are runtime errors and dependency issues Note: ByteUtils submodule still has compilation issues due to missing dependencies (itertools, augmented-btrees) but this is a local hack and should be solvable separately. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixes DeBruijn index lookup for recursive Candid types by properly propagating recursive_types_map through build_compound_type and build_types. Also fixes typo in utils.mo (toArgeType → toArgType), renames PureMapType to PureMap, and replaces Array.tabulate with Nat.range in tests. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace Array.flatten([a, b]) with Array.concat(a, b) in blob_concat helper function, as Array.concat is the idiomatic way to concatenate exactly two arrays. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove unused Prelude import from bench/{serde,types}.bench.mo and remove
base@0.16.0 dependency from mops.toml. Update moc toolchain version
from 0.16.2 to 1.1.0.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace all Prelude.unreachable() calls with Runtime.unreachable() from mo:core and remove unused Prelude imports. This continues the migration from mo:base to mo:core. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace Buffer imports from mo:base with List from mo:core in bench and test files. List is the successor to Buffer in the mo:core library. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace direct imports from mo:core/List with Utils.Buffer module. The mo:core/List module doesn't export a Buffer interface, so we use the local Utils.Buffer wrapper which provides a Buffer-like API around mo:core/List for compatibility. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The Prelude module from mo:base was imported but never used in these test files. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
||
| [dependencies] | ||
| "base@0.16.0" = "0.16.0" | ||
| core = "/Users/ggreif/motoko-core/src" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later this will come from mops too.
| [toolchain] | ||
| wasmtime = "33.0.1" | ||
| moc = "0.16.2" | ||
| moc = "1.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.16.3 should be required
| type Map<K, V> = PureMap.Map<K, V>; | ||
| type Set<A> = PureSet.Set<A>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be destructuring imports
The Debug module was imported but never used in this test file. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace Debug.trap calls with Runtime.trap and remove unused Debug import from serde.bench.mo. types.bench.mo keeps Debug for Debug.print usage. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The mo:core migration changes the iteration order of maps and records compared to mo:base. Updated test assertions to match the new ordering while maintaining semantic equivalence - the URL-encoded parameters are just permutations of the same data. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ByteUtils is now managed via mops as a remote dependency rather than a local submodule. Updated mops.toml to point to the GitHub repository and added ByteUtils/ to .gitignore. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added workaround dependencies (base@0.14.13, buffer@0.1.0, and xtended-numbers variants) to satisfy ByteUtils package requirements when used as a remote dependency. Also fixed xtended-numbers imports in CBOR to use unversioned package name. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Resolves #41.
The
corelibrary is the future and Caffeine uses it exclusively.