Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@web3api/ens-plugin-js

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3api/ens-plugin-js - npm Package Compare versions

Comparing version 0.0.1-prealpha.13 to 0.0.1-prealpha.15

8

build/index.d.ts
import { Client, Plugin, PluginManifest, PluginModules, PluginFactory } from "@web3api/core-js";
export declare type Address = string;
export interface Addresses {
[network: string]: Address;
}
export interface EnsConfig {
address?: Address;
addresses?: Addresses;
}
export declare class EnsPlugin extends Plugin {
private _config;
static defaultEnsAddress: string;
constructor(_config: EnsConfig);

@@ -12,3 +16,3 @@ static manifest(): PluginManifest;

getModules(client: Client): PluginModules;
setAddress(address: Address): void;
setAddresses(addresses: Addresses): void;
ensToCID(domain: string, client: Client): Promise<string>;

@@ -15,0 +19,0 @@ }

@@ -66,4 +66,4 @@ "use strict";

// Sanitize address
if (_this._config.address) {
_this.setAddress(_this._config.address);
if (_this._config.addresses) {
_this.setAddresses(_this._config.addresses);
}

@@ -85,8 +85,12 @@ return _this;

};
EnsPlugin.prototype.setAddress = function (address) {
this._config.address = address_1.getAddress(address);
EnsPlugin.prototype.setAddresses = function (addresses) {
this._config.addresses = {};
for (var _i = 0, _a = Object.keys(addresses); _i < _a.length; _i++) {
var network = _a[_i];
this._config.addresses[network] = address_1.getAddress(addresses[network]);
}
};
EnsPlugin.prototype.ensToCID = function (domain, client) {
return __awaiter(this, void 0, void 0, function () {
var ensAddress, ensAbi, resolverAbi, domainNode, callView, resolverAddress, hash, e_1, err_1;
var ensAbi, resolverAbi, ensAddress, network, hasNetwork, domainNode, callView, resolverAddress, hash, e_1, err_1;
var _this = this;

@@ -96,3 +100,2 @@ return __generator(this, function (_a) {

case 0:
ensAddress = this._config.address || "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
ensAbi = {

@@ -105,7 +108,22 @@ resolver: "function resolver(bytes32 node) external view returns (address)",

};
ensAddress = EnsPlugin.defaultEnsAddress;
// Remove the ENS URI scheme & authority
domain = domain.replace("w3://", "");
domain = domain.replace("ens/", "");
network = "mainnet";
hasNetwork = /^[A-Za-z0-9]+\//i.exec(domain);
if (hasNetwork) {
network = domain.substring(0, domain.indexOf("/"));
// Remove the network from the domain URI's path
domain = domain.replace(network + "/", "");
// Lowercase only
network = network.toLowerCase();
// Check if we have a custom address configured
// for this network
if (this._config.addresses && this._config.addresses[network]) {
ensAddress = this._config.addresses[network];
}
}
domainNode = ethers_1.ethers.utils.namehash(domain);
callView = function (address, method, args) { return __awaiter(_this, void 0, void 0, function () {
callView = function (address, method, args, networkNameOrChainId) { return __awaiter(_this, void 0, void 0, function () {
var _a, data, errors;

@@ -116,3 +134,3 @@ return __generator(this, function (_b) {

uri: "ens/ethereum.web3api.eth",
query: "query {\n callView(\n address: $address,\n method: $method,\n args: $args\n )\n }",
query: "query {\n callView(\n address: $address,\n method: $method,\n args: $args,\n connection: $connection\n )\n }",
variables: {

@@ -122,2 +140,7 @@ address: address,

args: args,
connection: networkNameOrChainId
? {
networkNameOrChainId: networkNameOrChainId,
}
: undefined,
},

@@ -140,5 +163,3 @@ })];

}); };
return [4 /*yield*/, callView(ensAddress, ensAbi.resolver, [
domainNode,
])];
return [4 /*yield*/, callView(ensAddress, ensAbi.resolver, [domainNode], network)];
case 1:

@@ -149,5 +170,3 @@ resolverAddress = _a.sent();

_a.trys.push([2, 4, , 9]);
return [4 /*yield*/, callView(resolverAddress, resolverAbi.contenthash, [
domainNode,
])];
return [4 /*yield*/, callView(resolverAddress, resolverAbi.contenthash, [domainNode], network)];
case 3:

@@ -161,5 +180,3 @@ hash = _a.sent();

_a.trys.push([5, 7, , 8]);
return [4 /*yield*/, callView(resolverAddress, resolverAbi.content, [
domainNode,
])];
return [4 /*yield*/, callView(resolverAddress, resolverAbi.content, [domainNode], network)];
case 6:

@@ -183,3 +200,3 @@ // Fallback, contenthash doesn't exist, try content

else {
throw Error("Unkown CID format, CID hash: " + hash);
throw Error("Unknown CID format, CID hash: " + hash);
}

@@ -191,2 +208,3 @@ return [2 /*return*/];

};
EnsPlugin.defaultEnsAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
return EnsPlugin;

@@ -193,0 +211,0 @@ }(core_js_1.Plugin));

{
"name": "@web3api/ens-plugin-js",
"description": "Web3API ENS Javascript Plugin",
"version": "0.0.1-prealpha.13",
"version": "0.0.1-prealpha.15",
"license": "MIT",

@@ -23,3 +23,3 @@ "repository": {

"dependencies": {
"@web3api/core-js": "0.0.1-prealpha.13",
"@web3api/core-js": "0.0.1-prealpha.15",
"ethers": "5.0.7"

@@ -35,3 +35,3 @@ },

},
"gitHead": "c43fbd8f15c98767971d9aaef4cae15563327af4",
"gitHead": "e35f8a9a645afabe9d395d6c880a5a8d00c6e2e1",
"publishConfig": {

@@ -38,0 +38,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc