-
Notifications
You must be signed in to change notification settings - Fork 205
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
feat: add the ability for a contract to get a synchronous seat #1389
Conversation
c5379cb
to
9db00c7
Compare
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.
I think we don't want to burn the associated assets, and will need a way to get the payouts. I think the seats made this way should be indistinguishable from other seats after being made - there should be an associated UserSeat that gets made.
packages/zoe/src/zoeService/zoe.js
Outdated
const instanceAdmin = instanceToInstanceAdmin.get(instance); | ||
instanceAdmin.removeZoeSeatAdmin(seatAdmin); | ||
|
||
// burn the holdings to keep Zoe's book straight |
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.
I don't think we ever want to burn the holdings - the contract or someone else probably wants them
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.
okay. Made available to contract. This needs a test.
packages/zoe/src/zoeService/zoe.js
Outdated
|
||
const { notifier, updater } = makeNotifierKit(); | ||
|
||
const seatAdmin = { |
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.
I think we should use the same seatAdmin code and not have duplication here
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.
done
packages/zoe/src/zoeService/zoe.js
Outdated
@@ -209,6 +209,34 @@ function makeZoe(vatAdminSvc) { | |||
brandToPurse.init(brand, E(issuer).makeEmptyPurse()); | |||
} | |||
}), | |||
makeEmptySeat: (keyword, initialAllocation) => { |
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.
If it is an empty seat, why does it have an initial allocation?
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.
dropped
|
||
E(zoeInstanceAdmin) | ||
.makeEmptySeat(keyword, initialAllocation, proposal) | ||
.then(({ seatAdmin: zoeSeatAdmin, seatData }) => { |
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.
Let's call this the ZoeSeatAdmin in the returned object too. It's called that in Zoe.
}); | ||
const { zcfSeat, zcfSeatAdmin } = makeSeatAdmin( | ||
allSeatStagings, | ||
zoeSeatAdminPromiseKit.promise, |
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.
Nice, since this is remote anyways, and we need to call E(zoeSeatAdmin), we can use a promise. Cool!
@@ -225,6 +241,33 @@ export function buildRootObject() { | |||
issuerTable.getIssuerRecordByIssuer(issuer).brand, | |||
getAmountMath, | |||
makeZCFMint, | |||
addEmptySeat: keyword => { |
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.
why is there a keyword?
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 gone now.
9db00c7
to
7ab7d0e
Compare
3554262
to
4585c45
Compare
7ab7d0e
to
3f4b02d
Compare
zcf.addEmptySeat() would return a zcfSeat that the contract could use to hold allocations. untested
drop keyword parameter in addEmptySeat() extract makeZoeSeatAdminKit, use it for emptySeat, too. rename zcf seat construction to use 'Kit'
3f4b02d
to
5235f5b
Compare
@@ -164,6 +166,20 @@ export function buildRootObject() { | |||
return zcfMint; | |||
}; | |||
|
|||
function updateNotiferFrom(updater, notifier, nextCount = undefined) { |
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.
Can you just use updateFromNotifier
in packages/notifier
?
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.
yes, of course.
@@ -164,6 +166,20 @@ export function buildRootObject() { | |||
return zcfMint; | |||
}; | |||
|
|||
function updateNotiferFrom(updater, notifier, nextCount = undefined) { | |||
notifier.getUpdateSince(nextCount).then( |
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.
Isn't this notifier
actually a reference to a remote notifier, the one in the zoe vat? If so, this would need to be E(notifier).
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.
moot.
packages/zoe/src/internal-types.js
Outdated
@@ -64,7 +64,7 @@ | |||
|
|||
/** | |||
* Make the ZCF seat and seat admin | |||
* @callback MakeSeatAdmin | |||
* @callback MakeZcfSeatAdmin |
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.
MakeZcfSeatAdminKit
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.
done.
packages/zoe/src/zoeService/zoe.js
Outdated
@@ -207,35 +230,24 @@ function makeZoe(vatAdminSvc) { | |||
brandToPurse.init(brand, E(issuer).makeEmptyPurse()); | |||
} | |||
}), | |||
makeEmptySeat: (initialAllocation, proposal) => { |
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.
I like the generality of leaving it up to zcf to determine the initialAllocation
and proposal
. But in that case, this method needs a new name.
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.
I see it returns a kit so its name should reflect that too.
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.
makeOfferlessSeat is my starting point.
packages/zoe/src/zoeService/zoe.js
Outdated
const offerResultPromiseKit = makePromiseKit(); | ||
const exitObjPromiseKit = makePromiseKit(); | ||
const { notifier, updater } = makeNotifierKit(); | ||
let currentAllocation = initialAllocation; | ||
|
||
const instanceAdmin = instanceToInstanceAdmin.get(instance); | ||
|
||
/** @type {ZoeSeatAdmin} */ |
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.
ZoeSeatAdminKit
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.
moved
packages/zoe/src/zoeService/zoe.js
Outdated
@@ -207,35 +230,24 @@ function makeZoe(vatAdminSvc) { | |||
brandToPurse.init(brand, E(issuer).makeEmptyPurse()); | |||
} | |||
}), | |||
makeEmptySeat: (initialAllocation, proposal) => { |
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.
Add a declaration of makeEmptySeat
(or whatever it's called) to the ZoeInstanceAdmin
type.
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.
Yup
brandToPurse, | ||
promises = {}, | ||
) => { | ||
const payoutPromiseKit = promises.payout || makePromiseKit(); |
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 payout
option is unused. Is it needed?
import { assert } from '@agoric/assert'; | ||
import { E } from '@agoric/eventual-send'; | ||
|
||
export const makeZoeSeatAdminKit = ( |
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.
Good. Pulling this out into a separately reusable function made everything better.
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.
Not quite everything, but it did help a lot.
@@ -256,15 +258,44 @@ export function buildRootObject() { | |||
issuerTable.getIssuerRecordByIssuer(issuer).brand, | |||
getAmountMath, | |||
makeZCFMint, | |||
addEmptySeat: () => { |
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.
Does addEmptySeat
sound like it's adding one that already exists?
Should it be makeEmptySeatKit
?
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.
I don't much like the name here for a user-facing method, but it fits our model for a makeFooKit
, so done.
improved type annotations rename makeEmptySeat to makeOfferlessSeat don't return the zcfSeatAdmin to the contract
397de87
to
0b761fe
Compare
This is good enough to merge to the branch.
zcf.addEmptySeat() would return a zcfSeat that the contract could use
to hold allocations.
untested