-
Notifications
You must be signed in to change notification settings - Fork 220
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
Updates for oracle bootstrap #4891
Conversation
f686c2a
to
aa965c0
Compare
3d15399
to
55eeddc
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.
@turadg, please review the AmountKind change and the contract updates.
Done. Thanks for the instructions and clean commits.
packages/wallet/api/src/wallet.js
Outdated
@@ -238,8 +238,8 @@ export function buildRootObject(vatPowers) { | |||
* @type {WalletBridge} | |||
*/ | |||
const preapprovedBridge = Far('preapprovedBridge', { | |||
addOffer(offer) { | |||
return walletAdmin.addOffer(offer); | |||
addOffer(offer, meta = 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.
jsdoc better for optional.
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, I added a jsdoc to it. How do I indicate to the reader of this code (who isn't using Typescript) that the meta argument is optional without overriding the underlying default?
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.
https://jsdoc.app/tags-param.html#optional-parameters-and-default-values
I don't know the types of those params so improvising:
/**
* @param {Offer} offer
* @param {Meta} [meta]
*/
addOffer(offer, meta) {
(default values can be specified with =
but [meta=undefined]
I think is redundant because undefined
is what any param without an argument resolves to)
// See if we have associated parameters or just a raw value. | ||
const data = value.data || value; |
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 would it be one or the other?
} | ||
|
||
// Adapt the notifier to push results. | ||
const recurse = ({ value, updateCount }) => { |
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'm not clear on what value
can be. A type annotation would help. Is value
readonly?
const scaledData = Math.floor(parseInt(data, 10) * scaleValueOut); | ||
const newData = BigInt(scaledData); | ||
|
||
if (value.data) { |
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.
line 268 sort of also has this condition. consider making one conditional:
const scaleData = (data) => BigInt(Math.floor(parseInt(data, 10) * scaleValueOut));
let result;
if (value.data) {
// We have some associated parameters to push.
result = { ...value, data: scaleData(value.data) };
} else {
result = scaleData(value);
}
admin.pushResult(result).catch(console.error);
|
||
return zcf.makeInvitation(offerHandler, 'oracle invitation'); | ||
}, | ||
async initOracle(oracleInstance = undefined, query = 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.
ditto on jsdoc as way to expression optional param
assert(quoteKit, X`Must initializeQuoteMint before adding an oracle`); | ||
|
||
const oracleKey = oracleInstance || Far('fresh key'); |
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 understand this "fresh key". Will be be fresh each time it's constructed?
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. Every call to Far
creates a new object identity. I was leaning on default arguments to the Far
function, but have made it more explicit now.
/** @type {LegacyMap<Instance, Set<OracleRecord>>} */ | ||
const instanceToRecords = makeLegacyMap('oracleInstance'); | ||
/** | ||
* @typedef {{}} OracleKey |
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.
because TS is structurally typed, this make the type just documentation. Reading above it looks like
* @typedef {{}} OracleKey | |
* @typedef {Instance | Remotable<'fresh key'> } OracleKey |
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 is the type of an object without properties, which is what I want to indicate. Maybe this is where JSDoc types diverge from TS interfaces?
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 is the type of an object without properties, which is what I want to indicate.
In that case, 👍 . I assumed an OracleKey
was something more specific than an object without properties.
Maybe this is where JSDoc types diverge from TS interfaces?
I'm not aware of any divergences.
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 looked at each commit. I'm not quite confident enough to approve. I'd like to see responses to some of my questions or maybe talk about it with you.
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 looks like forward progress, to me.
I trust you'll consider @turadg 's comments as well.
3824d92
to
d1c10bc
Compare
refs: #3595
Description
Several changes needed for bootstrapping the oracle price feeds. Aside from the price aggregator mechanics, here are some of the additional tweaks:
startPriceAuthority
into pre-economy bootstrapSecurity Considerations
Documentation Considerations
Testing Considerations
Being tested with third parties as part of the oracle bootstrap process.