Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 799ae2d

Browse files
Revert "Put auth example earlier in list of examples (#96)" (#97)
This reverts commit fe4dc8c.
1 parent fe4dc8c commit 799ae2d

File tree

13 files changed

+162
-427
lines changed

13 files changed

+162
-427
lines changed

docs/SDKs/rust.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ Add the following sections to the `Cargo.toml` to import the `soroban-sdk`.
2929
testutils = ["soroban-sdk/testutils"]
3030

3131
[dependencies]
32-
soroban-sdk = "0.0.4"
32+
soroban-sdk = "0.0.3"
3333
```

docs/examples/authorization.mdx

Lines changed: 0 additions & 253 deletions
This file was deleted.

docs/examples/custom-types.mdx

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct FirstLast {
5353

5454
pub struct CustomTypesContract;
5555

56-
const NAME: Symbol = symbol!("NAME");
56+
const NAME: Symbol = Symbol::from_str("NAME");
5757

5858
#[contractimpl]
5959
impl CustomTypesContract {
@@ -123,9 +123,9 @@ retrieved later.
123123
```rust
124124
pub struct CustomTypesContract;
125125

126-
const NAME: Symbol = symbol!("NAME");
126+
const NAME: Symbol = Symbol::from_str("NAME");
127127

128-
#[contractimpl]
128+
#[contractimpl(export_if = "export")]
129129
impl CustomTypesContract {
130130
pub fn store(env: Env, name: Name) {
131131
env.contract_data().set(NAME, name);
@@ -148,22 +148,25 @@ Open the `custom_types/src/test.rs` file to follow along.
148148
#[test]
149149
fn test() {
150150
let env = Env::default();
151-
let contract_id = BytesN::from_array(&env, &[0; 32]);
151+
let contract_id = FixedBinary::from_array(&env, [0; 32]);
152152
env.register_contract(&contract_id, CustomTypesContract);
153-
let client = CustomTypesContractClient::new(&env, &contract_id);
154153

155-
assert_eq!(client.retrieve(), Name::None);
154+
assert_eq!(retrieve::invoke(&env, &contract_id), Name::None);
156155

157-
client.store(&Name::FirstLast(FirstLast {
158-
first: symbol!("first"),
159-
last: symbol!("last"),
160-
}));
156+
store::invoke(
157+
&env,
158+
&contract_id,
159+
&Name::FirstLast(FirstLast {
160+
first: Symbol::from_str("first"),
161+
last: Symbol::from_str("last"),
162+
}),
163+
);
161164

162165
assert_eq!(
163-
client.retrieve(),
166+
retrieve::invoke(&env, &contract_id),
164167
Name::FirstLast(FirstLast {
165-
first: symbol!("first"),
166-
last: symbol!("last"),
168+
first: Symbol::from_str("first"),
169+
last: Symbol::from_str("last"),
167170
}),
168171
);
169172
}
@@ -180,46 +183,44 @@ Contracts must be registered with the environment with a contract ID, which is a
180183
32-byte value.
181184

182185
```rust
183-
let contract_id = BytesN::from_array(&env, [0; 32]);
184-
env.register_contract(&contract_id, CustomTypesContract);
186+
let contract_id = FixedBinary::from_array(&env, [0; 32]);
187+
env.register_contract(&contract_id, HelloContract);
185188
```
186189

187190
All public functions within an `impl` block that is annotated with the
188-
`#[contractimpl]` attribute have a corresponding function generated in a
189-
generated client type. The client type will be named the same as the contract
190-
type with `Client` appended. For example, in our contract the contract type is
191-
`CustomTypesContract`, and the client is named `CustomTypesContractClient`.
192-
193-
```rust
194-
let client = CustomTypesContractClient::new(&env, &contract_id);
195-
```
191+
`#[contractimpl]` attribute have an `invoke` function generated, that can be
192+
used to invoke the contract function within the environment.
196193

197194
The test invokes the `retrieve` function on the registered contract, and asserts
198195
that it returns `Name::None`.
199196

200197
```rust
201-
assert_eq!(client.retrieve(), Name::None);
198+
assert_eq!(retrieve::invoke(&env, &contract_id), Name::None);
202199
```
203200

204201
The test then invokes the `store` function on the registered contract, to change
205202
the name that is stored.
206203

207204
```rust
208-
client.store(&Name::FirstLast(FirstLast {
209-
first: symbol!("first"),
210-
last: symbol!("last"),
211-
}));
205+
store::invoke(
206+
&env,
207+
&contract_id,
208+
&Name::FirstLast(FirstLast {
209+
first: Symbol::from_str("first"),
210+
last: Symbol::from_str("last"),
211+
}),
212+
);
212213
```
213214

214215
The test invokes the `retrieve` function again, to assert that it returns the
215216
name that was previously stored.
216217

217218
```rust
218219
assert_eq!(
219-
client.retrieve(),
220+
retrieve::invoke(&env, &contract_id),
220221
Name::FirstLast(FirstLast {
221-
first: symbol!("first"),
222-
last: symbol!("last"),
222+
first: Symbol::from_str("first"),
223+
last: Symbol::from_str("last"),
223224
}),
224225
);
225226
```

0 commit comments

Comments
 (0)