-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add getIssuerForBrand to zoe (#1276)
* zoe: add getIssuerForBrand * zoeHelpers: print more info when offer safety is violated * zoe: better assert when offerHandles is not an Array * feat: add getIssuerFromBrand to zoe * feat: add getIssuerFromBrand to zoe * feat: `addPool` now returns useful pool controls `addPool` returns the secondary token issuers, new liquidity issuers and such. * chore: es-lint fixes. * chore: add test Co-authored-by: Brian Warner <[email protected]> Co-authored-by: Kate Sills <[email protected]>
- Loading branch information
1 parent
2c506a2
commit 4fe3c83
Showing
6 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* global harden */ | ||
|
||
import '@agoric/install-ses'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { test } from 'tape-promise/tape'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import bundleSource from '@agoric/bundle-source'; | ||
|
||
import { makeZoe } from '../../../src/zoe'; | ||
import { setup } from '../setupBasicMints'; | ||
|
||
const contractRoot = `${__dirname}/zcfTesterContract`; | ||
|
||
test('zoe - test zcf', async t => { | ||
t.plan(1); | ||
const { moolaIssuer, simoleanIssuer } = setup(); | ||
const zoe = makeZoe(); | ||
|
||
// pack the contract | ||
const bundle = await bundleSource(contractRoot); | ||
// install the contract | ||
const installationHandle = await zoe.install(bundle); | ||
|
||
// Alice creates an instance | ||
const issuerKeywordRecord = harden({ | ||
Pixels: moolaIssuer, | ||
Money: simoleanIssuer, | ||
}); | ||
t.doesNotReject(() => | ||
zoe.makeInstance(installationHandle, issuerKeywordRecord), | ||
); | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/zoe/test/unitTests/contracts/zcfTesterContract.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* global harden */ | ||
// @ts-check | ||
|
||
import { assert } from '@agoric/assert'; | ||
|
||
/** | ||
* Tests ZCF | ||
* | ||
* @typedef {import('../../../src/zoe').ContractFacet} ContractFacet | ||
* @typedef {import('@agoric/ERTP').Amount} Amount | ||
* @param {ContractFacet} zcf | ||
*/ | ||
const makeContract = zcf => { | ||
const { brandKeywordRecord, issuerKeywordRecord } = zcf.getInstanceRecord(); | ||
Object.keys(brandKeywordRecord).forEach(keyword => { | ||
// TODO: import tap/tape and do t.equals | ||
assert.equal( | ||
zcf.getIssuerForBrand(brandKeywordRecord[keyword]), | ||
issuerKeywordRecord[keyword], | ||
); | ||
}); | ||
return zcf.makeInvitation(() => {}, 'test'); | ||
}; | ||
|
||
harden(makeContract); | ||
export { makeContract }; |