Skip to content
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

Fill gaps in ref conversions to Val #1479

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

leighmcculloch
Copy link
Member

@leighmcculloch leighmcculloch commented Oct 24, 2024

What

Fill gaps in ref conversions to Val.

Why

Needed for:

@graydon
Copy link
Contributor

graydon commented Oct 25, 2024

Mmm I think this is mostly-ok but I also think that since it's an impl of a public type and a public trait it falls under a major semver change? Maybe?

@leighmcculloch
Copy link
Member Author

It does, but that's okay, it's targeting the v22 major release because it's required for the SDK changes being made for constructors.

@leighmcculloch leighmcculloch added this pull request to the merge queue Oct 31, 2024
Merged via the queue into main with commit bd0c80a Oct 31, 2024
12 checks passed
@leighmcculloch leighmcculloch deleted the fill-gaps-in-ref-conversions branch October 31, 2024 16:56
github-merge-queue bot pushed a commit to stellar/rs-soroban-sdk that referenced this pull request Nov 1, 2024
### What
Add ContractArgs for building function args.

### Usage

```diff
-let contract_id = env.register(Contract, (100_u32, 1000_i64));
+let contract_id = env.register(Contract, ContractArgs::__constructor(&100_u32, &1000_i64));
```

### Diff of generated code for constructor test vector

```diff
@@ -7,6 +7,8 @@ extern crate core;
 extern crate compiler_builtins as _;
 use soroban_sdk::{contract, contractimpl, contracttype, Env};
 pub struct Contract;
+///ContractArgs is a type for building arg lists for functions defined in "Contract".
+pub struct ContractArgs;
 ///ContractClient is a client for calling the contract defined in "Contract".
 pub struct ContractClient<'a> {
     pub env: soroban_sdk::Env,
@@ -210,6 +212,17 @@ impl<'a> ContractClient<'a> {
         res
     }
 }
+impl ContractArgs {
+    pub fn __constructor<'i>(
+        init_key: &'i u32,
+        init_value: &'i i64,
+    ) -> (&'i u32, &'i i64) {
+        (init_key, init_value)
+    }
+    pub fn get_data<'i>(key: &'i DataKey) -> (&'i DataKey,) {
+        (key,)
+    }
+}
 #[doc(hidden)]
 pub mod ____constructor {
     use super::*;
```

### Why

To provide a way to make specifying args as concrete.

Dependent on:
- stellar/rs-soroban-env#1479

Close #1348

### Note

This is still very much an experiment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants