Skip to content

Commit

Permalink
allow withdraw from frame/deadreare + add banner in collectionInfo st…
Browse files Browse the repository at this point in the history
…ats query
  • Loading branch information
mihaieremia committed Aug 13, 2024
1 parent df6c283 commit c5d4f45
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
81 changes: 60 additions & 21 deletions src/interactions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Interaction } from '@multiversx/sdk-core/out'
import { Interaction } from '@multiversx/sdk-core/out'
import { BytesValue, VariadicValue } from '@multiversx/sdk-core/out'
import { Address } from '@multiversx/sdk-core/out/address'
import type { IPlainTransactionObject } from '@multiversx/sdk-core/out/interface'
Expand Down Expand Up @@ -334,7 +334,7 @@ export class SCInteraction {
sender: WithSenderAndNonce
signature?: string
market?: string
}): IPlainTransactionObject {
}): IPlainTransactionObject[] {
if (market === 'xoxno') {
const interaction = this.xo.methodsExplicit.withdraw([
BytesValue.fromHex(signature!),
Expand All @@ -344,14 +344,50 @@ export class SCInteraction {
if (sender.nonce) {
interaction.withNonce(sender.nonce)
}
return interaction
return [interaction
.withChainID(this.api.chain)
.withSender(new Address(sender.address))
.withGasLimit(
Math.min(600_000_000, 25_000_000 + auctionIDs.length * 8_000_000)
)
.buildTransaction()
.toPlainObject()
.toPlainObject()];
} else if (market == 'frameit') {
return auctionIDs.map((auction_id, index) => {
const interaction = this.xo.methodsExplicit.withdraw([
new U64Value(auction_id),
])
if (sender.nonce) {
interaction.withNonce(sender.nonce + index)
}
return interaction
.withChainID(this.api.chain)
.withSender(new Address(sender.address))
.withGasLimit(
Math.min(600_000_000, 25_000_000)
)
.withExplicitReceiver(new Address(this.config.FM_SC))
.buildTransaction()
.toPlainObject();
})
} else if (market == 'deadrare') {
return auctionIDs.map((auction_id, index) => {
const interaction = this.xo.methodsExplicit.withdraw([
new U64Value(auction_id),
])
if (sender.nonce) {
interaction.withNonce(sender.nonce + index)
}
return interaction
.withChainID(this.api.chain)
.withSender(new Address(sender.address))
.withGasLimit(
Math.min(600_000_000, 25_000_000)
)
.withExplicitReceiver(new Address(this.config.DR_SC))
.buildTransaction()
.toPlainObject();
})
} else {
throw new Error('Market not supported')
}
Expand All @@ -366,8 +402,10 @@ export class SCInteraction {

public withdrawGlobalOffer(
offerID: number,
market = "xoxno",

Check failure on line 405 in src/interactions/index.ts

View workflow job for this annotation

GitHub Actions / publish

'market' is declared but its value is never read.
senderNonce: WithSenderAndNonce
): IPlainTransactionObject {

const interaction = this.xo.methods.withdrawGlobalOffer([offerID])

if (senderNonce.nonce) {
Expand All @@ -379,6 +417,7 @@ export class SCInteraction {
.withGasLimit(20_000_000)
.buildTransaction()
.toPlainObject()

}

/**
Expand All @@ -402,10 +441,10 @@ export class SCInteraction {
}
const interaction = signature
? this.xo.methods.acceptGlobalOffer([
offer_id,
auction_ids_opt,
signature,
])
offer_id,
auction_ids_opt ?? [],
signature,
])
: this.xo.methods.acceptGlobalOffer([offer_id, auction_ids_opt])
interaction.withSender(new Address(address))
if (nfts.length > 0) {
Expand All @@ -423,8 +462,8 @@ export class SCInteraction {
.withGasLimit(
Math.min(
35_000_000 +
(nfts.length + auction_ids_opt.length) * 7_000_000 +
(signature == undefined ? 15_000_000 : 0),
(nfts.length + auction_ids_opt.length) * 7_000_000 +
(signature == undefined ? 15_000_000 : 0),
600_000_000
)
)
Expand Down Expand Up @@ -687,14 +726,14 @@ export class SCInteraction {
tokenTransfers: isEgld
? undefined
: [
new TokenTransfer({
token: new Token({
identifier: payment.collection,
nonce: BigInt(payment.nonce ?? 0),
}),
amount: BigInt(payment.amount),
new TokenTransfer({
token: new Token({
identifier: payment.collection,
nonce: BigInt(payment.nonce ?? 0),
}),
],
amount: BigInt(payment.amount),
}),
],
})

if (sender.nonce) {
Expand Down Expand Up @@ -845,11 +884,11 @@ export class SCInteraction {
interaction.withValue(
bigNumber
? TokenTransfer.egldFromBigInteger(
new BigNumber(amount).multipliedBy(quantity)
)
new BigNumber(amount).multipliedBy(quantity)
)
: TokenTransfer.egldFromAmount(
new BigNumber(amount).multipliedBy(quantity)
)
new BigNumber(amount).multipliedBy(quantity)
)
)
} else {
if (!bigNumber) {
Expand Down
1 change: 1 addition & 0 deletions src/types/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ export type CollectionStatsDoc = {
// applied after db call
collectionInfo?: {
name?: string
banner?: string
description?: string
isVerified: boolean
isVisible: boolean
Expand Down

0 comments on commit c5d4f45

Please sign in to comment.