Skip to content

Commit

Permalink
Merge pull request #471 from rabbitholegg/mmackz/manifold/amount-zero
Browse files Browse the repository at this point in the history
fix(manifold): fix amount zero issue
  • Loading branch information
mmackz authored Aug 8, 2024
2 parents d0c87a2 + 9ce23a3 commit 367c590
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-fans-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/questdk-plugin-manifold": patch
---

fix amount zero issue
19 changes: 14 additions & 5 deletions packages/manifold/src/Manifold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
DEFAULT_ACCOUNT,
type MintIntentParams,
chainIdToViemChain,
formatAmount,
getExitAddresses,
getMintAmount,
} from '@rabbitholegg/questdk-plugin-utils'
import axios from 'axios'
import {
Expand Down Expand Up @@ -49,7 +51,7 @@ export const mint = async (
$abiAbstract: ABI_MULTI,
creatorContractAddress: contractAddress,
instanceId,
mintCount: amount,
mintCount: formatAmount(amount),
mintFor: recipient,
},
]
Expand Down Expand Up @@ -119,9 +121,17 @@ export const simulateMint = async (
const from = account ?? DEFAULT_ACCOUNT

const instanceId = await getInstanceId(chainId, contractAddress, tokenId ?? 1)
const mintAmount = getMintAmount(amount)

if (amount > 1) {
const mintArgs = [contractAddress, instanceId, amount, [], [], recipient]
if (mintAmount > 1n) {
const mintArgs = [
contractAddress,
instanceId,
mintAmount,
[],
[],
recipient,
]
try {
const result = await _client.simulateContract({
address: ERC1155_CONTRACT,
Expand Down Expand Up @@ -188,8 +198,7 @@ export const getFees = async (
tokenId ?? 1,
)

const quantityToMint =
typeof amount === 'number' ? BigInt(amount) : BigInt(1)
const quantityToMint = getMintAmount(amount)

if (instanceId) {
const response = await axios.get(
Expand Down

0 comments on commit 367c590

Please sign in to comment.