Skip to content

Commit

Permalink
Merge pull request #279 from public-awesome/fetch-creation-fees
Browse files Browse the repository at this point in the history
Fetch collection creation fees from factory parameters
  • Loading branch information
shanev authored Jul 6, 2023
2 parents f5d458b + 16b3c1a commit c1160a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/create-collection/base-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {

const config = require('../../config');

const NEW_COLLECTION_FEE = coins('250000000', 'ustars');

function clean(obj: any) {
return JSON.parse(JSON.stringify(obj));
}
Expand Down Expand Up @@ -70,6 +68,8 @@ export async function create_minter() {

const tempMsg = { create_minter: initMsg };

const creationFee = paramsResponse.params.creation_fee.amount;

if (
tempMsg.create_minter?.collection_params.info?.royalty_info
?.payment_address === undefined &&
Expand All @@ -87,9 +87,9 @@ export async function create_minter() {
console.log(JSON.stringify(msg, null, 2));
console.log(
'Cost of minter instantiation: ' +
NEW_COLLECTION_FEE[0].amount +
creationFee +
' ' +
NEW_COLLECTION_FEE[0].denom
'ustars'
);
const answer = await inquirer.prompt([
{
Expand All @@ -106,7 +106,7 @@ export async function create_minter() {
msg,
'auto',
config.name,
NEW_COLLECTION_FEE
coins(creationFee, 'ustars')
);
const wasmEvent = result.logs[0].events.find((e) => e.type === 'wasm');
console.info(
Expand Down
10 changes: 6 additions & 4 deletions src/create-collection/minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export async function create_minter(params: MinterParams) {
);
console.log('params response', paramsResponse);

const creationFee = paramsResponse.params.creation_fee.amount;

const tempMsg = { create_minter: initMsg };

// TODO use recursive cleanup of undefined and null values
Expand All @@ -165,7 +167,7 @@ export async function create_minter(params: MinterParams) {
msg: toUtf8(
JSON.stringify(obj)
),
funds:NEW_COLLECTION_FEE,
funds: coins(creationFee, 'ustars'),
},
};

Expand All @@ -180,9 +182,9 @@ export async function create_minter(params: MinterParams) {
console.log(JSON.stringify(msg, null, 2));
console.log(
'Cost of minter instantiation: ' +
NEW_COLLECTION_FEE[0].amount +
creationFee +
' ' +
NEW_COLLECTION_FEE[0].denom
'ustars'
);
console.log("Total gas fee to be paid",await client.simulate(account, [encodeMsg],undefined)+" ustars");
const answer = await inquirer.prompt([
Expand All @@ -200,7 +202,7 @@ export async function create_minter(params: MinterParams) {
msg,
'auto',
config.name,
NEW_COLLECTION_FEE
coins(creationFee, 'ustars')
);
const wasmEvent = result.logs[0].events.find((e) => e.type === 'wasm');
console.info(
Expand Down
12 changes: 6 additions & 6 deletions src/create-collection/open-edition-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { toUtf8 } from '@cosmjs/encoding';

const config = require('../../config');

const NEW_COLLECTION_FEE = coins('1000000000', 'ustars');

function clean(obj: any) {
return JSON.parse(JSON.stringify(obj));
}
Expand Down Expand Up @@ -151,6 +149,8 @@ export async function create_minter(params: OpenEditionMinterParams) {

const tempMsg = { create_minter: initMsg };

const creationFee = paramsResponse.params.creation_fee.amount;

// TODO use recursive cleanup of undefined and null values
if (
tempMsg.create_minter?.collection_params.info?.royalty_info
Expand All @@ -171,7 +171,7 @@ export async function create_minter(params: OpenEditionMinterParams) {
msg: toUtf8(
JSON.stringify(obj)
),
funds:NEW_COLLECTION_FEE,
funds:coins(creationFee, 'ustars')
},
};

Expand All @@ -186,9 +186,9 @@ export async function create_minter(params: OpenEditionMinterParams) {
console.log(JSON.stringify(msg, null, 2));
console.log(
'Cost of minter instantiation: ' +
NEW_COLLECTION_FEE[0].amount +
creationFee +
' ' +
NEW_COLLECTION_FEE[0].denom
'ustars'
);
console.log("Total gas fee to be paid: ",await client.simulate(account, [encodeMsg],undefined)+" ustars");
const answer = await inquirer.prompt([
Expand All @@ -206,7 +206,7 @@ export async function create_minter(params: OpenEditionMinterParams) {
msg,
'auto',
config.name,
NEW_COLLECTION_FEE
coins(creationFee, 'ustars')
);
const wasmEvent = result.logs[0].events.find((e) => e.type === 'wasm');
console.info(
Expand Down

0 comments on commit c1160a1

Please sign in to comment.