Skip to content

Commit b89be24

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 199e9af commit b89be24

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
@@ -1738,7 +1738,7 @@ impl Env {
17381738
/// current contract function for authorization. This lets
17391739
/// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
17401740
/// same function name that [`Address::require_auth`] uses.
1741-
pub fn as_contract_with_func<T>(
1741+
pub fn as_contract_fn<T>(
17421742
&self,
17431743
id: &Address,
17441744
func: &crate::Symbol,
@@ -1846,7 +1846,7 @@ impl Env {
18461846
/// the current contract function for authorization. This lets
18471847
/// [`mock_auths`][Self::mock_auths] and [`auths`][Self::auths] observe the
18481848
/// same function name that [`Address::require_auth`] uses.
1849-
pub fn try_as_contract_with_func<T, E>(
1849+
pub fn try_as_contract_fn<T, E>(
18501850
&self,
18511851
id: &Address,
18521852
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)