Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deniz/support ibc minters #280

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions config.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ module.exports = {
// The code ID for vending flexible minter for use with whitelist flexible
flexibleVendingMinterCodeId: 2601,
// Addr for vending factory contract
vendingFactory:
'stars18h7ugh8eaug7wr0w4yjw0ls5s937z35pnkg935ucsek2y9xl3gaqqk4jtx',
vendingFactoryAddresses:
['stars18h7ugh8eaug7wr0w4yjw0ls5s937z35pnkg935ucsek2y9xl3gaqqk4jtx'],
// Addr for updatable vending factory contract
updatableVendingFactory:
'stars1h65nms9gwg4vdktyqj84tu50gwlm34e0eczl5w2ezllxuzfxy9esa9qlt0',
updatableVendingFactoryAddresses:
['stars1h65nms9gwg4vdktyqj84tu50gwlm34e0eczl5w2ezllxuzfxy9esa9qlt0'],
// Addr for flexible vending factory contract
flexibleVendingFactory:
'stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q',
flexibleVendingFactoryAddresses:
['stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q'],
// Addr for open edition factory contract
openEditionFactory:
'stars13r06dn4jc6mudvvkl9rclxjctywm4nhl045jn9f8mk6vc53eylusy4zxzj',
openEditionFactoryAddresses:
['stars13r06dn4jc6mudvvkl9rclxjctywm4nhl045jn9f8mk6vc53eylusy4zxzj'],
// Addr for open edition updatable factory contract
openEditionUpdatableFactory:
'stars1n7np7wdmm4ea8tapkz00j3jtxupne0g8v9jj02j96wfn9w9ukxgs6hcsv0',
openEditionUpdatableFactoryAddresses:
['stars1n7np7wdmm4ea8tapkz00j3jtxupne0g8v9jj02j96wfn9w9ukxgs6hcsv0'],
// The code ID for open edition minter
openEditionMinterCodeId: 2579,
// The code ID for the whitelist contract
Expand Down
59 changes: 38 additions & 21 deletions src/create-collection/minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
formatRoyaltyInfo,
} from '../helpers/utils';
import { toUtf8 } from '@cosmjs/encoding';
import Prompt from 'inquirer/lib/prompts/base';

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

Expand All @@ -25,17 +26,17 @@ export type MinterParams =
| {
sg721CodeId: number;
vendingMinterCodeId: number;
vendingFactory: string;
vendingFactoryAddresses: string;
[k: string]: unknown;
}
| undefined;

export async function create_minter(params: MinterParams) {
if (params !== undefined) {
const { sg721CodeId, vendingMinterCodeId, vendingFactory } = params;
const { sg721CodeId, vendingMinterCodeId, vendingFactoryAddresses } = params;
config.sg721BaseCodeId = sg721CodeId;
config.vendingMinterCodeId = vendingMinterCodeId;
config.vendingFactory = vendingFactory;
config.vendingFactoryAddresses = vendingFactoryAddresses;
}
console.log('Collection name:', config.name);
console.log('Account:', config.account, '\n');
Expand Down Expand Up @@ -104,14 +105,42 @@ export async function create_minter(params: MinterParams) {
);
}

const factories = await Promise.all(
config.vendingFactoryAddresses.map(async (address: string) => {
const factory = await client.queryContractSmart(address, {
params: {},
});
return {
address: address,
denom: factory.params.min_mint_price.denom,
fee: factory.params.creation_fee.amount,
}
})
);

const pickedFactory = await inquirer.prompt([
{
message: 'Pick a denom',
name: 'params',
type: 'list',
choices: factories.map((factory: any, index: number) => {
return {
name: factory.denom,
value: factory,
};
}
),
},
]);

const initMsg: CreateMinterMsgForVendingMinterInitMsgExtension = {
init_msg: {
base_token_uri: config.baseTokenUri,
start_time: startTime,
num_tokens: config.numTokens,
mint_price: {
amount: (config.mintPrice * 1000000).toString(),
denom: 'ustars',
denom: pickedFactory.params.denom,
},
per_address_limit: config.perAddressLimit,
payment_address: paymentAddress,
Expand All @@ -131,19 +160,7 @@ export async function create_minter(params: MinterParams) {
},
},
};

