-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7130 from Agoric/6694-kernel-disconnect-promises
fix(SwingSet): move promise rejection from stopVat to the kernel
- Loading branch information
Showing
27 changed files
with
1,099 additions
and
581 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
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,40 @@ | ||
import { Far } from '@endo/marshal'; | ||
import { getCopyMapEntries, M } from '@agoric/store'; | ||
import { makePromiseKit } from '@endo/promise-kit'; | ||
import { | ||
prepareExo, | ||
provideDurableMapStore, | ||
watchPromise, | ||
} from '@agoric/vat-data'; | ||
|
||
export function buildRootObject(_vatPowers, vatParameters, baggage) { | ||
const settlements = provideDurableMapStore(baggage, 'settlements'); | ||
const PromiseWatcherI = M.interface('PromiseWatcher', { | ||
onFulfilled: M.call(M.any(), M.string()).returns(), | ||
onRejected: M.call(M.any(), M.string()).returns(), | ||
}); | ||
const watcher = prepareExo(baggage, 'PromiseWatcher', PromiseWatcherI, { | ||
onFulfilled(value, name) { | ||
settlements.init(name, harden({ status: 'fulfilled', value })); | ||
}, | ||
onRejected(reason, name) { | ||
settlements.init(name, harden({ status: 'rejected', reason })); | ||
}, | ||
}); | ||
|
||
return Far('root', { | ||
watchLocalPromise: (name, fulfillment, rejection) => { | ||
const { promise, resolve, reject } = makePromiseKit(); | ||
if (fulfillment !== undefined) { | ||
resolve(fulfillment); | ||
} else if (rejection !== undefined) { | ||
reject(rejection); | ||
} | ||
watchPromise(promise, watcher, name); | ||
}, | ||
getSettlements: () => { | ||
const settlementsCopyMap = settlements.snapshot(); | ||
return Object.fromEntries(getCopyMapEntries(settlementsCopyMap)); | ||
}, | ||
}); | ||
} |
Oops, something went wrong.