-
Notifications
You must be signed in to change notification settings - Fork 206
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
fix(zcf): mint kind during reincarnation #7508
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,14 @@ import './types.js'; | |
|
||
const { Fail } = assert; | ||
|
||
export const makeZCFMintFactory = async ( | ||
zcfBaggage, | ||
recordIssuer, | ||
getAssetKindByBrand, | ||
makeEmptySeatKit, | ||
reallocator, | ||
export const makeZCFMintFactory = ( | ||
/** @type {import('@agoric/vat-data').Baggage} */ zcfBaggage, | ||
/** @type {{ (keyword: string, issuerRecord: IssuerRecord): void }} */ recordIssuer, | ||
/** @type {GetAssetKindByBrand} */ getAssetKindByBrand, | ||
/** @type { (exit?: undefined) => { zcfSeat: any; userSeat: Promise<UserSeat> }} */ makeEmptySeatKit, | ||
/** @type {ZcfMintReallocator} */ reallocator, | ||
) => { | ||
/** @type {SetStore<ZCFMint>} The set of baggages for zcfMints */ | ||
/** @type {SetStore<import('@agoric/vat-data').Baggage>} The set of baggages for zcfMints */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way to make this type more specific, to declare that it holds a set of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be pretty awkward since a MapStore allows any keys. We could have a subtype that maintains a list of keyname to type mappings and conditions |
||
const zcfMintBaggageSet = provideDurableSetStore(zcfBaggage, 'baggageSet'); | ||
|
||
/** | ||
|
@@ -34,15 +34,14 @@ export const makeZCFMintFactory = async ( | |
* | ||
* @param {import('@agoric/vat-data').Baggage} zcfMintBaggage | ||
*/ | ||
const provideDurableZcfMint = async zcfMintBaggage => { | ||
const provideDurableZcfMint = zcfMintBaggage => { | ||
const keyword = zcfMintBaggage.get('keyword'); | ||
const zoeMint = zcfMintBaggage.get('zoeMint'); | ||
const { | ||
brand: mintyBrand, | ||
issuer: mintyIssuer, | ||
displayInfo: mintyDisplayInfo, | ||
} = await E(zoeMint).getIssuerRecord(); | ||
// AWAIT | ||
} = zcfMintBaggage.get('issuerRecord'); | ||
const mintyIssuerRecord = makeIssuerRecord( | ||
mintyBrand, | ||
mintyIssuer, | ||
|
@@ -126,12 +125,6 @@ export const makeZCFMintFactory = async ( | |
); | ||
}; | ||
|
||
const makeDurableZcfMint = async (keyword, zoeMint, zcfMintBaggage) => { | ||
zcfMintBaggage.init('keyword', keyword); | ||
zcfMintBaggage.init('zoeMint', zoeMint); | ||
return provideDurableZcfMint(zcfMintBaggage); | ||
}; | ||
|
||
const ZCFMintFactoryI = M.interface('ZCFMintFactory', { | ||
makeZCFMintInternal: M.call(M.string(), M.remotable('ZoeMint')).returns( | ||
M.promise(), | ||
|
@@ -150,21 +143,24 @@ export const makeZCFMintFactory = async ( | |
ZCFMintFactoryI, | ||
{ | ||
async makeZCFMintInternal(keyword, zoeMint) { | ||
const issuerRecord = await E(zoeMint).getIssuerRecord(); | ||
|
||
const zcfMintBaggage = makeScalarBigMapStore('zcfMintBaggage', { | ||
durable: true, | ||
}); | ||
const zcfMint = await makeDurableZcfMint( | ||
keyword, | ||
zoeMint, | ||
zcfMintBaggage, | ||
); | ||
zcfMintBaggageSet.add(zcfMint); | ||
return zcfMint; | ||
|
||
zcfMintBaggage.init('issuerRecord', issuerRecord); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works, but it now looks awfully like per- But, probably out of scope for this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I'll follow up with that. |
||
zcfMintBaggage.init('keyword', keyword); | ||
zcfMintBaggage.init('zoeMint', zoeMint); | ||
zcfMintBaggageSet.add(zcfMintBaggage); | ||
|
||
return provideDurableZcfMint(zcfMintBaggage); | ||
}, | ||
}, | ||
); | ||
|
||
for (const zcfMintBaggage of zcfMintBaggageSet.values()) { | ||
// call for side-effect of redefining the kinds | ||
provideDurableZcfMint(zcfMintBaggage); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,10 @@ export const makeZCFZygote = async ( | |
// Make the instanceRecord | ||
const makeInstanceRecord = makeInstanceRecordStorage(zcfBaggage); | ||
|
||
const recordIssuer = (keyword, issuerRecord) => { | ||
const recordIssuer = ( | ||
/** @type {string} */ keyword, | ||
/** @type {IssuerRecord} */ issuerRecord, | ||
Comment on lines
+94
to
+95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
) => { | ||
getInstanceRecHolder().addIssuer(keyword, issuerRecord); | ||
storeIssuerRecord(issuerRecord); | ||
}; | ||
|
@@ -332,7 +335,7 @@ export const makeZCFZygote = async ( | |
zcfBaggage, | ||
)); | ||
|
||
zcfMintFactory = await makeZCFMintFactory( | ||
zcfMintFactory = makeZCFMintFactory( | ||
zcfBaggage, | ||
recordIssuer, | ||
getAssetKindByBrand, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a radical shift in style from
@param
. Why? At least at first, I do not find it more readable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the style that "infer params from usage" automates. I think it's worth allowing because it removes the need to repeat the parameter name.