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

add addChallengeTypes task #16

Open
wants to merge 1 commit into
base: mint-challenge
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
54 changes: 54 additions & 0 deletions packages/contracts/data/challengeTypes/challengeTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ChallengeTypeInput } from "../../tasks/addChallengeTypes";

export const challengeTypes: ChallengeTypeInput[] = [
{
id: 0,
name: "The Void",
description: "The Void",
prtclePrice: 0,
maxQuantity: 0,
canPurchaseWithPrtcle: false,
canBeTransferred: false,
totalQuantity: 0,
},
{
id: 1,
name: "BWW Blazin Wing Challenge",
description: "Eat 10 wings in 5 minutes; no water",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 2,
name: "Do a Backflip",
description: "Do a Backflip Description",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 3,
name: "Hold My Breathe for 5 minutes",
description: "Hold My Breathe for 5 minutes",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 4,
name: "Dunk a Basketball",
description: "Dunk",
prtclePrice: 50,
maxQuantity: "250",
canPurchaseWithPrtcle: true,
canBeTransferred: true,
totalQuantity: 0,
},
];
4 changes: 2 additions & 2 deletions packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require("./tasks/verifyFacet.ts");
require("./tasks/generateDiamondABI.ts");
// require("./tasks/generateDiamondABI_eth.ts");
require("./tasks/batchDeposit.ts");
// require("./tasks/addItemTypes.ts");
require("./tasks/addChallengeTypes.ts");

// You have to export an object to set up your config
// This object can have the following optional entries:
Expand All @@ -36,7 +36,7 @@ export default {
},
// xdai: {
// url: process.env.XDAI_URL,

// // url: 'https://rpc-mainnet.maticvigil.com/',
// accounts: [process.env.CHALLENGE_MANAGER],
// // blockGasLimit: 20000000,
Expand Down
183 changes: 92 additions & 91 deletions packages/contracts/scripts/testChallengeTypes.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,99 @@
const { isThrowStatement } = require('typescript')
const { isThrowStatement } = require("typescript");
const { ethers } = require("ethers");

const challengeTypes = [
{
id: 0,
name: 'The Void',
description: 'The Void',
prtclePrice: 0,
maxQuantity: 0,
canPurchaseWithPrtcle: false,
canBeTransferred: false,
totalQuantity: 0,
},
{
id: 1,
name: 'BWW Blazin Wing Challenge',
description: 'Eat 10 wings in 5 minutes; no water',
prtclePrice: 5,
maxQuantity: '1000',
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 2,
name: 'Do a Backflip',
description: 'Do a Backflip Description',
prtclePrice: 5,
maxQuantity: '1000',
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 3,
name: 'Hold My Breathe for 5 minutes',
description: 'Hold My Breathe for 5 minutes',
prtclePrice: 5,
maxQuantity: '1000',
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 4,
name: 'Dunk a Basketball',
description: 'Dunk',
prtclePrice: 50,
maxQuantity: '250',
canPurchaseWithPrtcle: true,
canBeTransferred: true,
totalQuantity: 0
}
]

function eightBitIntArrayToUint(array) {
if (array.length === 0) {
return ethers.BigNumber.from(0)
}
const uint = []
for (const num of array) {
if (num > 127) {
throw (Error('Value beyond signed 8 int '))
}
const value = ethers.BigNumber.from(num).toTwos(8)
uint.unshift(value.toHexString().slice(2))
}
return ethers.BigNumber.from('0x' + uint.join(''))
{
id: 0,
name: "The Void",
description: "The Void",
prtclePrice: 0,
maxQuantity: 0,
canPurchaseWithPrtcle: false,
canBeTransferred: false,
totalQuantity: 0,
},
{
id: 1,
name: "BWW Blazin Wing Challenge",
description: "Eat 10 wings in 5 minutes; no water",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 2,
name: "Do a Backflip",
description: "Do a Backflip Description",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 3,
name: "Hold My Breathe for 5 minutes",
description: "Hold My Breathe for 5 minutes",
prtclePrice: 5,
maxQuantity: "1000",
canPurchaseWithPrtcle: false,
canBeTransferred: true,
totalQuantity: 0,
},
{
id: 4,
name: "Dunk a Basketball",
description: "Dunk",
prtclePrice: 50,
maxQuantity: "250",
canPurchaseWithPrtcle: true,
canBeTransferred: true,
totalQuantity: 0,
},
];

function eightBitIntArrayToUint(array) {
if (array.length === 0) {
return ethers.BigNumber.from(0);
}

function boolsArrayToUint16(bools) {
const uint = []
for (const b of bools) {
if (b) {
uint.push('1')
} else {
uint.push('0')
}
const uint = [];
for (const num of array) {
if (num > 127) {
throw Error("Value beyond signed 8 int ");
}
// console.log(bools)
// console.log(uint.join(''))
// console.log(uint.join('').padStart(16, '0'))
// console.log('-------------')
return parseInt(uint.join('').padStart(16, '0'), 2)
const value = ethers.BigNumber.from(num).toTwos(8);
uint.unshift(value.toHexString().slice(2));
}


function getChallengeTypes() {
const result = []
for (const challengeType of challengeTypes) {
challengeType.prtclePrice = ethers.utils.parseEther(challengeType.prtclePrice.toString())
result.push(challengeType)

return ethers.BigNumber.from("0x" + uint.join(""));
}

function boolsArrayToUint16(bools) {
const uint = [];
for (const b of bools) {
if (b) {
uint.push("1");
} else {
uint.push("0");
}
return result
}

exports.challengeTypes = getChallengeTypes()
// console.log(bools)
// console.log(uint.join(''))
// console.log(uint.join('').padStart(16, '0'))
// console.log('-------------')
return parseInt(uint.join("").padStart(16, "0"), 2);
}

function getChallengeTypes() {
const result = [];
for (const challengeType of challengeTypes) {
challengeType.prtclePrice = ethers.utils.parseEther(
challengeType.prtclePrice.toString()
);
result.push(challengeType);
}
return result;
}

exports.challengeTypes = getChallengeTypes();
Loading