Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename produceIssuer to makeIssuerKit #1305

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ERTP/src/issuer.chainmail
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ interface Brand {
* default, is used for basic fungible tokens.
*/
interface IssuerMaker {
produceIssuer(
makeIssuerKit(
allegedName :String,
mathHelperName :String) -> (IssuerResults);
}

/**
* The return value of produceIssuer
* The return value of makeIssuerKit
*/
struct IssuerResults ( ) {
mint :Mint;
Expand Down
10 changes: 5 additions & 5 deletions packages/ERTP/src/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import makeAmountMath from './amountMath';
* @typedef {Object} IssuerMaker
* Makes Issuers.
*
* @property {(allegedName: string, mathHelperName: string) => IssuerResults} produceIssuer
* @property {(allegedName: string, mathHelperName: string) => IssuerResults} makeIssuerKit
* The allegedName becomes part of the brand in asset descriptions. The
* allegedName doesn't have to be a string, but it will only be used for
* its value. The allegedName is useful for debugging and double-checking
Expand All @@ -109,7 +109,7 @@ import makeAmountMath from './amountMath';
* default, is used for basic fungible tokens.
*
* @typedef {Object} IssuerResults
* The return value of produceIssuer
* The return value of makeIssuerKit
*
* @property {Mint} mint
* @property {Issuer} issuer
Expand Down Expand Up @@ -229,7 +229,7 @@ import makeAmountMath from './amountMath';
* @param {string} mathHelpersName
* @returns {IssuerResults}
*/
function produceIssuer(allegedName, mathHelpersName = 'nat') {
function makeIssuerKit(allegedName, mathHelpersName = 'nat') {
assert.typeof(allegedName, 'string');

const brand = harden({
Expand Down Expand Up @@ -500,6 +500,6 @@ function produceIssuer(allegedName, mathHelpersName = 'nat') {
});
}

harden(produceIssuer);
harden(makeIssuerKit);

export default produceIssuer;
export default makeIssuerKit;
4 changes: 2 additions & 2 deletions packages/ERTP/test/swingsetTests/splitPayments/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global harden */

import produceIssuer from '../../../src/issuer';
import makeIssuerKit from '../../../src/issuer';

function build(E, log) {
function testSplitPayments(aliceMaker) {
log('start test splitPayments');
const { mint: moolaMint, issuer, amountMath } = produceIssuer('moola');
const { mint: moolaMint, issuer, amountMath } = makeIssuerKit('moola');
const moolaPayment = moolaMint.mintPayment(amountMath.make(1000));

const aliceP = E(aliceMaker).make(issuer, amountMath, moolaPayment);
Expand Down
40 changes: 20 additions & 20 deletions packages/ERTP/test/unitTests/test-issuerObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import '@agoric/install-ses';
import test from 'tape-promise/tape';
import { E } from '@agoric/eventual-send';

import produceIssuer from '../../src/issuer';
import makeIssuerKit from '../../src/issuer';

test('issuer.getBrand, brand.isMyIssuer', t => {
try {
const { issuer, brand } = produceIssuer('fungible');
const { issuer, brand } = makeIssuerKit('fungible');
const myBrand = issuer.getBrand();
t.ok(myBrand.isMyIssuer(issuer));
t.equals(
brand,
myBrand,
'brand returned from `produceIssuer` and from `getBrand` the same',
'brand returned from `makeIssuerKit` and from `getBrand` the same',
);
t.equals(issuer.getAllegedName(), myBrand.getAllegedName());
t.equals(issuer.getAllegedName(), 'fungible');
Expand All @@ -26,7 +26,7 @@ test('issuer.getBrand, brand.isMyIssuer', t => {

test('issuer.getAmountMath', t => {
try {
const { issuer, amountMath, brand } = produceIssuer('fungible');
const { issuer, amountMath, brand } = makeIssuerKit('fungible');
t.equals(issuer.getAmountMath(), amountMath);
const fungible = amountMath.make;
t.ok(
Expand All @@ -46,7 +46,7 @@ test('issuer.getAmountMath', t => {

test('issuer.getMathHelpersName', t => {
try {
const { issuer } = produceIssuer('fungible');
const { issuer } = makeIssuerKit('fungible');
t.equals(issuer.getMathHelpersName(), 'nat');
} catch (e) {
t.assert(false, e);
Expand All @@ -57,7 +57,7 @@ test('issuer.getMathHelpersName', t => {

test('issuer.makeEmptyPurse', t => {
t.plan(6);
const { issuer, mint, amountMath, brand } = produceIssuer('fungible');
const { issuer, mint, amountMath, brand } = makeIssuerKit('fungible');
const purse = issuer.makeEmptyPurse();
const payment = mint.mintPayment(amountMath.make(837));

Expand Down Expand Up @@ -104,7 +104,7 @@ test('issuer.makeEmptyPurse', t => {

test('purse.deposit', async t => {
t.plan(4);
const { issuer, mint, amountMath } = produceIssuer('fungible');
const { issuer, mint, amountMath } = makeIssuerKit('fungible');
const fungible0 = amountMath.getEmpty();
const fungible17 = amountMath.make(17);
const fungible25 = amountMath.make(25);
Expand Down Expand Up @@ -139,7 +139,7 @@ test('purse.deposit', async t => {

test('purse.deposit promise', t => {
t.plan(1);
const { issuer, mint, amountMath } = produceIssuer('fungible');
const { issuer, mint, amountMath } = makeIssuerKit('fungible');
const fungible25 = amountMath.make(25);

const purse = issuer.makeEmptyPurse();
Expand All @@ -155,7 +155,7 @@ test('purse.deposit promise', t => {

test('purse.makeDepositFacet', t => {
t.plan(2);
const { issuer, mint, amountMath } = produceIssuer('fungible');
const { issuer, mint, amountMath } = makeIssuerKit('fungible');
const fungible25 = amountMath.make(25);

const purse = issuer.makeEmptyPurse();
Expand All @@ -180,7 +180,7 @@ test('purse.makeDepositFacet', t => {

test('issuer.burn', t => {
t.plan(2);
const { issuer, mint, amountMath } = produceIssuer('fungible');
const { issuer, mint, amountMath } = makeIssuerKit('fungible');
const payment1 = mint.mintPayment(amountMath.make(837));

E(issuer)
Expand All @@ -197,7 +197,7 @@ test('issuer.burn', t => {

test('issuer.claim', t => {
t.plan(3);
const { issuer, amountMath, mint } = produceIssuer('fungible');
const { issuer, amountMath, mint } = makeIssuerKit('fungible');
const payment1 = mint.mintPayment(amountMath.make(2));
E(issuer)
.claim(payment1, amountMath.make(2))
Expand All @@ -220,7 +220,7 @@ test('issuer.claim', t => {

test('issuer.splitMany bad amount', t => {
try {
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const payment = mint.mintPayment(amountMath.make(1000));
const badAmounts = Array(2).fill(amountMath.make(10));
t.rejects(
Expand All @@ -237,7 +237,7 @@ test('issuer.splitMany bad amount', t => {

test('issuer.splitMany good amount', t => {
t.plan(11);
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const oldPayment = mint.mintPayment(amountMath.make(100));
const goodAmounts = Array(10).fill(amountMath.make(10));

Expand Down Expand Up @@ -265,8 +265,8 @@ test('issuer.splitMany good amount', t => {

test('issuer.split bad amount', t => {
try {
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { amountMath: otherUnitOps } = produceIssuer('other fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const { amountMath: otherUnitOps } = makeIssuerKit('other fungible');
const payment = mint.mintPayment(amountMath.make(1000));
t.rejects(
_ => E(issuer).split(payment, otherUnitOps.make(10)),
Expand All @@ -282,7 +282,7 @@ test('issuer.split bad amount', t => {

test('issuer.split good amount', t => {
t.plan(3);
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const oldPayment = mint.mintPayment(amountMath.make(20));

const checkPayments = splitPayments => {
Expand All @@ -309,7 +309,7 @@ test('issuer.split good amount', t => {

test('issuer.combine good payments', t => {
t.plan(101);
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const payments = [];
for (let i = 0; i < 100; i += 1) {
payments.push(mint.mintPayment(amountMath.make(1)));
Expand Down Expand Up @@ -339,7 +339,7 @@ test('issuer.combine good payments', t => {

test('issuer.combine array of promises', t => {
t.plan(1);
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const paymentsP = [];
for (let i = 0; i < 100; i += 1) {
const freshPayment = mint.mintPayment(amountMath.make(1));
Expand All @@ -361,8 +361,8 @@ test('issuer.combine array of promises', t => {

test('issuer.combine bad payments', t => {
try {
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint: otherMint, amountMath: otherAmountMath } = produceIssuer(
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const { mint: otherMint, amountMath: otherAmountMath } = makeIssuerKit(
'other fungible',
);
const payments = [];
Expand Down
14 changes: 7 additions & 7 deletions packages/ERTP/test/unitTests/test-mintObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import '@agoric/install-ses';
import { test } from 'tape-promise/tape';

import produceIssuer from '../../src/issuer';
import makeIssuerKit from '../../src/issuer';

test('mint.getIssuer', t => {
try {
const { mint, issuer } = produceIssuer('fungible');
const { mint, issuer } = makeIssuerKit('fungible');
t.equals(mint.getIssuer(), issuer);
} catch (e) {
t.assert(false, e);
Expand All @@ -19,7 +19,7 @@ test('mint.getIssuer', t => {

test('mint.mintPayment default natMathHelper', t => {
t.plan(2);
const { mint, issuer, amountMath } = produceIssuer('fungible');
const { mint, issuer, amountMath } = makeIssuerKit('fungible');
const fungible1000 = amountMath.make(1000);
const payment1 = mint.mintPayment(fungible1000);
issuer.getAmountOf(payment1).then(paymentBalance1 => {
Expand All @@ -34,7 +34,7 @@ test('mint.mintPayment default natMathHelper', t => {

test('mint.mintPayment strSetMathHelpers', t => {
t.plan(2);
const { mint, issuer, amountMath } = produceIssuer('items', 'strSet');
const { mint, issuer, amountMath } = makeIssuerKit('items', 'strSet');
const items1and2and4 = amountMath.make(harden(['1', '2', '4']));
const payment1 = mint.mintPayment(items1and2and4);
issuer.getAmountOf(payment1).then(paymentBalance1 => {
Expand All @@ -50,7 +50,7 @@ test('mint.mintPayment strSetMathHelpers', t => {

test('mint.mintPayment setMathHelpers', t => {
t.plan(3);
const { mint, issuer, amountMath } = produceIssuer('items', 'set');
const { mint, issuer, amountMath } = makeIssuerKit('items', 'set');
const item1handle = {};
const item2handle = {};
const item3handle = {};
Expand All @@ -76,7 +76,7 @@ test('mint.mintPayment setMathHelpers', t => {

test('mint.mintPayment setMathHelpers with invites', t => {
t.plan(2);
const { mint, issuer, amountMath } = produceIssuer('items', 'set');
const { mint, issuer, amountMath } = makeIssuerKit('items', 'set');
const instanceHandle1 = {};
const invite1Extent = { handle: {}, instanceHandle: instanceHandle1 };
const invite2Extent = { handle: {}, instanceHandle: instanceHandle1 };
Expand All @@ -102,7 +102,7 @@ test('non-fungible tokens example', t => {
mint: balletTicketMint,
issuer: balletTicketIssuer,
amountMath,
} = produceIssuer('Agoric Ballet Opera tickets', 'set');
} = makeIssuerKit('Agoric Ballet Opera tickets', 'set');

const startDateString = new Date(2020, 1, 17, 20, 30).toISOString();

Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-mints.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global harden */

import produceIssuer from '@agoric/ertp';
import makeIssuerKit from '@agoric/ertp';

import makeStore from '@agoric/store';

Expand All @@ -25,7 +25,7 @@ function build(_E, _log) {
getMints: issuerNames => issuerNames.map(api.getMint),
// For example, issuerNameSingular might be 'moola', or 'simolean'
makeMintAndIssuer: issuerNameSingular => {
const { mint, issuer, amountMath } = produceIssuer(issuerNameSingular);
const { mint, issuer, amountMath } = makeIssuerKit(issuerNameSingular);
mintsAndMath.init(issuerNameSingular, { mint, amountMath });
return issuer;
},
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-swingset/test/unitTests/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { test } from 'tape-promise/tape';
import bundleSource from '@agoric/bundle-source';
import makeAmountMath from '@agoric/ertp/src/amountMath';

import produceIssuer from '@agoric/ertp';
import makeIssuerKit from '@agoric/ertp';
import { makeZoe } from '@agoric/zoe';
import { makeRegistrar } from '@agoric/registrar';

Expand All @@ -24,9 +24,9 @@ const setupTest = async () => {
inboxStateChangeLog.push(data);
};

const moolaBundle = produceIssuer('moola');
const simoleanBundle = produceIssuer('simolean');
const rpgBundle = produceIssuer('rpg', 'strSet');
const moolaBundle = makeIssuerKit('moola');
const simoleanBundle = makeIssuerKit('simolean');
const rpgBundle = makeIssuerKit('rpg', 'strSet');
const zoe = makeZoe();
const registry = makeRegistrar();
const board = makeBoard();
Expand Down
4 changes: 2 additions & 2 deletions packages/spawner/src/contractHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { importBundle } from '@agoric/import-bundle';
import makeStore from '@agoric/weak-store';
import { assert, details } from '@agoric/assert';
import { allComparable } from '@agoric/same-structure';
import produceIssuer from '@agoric/ertp';
import makeIssuerKit from '@agoric/ertp';
import { producePromise } from '@agoric/produce-promise';
import { E, HandledPromise } from '@agoric/eventual-send';

Expand Down Expand Up @@ -36,7 +36,7 @@ function makeContractHost(vatPowers, additionalEndowments = {}) {
mint: inviteMint,
issuer: inviteIssuer,
amountMath: inviteAmountMath,
} = produceIssuer('contract host', 'set');
} = makeIssuerKit('contract host', 'set');

function redeem(allegedInvitePayment) {
return inviteIssuer.getAmountOf(allegedInvitePayment).then(inviteAmount => {
Expand Down
8 changes: 4 additions & 4 deletions packages/spawner/test/swingsetTests/contractHost/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ function build(E, log) {

const { mint: moneyMint, issuer: moneyIssuer } = await E(
mint,
).produceIssuer('moola');
).makeIssuerKit('moola');
const moolaAmountMath = await getLocalAmountMath(moneyIssuer);
const moola = moolaAmountMath.make;
const aliceMoneyPaymentP = E(moneyMint).mintPayment(moola(1000));
const bobMoneyPaymentP = E(moneyMint).mintPayment(moola(1001));

const { mint: stockMint, issuer: stockIssuer } = await E(
mint,
).produceIssuer('Tyrell');
).makeIssuerKit('Tyrell');
const stockAmountMath = await getLocalAmountMath(stockIssuer);
const stocks = stockAmountMath.make;
const aliceStockPaymentP = E(stockMint).mintPayment(stocks(2002));
Expand Down Expand Up @@ -188,15 +188,15 @@ function build(E, log) {

const { mint: moneyMint, issuer: moneyIssuer } = await E(
mint,
).produceIssuer('clams');
).makeIssuerKit('clams');
const moneyAmountMath = await getLocalAmountMath(moneyIssuer);
const money = moneyAmountMath.make;
const aliceMoneyPayment = await E(moneyMint).mintPayment(money(1000));
const bobMoneyPayment = await E(moneyMint).mintPayment(money(1001));

const { mint: stockMint, issuer: stockIssuer } = await E(
mint,
).produceIssuer('fudco');
).makeIssuerKit('fudco');
const stockAmountMath = await getLocalAmountMath(stockIssuer);
const stocks = stockAmountMath.make;
const aliceStockPayment = await E(stockMint).mintPayment(stocks(2002));
Expand Down
4 changes: 2 additions & 2 deletions packages/spawner/test/swingsetTests/contractHost/vat-mint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

/* global harden */

import produceIssuer from '@agoric/ertp';
import makeIssuerKit from '@agoric/ertp';

function build(_E, _log) {
return harden({ produceIssuer });
return harden({ makeIssuerKit });
}
harden(build);

Expand Down
Loading