-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck-user-collection.js
More file actions
159 lines (133 loc) Β· 6.55 KB
/
Copy pathcheck-user-collection.js
File metadata and controls
159 lines (133 loc) Β· 6.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/**
* Check if a user has SemesterZero Chapter 5 collection set up correctly
* Usage: node check-user-collection.js <wallet_address>
*
* Example: node check-user-collection.js 0xdca7ac623136e447
*/
import * as fcl from '@onflow/fcl';
// Configure FCL for Mainnet
fcl.config()
.put('accessNode.api', 'https://rest-mainnet.onflow.org')
.put('flow.network', 'mainnet');
const CHECK_COLLECTION_SCRIPT = `
import SemesterZero from 0xce9dd43888d99574
import NonFungibleToken from 0x1d7e57aa55817448
access(all) fun main(address: Address): {String: AnyStruct} {
let account = getAccount(address)
// Check for CORRECT collection path
let hasCorrectStorage = account.storage.type(at: /storage/SemesterZeroChapter5Collection) != nil
// Check for WRONG collection path (from old code)
let hasWrongStorage = account.storage.type(at: /storage/SemesterZeroV3Collection) != nil
// Check public capability
let collectionCap = account.capabilities.get<&SemesterZero.Chapter5Collection>(
/public/SemesterZeroChapter5Collection
)
let hasCorrectCapability = collectionCap.check()
// Try to borrow and get NFT count
var nftCount: Int = 0
if hasCorrectCapability {
if let collection = collectionCap.borrow() {
nftCount = collection.getIDs().length
}
}
return {
"hasCorrectCollection": hasCorrectStorage && hasCorrectCapability,
"hasCorrectStorage": hasCorrectStorage,
"hasCorrectCapability": hasCorrectCapability,
"hasWrongStorage": hasWrongStorage,
"nftCount": nftCount,
"readyForFlowty": hasCorrectStorage && hasCorrectCapability
}
}
`;
async function checkUserCollection(address) {
console.log('\nπ Checking SemesterZero Collection Setup\n');
console.log('ββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
console.log(`π€ Wallet Address: ${address}`);
console.log(`π Flowty Collection: https://www.flowty.io/collection/0xce9dd43888d99574/SemesterZero\n`);
console.log('ββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
try {
const result = await fcl.query({
cadence: CHECK_COLLECTION_SCRIPT,
args: (arg, t) => [arg(address, t.Address)]
});
console.log('π Collection Status:\n');
// Main status
if (result.hasCorrectCollection) {
console.log('β
COLLECTION READY FOR FLOWTY!');
console.log(` - Storage: β
Set up correctly`);
console.log(` - Capability: β
Public access enabled`);
console.log(` - NFT Count: ${result.nftCount} NFTs`);
} else {
console.log('β COLLECTION NOT SET UP CORRECTLY');
console.log(` - Storage: ${result.hasCorrectStorage ? 'β
' : 'β'} ${result.hasCorrectStorage ? 'Found' : 'Missing'}`);
console.log(` - Capability: ${result.hasCorrectCapability ? 'β
' : 'β'} ${result.hasCorrectCapability ? 'Enabled' : 'Not enabled'}`);
}
console.log();
// Check for wrong path
if (result.hasWrongStorage) {
console.log('β οΈ WARNING: OLD COLLECTION DETECTED');
console.log(' You have a collection at the WRONG storage path.');
console.log(' This was created by the old version of the code.');
console.log(' Flowty will NOT recognize this collection.\n');
console.log(' π Action Required:');
console.log(' 1. Contact support to migrate your collection');
console.log(' 2. Or create a new collection at the correct path\n');
}
// Recommendations
console.log('ββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
if (result.readyForFlowty) {
console.log('π NEXT STEPS:\n');
console.log('1. Visit Flowty marketplace:');
console.log(' https://www.flowty.io/collection/0xce9dd43888d99574/SemesterZero\n');
console.log('2. Connect your wallet\n');
console.log('3. Your NFTs should appear automatically!\n');
if (result.nftCount === 0) {
console.log('π Note: You have 0 NFTs in this collection.');
console.log(' Complete objectives in Flunks: Semester Zero to earn NFTs!\n');
}
} else {
console.log('βοΈ SETUP REQUIRED:\n');
console.log('Option 1 - Use flunks.net (Recommended):\n');
console.log(' 1. Visit https://flunks.net');
console.log(' 2. Connect your Flow Wallet (not Dapper)');
console.log(' 3. Go to Paradise Motel β Lobby');
console.log(' 4. Click "π« Set up Collection"\n');
console.log('Option 2 - Use Flowty:\n');
console.log(' 1. Visit https://www.flowty.io/collection/0xce9dd43888d99574/SemesterZero');
console.log(' 2. Connect your Flow Wallet');
console.log(' 3. Click "Enable Collection" if available\n');
console.log('π‘ TIP: If you\'re using Dapper Wallet:');
console.log(' Dapper has limitations with collection setup.');
console.log(' Use Flow Wallet extension or Dapper\'s Account Linking feature.');
console.log(' Guide: https://support.meetdapper.com/hc/en-us/articles/20744347884819\n');
}
console.log('ββββββββββββββββββββββββββββββββββββββββββββββββββββ\n');
} catch (error) {
console.error('\nβ Error checking collection:', error.message);
console.error('\nPlease verify:');
console.error('- Wallet address is correct');
console.error('- Address starts with 0x');
console.error('- Address is 18 characters long');
console.error('- You are connected to Flow Mainnet\n');
}
}
// Get wallet address from command line
const walletAddress = process.argv[2];
if (!walletAddress) {
console.error('\nβ Error: No wallet address provided\n');
console.error('Usage: node check-user-collection.js <wallet_address>\n');
console.error('Example: node check-user-collection.js 0xdca7ac623136e447\n');
process.exit(1);
}
// Validate address format
if (!walletAddress.startsWith('0x') || walletAddress.length !== 18) {
console.error('\nβ Error: Invalid wallet address format\n');
console.error('Flow wallet addresses must:');
console.error('- Start with 0x');
console.error('- Be 18 characters long (including 0x)');
console.error('\nExample: 0xdca7ac623136e447\n');
process.exit(1);
}
// Run the check
checkUserCollection(walletAddress);