Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

deps: update @multiformats/multiaddr to 11.0.0 #59

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ updates:
interval: daily
time: "10:00"
open-pull-requests-limit: 10
commit-message:
prefix: "deps"
prefix-development: "deps(dev)"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)
- [Contribution](#contribution)
- [Contribute](#contribute-1)

## Install

Expand Down Expand Up @@ -59,6 +59,6 @@ Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribution
## Contribute

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
"release": "patch"
},
{
"type": "chore",
"type": "docs",
"release": "patch"
},
{
"type": "docs",
"type": "test",
"release": "patch"
},
{
"type": "test",
"type": "deps",
"release": "patch"
},
{
Expand Down Expand Up @@ -140,7 +140,11 @@
},
{
"type": "docs",
"section": "Trivial Changes"
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
Expand Down Expand Up @@ -172,10 +176,10 @@
},
"dependencies": {
"@achingbrain/ip-address": "^8.1.0",
"@libp2p/interface-connection": "^3.0.1",
"@libp2p/interface-peer-store": "^1.0.0",
"@libp2p/interface-connection": "^3.0.2",
"@libp2p/interface-peer-store": "^1.2.1",
"@libp2p/logger": "^2.0.0",
"@multiformats/multiaddr": "^10.1.1",
"@multiformats/multiaddr": "^11.0.0",
"abortable-iterator": "^4.0.2",
"err-code": "^3.0.1",
"is-loopback-addr": "^2.0.1",
Expand Down
9 changes: 8 additions & 1 deletion src/array-equals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,12 @@
*/
export function arrayEquals (a: any[], b: any[]) {
const sort = (a: any, b: any) => a.toString().localeCompare(b.toString())
return a.length === b.length && b.sort(sort) && a.sort(sort).every((item, index) => b[index].equals(item))

if (a.length !== b.length) {
return false
}

b.sort(sort)

return a.sort(sort).every((item, index) => b[index].equals(item))
}
8 changes: 4 additions & 4 deletions src/ip-port-to-multiaddr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@libp2p/logger'
import { Multiaddr } from '@multiformats/multiaddr'
import { multiaddr } from '@multiformats/multiaddr'
import errCode from 'err-code'
import { Address4, Address6 } from '@achingbrain/ip-address'

Expand Down Expand Up @@ -30,15 +30,15 @@ export function ipPortToMultiaddr (ip: string, port: number | string) {
try {
// Test valid IPv4
new Address4(ip) // eslint-disable-line no-new
return new Multiaddr(`/ip4/${ip}/tcp/${port}`)
return multiaddr(`/ip4/${ip}/tcp/${port}`)
} catch {}

try {
// Test valid IPv6
const ip6 = new Address6(ip)
return ip6.is4()
? new Multiaddr(`/ip4/${ip6.to4().correctForm()}/tcp/${port}`)
: new Multiaddr(`/ip6/${ip}/tcp/${port}`)
? multiaddr(`/ip4/${ip6.to4().correctForm()}/tcp/${port}`)
: multiaddr(`/ip6/${ip}/tcp/${port}`)
} catch (err) {
const errMsg = `invalid ip:port for creating a multiaddr: ${ip}:${port}`
log.error(errMsg)
Expand Down