Skip to content

Commit

Permalink
feat(offers): fetch active orders
Browse files Browse the repository at this point in the history
  • Loading branch information
plondon committed Dec 27, 2021
1 parent 5ead33f commit fec1e45
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
getNftBuyOrders,
getNftSellOrder
} from '@core/redux/payment/nfts'
import { OPENSEA_SHARED_MARKETPLACE } from '@core/redux/payment/nfts/utils'
import { OPENSEA_SHARED_MARKETPLACE, WETH_ADDRESS } from '@core/redux/payment/nfts/utils'
import { Await } from '@core/types'
import { errorHandler } from '@core/utils'
import { getPrivateKey } from '@core/utils/eth'
Expand Down Expand Up @@ -528,12 +528,18 @@ export default ({ api }: { api: APIType }) => {
if (action.payload.offer) {
// User wants to cancel offer
if (action.payload.offer.from_account.address.toLowerCase() === ethAddr.toLowerCase()) {
const activeOrders = yield call(
api.getNftOrders,
undefined,
action.payload.offer.asset.asset_contract.address,
action.payload.offer.asset.token_id,
// TODO: rinkeby
WETH_ADDRESS,
0,
ethAddr
)
console.log(activeOrders)
debugger
// const activeOrder = yield call(
// api.getOrderByContractAndId,
// action.payload.offer.asset.asset_contract.address,
// action.payload.offer.asset.token_id
// )
yield put(A.setOrderFlowStep({ step: NftOrderStepEnum.CANCEL_OFFER }))
} else {
// User wants to accept offer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,55 +98,6 @@ const CancelOffer: React.FC<Props> = (props) => {
/>
</Value>
</Row>
<>
<Row>
<Title>
<b>
<FormattedMessage id='copy.amount' defaultMessage='Amount' />
</b>
</Title>
<Value>
<Field name='amount' component={NumberBox} />
</Value>
<Value>
<FiatDisplay size='12px' weight={600} coin={formValues.coin}>
{convertCoinToCoin({
baseToStandard: false,
coin: formValues.coin,
value: formValues.amount
}) || 0}
</FiatDisplay>
</Value>
</Row>
{activeOrder ? (
<Row>
<Title>
<FormattedMessage id='copy.current_price' defaultMessage='Current Price' />
</Title>
<Value>
<div style={{ display: 'flex' }}>
<CoinDisplay
size='14px'
color='black'
weight={600}
coin={activeOrder.paymentTokenContract?.symbol}
>
{activeOrder.basePrice}
</CoinDisplay>
&nbsp;-&nbsp;
<FiatDisplay
size='12px'
color='grey600'
weight={600}
coin={activeOrder.paymentTokenContract?.symbol}
>
{activeOrder.basePrice}
</FiatDisplay>
</div>
</Value>
</Row>
) : null}
</>
</Form>
{activeOrder ? (
<StickyCTA>
Expand All @@ -157,19 +108,9 @@ const CancelOffer: React.FC<Props> = (props) => {
fullwidth
data-e2e='makeOfferNft'
disabled={disabled}
onClick={() => nftActions.createOffer({ order: activeOrder, ...formValues })}
// onClick={() => nftActions.createOffer({ order: activeOrder, ...formValues })}
>
{formValues.amount ? (
<FormattedMessage
id='copy.mark_for_sale'
defaultMessage='Make an Offer for {val}'
values={{
val: `${formValues.amount} ${formValues.coin}`
}}
/>
) : (
<FormattedMessage id='copy.mark_for_sale' defaultMessage='Make an Offer' />
)}
<FormattedMessage id='copy.cancel_offer' defaultMessage='Cancel Offer' />
</Button>
</StickyCTA>
) : null}
Expand Down
7 changes: 5 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/nfts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ export default ({ apiUrl, get, post }) => {
token_ids: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
payment_token_address = '0x0000000000000000000000000000000000000000', // eth
side = 1 // 0 for buy, 1 for sell,
side = 1, // 0 for buy, 1 for sell
taker?: string
): NftOrdersType => {
return get({
endPoint: `/orders?asset_contract_address=${asset_contract_address}&sale_kind=0&bundled=false&include_bundled=false&include_invalid=false&is_english=false&side=${side}&limit=${limit}&token_ids=${token_ids}`,
endPoint: `/orders?asset_contract_address=${asset_contract_address}&payment_token_address=${payment_token_address}&sale_kind=0&bundled=false&include_bundled=false&include_invalid=false&is_english=false&side=${side}&limit=${limit}&token_ids=${token_ids}${
taker ? `&taker=${taker}` : ''
}`,
ignoreQueryParams: true,
url: `${explorerUrl}`
})
Expand Down
4 changes: 2 additions & 2 deletions packages/blockchain-wallet-v4/src/redux/payment/nfts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const DEFAULT_MAX_BOUNTY = DEFAULT_SELLER_FEE_BASIS_POINTS
export const ENJIN_ADDRESS = '0xfaaFDc07907ff5120a76b34b731b278c38d6043C'
export const ENJIN_COIN_ADDRESS = '0xf629cbd94d3791c9250152bd8dfbdf380e2a3b9c'
export const OPENSEA_SHARED_MARKETPLACE = '0x495f947276749ce646f68ac8c248420045cb7b5e'
const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
const WETH_ADDRESS_RINKEBY = '0xc778417E063141139Fce010982780140Aa0cD5Ab'
export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
export const WETH_ADDRESS_RINKEBY = '0xc778417E063141139Fce010982780140Aa0cD5Ab'
const WYVERN_TOKEN_PAYMENT_PROXY = '0xe5c783ee536cf5e63e792988335c4255169be4e1'
const WYVERN_TOKEN_PAYMENT_PROXY_RINKEBY = '0x82d102457854c985221249f86659c9d6cf12aa72'
const WYVERN_CONTRACT_ADDR_RINKEBY = '0x5206e78b21Ce315ce284FB24cf05e0585A93B1d9'
Expand Down

0 comments on commit fec1e45

Please sign in to comment.