-
Notifications
You must be signed in to change notification settings - Fork 251
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
List of odd APIs #387
Comments
The most prevalent one I've been thinking about has been around the collections API, specifically the map types. It would be ideal if the API matches I think it would be also awesome if we added the entry API to these types, which would come with some overhead of having to cache all values (which I think is a thing to strive for anyway to avoid redundant storage reads), but it allows for some very clean usage. If these data structures are modified to cache loaded values from storage, which would take some careful checking of the safety to make sure the API couldn't be misused, we can have APIs for these collections that more closely match std and also potentially save on gas usages from redundant reads. I'll edit this comment with other ideas to list in the same form as your list, I just needed to add some additional context for this example because it's larger. |
Right, there's also a minor point that |
I'd also recommend replace |
Can the |
Okay, I've updated the original post by changing to checkboxes for completion, linking to PRs, and separating it into potential 4.0 upgrades and future updates. Feel free for anyone to add anything or change where the items are if you think anything should/shouldn't be included |
Also as a point of discussion, possibly in this release, we can rename some of the VMContext attributes ref #14. This is currently a breaking change because all fields are publicly exposed (which is a nightmare to maintain), but can be easily phased out depending on if people have started to switch over to Perhaps this can be in a future release, as it would be annoying to migrate for only a cosmetic change |
Note that So:
|
Added switching storage key type to the list of future improvements based on #402 (comment). I've kept in future changes because changing the trait return type can add additional breakages that might be unwanted. Alternatively or before then can just change the types which contain the keys (collections) to Possibly could be added in the next release though, does anyone have thoughts? |
Something which occurred to me yesterday: in env, we have functions like |
This issue is for me to brain dump all API papercuts I find, just so that I don't forget about them
4.0 Breaking release:
env::log
uses<span class="error">[u8]</span>
rather thenstr
Switch log signature to str from bytes #366Gas
is not a newtype (along with a bunch of other types) refactor(types)!: create newtype for gas #471Base58PublicKey
an enum or struct which does not erase curve type and expose underlying bytes #447 feat: Make CurveType accessible within Base58PublicKey #453ValidAccountId
and makeAccountId
a newtype #446 refactor(types): change account id to newtype and deprecate ValidAccountId #448impl TryFrom<String> for CurveType
should beFromStr
feat(json_types): implement FromStr for Base58CryptoHash and cleanup #398VMConfig
andVMContext
are available whentarget = wasm32
refactor: replace syscall interactions in wasm32 environment #417ValidAccountId
shouldn't haveTryFrom<&str>
or inherentto_string
feat(json_types): implement FromStr for ValidAccountId #391BLOCKCHAIN_INTERFACE
for wasm32 env refactor: replace syscall interactions in wasm32 environment #4174.0 Stretch goal:
add_access_key
of the Promise API takes in method names as aVec<u8>
which assumes you know that it's a comma-separated utf8 bytes. Would be nice if it could just take something likeimpl IntoIterator<Item = &str>
, or&<span class="error">[&str]</span>
if cautious about using generics hereFuture changes:
near_sdk::CryptoHash
andnear_sdk::MerkleHash
which are similar, but not the sameinit
methods require implementing panicking defaults yourself&mut self
methods can overwrite manually changed contract storage, foot gun when writing migrations.range
request has an unergonomic signature: https://doc.rust-lang.org/stable/std/collections/struct.BTreeMap.html#method.range, https://docs.rs/near-sdk/3.1.0/near_sdk/collections/struct.TreeMap.html#method.range (This will be deprecated when transitioning from collections anyway)collections
types to caching and idiomatic variants instore
module (doesn't require semver breaking change)type Duration = u64
while we havecore::time::Duration
Vec<u8>
when they do not and should not be resized, so they can be switched toBox<<span class="error">[u8]</span>>
to save on memory and have some compiler checks to make sure this isn't misusedjson_types
areBox<dyn std::error::Error>
when they could be concrete typesjson_types
module is suspicious. If we newtype most of the things, the need for this module should go away. Also if integers are serialized as strings at serialization level, the wrapper types won't be needed (Handle u64 and u128 at the serializer layer rather than via wrapper types? #408)Vec<u8>
when they can just return arrays of the length of the hash type (feat: Implement fixed length hash functions and optimize existing imlementations #646)gas
function exported fromMockedBlockchain
should probably not be exposed or be renamed touse_gas
if keptThe text was updated successfully, but these errors were encountered: