From 91686a8463257c8f503c96d7052d54e2e5367704 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 01:44:02 +0800 Subject: [PATCH 01/14] Update web3.js --- src/mint/web3.js | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index a469458..6480e14 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -50,35 +50,11 @@ const getDefaultMintPrice = () => { } const getMintPrice = async () => { - const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('price') || key.toLowerCase().includes('cost')) - ) - switch (matches.length) { - // Use auto-detection only when sure - // Otherwise this code might accidentally use presale price instead of public minting price - case 1: - console.log("Using price method auto-detection") - return NFTContract.methods[matches[0]]().call() - case 0: - const defaultMintPrice = getDefaultMintPrice() - if (defaultMintPrice === undefined) { - alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") - } - return defaultMintPrice - default: - console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice'] - const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) - if (!name) { - const defaultMintPrice = getDefaultMintPrice() - console.log("defaultMintPrice", defaultMintPrice) - if (defaultMintPrice === undefined) { - alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") - } - return defaultMintPrice - } - return NFTContract.methods[findMethodByName(name)]().call(); - } + const prices = await NFTContract.methods.versionParams(1).call(); + + console.log('prices', prices) + + return prices.prices.friends; } export const getMintedNumber = async () => { @@ -100,8 +76,8 @@ export const getMintedNumber = async () => { export const getMaxSupply = async () => { if (!NFTContract) return undefined - if (NFTContract.methods.maxSupply) - return await NFTContract.methods.maxSupply().call() + if (NFTContract.methods.currentMaxSupply) + return await NFTContract.methods.currentMaxSupply().call() if (NFTContract.methods.MAX_SUPPLY) return await NFTContract.methods.MAX_SUPPLY().call() alert("Widget doesn't know how to fetch maxSupply from your contract. Contact https://buildship.xyz to resolve this.") From bdbe1d2cf1542ef5268df9e69900c1ea68abf945 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 02:20:16 +0800 Subject: [PATCH 02/14] Update web3.js --- src/mint/web3.js | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 6480e14..61d1723 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -50,11 +50,35 @@ const getDefaultMintPrice = () => { } const getMintPrice = async () => { - const prices = await NFTContract.methods.versionParams(1).call(); - - console.log('prices', prices) - - return prices.prices.friends; + const matches = Object.keys(NFTContract.methods).filter(key => + !key.includes("()") && (key.toLowerCase().includes('publicCost') || key.toLowerCase().includes('cost')) + ) + switch (matches.length) { + // Use auto-detection only when sure + // Otherwise this code might accidentally use presale price instead of public minting price + case 1: + console.log("Using price method auto-detection") + return NFTContract.methods[matches[0]]().call() + case 0: + const defaultMintPrice = getDefaultMintPrice() + if (defaultMintPrice === undefined) { + alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") + } + return defaultMintPrice + default: + console.log("Using hardcoded price detection") + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice'] + const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) + if (!name) { + const defaultMintPrice = getDefaultMintPrice() + console.log("defaultMintPrice", defaultMintPrice) + if (defaultMintPrice === undefined) { + alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") + } + return defaultMintPrice + } + return NFTContract.methods[findMethodByName(name)]().call(); + } } export const getMintedNumber = async () => { From e25fb877f5aa56c4f872e91b31bde11685c4755f Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 08:30:44 +0800 Subject: [PATCH 03/14] Update web3.js --- src/mint/web3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 61d1723..10fcbd1 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice'] + const methodNameVariants = [] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From 5c70a930ecfbb91f6fe14bcfd27d379d014c80aa Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 08:40:38 +0800 Subject: [PATCH 04/14] Update web3.js --- src/mint/web3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 10fcbd1..2ec4c78 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('publicCost') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('mintCompliance') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = [] + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'mintCompliance'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From 34ada8b40d7e903cfa52fa93ed9dc80b1b7cd92a Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 08:50:49 +0800 Subject: [PATCH 05/14] Update web3.js --- src/mint/web3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 2ec4c78..60c455c 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'mintCompliance'] + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', '_mintAmount'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From 55a28fb87696f349abb554d471845f5aa5a75f45 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 08:57:01 +0800 Subject: [PATCH 06/14] Update web3.js --- src/mint/web3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 60c455c..2736495 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('mintCompliance') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('_mintAmount') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure From 24c4c9fc59f9d4d74cf8fdd692a331fe1a223cc6 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 09:12:04 +0800 Subject: [PATCH 07/14] Update web3.js --- src/mint/web3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 2736495..4bb55f1 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('_mintAmount') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('cycv2Address') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', '_mintAmount'] + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', '_mintAmount', 'cycv2Address'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From b622c482c27ffcb030978e3b08ab39792f758db9 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 09:26:17 +0800 Subject: [PATCH 08/14] Update web3.js --- src/mint/web3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 4bb55f1..c5baf3d 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('cycv2Address') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('require') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', '_mintAmount', 'cycv2Address'] + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From 60b929f99a006d0ef0549bf938815a6daabb2ce2 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 09:51:05 +0800 Subject: [PATCH 09/14] Update web3.js --- src/mint/web3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index c5baf3d..8bfb307 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('require') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('token.balanceOf') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure From bc9ab42c419ef2552bcbf7804ba2ce381c12cd15 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 10:18:46 +0800 Subject: [PATCH 10/14] Update web3.js --- src/mint/web3.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 8bfb307..070a4aa 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -51,7 +51,7 @@ const getDefaultMintPrice = () => { const getMintPrice = async () => { const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('token.balanceOf') || key.toLowerCase().includes('cost')) + !key.includes("()") && (key.toLowerCase().includes('ownerAmount') || key.toLowerCase().includes('cost')) ) switch (matches.length) { // Use auto-detection only when sure @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address'] + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address', 'require', '800000'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() From 06ab0071284f52374e522b68806fc4c4e158cdb7 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 10:31:04 +0800 Subject: [PATCH 11/14] Update web3.js --- src/mint/web3.js | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 070a4aa..d62bea3 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -50,35 +50,11 @@ const getDefaultMintPrice = () => { } const getMintPrice = async () => { - const matches = Object.keys(NFTContract.methods).filter(key => - !key.includes("()") && (key.toLowerCase().includes('ownerAmount') || key.toLowerCase().includes('cost')) - ) - switch (matches.length) { - // Use auto-detection only when sure - // Otherwise this code might accidentally use presale price instead of public minting price - case 1: - console.log("Using price method auto-detection") - return NFTContract.methods[matches[0]]().call() - case 0: - const defaultMintPrice = getDefaultMintPrice() - if (defaultMintPrice === undefined) { - alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") - } - return defaultMintPrice - default: - console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address', 'require', '800000'] - const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) - if (!name) { - const defaultMintPrice = getDefaultMintPrice() - console.log("defaultMintPrice", defaultMintPrice) - if (defaultMintPrice === undefined) { - alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") - } - return defaultMintPrice - } - return NFTContract.methods[findMethodByName(name)]().call(); - } + const prices = await NFTContract.methods.mint(1).call(); + + console.log('prices', prices) + + return prices.prices.friends; } export const getMintedNumber = async () => { From 6cbf70810f86781d78d2d7e8907221f36b2a0f04 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 10:36:48 +0800 Subject: [PATCH 12/14] Update web3.js --- src/mint/web3.js | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index d62bea3..26d215f 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -50,12 +50,35 @@ const getDefaultMintPrice = () => { } const getMintPrice = async () => { - const prices = await NFTContract.methods.mint(1).call(); - - console.log('prices', prices) - - return prices.prices.friends; -} + const matches = Object.keys(NFTContract.methods).filter(key => + !key.includes("()") && (key.toLowerCase().includes('ownerAmount') || key.toLowerCase().includes('cost')) + ) + switch (matches.length) { + // Use auto-detection only when sure + // Otherwise this code might accidentally use presale price instead of public minting price + case 1: + console.log("Using price method auto-detection") + return NFTContract.methods[matches[0]]().call() + case 0: + const defaultMintPrice = getDefaultMintPrice() + if (defaultMintPrice === undefined) { + alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") + } + return defaultMintPrice + default: + console.log("Using hardcoded price detection") + const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address', 'require', '800000', 'ownerAmount'] + const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) + if (!name) { + const defaultMintPrice = getDefaultMintPrice() + console.log("defaultMintPrice", defaultMintPrice) + if (defaultMintPrice === undefined) { + alert("Buildship widget doesn't know how to fetch price from your contract. Contact https://buildship.xyz in Discord to resolve this.") + } + return defaultMintPrice + } + return NFTContract.methods[findMethodByName(name)]().call(); + } export const getMintedNumber = async () => { if (!NFTContract) From 3bf8299fa4bf14ad1edb10189c3e0f47a93de6e6 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 10:40:19 +0800 Subject: [PATCH 13/14] Update web3.js --- src/mint/web3.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mint/web3.js b/src/mint/web3.js index 26d215f..8c2b869 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -67,7 +67,7 @@ const getMintPrice = async () => { return defaultMintPrice default: console.log("Using hardcoded price detection") - const methodNameVariants = ['price', 'cost', 'public_sale_price', 'getPrice', 'token.balanceOf', 'cycv2Address', 'require', '800000', 'ownerAmount'] + const methodNameVariants = ['price', 'cost', 'getPrice', 'token.balanceOf', 'cycv2Address', 'require', '800000', 'ownerAmount'] const name = methodNameVariants.find(n => findMethodByName(n) !== undefined) if (!name) { const defaultMintPrice = getDefaultMintPrice() @@ -79,6 +79,7 @@ const getMintPrice = async () => { } return NFTContract.methods[findMethodByName(name)]().call(); } +} export const getMintedNumber = async () => { if (!NFTContract) From 07babbe5f7aba43a8514ec5d5e7f7d12614423d3 Mon Sep 17 00:00:00 2001 From: Ncrypt16 <104200150+Ncrypt16@users.noreply.github.com> Date: Sat, 2 Jul 2022 12:44:51 +0800 Subject: [PATCH 14/14] Update web3.js --- src/mint/web3.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mint/web3.js b/src/mint/web3.js index 8c2b869..a926e56 100644 --- a/src/mint/web3.js +++ b/src/mint/web3.js @@ -50,6 +50,7 @@ const getDefaultMintPrice = () => { } const getMintPrice = async () => { + return 0 const matches = Object.keys(NFTContract.methods).filter(key => !key.includes("()") && (key.toLowerCase().includes('ownerAmount') || key.toLowerCase().includes('cost')) )