Merge pull request #180 from public-awesome/account-for-zero-airdrop-fee

This commit is contained in:
Jorge Hernandez 2023-06-22 18:58:50 -06:00 committed by GitHub
commit 7b18cffe87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -361,7 +361,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.', 'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
) )
} }
console.log((Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)) / 100) const airdropFee = Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)
const res = await client.execute( const res = await client.execute(
senderAddress, senderAddress,
contractAddress, contractAddress,
@ -370,12 +370,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
}, },
'auto', 'auto',
'', '',
[ airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
coin(
(Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)) / 100 / 100,
'ustars',
),
],
) )
return res.transactionHash return res.transactionHash
}) })
@ -396,7 +391,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.', 'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
) )
} }
const airdropFee = Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)
const executeContractMsgs: MsgExecuteContractEncodeObject[] = [] const executeContractMsgs: MsgExecuteContractEncodeObject[] = []
for (let i = 0; i < batchNumber; i++) { for (let i = 0; i < batchNumber; i++) {
const msg = { const msg = {
@ -408,12 +403,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
sender: senderAddress, sender: senderAddress,
contract: contractAddress, contract: contractAddress,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [ funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
coin(
(Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)) / 100 / 100,
'ustars',
),
],
}), }),
} }
@ -441,7 +431,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.', 'Unable to retrieve a valid airdrop mint price. It may be that the given contract address does not belong to a Open Edition Factory.',
) )
} }
const airdropFee = Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)
const executeContractMsgs: MsgExecuteContractEncodeObject[] = [] const executeContractMsgs: MsgExecuteContractEncodeObject[] = []
for (let i = 0; i < recipients.length; i++) { for (let i = 0; i < recipients.length; i++) {
const msg = { const msg = {
@ -453,12 +443,7 @@ export const openEditionMinter = (client: SigningCosmWasmClient, txSigner: strin
sender: senderAddress, sender: senderAddress,
contract: contractAddress, contract: contractAddress,
msg: toUtf8(JSON.stringify(msg)), msg: toUtf8(JSON.stringify(msg)),
funds: [ funds: airdropFee > 0 ? [coin(airdropFee / 100 / 100, 'ustars')] : [],
coin(
(Number(price) * Number(factoryParameters.params.extension?.airdrop_mint_fee_bps)) / 100 / 100,
'ustars',
),
],
}), }),
} }