Skip to content

Commit

Permalink
refactor(ERTP): use jessie in issuer.js (#2606)
Browse files Browse the repository at this point in the history
* refactor(ERTP): use jessie in issuer.js

* chore: include iterable in makeFlexSet

* chore(ERTP): get makeSet from lib-jessie package

* chore: update yarn.lock for lib-jessie

Co-authored-by: Mark S. Miller <erights@users.noreply.github.com>
  • Loading branch information
dckc and erights authored Mar 18, 2021
1 parent e80d6c6 commit 3629e2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 11 additions & 0 deletions packages/ERTP/src/collections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// @ts-check

/**
* TODO: move to https://github.com/Agoric/readonly-collections-shim ?
*
* @returns {Set<T>}
* @template T
*/
export function makeFlexSet() {
return new Set();
}
7 changes: 4 additions & 3 deletions packages/ERTP/src/issuer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @ts-check
/* global makeWeakStore */

'use jessie';

import { assert, details as X } from '@agoric/assert';
import { makeExternalStore } from '@agoric/store';
import { E } from '@agoric/eventual-send';
Expand Down Expand Up @@ -97,7 +99,7 @@ function makeIssuerKit(
const purse = Far(makeFarName(allegedName, ERTPKind.PURSE), {
deposit: (srcPayment, optAmount = undefined) => {
if (isPromise(srcPayment)) {
throw new TypeError(
throw TypeError(
`deposit does not accept promises as first argument. Instead of passing the promise (deposit(paymentPromise)), consider unwrapping the promise first: paymentPromise.then(actualPayment => deposit(actualPayment))`,
);
}
Expand Down Expand Up @@ -160,11 +162,10 @@ function makeIssuerKit(
// other uses.

if (payments.length > 1) {
// TODO: replace with a Set that understands virtual objects
const antiAliasingStore = makeWeakStore('payment');
payments.forEach(payment => {
if (antiAliasingStore.has(payment)) {
throw new Error('same payment seen twice');
throw Error('same payment seen twice');
}
antiAliasingStore.init(payment, undefined);
});
Expand Down

0 comments on commit 3629e2c

Please sign in to comment.