Skip to content

Commit 0d8ead0

Browse files
committed
docs: add zcf.atomicRearrange()
1 parent f9c8677 commit 0d8ead0

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

main/reference/zoe-api/zoe-contract-facet.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ The contract instance is launched by **E(Zoe).startInstance()**, and is given ac
1010
the **zcf** object during that launch (see [Contract Requirements](/guides/zoe/contract-requirements)).
1111
In the operations below, **instance** is the handle for the running contract instance.
1212

13+
14+
## zcf.atomicRearrange(transfers)
15+
16+
- **transfers**: **Array<[TransferPart](./zoe-data-types#transferpart)>**
17+
- Returns: None.
18+
19+
Asks Zoe to rearrange the **[Allocations](./zoe-data-types#allocation)** among the seats mentioned in
20+
_transfers_. _transfers_ are a set of changes to **Allocations** that must satisfy several
21+
constraints. If these constraints are all met, then the reallocation happens atomically. Otherwise an
22+
error is thrown and none of the proposed changes has any effect. The constraints are as follows.
23+
24+
- All the mentioned seats are still live.
25+
- There aren't any outstanding stagings for any of the mentioned seats.
26+
27+
Stagings are a reallocation mechanism that has been
28+
deprecated in favor of this **atomicRearrange()** function.
29+
To prevent confusion, each reallocation can only be
30+
expressed in the old way or the new way, but not a mixture.
31+
32+
- Overall conservation must be maintained. In other words, the reallocated
33+
**[Amounts](/reference/ertp-api/ertp-data-types#amount)** must balance out.
34+
- Offer Safety is preserved for each seat. That means reallocations can only take assets from a seat
35+
as long as either it gets the assets described in the want section of its proposal, or it retains
36+
all of the assets specified in the give section of the proposal. This constraint applies to each
37+
seat across the entire atomicRearrangement, not to the individual **TransferParts**.
38+
39+
Note that you can construct the **TransferParts** that make up the _transfers_ array manually, or for
40+
transfers that only include one seat, you can use the helper functions
41+
**[fromOnly()](./zoe-helpers#fromonly-fromseat-fromamounts)** and
42+
**[toOnly()](./zoe-helpers#toonly-toseat-toamounts)** to create
43+
**TransferParts** that only use a subset of the fields.
44+
45+
1346
## zcf.makeZCFMint(keyword, assetKind?, displayInfo?)
1447

1548
- **keyword**: **[Keyword](./zoe-data-types#keyword)**
@@ -411,5 +444,5 @@ buyerSeat.incrementBy(sellerSeat.decrementBy({ Items: wantedItems }));
411444
zcf.reallocate(buyerSeat, sellerSeat);
412445
```
413446
414-
**Note**: This method has been deprecated. Use **[atomicRearrange()](./zoe-helpers#atomicrearrange-zcf-transfers)** instead.
447+
**Note**: This method has been deprecated. Use **[atomicRearrange()](./#atomicrearrange-transfers)** instead.
415448
:::

main/reference/zoe-api/zoe-helpers.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
Asks Zoe to rearrange the **[Allocations](./zoe-data-types#allocation)** among the seats mentioned in
2525
_transfers_. _transfers_ are a set of changes to **Allocations** that must satisfy several
2626
constraints. If these constraints are all met, then the reallocation happens atomically. Otherwise an
27-
error is thrown and none of the propossed changes has any effect. The constraints are as follows.
27+
error is thrown and none of the proposed changes has any effect. The constraints are as follows.
2828

2929
- All the mentioned seats are still live.
3030
- There aren't any outstanding stagings for any of the mentioned seats.

0 commit comments

Comments
 (0)