-
Notifications
You must be signed in to change notification settings - Fork 238
RFQ-T Firm Quotes #162
RFQ-T Firm Quotes #162
Conversation
They're already deployed in the snapshot. No need to deploy them again.
To avoid trying to descend into docker-created folders, which are root-access-only when running in a Linux environment.
Because it's used (in the mocha invocation) and wasn't present after `yarn install`.
@steveklebanoff , @PirosB3 and I had a call where we went over this code together. Aside from the inline comments I've already made, we also generated this feedback:
|
src/services/swap_service.ts
Outdated
} = params; | ||
const assetSwapperOpts = { | ||
...ASSET_SWAPPER_MARKET_ORDERS_OPTS, | ||
slippagePercentage, | ||
bridgeSlippage: slippagePercentage, | ||
gasPrice: providedGasPrice, | ||
excludedSources, // TODO(dave4506): overrides the excluded sources selected by chainId | ||
apiKey, | ||
intentOnFilling, | ||
takerAddress: from, |
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.
Consider not conflating from
and takerAddress
. As you discovered, this is sometimes not often the case. I.e Via forwarder takerAddress
is the Forwarder, from is the end user.
What happens when the Forwarder is used? the takerAddress
in the order MUST be the Forwarder contract.
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 tried to account for this here: 0255b25. Does that address the issue?
Addresses review comment #162 (comment)
Just pass the API key through to the maker. Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Just pass the API key through to the maker. Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
Addresses review comment #162 (comment)
src/handlers/swap_handlers.ts
Outdated
req.query.intentOnFilling === undefined | ||
? undefined | ||
: { | ||
intentOnFilling: ['true', ''].includes(req.query.intentOnFilling) ? true : false, |
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 we just do something like the following?
const rfqt = req.query.intentOnFilling === 'true' ? { intentOnFilling: true } : 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.
I did some digging when I updated the schemas here. I had initially wanted to make them type: "boolean"
(whatever exactly that would mean!) but the jsonschema
package didn't handle that nicely. Later discovered this question which is a good analog to what we're doing here: OAI/OpenAPI-Specification#1782
I changed this here because I liked the idea of the mere presence of this flag indicating it should be true, eg /quote?intentOnFilling&...
.
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.
How we resolve #162 (comment) will impact this
src/handlers/swap_handlers.ts
Outdated
}; | ||
// tslint:disable-next-line:boolean-naming | ||
const skipValidation = | ||
req.query.skipValidation === undefined ? false : ['true', ''].includes(req.query.skipValidation) ? true : false; |
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 do we want to consider req.query.skipValidation === ''
as true?
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.
Same logic behind my recent change to intentOnFilling
. I think it makes logical sense to be able to say just /quote?skipValidation&...
, and when that's the query string, req.query
here contains "skipValidation": ""
.
"type": "string" | ||
}, | ||
"intentOnFilling": { | ||
"type": "string", |
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 we use a boolean
type here? http://json-schema.org/understanding-json-schema/reference/boolean.html
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 wanted to. I tried. jsonschema
choked on it.
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.
At test runtime i get this json schema error
{\"field\":\"instance.intentOnFilling\",\"code\":1001,\"reason\":\"is not of a type(s) boolean\"}
This happened no matter whether my client said quote?intentOnFilling
or quote?intenOnFilling=true
.
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.
Got it.
I think this schema could be cleaner if we:
- get rid of the
flag
functionality (i.e. setting?intentOnFilling
indicating thatintentOnFilling
is equal totrue
). I have not seen this used in query parameters before, and IMHO is not super important to support - Use an
enum
type to force the consumer of the API to specify the texttrue
,false
for our 'boolean' params (intentOnFilling, skipValidaiton). (See https://stackoverflow.com/a/16826238 and https://json-schema.org/understanding-json-schema/reference/generic.html#enumerated-values- Make sure to keep specifying these params optional though
This would allow ?skipValidation=truue
to raise a schema error instead of silently being set to false
on our backend.
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.
How's this: bb2814a
Addresses review comments #162 (comment) and #162 (comment)
Addresses review comments #162 (comment) and #162 (comment)
? undefined | ||
: { | ||
...rfqt, | ||
takerAddress: isETHSell ? getContractAddressesForChainOrThrow(CHAIN_ID).forwarder : from, |
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.
Would be good to add a comment describing what's happening 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.
Addressed in 03f7673
@@ -120,7 +140,7 @@ export class SwapService { | |||
const affiliatedData = this._attributeCallData(data, affiliateAddress); | |||
|
|||
let suggestedGasEstimate = new BigNumber(gas); | |||
if (from) { | |||
if (!skipValidation && from) { |
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.
👍
LGTM pending:
|
* generate source maps * abstract tests out into nested contexts * test for skipping validation * dont include order for maker who does not have allowances set * bad api key test * fix test names and explicitly deposit so taker can fill
Addresses the following review comments: - #162 (comment) - #162 (comment) - #162 (comment)
Addresses review comment #162 (comment)
Addresses the following review comments: - #162 (comment) - #162 (comment) - #162 (comment)
Addresses review comment #162 (comment)
This reverts commit 08f4d31.
This reverts commit 7c448d3.
Pin to a gitpkg publish of the monorepo dependencies changed to support this PR to a commit hash of the development branch, rather than that of my PR branch.
I published a custom ganache image, with a monorepo commit hash appended to the version number for reference.
deploy kovan-staging |
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!
src/handlers/swap_handlers.ts
Outdated
const rfqt = | ||
req.query.intentOnFilling === undefined | ||
? undefined | ||
: { intentOnFilling: req.query.intentOnFilling === 'true' ? true : false }; |
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.
Nit but can't this just be { intentOnFilling: req.query.intentOnFilling === 'true' }
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.
Addressed in 735fe3e
}, | ||
"skipValidation": { | ||
"type": "string", | ||
"allowEmptyValue": true | ||
"enum": ["true", "false"] |
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 PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
These changes depend on the changes in 0xProject/0x-monorepo#2541 .
Every commit is crafted to be completely independent and atomic. I suggest you review them one at a time, in order to give better context, rather than just reviewing all of the changes at once.
The following commits should be removed before merging:
TEMPORARY: Update gitpkg monorepo references
, 26d8527TEMPORARY: use gene's ganache snapshot for tests
, 0b09babChecklist: