Skip to content

Commit

Permalink
Merge pull request #505 from rabbitholegg/mmackz/update-amount-util-f…
Browse files Browse the repository at this point in the history
…unctions

refactor: use updated amount util functions
  • Loading branch information
mmackz authored Aug 8, 2024
2 parents 346b61e + b38b9f4 commit d3f2724
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .changeset/itchy-shoes-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@rabbitholegg/questdk-plugin-basepaint": patch
"@rabbitholegg/questdk-plugin-manifold": patch
"@rabbitholegg/questdk-plugin-moshicam": patch
"@rabbitholegg/questdk-plugin-fabric": patch
---

update mint util functions
4 changes: 2 additions & 2 deletions packages/basepaint/src/Basepaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@rabbitholegg/questdk'
import { type Address } from 'viem'
import { BASE_CHAIN_ID, CONTRACT_ADDRESS, MINT_ABI } from './constants'
import { formatAmount } from '@rabbitholegg/questdk-plugin-utils'
import { formatAmountToFilterOperator } from '@rabbitholegg/questdk-plugin-utils'

export const mint = async (
mint: MintActionParams,
Expand All @@ -18,7 +18,7 @@ export const mint = async (
input: {
$abi: MINT_ABI,
day: tokenId,
count: formatAmount(amount),
count: formatAmountToFilterOperator(amount),
},
})
}
Expand Down
10 changes: 5 additions & 5 deletions packages/fabric/src/Fabric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
Chains,
DEFAULT_ACCOUNT,
chainIdToViemChain,
getMintAmount,
formatAmountToInteger,
type MintIntentParams,
} from '@rabbitholegg/questdk-plugin-utils'
import {
Expand Down Expand Up @@ -38,7 +38,7 @@ export const mint = async (
throw new Error('Contract data not found')
}

const numTokens = minPurchaseSeconds * tps * getMintAmount(amount)
const numTokens = minPurchaseSeconds * tps * formatAmountToInteger(amount)

return compressJson({
chainId,
Expand Down Expand Up @@ -84,7 +84,7 @@ export const getFees = async (
throw new Error('Contract data not found')
}

const mintUnits = getMintAmount(amount)
const mintUnits = formatAmountToInteger(amount)

const mintCost = minPurchaseSeconds * tps * mintUnits

Expand All @@ -109,7 +109,7 @@ export const getMintIntent = async (
throw new Error('Contract data not found')
}

const mintArgs = [minPurchaseSeconds * tps * getMintAmount(amount)]
const mintArgs = [minPurchaseSeconds * tps * formatAmountToInteger(amount)]

const data = encodeFunctionData({
abi: FABRIC_MINT_ABI,
Expand Down Expand Up @@ -155,7 +155,7 @@ export const simulateMint = async (
throw new Error('Contract data not found')
}

const mintArgs = [minPurchaseSeconds * tps * getMintAmount(amount)]
const mintArgs = [minPurchaseSeconds * tps * formatAmountToInteger(amount)]

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

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

if (mintAmount > 1n) {
const mintArgs = [
Expand Down Expand Up @@ -198,7 +198,7 @@ export const getFees = async (
tokenId ?? 1,
)

const quantityToMint = getMintAmount(amount)
const quantityToMint = formatAmountToInteger(amount)

if (instanceId) {
const response = await axios.get(
Expand Down
12 changes: 6 additions & 6 deletions packages/moshicam/src/Moshicam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
DEFAULT_ACCOUNT,
type MintIntentParams,
chainIdToViemChain,
formatAmount,
getMintAmount,
formatAmountToFilterOperator,
formatAmountToInteger,
} from '@rabbitholegg/questdk-plugin-utils'
import {
type Address,
Expand All @@ -35,7 +35,7 @@ export const mint = async (
$abi: IMOSHI_PIC1155_ABI,
to: recipient,
id: tokenId,
quantity: formatAmount(amount),
quantity: formatAmountToFilterOperator(amount),
},
})
}
Expand All @@ -47,7 +47,7 @@ export const getMintIntent = async (

const tokenIdToMint = tokenId ? tokenId : 0

const quantityToMint = getMintAmount(amount)
const quantityToMint = formatAmountToInteger(amount)

const data = encodeFunctionData({
abi: IMOSHI_PIC1155_ABI,
Expand Down Expand Up @@ -77,7 +77,7 @@ export const getFees = async (
chain: chainIdToViemChain(chainId),
transport: http(),
})
const quantityToMint = getMintAmount(amount)
const quantityToMint = formatAmountToInteger(amount)
try {
const data = (await client.readContract({
address: contractAddress,
Expand Down Expand Up @@ -109,7 +109,7 @@ export const simulateMint = async (
throw new Error(`${chainId} is not supported`)
}

const amountToMint = getMintAmount(amount)
const amountToMint = formatAmountToInteger(amount)

const _client = (client ??
createPublicClient({
Expand Down

0 comments on commit d3f2724

Please sign in to comment.