-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mezo testnet as a builtin network (#3780)
Adds Mezo testnet as a built-in network, there's no support yet for reverse name resolution. The price for the network base asset is resolved as the price for tBTC. ## Testing env ``` SUPPORT_MEZO_NETWORK=true ``` Latest build: [extension-builds-3780](https://github.com/tahowallet/extension/suites/34891830413/artifacts/2653025518) (as of Wed, 26 Feb 2025 02:09:25 GMT).
- Loading branch information
Showing
23 changed files
with
195 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { fetchJson } from "@ethersproject/web" | ||
import { AddressOnNetwork, NameOnNetwork } from "../../../accounts" | ||
import { MEZO_TESTNET } from "../../../constants" | ||
import { sameNetwork } from "../../../networks" | ||
import { NameResolver } from "../name-resolver" | ||
import { normalizeEVMAddress } from "../../../lib/utils" | ||
|
||
const MEZO_SUPPORTED_NETWORKS = [MEZO_TESTNET] | ||
|
||
export default function mezoResolver(): NameResolver<"MEZO"> { | ||
return { | ||
type: "MEZO", | ||
canAttemptNameResolution(): boolean { | ||
return true | ||
}, | ||
canAttemptAvatarResolution(): boolean { | ||
return false | ||
}, | ||
canAttemptAddressResolution({ name, network }: NameOnNetwork): boolean { | ||
return ( | ||
name.endsWith(".mezo") && | ||
MEZO_SUPPORTED_NETWORKS.some((supportedNetwork) => | ||
sameNetwork(network, supportedNetwork), | ||
) | ||
) | ||
}, | ||
|
||
async lookUpAddressForName({ | ||
name, | ||
network, | ||
}: NameOnNetwork): Promise<AddressOnNetwork | undefined> { | ||
type ResolveNameData = { | ||
mezoId: string | ||
evmAddress: string | ||
btcAddress: null | string | ||
} | ||
|
||
const data: ResolveNameData = await fetchJson( | ||
`https://portal.api.mezo.org/api/v2/external/accounts?mezoId=${name}`, | ||
) | ||
|
||
return { | ||
address: normalizeEVMAddress(data.evmAddress), | ||
network, | ||
} | ||
}, | ||
async lookUpAvatar() { | ||
return undefined | ||
}, | ||
async lookUpNameForAddress( | ||
_: AddressOnNetwork, | ||
): Promise<NameOnNetwork | undefined> { | ||
// FIXME: Missing endpoint | ||
return undefined | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.