@@ -198,7 +198,6 @@ struct CollectionInfo {
198198 let similarTokens : SimilarTokensGetter ?
199199 let rarityRank : RarityRankGetter
200200}
201-
202201struct CollectionData : HasContractInterface {
203202 let recentTrades : NftRecentTradesObject
204203 let contract : ContractInterface
@@ -264,195 +263,12 @@ let CryptoPunks_rarityRanks : [UInt] = load("CryptoPunks_rarityRanks.json")
264263let AsciiPunks_nearestTokens : [ [ UInt ] ] = load ( " AsciiPunks_nearestTokens.json " )
265264let AsciiPunks_rarityRanks : [ UInt ] = load ( " AsciiPunks_rarityRanks.json " )
266265
266+ let BAYC_nearestTokens : [ [ UInt ] ] = load ( " BoredApeYachtClub_nearestTokens.json " )
267+ let BAYC_rarityRanks : [ UInt ] = load ( " BoredApeYachtClub_rarityRanks.json " )
268+
269+
267270let cryptoPunksContract = CryptoPunksContract ( ) ;
268271let cryptoKittiesContract = CryptoKittiesAuction ( ) ;
269272let asciiPunksContract = AsciiPunksContract ( ) ;
270273let autoGlyphsContract = AutoglyphsContract ( )
271274let baycContract = BAYC_Contract ( )
272-
273- let CompositeCollection = CompositeRecentTradesObject ( [
274- CompositeRecentTradesObject . CollectionInitializer (
275- info: CollectionInfo (
276- address: cryptoPunksContract. contractAddressHex,
277- url1: SAMPLE_PUNKS [ 0 ] ,
278- url2: SAMPLE_PUNKS [ 1 ] ,
279- url3: SAMPLE_PUNKS [ 2 ] ,
280- url4: SAMPLE_PUNKS [ 3 ] ,
281- name: " CryptoPunks " ,
282- webLink: URL ( string: " https://www.larvalabs.com/cryptopunks " ) !,
283- themeColor: Color . yellow,
284- themeLabelColor: Color . systemBackground,
285- subThemeColor: /* FFB61E */ Color ( red: 255 / 255 , green: 182 / 255 , blue: 30 / 255 ) ,
286- collectionColor: Color . yellow,
287- disableRecentTrades: false ,
288- blur: 0 ,
289- samplePadding: 10 ,
290- similarTokens : SimilarTokensGetter ( label: " Punks " ) { tokenId in CryptoPunks_nearestTokens [ safe: Int ( tokenId) ] } ,
291- rarityRank : { tokenId in CryptoPunks_rarityRanks [ safe: Int ( tokenId) ] } ) ,
292- contract: cryptoPunksContract) ,
293- CompositeRecentTradesObject . CollectionInitializer (
294- info: CollectionInfo (
295- address: autoGlyphsContract. contractAddressHex,
296- url1: SAMPLE_AUTOGLYPHS [ 0 ] ,
297- url2: SAMPLE_AUTOGLYPHS [ 1 ] ,
298- url3: SAMPLE_AUTOGLYPHS [ 2 ] ,
299- url4: SAMPLE_AUTOGLYPHS [ 3 ] ,
300- name: " Autoglyphs " ,
301- webLink: URL ( string: " https://www.larvalabs.com/autoglyphs " ) !,
302- themeColor: Color . label,
303- themeLabelColor: Color . gray,
304- subThemeColor: Color . label,
305- collectionColor: Color . white,
306- disableRecentTrades: false ,
307- blur: 0 ,
308- samplePadding: 10 ,
309- similarTokens: nil ,
310- rarityRank : { tokenId in nil } ) ,
311- contract: autoGlyphsContract) ,
312- CompositeRecentTradesObject . CollectionInitializer (
313- info: CollectionInfo (
314- address: asciiPunksContract. contractAddressHex,
315- url1: SAMPLE_ASCII_PUNKS [ 0 ] ,
316- url2: SAMPLE_ASCII_PUNKS [ 1 ] ,
317- url3: SAMPLE_ASCII_PUNKS [ 2 ] ,
318- url4: SAMPLE_ASCII_PUNKS [ 3 ] ,
319- name: " AsciiPunks " ,
320- webLink: URL ( string: " https://asciipunks.com " ) !,
321- themeColor: Color . label,
322- themeLabelColor: Color . systemBackground,
323- subThemeColor: Color . label,
324- collectionColor: Color . black,
325- disableRecentTrades: false ,
326- blur: 0 ,
327- samplePadding: 10 ,
328- similarTokens : SimilarTokensGetter ( label: " Punks " ) { tokenId in AsciiPunks_nearestTokens [ safe: Int ( tokenId) ] } ,
329- rarityRank : { tokenId in AsciiPunks_rarityRanks [ safe: Int ( tokenId) ] } ) ,
330- contract: asciiPunksContract) ,
331- CompositeRecentTradesObject . CollectionInitializer (
332- info: CollectionInfo (
333- address: baycContract. contractAddressHex,
334- url1: SAMPLE_BAYC [ 0 ] ,
335- url2: SAMPLE_BAYC [ 1 ] ,
336- url3: SAMPLE_BAYC [ 2 ] ,
337- url4: SAMPLE_BAYC [ 3 ] ,
338- name: " BoredApeYachtClub " ,
339- webLink: URL ( string: " https://boredapeyachtclub.com/#/ " ) !,
340- themeColor: Color . black,
341- themeLabelColor: Color . white,
342- subThemeColor: Color . white,
343- collectionColor: Color . black,
344- disableRecentTrades: false ,
345- blur: 0 ,
346- samplePadding: 15 ,
347- similarTokens: nil ,
348- rarityRank : { tokenId in nil } ) ,
349- contract: baycContract) ,
350- CompositeRecentTradesObject . CollectionInitializer (
351- info: CollectionInfo (
352- address: cryptoKittiesContract. contractAddressHex,
353- url1: SAMPLE_KITTIES [ 0 ] ,
354- url2: SAMPLE_KITTIES [ 1 ] ,
355- url3: SAMPLE_KITTIES [ 2 ] ,
356- url4: SAMPLE_KITTIES [ 3 ] ,
357- name: " CryptoKitties " ,
358- webLink: URL ( string: " https://www.cryptokitties.co " ) !,
359- themeColor: /* 78e08f */ Color ( red: 120 / 255 , green: 224 / 255 , blue: 143 / 255 ) ,
360- themeLabelColor: Color . systemBackground,
361- subThemeColor: /* 78e08f */ Color ( red: 120 / 255 , green: 224 / 255 , blue: 143 / 255 ) ,
362- collectionColor: /* 78e08f */ Color ( red: 120 / 255 , green: 224 / 255 , blue: 143 / 255 ) ,
363- disableRecentTrades: true ,
364- blur: 0 , samplePadding: 0 ,
365- similarTokens: nil ,
366- rarityRank : { tokenId in nil } ) ,
367- contract: cryptoKittiesContract) ,
368- ]
369- )
370-
371- let SampleToken = NFT (
372- address: " 0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb " ,
373- tokenId: 340 , name: " CryptoPunks " ,
374- media: . image( MediaImageEager ( URL ( string: " https://www.larvalabs.com/public/images/cryptopunks/punk0385.png " ) !) ) )
375-
376- let SampleCollection = CompositeCollection . collections [ 0 ]
377-
378-
379- public extension Color {
380- static let lightText = Color ( UIColor . lightText)
381- static let darkText = Color ( UIColor . darkText)
382-
383- static let label = Color ( UIColor . label)
384- static let secondaryLabel = Color ( UIColor . secondaryLabel)
385- static let tertiaryLabel = Color ( UIColor . tertiaryLabel)
386- static let quaternaryLabel = Color ( UIColor . quaternaryLabel)
387-
388- static let systemBackground = Color ( UIColor . systemBackground)
389- static let secondarySystemBackground = Color ( UIColor . secondarySystemBackground)
390- static let tertiarySystemBackground = Color ( UIColor . tertiarySystemBackground)
391-
392- // There are more..
393- }
394-
395- let COLLECTIONS : [ Collection ] = CompositeCollection . collections
396-
397- struct CollectionsFactory {
398-
399- let collections : [ String : Collection ] = Dictionary ( uniqueKeysWithValues: COLLECTIONS . map { ( $0. info. address, $0) } )
400-
401- func getByAddress( _ address: String ) -> Collection ? {
402- return collections [ address]
403- }
404-
405- }
406-
407- let collectionsFactory = CollectionsFactory ( )
408-
409- extension Array {
410- subscript ( safe index: Int ) -> Element ? {
411- return indices ~= index ? self [ index] : nil
412- }
413- }
414-
415- extension String {
416- /*
417- Truncates the string to the specified length number of characters and appends an optional trailing string if longer.
418- - Parameter length: Desired maximum lengths of a string
419- - Parameter trailing: A 'String' that will be appended after the truncation.
420-
421- - Returns: 'String' object.
422- */
423- func trunc( length: Int , trailing: String = " … " ) -> String {
424- return ( self . count > length) ? self . prefix ( length) + trailing : self
425- }
426-
427- func deletingPrefix( _ prefix: String ) -> String {
428- guard self . hasPrefix ( prefix) else { return self }
429- return String ( self . dropFirst ( prefix. count) )
430- }
431- }
432-
433- extension URL {
434- func params( ) -> [ String : Any ] {
435- var dict = [ String: Any] ( )
436-
437- if let components = URLComponents ( url: self , resolvingAgainstBaseURL: false ) {
438- if let queryItems = components. queryItems {
439- for item in queryItems {
440- dict [ item. name] = item. value!
441- }
442- }
443- return dict
444- } else {
445- return [ : ]
446- }
447- }
448- }
449-
450- let SAMPLE_WALLET_ADDRESS = try ! EthereumAddress (
451- hex: " 0x208b82b04449cd51803fae4b1561450ba13d9510 " ,
452- eip55: false )
453-
454- enum CloudDefaultStorageKeys : String {
455- case walletAddress = " walletAddress "
456- case favoritesDict = " favoritesDict "
457- case friendsDict = " friendsDict "
458- }
0 commit comments