开始出售方法增加过期时间参数

This commit is contained in:
CounterFire2023 2024-06-24 16:52:57 +08:00
parent 06c00e8a9a
commit ccfa3b599e
3 changed files with 12 additions and 5 deletions

View File

@ -12,3 +12,4 @@ VUE_APP_PASSPORT_MARKET_ADDRESS=0x7d117aA8BD6D31c4fa91722f246388f38ab1942c
VUE_APP_MKT_API='https://market-test.kingsome.cn'
VUE_APP_NET_ID='13473'
VUE_APP_MARKET_CURRENCY='0xFd42bfb03212dA7e1A4608a44d7658641D99CF34'
VUE_APP_MAKEFEE_ADDRESS='0x50A8e60041A206AcaA5F844a1104896224be6F39'

View File

@ -74,7 +74,7 @@ const addCart = async (val) => {
tokens: [
{
token_id: val.nft.token_id,
token_type: val.nft.type,
contract_address: val.nft.contract_address,
}
]
}

View File

@ -8,6 +8,7 @@ const clientId = import.meta.env.VUE_APP_PASSPORT_CLIENT_ID
const redirectUri = import.meta.env.VUE_APP_PASSPORT_REDIRECT_URI
const logoutRedirectUri = import.meta.env.VUE_APP_PASSPORT_LOGOUT_URI
const marketAddress = import.meta.env.VUE_APP_PASSPORT_MARKET_ADDRESS
const makeFeeAddress = import.meta.env.VUE_APP_MAKEFEE_ADDRESS
const NATIVE = 'NATIVE'
const ERC20 = 'ERC20'
@ -63,6 +64,7 @@ class LPassportWallet {
this.web3Provider = new providers.Web3Provider(passportProvider);
this.signer = this.web3Provider.getSigner();
const accounts = await passportProvider.request({ method: "eth_requestAccounts" })
console.log('address: ', accounts)
const accessToken = await this.passportInstance.getAccessToken();
console.log('accessToken:', accessToken)
// const idToken = await passportInstance.getIdToken();
@ -91,7 +93,7 @@ class LPassportWallet {
* 准备一个ERC721的挂单
* @returns
*/
async _prepareERC721Listing({ contractAddress, tokenId, type = 'ERC721', currencyAddress, currencyAmount}){
async _prepareERC721Listing({ contractAddress, tokenId, type = 'ERC721', currencyAddress, currencyAmount, orderExpiry}){
const offerer = await this.signer.getAddress();
const buyData = {
amount: currencyAmount,
@ -110,6 +112,7 @@ class LPassportWallet {
tokenId,
type,
},
orderExpiry
});
console.log(preparedListing.actions)
let orderSignature = ''
@ -155,7 +158,7 @@ class LPassportWallet {
// Optional maker marketplace fee
makerFees: [{
amount,
recipientAddress: marketAddress, // Replace address with your own marketplace address
recipientAddress: makeFeeAddress, // Replace address with your own marketplace address
}],
});
console.log('order:', order);
@ -169,10 +172,11 @@ class LPassportWallet {
* @param {string} tokenId NFT的tokenId
* @param {string} currencyAddress NATIVE 或者 ERC20的合约地址
* @param {string} currencyAmount 出售价格, 单位 wei
* @param {Date} orderExpiry 过期时间
*/
async beginSellERC721({contractAddress, tokenId, currencyAddress, currencyAmount}) {
async beginSellERC721({contractAddress, tokenId, currencyAddress, currencyAmount, orderExpiry}) {
const { preparedListing, orderSignature } =
await this._prepareERC721Listing({contractAddress, tokenId, currencyAddress, currencyAmount});
await this._prepareERC721Listing({contractAddress, tokenId, currencyAddress, currencyAmount, orderExpiry});
const order = await this._createListing(preparedListing, orderSignature, currencyAmount);
return order
}
@ -233,6 +237,8 @@ class LPassportWallet {
console.log(
`Fulfilling listings ${fulfillableOrders}, transaction expiry ${expiration}`
);
} else {
throw new Error('insufficint balance')
}
} catch (e) {
console.error(`Fulfill bulk orders request failed with ${e}`);