Skip to content

Commit

Permalink
UNS support (#50)
Browse files Browse the repository at this point in the history
* remove crypto validation except .zil (#42)

* remove crypto validation except .zil

* remove specific domain constant

* Added ERC721 metadata methods (#43)

* Added erc methods

* rename cns to uns

* rename files and update resolver abi

* fix metadata api request

* get and use new config files

* clean up

* clean

* parse cnsRegistry as well

* review updates

* Redme and tests

* fix buildContract and cns

* fix xcode

* correctly parse both registry contracts

* remove unused resolver contract entry

* move tests from mainnet to rinkeby

* Update isSupportedDomain (#46)

* update proxy reader abi

* fix abi parsing due to new abi

* isSupportedDomain

* update tests

* don't check for isSupported under the hood, instead if ending is on .zil use zns otherwise use uns

* code clean issupported

* add tests for new tlds

* try to make async call instead of sync on tokensOwnedBy

* make calls async

* clean up

* Use newuri for unhash (#47)

* Use event for unhash
* Add pulling registry from proxy reader
* Tests for abicoder, remove unused code

* Update CryptoSwift to newest version. Remove EthereumAddress dependency (moved to support files) (#49)

* Revert "Merge pull request #41 from unstoppabledomains/removeEns" (#48)

* Revert "Merge pull request #41 from unstoppabledomains/removeEns"

This reverts commit a1cbfea, reversing
changes made to 4ea6607.

* changelog

* update getServiceOf

* revert he changes in podspec

* make sure uns will not recognize the ens domains

* Update Sources/UnstoppableDomainsResolution/Resolution.swift

* Update Sources/UnstoppableDomainsResolution/NamingServices/ENS.swift

* my fixes

Co-authored-by: Sergei Merenkov <mer.sergei@gmail.com>

* allow any network as long as proxyReader contract is defined

* allow zns to use custom network

* better error when ens or zns doesn't receive registry address with custom network

* update changelog

* update changelog

* expand changelog

* fix dependency

* Update changelog

* Update changelog

Co-authored-by: JohnnyJumper <johnny@unstoppabledomains.com>
Co-authored-by: Mike <5020980+DancingAxolotl@users.noreply.github.com>
Co-authored-by: Gentelman John <jeyhunt@gmail.com>
Co-authored-by: Kirill Beresnev <derainberk@gmail.com>
  • Loading branch information
5 people committed Jul 21, 2021
1 parent 9ca3808 commit 1161c00
Show file tree
Hide file tree
Showing 48 changed files with 6,679 additions and 2,075 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Resolution-swift CHANGELOG

## 2.0.0

### Breaking changes

- `Resolution#isSupported` is now making an async call. Method signature was changed.
- `Configurations` class accepts `uns` configs instead of `cns`.
- For example: `let resolution = try Resolution(configs: Configurations(uns: NamingServiceConfig(...uns config)));`

### New methods and features

- Support new TLD's ( .888, .nft, .coin, .blockchain, .wallet, .x, .bitcoin, .dao )
- Introduce Resolution#tokenURI - Retrieves the tokenURI from the registry smart contract
- Introduce Resolution#tokenURIMetadata - Retrieves the data from the endpoint provided by tokenURI from the registry smart contract.
- Introduce Resolution#unhash - Retrieves the domain name from token metadata that is provided by tokenURI from the registry smart contract
- Return `ENS` support
- Allowed custom networks for each of the naming services. If custom network has been set, it is required to set the proxyReader contract address for UNS and registryAddress for ENS && ZNS (see `./Sources/UnstoppableDomainsResolution/Resources/UNS/uns-config.json`)

## 1.0.0
- Remove Ens support ([#41](https://github.com/unstoppabledomains/resolution-swift/pull/41)) via [@JohnnyJumper](https://github.com/JohnnyJumper)

Expand Down
13 changes: 2 additions & 11 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,8 @@
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"state": {
"branch": null,
"revision": "3a2acbb32ab68215ee1596ee6004da8e90c3721b",
"version": "1.0.0"
}
},
{
"package": "EthereumAddress",
"repositoryURL": "https://github.com/shamatar/EthereumAddress.git",
"state": {
"branch": null,
"revision": "a8eb4fc1dc03c068bf88585d8f5a2dd3572664ca",
"version": "1.3.0"
"revision": "8d4f6384e0a8cc41f2005247241dd553963a492a",
"version": "1.4.1"
}
}
]
Expand Down
20 changes: 10 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ let package = Package(
targets: ["UnstoppableDomainsResolution"])
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.0.0"),
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.0.0"),
.package(url: "https://github.com/shamatar/EthereumAddress.git", from: "1.3.0")
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.3.8"),
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.0.0")
],
targets: [
.target(
name: "UnstoppableDomainsResolution",
dependencies: ["CryptoSwift", "BigInt", "EthereumAddress"],
dependencies: ["CryptoSwift", "BigInt"],
resources: [
.process("Resources/CNS/supported-keys.json"),
.process("Resources/CNS/cnsProxyReader.json"),
.process("Resources/CNS/cnsRegistry.json"),
.process("Resources/CNS/cnsResolver.json"),
.process("Resources/CNS/network-config.json"),
.process("Resources/UNS/supported-keys.json"),
.process("Resources/UNS/unsProxyReader.json"),
.process("Resources/UNS/unsRegistry.json"),
.process("Resources/UNS/cnsRegistry.json"),
.process("Resources/UNS/unsResolver.json"),
.process("Resources/UNS/uns-config.json"),
.process("Resources/ENS/ensRegistry.json"),
.process("Resources/ENS/ensResolver.json")
],
Expand All @@ -35,7 +35,7 @@ let package = Package(
.testTarget(
name: "ResolutionTests",
dependencies: ["UnstoppableDomainsResolution"],
exclude:["Info.plist"],
exclude: ["Info.plist"],
swiftSettings: [.define("INSIDE_PM")]
)
]
Expand Down
42 changes: 36 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@ Resolution is primarily built and maintained by [Unstoppable Domains](https://un

Resoultion supports decentralized domains across three main zones:

- Crypto Name Service (CNS)
- Crypto Name Service (uns)
- `.crypto`
- Zilliqa Name Service (ZNS)
- `.coin`
- `.wallet`
- `.bitcoin`
- `.blockchain`
- `.x`
- `.888`
- `.nft`
- `.dao`
- Zilliqa Name Service (zns)
- `.zil`
- Ethereum Name Service (ENS)
- `.eth`
- `.kred`
- `.xyz`
- `.luxe`

# Installation into the project

## Cocoa Pods
Expand Down Expand Up @@ -120,16 +134,19 @@ resolution.record(domain: "ryan.crypto", record: "custom.record.value") { result
Version 0.3.0 introduced the `Configurations` struct that is used for configuring each connected naming service.
Library can offer three naming services at the moment:

* `cns` resolves `.crypto` domains,
* `uns` resolves `.crypto` , `.coin`, `.wallet`, `.bitcoin`, `.blockchain`, `.x`, `.888`, `.nft`, `.dao` domains,
* `ens` resolves `.eth`, `.kred`, `.xyz`, `.luxe` domains
* `zns` resolves `.zil` domains

By default, each of them is using the mainnet network via infura provider.
Unstoppable domains are using the infura key with no restriction for CNS.
Unstoppable domains are using the infura key with no restriction for UNS.
Unstoppable domains recommends setting up your own provider for ENS, as we don't guarantee ENS Infura key availability.

You can update each naming service separately

```swift
let resolution = try Resolution(configs: Configurations(
cns: NamingServiceConfig(
uns: NamingServiceConfig(
providerUrl: "https://rinkeby.infura.io/v3/3c25f57353234b1b853e9861050f4817",
network: "rinkeby"
)
Expand All @@ -147,13 +164,26 @@ resolution.addr(domain: "udtestdev-creek.crypto", ticker: "eth") { (result) in
XCTFail("Expected Eth Address, but got \(error)")
}
}

// naming services that hasn't been touched by Configrations struct are using default settings
// the following will look up monkybrain.eth on the mainnet via infura provider

resolution.addr(domain: "monkybrain.eth", ticker: "eth") { (result) in
switch result {
case .success(let returnValue):
ethENSAddress = returnValue
domainEthReceived.fulfill()
case .failure(let error):
XCTFail("Expected Eth Address, but got \(error)")
}
}
```

## Batch requesting of owners

Version 0.1.3 introduced the `batchOwners(domains: _, completion: _ )` method which adds additional convenience when making multiple domain owner queries.

> This method is only compatible with CNS-based domains. Using this method with any other domain type will throw the error: `ResolutionError.methodNotSupported`.
> This method is only compatible with uns-based domains. Using this method with any other domain type will throw the error: `ResolutionError.methodNotSupported`.
As opposed to the single `owner(domain: _, completion: _)` method, this batch request will return an array of owners `[String?]`. If the the domain is not registered or its value is `null`, the corresponding array element of the response will be `nil` without throwing an error.

Expand Down
Loading

0 comments on commit 1161c00

Please sign in to comment.