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

tkn

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tkn - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

15

index.js

@@ -5,4 +5,4 @@ import { ethers } from 'ethers';

// Setup Ethereum provider and contract
const provider = new ethers.CloudflareProvider();
// const provider = new ethers.providers.AlchemyProvider(); // Defaults to Ethereum mainnet
// const provider = new ethers.CloudflareProvider();
const provider = new ethers.AlchemyProvider("mainnet", 'sS_1IxXGm493hjmf5bCCMom3dd6294Uv'); // Defaults to Ethereum mainnet
const resolver = new ethers.Contract('0xe121A6e3a50008EFE9C617214320c2f9fF903411', [

@@ -31,8 +31,9 @@ 'function resolve(bytes name, bytes call) external view returns (bytes memory)',

// Updated lookup function to be environment-agnostic
async function fetch(name) {
async function lookup(prefix) {
try {
const ensName = ethers.namehash(`${name}.tkn.eth`);
const calls = profile.makeCallsForName(ensName);
if (prefix && !prefix.endsWith('.')) prefix += '.';
const name = `${prefix}tkn.eth`;
const calls = profile.makeCallsForName(name);
const multi = iface.encodeFunctionData('multicall', [calls]);
const res = await resolver.resolve(ethers.namehash(ensName), multi, { enableCcipRead: true });
const res = await resolver.resolve(ethers.dnsEncode(name, 255), multi, { enableCcipRead: true });
const [answers] = iface.decodeFunctionResult('multicall', res);

@@ -49,3 +50,3 @@ const record = new Record();

const tkn = {
fetch,
lookup,
// other utilities

@@ -52,0 +53,0 @@ };

{
"name": "tkn",
"version": "0.1.2",
"version": "0.1.3",
"description": "The Token Name Service NPM package",

@@ -5,0 +5,0 @@ "type": "module",

import { tkn } from '../index'; // Adjust the path as necessary
describe('tkn.fetch', () => {
describe('tkn.lookup', () => {
it('should fetch data for "frame"', async () => {
const result = await tkn.fetch('eth');
const result = await tkn.lookup('eth');
expect(result).toBeDefined();
expect(result).toHaveProperty('name');
expect(result.name).toEqual('Ethereum');
console.log(result);
expect(result.name).toEqual('frame.eth');
});
});
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