Skip to content

Commit aee3cdd

Browse files
committed
wip
1 parent 65b4ed8 commit aee3cdd

File tree

14 files changed

+234
-99
lines changed

14 files changed

+234
-99
lines changed

common/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"@types/node": "^20.11.17",
2929
"@typescript-eslint/eslint-plugin": "^6.21.0",
3030
"@typescript-eslint/parser": "^6.21.0",
31-
"dotenv": "^16.4.1",
3231
"eslint": "^8.56.0",
3332
"eslint-config-prettier": "^9.1.0",
3433
"ethers": "^5.7.2",

common/src/collection/collection-get.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ const collectionGet = async (chainId: number, address: string, account = ADDRESS
8383
collection = await resolverGetCollection(chainId, address, account);
8484
} catch (err: unknown) {
8585
const reason = (err as TxError).reason || "No explicit reason";
86-
if (reason == "Not ERC165") {
87-
console.warn(`Invalid NFT collection: Not ERC165 => ${explorerAddressUrl(chainId, address)}\n`);
86+
87+
if (reason === "Not ERC165") {
88+
console.info(`Collection is not ERC165, so not ERC721 => ${explorerAddressUrl(chainId, address)}\n`);
8889
} else {
8990
console.error(`ERROR collectionGet: ${reason} => ${explorerAddressUrl(chainId, address)}\n`);
91+
throw new Error(`ERROR collectionGet: ${reason}`);
9092
}
9193
}
9294
// console.log(`collectionGet ${keyCollection(chainId, address, account)}\n`, collection);

common/src/common/config.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,28 @@ const getOpenBound = (chainId: number): string => getAddresses(chainId)?.OpenBou
4848
const hasOpenBound = (chainId: number): boolean => isAddress(getOpenBound(chainId));
4949

5050
// GET Dapp Url
51-
const getDappUrl = (chainId: number, ref: NftType | { address: string; tokenID: string }): string =>
52-
`${config.base}/#/${chainId}/${ref?.address?.toLowerCase()}/${ref?.tokenID}`;
51+
const getDappUrl = (
52+
chainId: number,
53+
ref: NftType | { address?: string; tokenID?: string } = {},
54+
base = "."
55+
): string => {
56+
let dappUrl = `${base}/#/${chainId}`;
57+
if (isAddress(ref.address)) {
58+
dappUrl += `/${ref.address}`;
59+
if (isNumeric(ref.tokenID)) dappUrl += `/${ref.tokenID}`;
60+
}
61+
return dappUrl;
62+
};
5363

5464
// GET Autoswarm Url
55-
const getAutoswarmUrl = (chainId: number, ref: NftType | { address: string; tokenID: string }): string =>
56-
`${config.storage.swarm.autoSwarm}/${chainId}/${ref?.address}/${ref?.tokenID}`;
65+
const getAutoswarmUrl = (chainId: number, ref: NftType | { address?: string; tokenID?: string } = {}): string => {
66+
let autoswarmUrl = `${config.storage.swarm.autoSwarm}/${chainId}`;
67+
if (isAddress(ref.address)) {
68+
autoswarmUrl += `/${ref.address}`;
69+
if (isNumeric(ref.tokenID)) autoswarmUrl += `/${ref.tokenID}`;
70+
}
71+
return autoswarmUrl;
72+
};
5773

5874
// nft url : nft://chainName/collectionAddress/tokenID
5975
const nftUrl3 = (chainId: number, address: string, tokenID = "", n = 999): string => {
@@ -110,7 +126,8 @@ const numberToHexString = (num = 0): string => "0x" + Number(num).toString(16);
110126
const urlToLink = (url: string, label?: string): string =>
111127
`<a href="${url}" class="link" target="_blank" rel="noreferrer">${label || url}</a>`;
112128

113-
const isNumeric = (stringNum: string): boolean => !isNaN(Number(stringNum)) && !isNaN(parseFloat(stringNum));
129+
const isNumeric = (stringNum: string | undefined): boolean =>
130+
stringNum !== undefined && !isNaN(Number(stringNum)) && !isNaN(parseFloat(stringNum));
114131
/////////////////////////////////////////////////////////////////////////////////////////////////////
115132

116133
/////////////////////////////////////////////////////////////////////////////////////////////////////

config/src/testnets.handlebars.json

+62-47
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,65 @@
11
[
2+
{
3+
"chainId": 11155111,
4+
"chainName": "sepolia",
5+
"rpcUrls": ["https://sepolia.infura.io/v3/{{INFURA_API_KEY}}", "https://rpc.ankr.com/eth_sepolia", "https://rpc.sepolia.org"],
6+
"nativeCurrency": {
7+
"name": "Ether",
8+
"symbol": "ETH",
9+
"decimals": 18
10+
},
11+
"blockExplorerUrls": ["https://sepolia.etherscan.io"],
12+
"etherscan": {
13+
"apiUrl": "https://api-sepolia.etherscan.io/"
14+
},
15+
"eip1559": true,
16+
"create": true,
17+
"linkedMainnet": 1
18+
},
19+
{
20+
"chainId": 534351,
21+
"chainName": "scroll-sepolia",
22+
"rpcUrls": ["https://sepolia-rpc.scroll.io/"],
23+
"nativeCurrency": {
24+
"name": "Scroll Ether",
25+
"symbol": "ETH",
26+
"decimals": 18
27+
},
28+
"blockExplorerUrls": ["https://sepolia.scrollscan.com/", "https://sepolia-blockscout.scroll.io"],
29+
"linkedMainnet": 534352,
30+
"linkedLayer1": 11155111,
31+
"eip1559": false,
32+
"create": true
33+
},
34+
{
35+
"chainId": 84532,
36+
"chainName": "base-sepolia",
37+
"rpcUrls": ["https://sepolia.base.org", "https://base-sepolia.blockpi.network/v1/rpc/public"],
38+
"nativeCurrency": {
39+
"name": "Sepolia Ether",
40+
"symbol": "sepETH",
41+
"decimals": 18
42+
},
43+
"blockExplorerUrls": ["https://sepolia.basescan.org", "https://base-sepolia.blockscout.com"],
44+
"etherscanApiKey": "{{ETHERSCAN_API_KEY_BASE}}",
45+
"create": true,
46+
"linkedMainnet": 8453,
47+
"linkedLayer1": 11155111
48+
},
49+
{
50+
"chainId": 999999999,
51+
"chainName": "zora-sepolia",
52+
"rpcUrls": ["https://sepolia.rpc.zora.energy"],
53+
"nativeCurrency": {
54+
"name": "Zora Ether",
55+
"symbol": "zETH",
56+
"decimals": 18
57+
},
58+
"blockExplorerUrls": ["https://sepolia.explorer.zora.energy/"],
59+
"linkedMainnet": 7777777,
60+
"linkedLayer1": 11155111,
61+
"create": true
62+
},
263
{
364
"chainId": 5,
465
"chainName": "goerli",
@@ -28,7 +89,7 @@
2889
"rpcUrls": ["https://goerli.base.org"],
2990
"nativeCurrency": {
3091
"name": "Goerli Ether",
31-
"symbol": "ETH",
92+
"symbol": "goeETH",
3293
"decimals": 18
3394
},
3495
"blockExplorerUrls": ["https://goerli.basescan.org", "https://base-goerli.blockscout.com"],
@@ -66,52 +127,6 @@
66127
"linkedLayer1": 5,
67128
"create": true
68129
},
69-
{
70-
"chainId": 11155111,
71-
"chainName": "sepolia",
72-
"rpcUrls": ["https://sepolia.infura.io/v3/{{INFURA_API_KEY}}", "https://rpc.ankr.com/eth_sepolia", "https://rpc.sepolia.org"],
73-
"nativeCurrency": {
74-
"name": "Ether",
75-
"symbol": "ETH",
76-
"decimals": 18
77-
},
78-
"blockExplorerUrls": ["https://sepolia.etherscan.io"],
79-
"etherscan": {
80-
"apiUrl": "https://api-sepolia.etherscan.io/"
81-
},
82-
"eip1559": true,
83-
"create": true,
84-
"linkedMainnet": 1
85-
},
86-
{
87-
"chainId": 534351,
88-
"chainName": "scroll-sepolia",
89-
"rpcUrls": ["https://sepolia-rpc.scroll.io/"],
90-
"nativeCurrency": {
91-
"name": "Scroll Ether",
92-
"symbol": "ETH",
93-
"decimals": 18
94-
},
95-
"blockExplorerUrls": ["https://sepolia-blockscout.scroll.io"],
96-
"linkedMainnet": 534352,
97-
"linkedLayer1": 11155111,
98-
"eip1559": false,
99-
"create": true
100-
},
101-
{
102-
"chainId": 999999999,
103-
"chainName": "zora-sepolia",
104-
"rpcUrls": ["https://sepolia.rpc.zora.energy"],
105-
"nativeCurrency": {
106-
"name": "Zora Ether",
107-
"symbol": "zETH",
108-
"decimals": 18
109-
},
110-
"blockExplorerUrls": ["https://sepolia.explorer.zora.energy/"],
111-
"linkedMainnet": 7777777,
112-
"linkedLayer1": 11155111,
113-
"create": true
114-
},
115130
{
116131
"chainId": 80001,
117132
"chainName": "mumbai",

gulp/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"autoprefixer": "^10.4.17",
1616
"cssnano": "^6.0.3",
1717
"del": "^6.1.1",
18-
"dotenv": "^16.4.1",
18+
1919
"gulp": "^4.0.2",
2020
"gulp-if": "^3.0.0",
2121
"gulp-imagemin": "^7.1.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.4.0",
44
"main": "index.js",
55
"scripts": {
6-
"clean": "rm -rf node_modules pnpm-lock.yaml web/dapp **/.turbo && pnpm -r clean",
6+
"clean": "rm -rf node_modules pnpm-lock.yaml .turbo web/dapp && pnpm -r clean",
77
"all": "pnpm clean && pnpm install && pnpm build",
88
"all:dapp": "pnpm clean && pnpm install && pnpm build:dapp",
99
"all:plugin": "pnpm clean && pnpm install && pnpm build:plugin",

svelte/src/components/Global/ButtonOwner.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { onMount } from "svelte";
44
55
/////////////////////////////////////////////////
6-
// <ButtonOwner bind:{owner} />
6+
// <ButtonOwner {account} bind:{owner} />
77
// Select All button
88
/////////////////////////////////////////////////
99
export let account: string;
@@ -13,7 +13,7 @@
1313
const toggleOwner = () =>
1414
(owner = isAddressNotZero(owner) ? ADDRESS_ZERO : isAddressNotZero(account) ? account : ADDRESS_ZERO);
1515
16-
onMount(toggleOwner);
16+
// onMount(toggleOwner);
1717
</script>
1818

1919
<button

svelte/src/components/Global/Create.svelte

+39-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import { metamaskSigner } from "@svelte/stores/metamask";
55
import CollectionCreate from "../Collection/CollectionCreate.svelte";
66
7+
import InputImportCollection from "../Input/InputImportCollection.svelte";
78
import NftMintPopup from "../Nft/NftMintPopup.svelte";
9+
import { networks } from "@common/common/networks";
810
911
/////////////////////////////////////////////////
1012
// <Create {chainId} {signer} />
@@ -15,26 +17,47 @@
1517
1618
let open = false;
1719
const toggle = () => (open = !open);
20+
21+
$: mint = signer && networks.getCreate(chainId);
1822
</script>
1923

20-
<a href="#create-modal" class="btn btn-default" title="Mint"><i class="fas fa-plus fa-left" />Create</a>
24+
<a href="#create-modal" class="btn btn-default" title="Mint"><i class="fas fa-plus fa-left" />Add</a>
2125

2226
<!-- Modal create -->
2327
<div class="modal-window" id="create-modal">
2428
<div class="modal-content">
2529
<a href="./#" title="Close" class="modal-close"><i class="fa fa-times" /></a>
2630

2731
<div class="modal-body">
28-
<div class="titre">
29-
<i class="fas fa-plus fa-left c-green" />What do you want to do ?
30-
</div>
32+
{#if mint}
33+
<div class="titre">
34+
<i class="fas fa-plus fa-left c-green" />What do you want to do ?
35+
</div>
3136

32-
<div class="txtcenter">
33-
<span role="button" tabindex="0" on:click={toggle} on:keydown={toggle} class="btn btn-default" title="Mint NFT"
34-
>Mint NFT</span
35-
>
36-
<span class="or">or</span>
37-
<a href="#add-collection" class="btn btn-second" title="Add a new collection">Create Collection</a>
37+
<div class="txtcenter">
38+
<span
39+
role="button"
40+
tabindex="0"
41+
on:click={toggle}
42+
on:keydown={toggle}
43+
class="btn btn-default"
44+
title="Mint NFT">Mint NFT</span
45+
>
46+
<span class="or">or</span>
47+
<a href="#add-collection" class="btn btn-second" title="Add a new collection">Create Collection</a>
48+
</div>
49+
{/if}
50+
51+
<div class="add-collection-address">
52+
<div class="titre">
53+
{#if mint}
54+
<span class="or">or</span>
55+
{:else}
56+
<i class="fas fa-plus fa-left c-green" />
57+
{/if}
58+
Add Custom Collection
59+
</div>
60+
<InputImportCollection />
3861
</div>
3962
</div>
4063
</div>
@@ -51,3 +74,9 @@
5174
<CollectionCreate {chainId} {signer} />
5275
</div>
5376
{/if}
77+
78+
<style>
79+
.add-collection-address {
80+
margin-top: 8rem;
81+
}
82+
</style>

0 commit comments

Comments
 (0)