Skip to content

Commit c158178

Browse files
committed
rename: as_contract_with_func -> as_contract_fn
The existing as_contract already takes a closure (func), so _with_func did not distinguish the new API. Rename to as_contract_fn / try_as_contract_fn to make clear the extra Symbol argument is the contract function name used for the auth frame (mock_auths / auths). Addresses review feedback from @leighmcculloch on #1920.
1 parent ecbb53a commit c158178

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

soroban-sdk/src/env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ impl Env {
17931793
/// current contract function for authorization. This lets
17941794
/// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
17951795
/// same function name that [`Address::require_auth`] uses.
1796-
pub fn as_contract_with_func<T>(
1796+
pub fn as_contract_fn<T>(
17971797
&self,
17981798
id: &Address,
17991799
func: &crate::Symbol,
@@ -1901,7 +1901,7 @@ impl Env {
19011901
/// the current contract function for authorization. This lets
19021902
/// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
19031903
/// same function name that [`Address::require_auth`] uses.
1904-
pub fn try_as_contract_with_func<T, E>(
1904+
pub fn try_as_contract_fn<T, E>(
19051905
&self,
19061906
id: &Address,
19071907
func: &crate::Symbol,

soroban-sdk/src/tests/env.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn test_register_restores_auth_before_panics() {
358358
}
359359

360360
#[test]
361-
fn test_as_contract_with_func() {
361+
fn test_as_contract_fn() {
362362
use crate::testutils::{MockAuth, MockAuthInvoke};
363363
use crate::IntoVal;
364364

@@ -379,13 +379,13 @@ fn test_as_contract_with_func() {
379379
},
380380
}]);
381381

382-
env.as_contract_with_func(&test_contract_id, &func_name, || {
382+
env.as_contract_fn(&test_contract_id, &func_name, || {
383383
user.require_auth();
384384
});
385385
}
386386

387387
#[test]
388-
fn test_try_as_contract_with_func() {
388+
fn test_try_as_contract_fn() {
389389
use crate::testutils::{MockAuth, MockAuthInvoke};
390390
use crate::IntoVal;
391391

@@ -407,7 +407,7 @@ fn test_try_as_contract_with_func() {
407407
},
408408
}]);
409409

410-
let result = env.try_as_contract_with_func::<Symbol, Error>(&addr, &func_name, || {
410+
let result = env.try_as_contract_fn::<Symbol, Error>(&addr, &func_name, || {
411411
user.require_auth();
412412
Symbol::new(&env, "hello")
413413
});

soroban-sdk/test_snapshots/tests/env/test_as_contract_with_func.1.json renamed to soroban-sdk/test_snapshots/tests/env/test_as_contract_fn.1.json

File renamed without changes.

soroban-sdk/test_snapshots/tests/env/test_try_as_contract_with_func.1.json renamed to soroban-sdk/test_snapshots/tests/env/test_try_as_contract_fn.1.json

File renamed without changes.

0 commit comments

Comments
 (0)