// should be stars1nelx34qg6xtm5u748jzjsahthddsktrrg5dw2rx8vzpc8hwwgk5q32mj2h
console.log('vending factory addr: ', config.vendingFactory);

const paramsResponse = await client.queryContractSmart(
config.vendingFactory,
{
params: {},
}
);
console.log('params response', paramsResponse);

const creationFee = paramsResponse.params.creation_fee.amount;
const creationFee = pickedFactory.params.fee

const tempMsg = { create_minter: initMsg };

Expand All @@ -163,7 +180,7 @@ export async function create_minter(params: MinterParams) {
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
value: {
sender: account,
contract: config.vendingFactory,
contract: pickedFactory.params.address,
msg: toUtf8(
JSON.stringify(obj)
),
Expand Down Expand Up @@ -198,7 +215,7 @@ export async function create_minter(params: MinterParams) {

const result = await client.execute(
account,
config.vendingFactory,
pickedFactory.params.address,
msg,
'auto',
config.name,
Expand All @@ -223,7 +240,7 @@ async function create_updatable_vending_minter() {
let params = {
sg721CodeId: config.sg721UpdatableCodeId,
vendingMinterCodeId: config.vendingMinterCodeId,
vendingFactory: config.updatableVendingFactory,
vendingFactoryAddresses: config.updatableVendingFactoryAddresses,
};
create_minter(params);
}
Expand All @@ -233,7 +250,7 @@ async function create_flex_vending_minter() {
let params = {
sg721CodeId: config.sg721BaseCodeId,
vendingMinterCodeId: config.flexibleVendingMinterCodeId,
vendingFactory: config.flexibleVendingFactory,
vendingFactoryAddresses: config.flexibleVendingFactoryAddresses,
};
create_minter(params);
}
Expand Down
54 changes: 37 additions & 17 deletions src/create-collection/open-edition-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ export type OpenEditionMinterParams =
| {
sg721CodeId: number;
openEditionMinterCodeId: number;
openEditionFactory: string;
openEditionFactoryAddresses: string;
[k: string]: unknown;
}
| undefined;

export async function create_minter(params: OpenEditionMinterParams) {
if (params !== undefined) {
const { sg721CodeId, openEditionMinterCodeId, openEditionFactory } = params;
const { sg721CodeId, openEditionMinterCodeId, openEditionFactoryAddresses } = params;
config.sg721OpenEditionCodeId = sg721CodeId;
config.openEditionMinterCodeId = openEditionMinterCodeId;
config.openEditionFactory = openEditionFactory;
config.openEditionFactoryAddresses = openEditionFactoryAddresses;
}
console.log('Collection name:', config.name);
console.log('Account:', config.account, '\n');
Expand Down Expand Up @@ -97,6 +97,34 @@ export async function create_minter(params: OpenEditionMinterParams) {
const startTradingTime: Timestamp | null = config.openEditionMinterConfig.startTradingTime
? (new Date(config.openEditionMinterConfig.startTradingTime).getTime() * 1_000_000).toString()
: null;

const factories = await Promise.all(
config.openEditionFactoryAddresses.map(async (address: string) => {
const factory = await client.queryContractSmart(address, {
params: {},
});
return {
address: address,
denom: factory.params.min_mint_price.denom,
fee: factory.params.creation_fee.amount,
}
})
);

const pickedFactory = await inquirer.prompt([
{
message: 'Pick a denom',
name: 'params',
type: 'list',
choices: factories.map((factory: any, index: number) => {
return {
name: factory.denom,
value: factory,
};
}
),
},
]);

const initMsg = {
init_msg: {
Expand All @@ -117,7 +145,7 @@ export async function create_minter(params: OpenEditionMinterParams) {
end_time: endTime,
mint_price: {
amount: (config.openEditionMinterConfig.mintPrice * 1000000).toString(),
denom: 'ustars',
denom: pickedFactory.params.denom,
},
per_address_limit: config.openEditionMinterConfig.perAddressLimit,
payment_address: paymentAddress,
Expand All @@ -137,19 +165,11 @@ export async function create_minter(params: OpenEditionMinterParams) {
},
};

console.log('Open Edition Factory address: ', config.openEditionFactory);

const paramsResponse = await client.queryContractSmart(
config.openEditionFactory,
{
params: {},
}
);
console.log('Open Edition Factory parameters: ', paramsResponse);
console.log('Open Edition Factory address: ', pickedFactory.params.address);

const tempMsg = { create_minter: initMsg };

const creationFee = paramsResponse.params.creation_fee.amount;
const creationFee = pickedFactory.params.fee;

// TODO use recursive cleanup of undefined and null values
if (
Expand All @@ -167,7 +187,7 @@ export async function create_minter(params: OpenEditionMinterParams) {
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
value: {
sender: account,
contract: config.openEditionFactory,
contract: pickedFactory.params.address,
msg: toUtf8(
JSON.stringify(obj)
),
Expand Down Expand Up @@ -202,7 +222,7 @@ export async function create_minter(params: OpenEditionMinterParams) {

const result = await client.execute(
account,
config.openEditionFactory,
pickedFactory.params.address,
msg,
'auto',
config.name,
Expand All @@ -227,7 +247,7 @@ async function create_updatable_open_edition_minter() {
let params = {
sg721CodeId: config.sg721OpenEditionUpdatableCodeId,
openEditionMinterCodeId: config.openEditionMinterCodeId,
openEditionFactory: config.openEditionUpdatableFactory,
openEditionFactoryAddresses: config.openEditionUpdatableFactoryAddresses,
};
create_minter(params);
}
Expand Down
20 changes: 19 additions & 1 deletion src/whitelist/whitelist-flex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,32 @@ async function init() {
new Date(config.whitelistEndTime).getTime() * 1_000_000
).toString();

const flexibleVendingDenoms = await Promise.all(
config.flexibleVendingFactoryAddresses.map(async (factoryAddress: string) => {
const res = await client.queryContractSmart(factoryAddress, {
params: {},
});
return res.params.min_mint_price.denom;
})
);
// Ask user to select a denom for whitelist mint price
const denom = await inquirer.prompt([
{
message: 'Select a denom for whitelist mint price',
name: 'denom',
type: 'list',
choices: flexibleVendingDenoms,
},
]);

// @ts-ignore
const msg: InstantiateMsg = {
members: whitelist,
start_time: whitelistStartTime,
end_time: whitelistEndTime,
mint_price: {
amount: (config.whitelistPrice * 1000000).toString(),
denom: 'ustars',
denom: denom.denom,
},
member_limit: config.whitelistMemberLimit,
admins: [config.account],
Expand Down
21 changes: 20 additions & 1 deletion src/whitelist/whitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ async function init() {

const admins = config.admins || [config.account];

const vendingMinterMintingDenoms = await Promise.all(
config.vendingFactoryAddresses.map(async (address: string) => {
let params = await client.queryContractSmart(address, {
params: {},
});
return params.params.min_mint_price.denom;
})
);

// Ask user to pick denom for whitelist
const denom = await inquirer.prompt([
{
message: 'Select a denom for whitelist mint price',
name: 'denom',
type: 'list',
choices: await vendingMinterMintingDenoms,
},
]);

// @ts-ignore
const msg: InstantiateMsg = {
admins: admins,
Expand All @@ -67,7 +86,7 @@ async function init() {
end_time: whitelistEndTime,
mint_price: {
amount: (config.whitelistPrice * 1000000).toString(),
denom: 'ustars',
denom: denom.denom,
},
per_address_limit: config.whitelistPerAddressLimit,
member_limit: config.whitelistMemberLimit,
Expand Down