Skip to content

Commit 6df24ef

Browse files
committed
chore: refine names, add mappedTo in TransferPartRecord
1 parent 593e65c commit 6df24ef

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

contract/src/offer-up.contract.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ export const start = async zcf => {
109109
const newItems = itemMint.mintGains(want);
110110
const charge = { Price: tradePrice };
111111
atomicRearrange(zcf, [
112-
{ fromSeat: buyerSeat, toSeat: proceeds, fromAmounts: charge },
113-
{ fromSeat: newItems, toSeat: buyerSeat, fromAmounts: want },
112+
{ from: buyerSeat, to: proceeds, amounts: charge },
113+
{ from: newItems, to: buyerSeat, amounts: want },
114114
]);
115115

116116
buyerSeat.exit(true);
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// @ts-check
22
import { atomicRearrange as atomicRearrangeTuples } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
3+
import { mapKeywords } from '@agoric/zoe/src/contractSupport/zoeHelpers.js';
34

45
/** @typedef {import("@agoric/zoe/src/contractSupport/atomicTransfer").TransferPart} TransferPart */
56

@@ -10,20 +11,24 @@ import { atomicRearrange as atomicRearrangeTuples } from '@agoric/zoe/src/contra
1011
* @param { Array<TransferPartRecord | TransferPart>} transferParts
1112
*
1213
* @typedef {{
13-
* fromSeat?: ZCFSeat,
14-
* toSeat?: ZCFSeat,
15-
* fromAmounts?: AmountKeywordRecord,
16-
* toAmounts?: AmountKeywordRecord
14+
* from?: ZCFSeat,
15+
* to?: ZCFSeat,
16+
* amounts?: AmountKeywordRecord,
17+
* mappedTo?: KeywordKeywordRecord
1718
* }} TransferPartRecord
1819
*/
1920
export const atomicRearrange = (zcf, transferParts) => {
2021
/** @type {TransferPart[]} */
2122
const tuples = harden(
22-
transferParts.map(part =>
23-
Array.isArray(part)
24-
? part
25-
: [part.fromSeat, part.toSeat, part.fromAmounts, part.toAmounts],
26-
),
23+
transferParts.map(part => {
24+
if (Array.isArray(part)) {
25+
return part;
26+
}
27+
const toAmounts = part.mappedTo
28+
? mapKeywords(part.amounts, part.mappedTo)
29+
: undefined;
30+
return [part.from, part.to, part.amounts, toAmounts];
31+
}),
2732
);
2833
return atomicRearrangeTuples(zcf, tuples);
2934
};

0 commit comments

Comments
 (0)