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

ethr-did-resolver

Package Overview
Dependencies
Maintainers
5
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethr-did-resolver - npm Package Compare versions

Comparing version 8.1.2 to 9.0.0

2

lib/config/deployments.d.ts

@@ -13,3 +13,3 @@ /**

*/
chainId: number;
chainId: number | bigint;
/**

@@ -16,0 +16,0 @@ * The ERC1056 contract address on this network

@@ -14,4 +14,9 @@ "use strict";

{ chainId: 30, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rsk', legacyNonce: true },
{ chainId: 31, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rsk:testnet', legacyNonce: true },
{
chainId: 31,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
name: 'rsk:testnet',
legacyNonce: true,
},
{
chainId: 246,

@@ -30,9 +35,34 @@ registry: '0xE29672f34e92b56C9169f9D485fFc8b9A136BCE4',

},
{ chainId: 246785, registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B', name: 'artis:tau1', legacyNonce: true },
{ chainId: 246529, registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B', name: 'artis:sigma1', legacyNonce: true },
{
chainId: 246785,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:tau1',
legacyNonce: true,
},
{
chainId: 246529,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:sigma1',
legacyNonce: true,
},
{ chainId: 137, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'polygon', legacyNonce: true },
{ chainId: 80001, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'polygon:test', legacyNonce: true },
{ chainId: 1313161554, registry: '0x63eD58B671EeD12Bc1652845ba5b2CDfBff198e0', name: 'aurora', legacyNonce: true },
{ chainId: 59140, registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818', name: 'linea:goerli', legacyNonce: false },
{
chainId: 80001,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
name: 'polygon:test',
legacyNonce: true,
},
{
chainId: 1313161554,
registry: '0x63eD58B671EeD12Bc1652845ba5b2CDfBff198e0',
name: 'aurora',
legacyNonce: true,
},
{
chainId: 59140,
registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818',
name: 'linea:goerli',
legacyNonce: false,
},
];
//# sourceMappingURL=deployments.js.map

@@ -1,3 +0,2 @@

import { Contract } from '@ethersproject/contracts';
import { Provider } from '@ethersproject/providers';
import { Contract, Provider } from 'ethers';
import { EthrDidRegistryDeployment } from './config/deployments';

@@ -16,4 +15,4 @@ /**

export interface ProviderConfiguration extends Omit<EthrDidRegistryDeployment, 'chainId'> {
provider?: Provider;
chainId?: string | number;
provider?: Provider | null;
chainId?: string | number | bigint;
web3?: any;

@@ -20,0 +19,0 @@ }

@@ -7,5 +7,3 @@ "use strict";

exports.configureResolverWithNetworks = exports.getContractForNetwork = void 0;
const bignumber_1 = require("@ethersproject/bignumber");
const contracts_1 = require("@ethersproject/contracts");
const providers_1 = require("@ethersproject/providers");
const ethers_1 = require("ethers");
const helpers_1 = require("./helpers");

@@ -38,9 +36,8 @@ const deployments_1 = require("./config/deployments");

function getContractForNetwork(conf) {
var _a, _b;
let provider = conf.provider || ((_a = conf.web3) === null || _a === void 0 ? void 0 : _a.currentProvider);
let provider = conf.provider || conf.web3?.currentProvider;
if (!provider) {
if (conf.rpcUrl) {
const chainIdRaw = conf.chainId ? conf.chainId : (_b = deployments_1.deployments.find((d) => d.name === conf.name)) === null || _b === void 0 ? void 0 : _b.chainId;
const chainId = chainIdRaw ? bignumber_1.BigNumber.from(chainIdRaw).toNumber() : chainIdRaw;
provider = new providers_1.JsonRpcProvider(conf.rpcUrl, chainId || 'any');
const chainIdRaw = conf.chainId ? conf.chainId : deployments_1.deployments.find((d) => d.name === conf.name)?.chainId;
const chainId = chainIdRaw ? BigInt(chainIdRaw) : chainIdRaw;
provider = new ethers_1.JsonRpcProvider(conf.rpcUrl, chainId || 'any');
}

@@ -51,3 +48,3 @@ else {

}
const contract = contracts_1.ContractFactory.fromSolidity(EthereumDIDRegistry_json_1.default)
const contract = ethers_1.ContractFactory.fromSolidity(EthereumDIDRegistry_json_1.default)
.attach(conf.registry || helpers_1.DEFAULT_REGISTRY_ADDRESS)

@@ -59,5 +56,4 @@ .connect(provider);

function configureNetwork(net) {
var _a;
const networks = {};
const chainId = net.chainId || ((_a = deployments_1.deployments.find((d) => net.name && (d.name === net.name || d.description === net.name))) === null || _a === void 0 ? void 0 : _a.chainId);
const chainId = net.chainId || deployments_1.deployments.find((d) => net.name && (d.name === net.name || d.description === net.name))?.chainId;
if (chainId) {

@@ -67,3 +63,3 @@ if (net.name) {

}
const id = typeof chainId === 'number' ? `0x${chainId.toString(16)}` : chainId;
const id = typeof chainId === 'bigint' || typeof chainId === 'number' ? `0x${chainId.toString(16)}` : chainId;
networks[id] = getContractForNetwork(net);

@@ -77,6 +73,5 @@ }

function configureNetworks(conf) {
var _a;
return {
...configureNetwork(conf),
...(_a = conf.networks) === null || _a === void 0 ? void 0 : _a.reduce((networks, net) => {
...conf.networks?.reduce((networks, net) => {
return { ...networks, ...configureNetwork(net) };

@@ -83,0 +78,0 @@ }, {}),

@@ -1,4 +0,2 @@

import { Signer } from '@ethersproject/abstract-signer';
import { CallOverrides, Contract } from '@ethersproject/contracts';
import { BlockTag, Provider, TransactionReceipt } from '@ethersproject/providers';
import { Signer, Contract, BlockTag, Provider, TransactionReceipt, Overrides, AddressLike } from 'ethers';
import { address, MetaSignature } from './helpers';

@@ -33,16 +31,16 @@ /**

getOwner(address: address, blockTag?: BlockTag): Promise<string>;
attachContract(controller?: address | Promise<address>): Promise<Contract>;
changeOwner(newOwner: address, options?: CallOverrides): Promise<TransactionReceipt>;
attachContract(controller?: AddressLike): Promise<Contract>;
changeOwner(newOwner: address, options?: Overrides): Promise<TransactionReceipt>;
createChangeOwnerHash(newOwner: address): Promise<string>;
changeOwnerSigned(newOwner: address, metaSignature: MetaSignature, options?: CallOverrides): Promise<TransactionReceipt>;
addDelegate(delegateType: string, delegateAddress: address, exp: number, options?: CallOverrides): Promise<TransactionReceipt>;
changeOwnerSigned(newOwner: address, metaSignature: MetaSignature, options?: Overrides): Promise<TransactionReceipt>;
addDelegate(delegateType: string, delegateAddress: address, exp: number, options?: Overrides): Promise<TransactionReceipt>;
createAddDelegateHash(delegateType: string, delegateAddress: address, exp: number): Promise<string>;
addDelegateSigned(delegateType: string, delegateAddress: address, exp: number, metaSignature: MetaSignature, options?: CallOverrides): Promise<TransactionReceipt>;
revokeDelegate(delegateType: string, delegateAddress: address, options?: CallOverrides): Promise<TransactionReceipt>;
addDelegateSigned(delegateType: string, delegateAddress: address, exp: number, metaSignature: MetaSignature, options?: Overrides): Promise<TransactionReceipt>;
revokeDelegate(delegateType: string, delegateAddress: address, options?: Overrides): Promise<TransactionReceipt>;
createRevokeDelegateHash(delegateType: string, delegateAddress: address): Promise<string>;
revokeDelegateSigned(delegateType: string, delegateAddress: address, metaSignature: MetaSignature, options?: CallOverrides): Promise<TransactionReceipt>;
setAttribute(attrName: string, attrValue: string, exp: number, options?: CallOverrides): Promise<TransactionReceipt>;
revokeDelegateSigned(delegateType: string, delegateAddress: address, metaSignature: MetaSignature, options?: Overrides): Promise<TransactionReceipt>;
setAttribute(attrName: string, attrValue: string, exp: number, options?: Overrides): Promise<TransactionReceipt>;
createSetAttributeHash(attrName: string, attrValue: string, exp: number): Promise<string>;
setAttributeSigned(attrName: string, attrValue: string, exp: number, metaSignature: MetaSignature, options?: CallOverrides): Promise<TransactionReceipt>;
revokeAttribute(attrName: string, attrValue: string, options?: CallOverrides): Promise<TransactionReceipt>;
setAttributeSigned(attrName: string, attrValue: string, exp: number, metaSignature: MetaSignature, options?: Overrides): Promise<TransactionReceipt>;
revokeAttribute(attrName: string, attrValue: string, options?: Overrides): Promise<TransactionReceipt>;
createRevokeAttributeHash(attrName: string, attrValue: string): Promise<string>;

@@ -57,4 +55,4 @@ /**

private getPaddedNonceCompatibility;
revokeAttributeSigned(attrName: string, attrValue: string, metaSignature: MetaSignature, options?: CallOverrides): Promise<TransactionReceipt>;
revokeAttributeSigned(attrName: string, attrValue: string, metaSignature: MetaSignature, options?: Overrides): Promise<TransactionReceipt>;
}
//# sourceMappingURL=controller.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EthrDidController = void 0;
const ethers_1 = require("ethers");
const configuration_1 = require("./configuration");
const helpers_1 = require("./helpers");
const bytes_1 = require("@ethersproject/bytes");
const keccak256_1 = require("@ethersproject/keccak256");
const strings_1 = require("@ethersproject/strings");
/**

@@ -39,4 +37,4 @@ * A class that can be used to interact with the ERC1056 contract on behalf of a local controller key-pair

}
else if (provider || (signer === null || signer === void 0 ? void 0 : signer.provider) || rpcUrl) {
const prov = provider || (signer === null || signer === void 0 ? void 0 : signer.provider);
else if (provider || signer?.provider || rpcUrl) {
const prov = provider || signer?.provider;
this.contract = (0, configuration_1.getContractForNetwork)({ name: net, provider: prov, registry, rpcUrl });

@@ -56,11 +54,22 @@ }

async getOwner(address, blockTag) {
const result = await this.contract.functions.identityOwner(address, { blockTag });
return result[0];
return this.contract.identityOwner(address, { blockTag });
}
async attachContract(controller) {
const currentOwner = controller ? await controller : await this.getOwner(this.address, 'latest');
const signer = this.signer
? this.signer
: this.contract.provider.getSigner(currentOwner) || this.contract.signer;
return this.contract.connect(signer);
let currentOwner = controller ? await controller : await this.getOwner(this.address, 'latest');
if (typeof currentOwner !== 'string')
currentOwner = await controller.getAddress();
let signer;
if (this.signer) {
signer = this.signer;
}
else {
if (!this.contract)
throw new Error(`No contract configured`);
if (!this.contract.runner)
throw new Error(`No runner configured for contract`);
if (!this.contract.runner.provider)
throw new Error(`No provider configured for runner in contract`);
signer = (await this.contract.runner.provider.getSigner(currentOwner)) || this.contract.signer;
}
return this.contract.connect(signer); // Needed because ethers attach returns a BaseContract
}

@@ -73,5 +82,5 @@ async changeOwner(newOwner, options = {}) {

};
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const ownerChange = await contract.functions.changeOwner(this.address, newOwner, overrides);
const ownerChange = await contract.changeOwner(this.address, newOwner, overrides);
return await ownerChange.wait();

@@ -81,10 +90,10 @@ }

const paddedNonce = await this.getPaddedNonceCompatibility();
const dataToHash = (0, bytes_1.hexConcat)([
const dataToHash = (0, ethers_1.concat)([
helpers_1.MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
(0, bytes_1.concat)([(0, strings_1.toUtf8Bytes)('changeOwner'), newOwner]),
(0, ethers_1.getBytes)((0, ethers_1.concat)([(0, ethers_1.toUtf8Bytes)('changeOwner'), newOwner])),
]);
return (0, keccak256_1.keccak256)(dataToHash);
return (0, ethers_1.keccak256)(dataToHash);
}

@@ -96,5 +105,5 @@ async changeOwnerSigned(newOwner, metaSignature, options = {}) {

};
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const ownerChange = await contract.functions.changeOwnerSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, newOwner, overrides);
const ownerChange = await contract.changeOwnerSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, newOwner, overrides);
return await ownerChange.wait();

@@ -107,6 +116,6 @@ }

};
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const delegateTypeBytes = (0, helpers_1.stringToBytes32)(delegateType);
const addDelegateTx = await contract.functions.addDelegate(this.address, delegateTypeBytes, delegateAddress, exp, overrides);
const addDelegateTx = await contract.addDelegate(this.address, delegateTypeBytes, delegateAddress, exp, overrides);
return await addDelegateTx.wait();

@@ -116,15 +125,15 @@ }

const paddedNonce = await this.getPaddedNonceCompatibility();
const dataToHash = (0, bytes_1.hexConcat)([
const dataToHash = (0, ethers_1.concat)([
helpers_1.MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
(0, bytes_1.concat)([
(0, strings_1.toUtf8Bytes)('addDelegate'),
(0, strings_1.formatBytes32String)(delegateType),
(0, ethers_1.concat)([
(0, ethers_1.toUtf8Bytes)('addDelegate'),
(0, ethers_1.encodeBytes32String)(delegateType),
delegateAddress,
(0, bytes_1.zeroPad)((0, bytes_1.hexlify)(exp), 32),
(0, ethers_1.zeroPadValue)((0, ethers_1.toBeHex)(exp), 32),
]),
]);
return (0, keccak256_1.keccak256)(dataToHash);
return (0, ethers_1.keccak256)(dataToHash);
}

@@ -136,6 +145,6 @@ async addDelegateSigned(delegateType, delegateAddress, exp, metaSignature, options = {}) {

};
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const delegateTypeBytes = (0, helpers_1.stringToBytes32)(delegateType);
const addDelegateTx = await contract.functions.addDelegateSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, delegateTypeBytes, delegateAddress, exp, overrides);
const addDelegateTx = await contract.addDelegateSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, delegateTypeBytes, delegateAddress, exp, overrides);
return await addDelegateTx.wait();

@@ -149,5 +158,5 @@ }

delegateType = delegateType.startsWith('0x') ? delegateType : (0, helpers_1.stringToBytes32)(delegateType);
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const addDelegateTx = await contract.functions.revokeDelegate(this.address, delegateType, delegateAddress, overrides);
const addDelegateTx = await contract.revokeDelegate(this.address, delegateType, delegateAddress, overrides);
return await addDelegateTx.wait();

@@ -157,10 +166,10 @@ }

const paddedNonce = await this.getPaddedNonceCompatibility();
const dataToHash = (0, bytes_1.hexConcat)([
const dataToHash = (0, ethers_1.concat)([
helpers_1.MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
(0, bytes_1.concat)([(0, strings_1.toUtf8Bytes)('revokeDelegate'), (0, strings_1.formatBytes32String)(delegateType), delegateAddress]),
(0, ethers_1.getBytes)((0, ethers_1.concat)([(0, ethers_1.toUtf8Bytes)('revokeDelegate'), (0, ethers_1.encodeBytes32String)(delegateType), delegateAddress])),
]);
return (0, keccak256_1.keccak256)(dataToHash);
return (0, ethers_1.keccak256)(dataToHash);
}

@@ -173,5 +182,5 @@ async revokeDelegateSigned(delegateType, delegateAddress, metaSignature, options = {}) {

delegateType = delegateType.startsWith('0x') ? delegateType : (0, helpers_1.stringToBytes32)(delegateType);
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const addDelegateTx = await contract.functions.revokeDelegateSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, delegateType, delegateAddress, overrides);
const addDelegateTx = await contract.revokeDelegateSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, delegateType, delegateAddress, overrides);
return await addDelegateTx.wait();

@@ -187,5 +196,5 @@ }

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const setAttrTx = await contract.functions.setAttribute(this.address, attrName, attrValue, exp, overrides);
const setAttrTx = await contract.setAttribute(this.address, attrName, attrValue, exp, overrides);
return await setAttrTx.wait();

@@ -196,11 +205,16 @@ }

// The incoming attribute value may be a hex encoded key, or an utf8 encoded string (like service endpoints)
const encodedValue = (0, bytes_1.isHexString)(attrValue) ? attrValue : (0, strings_1.toUtf8Bytes)(attrValue);
const dataToHash = (0, bytes_1.hexConcat)([
const encodedValue = (0, ethers_1.isHexString)(attrValue) ? attrValue : (0, ethers_1.toUtf8Bytes)(attrValue);
const dataToHash = (0, ethers_1.concat)([
helpers_1.MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
(0, bytes_1.concat)([(0, strings_1.toUtf8Bytes)('setAttribute'), (0, strings_1.formatBytes32String)(attrName), encodedValue, (0, bytes_1.zeroPad)((0, bytes_1.hexlify)(exp), 32)]),
(0, ethers_1.concat)([
(0, ethers_1.toUtf8Bytes)('setAttribute'),
(0, ethers_1.encodeBytes32String)(attrName),
encodedValue,
(0, ethers_1.zeroPadValue)((0, ethers_1.toBeHex)(exp), 32),
]),
]);
return (0, keccak256_1.keccak256)(dataToHash);
return (0, ethers_1.keccak256)(dataToHash);
}

@@ -215,5 +229,5 @@ async setAttributeSigned(attrName, attrValue, exp, metaSignature, options = {}) {

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const setAttrTx = await contract.functions.setAttributeSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, attrName, attrValue, exp, overrides);
const setAttrTx = await contract.setAttributeSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, attrName, attrValue, exp, overrides);
return await setAttrTx.wait();

@@ -229,5 +243,5 @@ }

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const revokeAttributeTX = await contract.functions.revokeAttribute(this.address, attrName, attrValue, overrides);
const revokeAttributeTX = await contract.revokeAttribute(this.address, attrName, attrValue, overrides);
return await revokeAttributeTX.wait();

@@ -237,10 +251,10 @@ }

const paddedNonce = await this.getPaddedNonceCompatibility(true);
const dataToHash = (0, bytes_1.hexConcat)([
const dataToHash = (0, ethers_1.concat)([
helpers_1.MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
(0, bytes_1.concat)([(0, strings_1.toUtf8Bytes)('revokeAttribute'), (0, strings_1.formatBytes32String)(attrName), (0, strings_1.toUtf8Bytes)(attrValue)]),
(0, ethers_1.getBytes)((0, ethers_1.concat)([(0, ethers_1.toUtf8Bytes)('revokeAttribute'), (0, ethers_1.encodeBytes32String)(attrName), (0, ethers_1.toUtf8Bytes)(attrValue)])),
]);
return (0, keccak256_1.keccak256)(dataToHash);
return (0, ethers_1.keccak256)(dataToHash);
}

@@ -262,3 +276,3 @@ /**

}
return (0, bytes_1.zeroPad)((0, bytes_1.arrayify)(await this.contract.nonce(nonceKey)), 32);
return (0, ethers_1.zeroPadValue)((0, ethers_1.toBeHex)(await this.contract.nonce(nonceKey)), 32);
}

@@ -273,5 +287,5 @@ async revokeAttributeSigned(attrName, attrValue, metaSignature, options = {}) {

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex');
const contract = await this.attachContract(overrides.from);
const contract = await this.attachContract(overrides.from ?? undefined);
delete overrides.from;
const revokeAttributeTX = await contract.functions.revokeAttributeSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, attrName, attrValue, overrides);
const revokeAttributeTX = await contract.revokeAttributeSigned(this.address, metaSignature.sigV, metaSignature.sigR, metaSignature.sigS, attrName, attrValue, overrides);
return await revokeAttributeTX.wait();

@@ -278,0 +292,0 @@ }

@@ -1,4 +0,3 @@

import { BigNumber } from '@ethersproject/bignumber';
import { VerificationMethod } from 'did-resolver';
import { Contract } from '@ethersproject/contracts';
import { Contract } from 'ethers';
export declare const identifierMatcher: RegExp;

@@ -10,3 +9,3 @@ export declare const nullAddress = "0x0000000000000000000000000000000000000000";

export declare type address = string;
export declare type uint256 = BigNumber;
export declare type uint256 = bigint;
export declare type bytes32 = string;

@@ -17,3 +16,3 @@ export declare type bytes = string;

previousChange: uint256;
validTo?: uint256;
validTo?: bigint;
_eventName: string;

@@ -74,3 +73,3 @@ blockNumber: number;

};
export declare function signMetaTxData(identity: string, signerAddress: string, privateKeyBytes: Uint8Array, dataBytes: Uint8Array, didReg: Contract): Promise<import("@ethersproject/bytes").Signature>;
export declare function signMetaTxData(identity: string, signerAddress: string, privateKeyBytes: Uint8Array, dataBytes: Uint8Array, didReg: Contract): Promise<import("ethers").Signature>;
export declare enum Errors {

@@ -77,0 +76,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Errors = exports.signMetaTxData = exports.interpretIdentifier = exports.stringToBytes32 = exports.bytes32toString = exports.strip0x = exports.legacyAlgoMap = exports.legacyAttrTypes = exports.eventNames = exports.verificationMethodTypes = exports.MESSAGE_PREFIX = exports.DEFAULT_JSON_RPC = exports.DEFAULT_REGISTRY_ADDRESS = exports.nullAddress = exports.identifierMatcher = void 0;
const address_1 = require("@ethersproject/address");
const transactions_1 = require("@ethersproject/transactions");
const keccak256_1 = require("@ethersproject/keccak256");
const bytes_1 = require("@ethersproject/bytes");
const signing_key_1 = require("@ethersproject/signing-key");
const ethers_1 = require("ethers");
exports.identifierMatcher = /^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/;

@@ -71,6 +67,6 @@ exports.nullAddress = '0x0000000000000000000000000000000000000000';

if (id.length > 42) {
return { address: (0, transactions_1.computeAddress)(id), publicKey: id, network };
return { address: (0, ethers_1.computeAddress)(id), publicKey: id, network };
}
else {
return { address: (0, address_1.getAddress)(id), network }; // checksum address
return { address: (0, ethers_1.getAddress)(id), network }; // checksum address
}

@@ -81,6 +77,6 @@ }

const nonce = await didReg.nonce(signerAddress);
const paddedNonce = (0, bytes_1.zeroPad)((0, bytes_1.arrayify)(nonce), 32);
const dataToSign = (0, bytes_1.hexConcat)(['0x1900', didReg.address, paddedNonce, identity, dataBytes]);
const hash = (0, keccak256_1.keccak256)(dataToSign);
return new signing_key_1.SigningKey(privateKeyBytes).signDigest(hash);
const paddedNonce = (0, ethers_1.zeroPadValue)((0, ethers_1.toBeHex)(nonce), 32);
const dataToSign = (0, ethers_1.concat)(['0x1900', await didReg.getAddress(), paddedNonce, identity, dataBytes]);
const hash = (0, ethers_1.keccak256)(dataToSign);
return new ethers_1.SigningKey(privateKeyBytes).sign(hash);
}

@@ -87,0 +83,0 @@ exports.signMetaTxData = signMetaTxData;

@@ -1,5 +0,4 @@

import { Contract } from '@ethersproject/contracts';
import { Log } from '@ethersproject/providers';
import { Log, Contract } from 'ethers';
import { ERC1056Event } from './helpers';
export declare function logDecoder(contract: Contract, logs: Log[]): ERC1056Event[];
//# sourceMappingURL=logParser.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logDecoder = void 0;
const bignumber_1 = require("@ethersproject/bignumber");
const helpers_1 = require("./helpers");

@@ -9,9 +8,9 @@ function populateEventMetaClass(logResult, blockNumber) {

const result = {};
if (logResult.eventFragment.inputs.length !== logResult.args.length) {
if (logResult.fragment.inputs.length !== logResult.args.length) {
throw new TypeError('malformed event input. wrong number of arguments');
}
logResult.eventFragment.inputs.forEach((input, index) => {
logResult.fragment.inputs.forEach((input, index) => {
let val = logResult.args[index];
if (typeof val === 'object') {
val = bignumber_1.BigNumber.from(val);
val = BigInt(val);
}

@@ -29,9 +28,12 @@ if (input.type === 'bytes32') {

const results = logs.map((log) => {
const res = contract.interface.parseLog(log);
const res = contract.interface.parseLog({ topics: [...log.topics], data: log.data });
if (!res)
return;
const event = populateEventMetaClass(res, log.blockNumber);
return event;
});
return results;
const cleanResults = results.filter((result) => result !== undefined);
return cleanResults;
}
exports.logDecoder = logDecoder;
//# sourceMappingURL=logParser.js.map

@@ -1,3 +0,2 @@

import { BigNumber } from '@ethersproject/bignumber';
import { BlockTag } from '@ethersproject/providers';
import { BlockTag } from 'ethers';
import { ConfigurationOptions } from './configuration';

@@ -21,3 +20,3 @@ import { DIDDocument, DIDResolutionOptions, DIDResolutionResult, DIDResolver, ParsedDID, Resolvable } from 'did-resolver';

*/
previousChange(address: string, networkId: string, blockTag?: BlockTag): Promise<BigNumber>;
previousChange(address: string, networkId: string, blockTag?: BlockTag): Promise<bigint>;
getBlockMetadata(blockHeight: number, networkId: string): Promise<{

@@ -31,5 +30,5 @@ height: string;

controllerKey?: string;
chainId: number;
chainId: bigint;
}>;
wrapDidDocument(did: string, address: string, controllerKey: string | undefined, history: ERC1056Event[], chainId: number, blockHeight: string | number, now: BigNumber): {
wrapDidDocument(did: string, address: string, controllerKey: string | undefined, history: ERC1056Event[], chainId: bigint, blockHeight: string | number, now: bigint): {
didDocument: DIDDocument;

@@ -36,0 +35,0 @@ deactivated: boolean;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EthrDidResolver = exports.getResolver = void 0;
const basex_1 = require("@ethersproject/basex");
const bignumber_1 = require("@ethersproject/bignumber");
const ethers_1 = require("ethers");
const configuration_1 = require("./configuration");

@@ -33,8 +32,17 @@ const controller_1 = require("./controller");

async previousChange(address, networkId, blockTag) {
const result = await this.contracts[networkId].functions.changed(address, { blockTag });
const result = await this.contracts[networkId].changed(address, { blockTag });
// console.log(`last change result: '${BigNumber.from(result['0'])}'`)
return bignumber_1.BigNumber.from(result['0']);
return result;
}
async getBlockMetadata(blockHeight, networkId) {
const block = await this.contracts[networkId].provider.getBlock(blockHeight);
const networkContract = this.contracts[networkId];
if (!networkContract)
throw new Error(`No contract configured for network ${networkId}`);
if (!networkContract.runner)
throw new Error(`No runner configured for contract with network ${networkId}`);
if (!networkContract.runner.provider)
throw new Error(`No provider configured for runner in contract with network ${networkId}`);
const block = await networkContract.runner.provider.getBlock(blockHeight);
if (!block)
throw new Error(`Block at height ${blockHeight} not found`);
return {

@@ -47,6 +55,12 @@ height: block.number.toString(),

const contract = this.contracts[networkId];
const provider = contract.provider;
if (!contract)
throw new Error(`No contract configured for network ${networkId}`);
if (!contract.runner)
throw new Error(`No runner configured for contract with network ${networkId}`);
if (!contract.runner.provider)
throw new Error(`No provider configured for runner in contract with network ${networkId}`);
const provider = contract.runner.provider;
const hexChainId = networkId.startsWith('0x') ? networkId : undefined;
//TODO: this can be used to check if the configuration is ok
const chainId = hexChainId ? bignumber_1.BigNumber.from(hexChainId).toNumber() : (await provider.getNetwork()).chainId;
const chainId = hexChainId ? BigInt(hexChainId) : (await provider.getNetwork()).chainId;
const history = [];

@@ -59,7 +73,7 @@ const { address, publicKey } = (0, helpers_1.interpretIdentifier)(identity);

const logs = await provider.getLogs({
address: contract.address,
address: await contract.getAddress(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
topics: [null, `0x000000000000000000000000${address.slice(2)}`],
fromBlock: previousChange.toHexString(),
toBlock: previousChange.toHexString(),
fromBlock: previousChange,
toBlock: previousChange,
});

@@ -71,3 +85,3 @@ const events = (0, logParser_1.logDecoder)(contract, logs);

history.unshift(event);
if (event.previousChange.lt(blockNumber)) {
if (event.previousChange < blockNumber) {
previousChange = event.previousChange;

@@ -80,3 +94,2 @@ }

wrapDidDocument(did, address, controllerKey, history, chainId, blockHeight, now) {
var _a;
const baseDIDDocument = {

@@ -114,5 +127,5 @@ '@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/secp256k1recovery-2020/v2'],

}
const validTo = event.validTo || bignumber_1.BigNumber.from(0);
const validTo = event.validTo || BigInt(0);
const eventIndex = `${event._eventName}-${event.delegateType || event.name}-${event.delegate || event.value}`;
if (validTo && validTo.gte(now)) {
if (validTo && validTo >= now) {
if (event._eventName === helpers_1.eventNames.DIDDelegateChanged) {

@@ -164,3 +177,3 @@ const currentEvent = event;

case 'base58':
pk.publicKeyBase58 = basex_1.Base58.encode(Buffer.from(currentEvent.value.slice(2), 'hex'));
pk.publicKeyBase58 = (0, ethers_1.encodeBase58)(Buffer.from(currentEvent.value.slice(2), 'hex'));
break;

@@ -187,3 +200,3 @@ case 'pem':

}
catch (_b) {
catch {
endpoint = Buffer.from(currentEvent.value.slice(2), 'hex').toString();

@@ -252,3 +265,3 @@ }

}
didDocument.assertionMethod = [...(((_a = didDocument.verificationMethod) === null || _a === void 0 ? void 0 : _a.map((pk) => pk.id)) || [])];
didDocument.assertionMethod = [...(didDocument.verificationMethod?.map((pk) => pk.id) || [])];
return deactivated

@@ -266,3 +279,2 @@ ? {

_unused, options) {
var _a;
const fullId = parsed.id.match(helpers_1.identifierMatcher);

@@ -284,9 +296,9 @@ if (!fullId) {

const qParams = new URLSearchParams(parsed.query);
blockTag = (_a = qParams.get('versionId')) !== null && _a !== void 0 ? _a : blockTag;
try {
blockTag = Number.parseInt(blockTag);
blockTag = qParams.get('versionId') ?? blockTag;
const parsedBlockTag = Number.parseInt(blockTag);
if (!Number.isNaN(parsedBlockTag)) {
blockTag = parsedBlockTag;
}
catch (e) {
else {
blockTag = 'latest';
// invalid versionId parameters are ignored
}

@@ -304,6 +316,6 @@ }

}
let now = bignumber_1.BigNumber.from(Math.floor(new Date().getTime() / 1000));
let now = BigInt(Math.floor(new Date().getTime() / 1000));
if (typeof blockTag === 'number') {
const block = await this.getBlockMetadata(blockTag, networkId);
now = bignumber_1.BigNumber.from(Date.parse(block.isoDate) / 1000);
now = BigInt(Date.parse(block.isoDate) / 1000);
}

@@ -310,0 +322,0 @@ else {

{
"name": "ethr-did-resolver",
"version": "8.1.2",
"version": "9.0.0",
"description": "Resolve DID documents for ethereum addresses and public keys",

@@ -86,3 +86,2 @@ "type": "commonjs",

"@babel/preset-typescript": "7.18.6",
"@ethersproject/strings": "5.7.0",
"@semantic-release/changelog": "6.0.1",

@@ -106,15 +105,5 @@ "@semantic-release/git": "10.0.1",

"dependencies": {
"@ethersproject/abi": "^5.6.3",
"@ethersproject/abstract-signer": "^5.6.2",
"@ethersproject/address": "^5.6.1",
"@ethersproject/basex": "^5.6.1",
"@ethersproject/bignumber": "^5.6.2",
"@ethersproject/bytes": "^5.6.1",
"@ethersproject/contracts": "^5.6.2",
"@ethersproject/keccak256": "^5.6.1",
"@ethersproject/providers": "^5.6.8",
"@ethersproject/signing-key": "^5.6.2",
"@ethersproject/transactions": "^5.6.2",
"did-resolver": "^4.0.1"
"did-resolver": "^4.0.1",
"ethers": "6.7.1"
}
}

@@ -1,2 +0,2 @@

import { InfuraProvider, JsonRpcProvider } from '@ethersproject/providers'
import { InfuraProvider, JsonRpcProvider } from 'ethers'
import { configureResolverWithNetworks } from '../configuration'

@@ -30,4 +30,4 @@

})
expect((<InfuraProvider>contracts['mainnet'].provider).projectId).not.toBeDefined()
expect((<JsonRpcProvider>contracts['mainnet'].provider).connection.url).toBe('redefine me')
expect((<InfuraProvider>contracts['mainnet'].runner!.provider).projectId).not.toBeDefined()
expect((<JsonRpcProvider>contracts['mainnet'].runner!.provider)._getConnection().url).toBe('redefine me')
})

@@ -69,3 +69,3 @@

rpcUrl: 'some rinkeby JSONRPC URL',
chainId: 1,
chainId: BigInt(1),
})

@@ -72,0 +72,0 @@ expect(contracts['0x1']).toBeDefined()

@@ -1,2 +0,2 @@

import { Contract, ContractFactory } from '@ethersproject/contracts'
import { BrowserProvider, Contract, ContractFactory, getBytes, SigningKey } from 'ethers'
import { Resolvable, Resolver } from 'did-resolver'

@@ -6,4 +6,2 @@ import { getResolver } from '../resolver'

import { createProvider } from './testUtils'
import { arrayify } from '@ethersproject/bytes'
import { SigningKey } from '@ethersproject/signing-key'
import { default as LegacyEthereumDIDRegistry } from './EthereumDIDRegistry-Legacy/LegacyEthereumDIDRegistry.json'

@@ -28,17 +26,19 @@ import { default as EthereumDIDRegistry } from '../config/EthereumDIDRegistry.json'

const web3Provider = createProvider()
let browserProvider: BrowserProvider
beforeAll(async () => {
const legacyFactory = ContractFactory.fromSolidity(LegacyEthereumDIDRegistry).connect(web3Provider.getSigner(0))
browserProvider = createProvider()
const legacyFactory = ContractFactory.fromSolidity(LegacyEthereumDIDRegistry).connect(
await browserProvider.getSigner(0)
)
legacyRegistryContract = await legacyFactory.deploy()
legacyRegistryContract = await legacyRegistryContract.deployed()
await legacyRegistryContract.deployTransaction.wait()
const legacyRegistryAddress = legacyRegistryContract.address
legacyRegistryContract = await legacyRegistryContract.waitForDeployment()
const legacyRegistryAddress = await legacyRegistryContract.getAddress()
const factory = ContractFactory.fromSolidity(EthereumDIDRegistry).connect(web3Provider.getSigner(0))
registryContract = await (await factory.deploy()).deployed()
await registryContract.deployTransaction.wait()
const registryAddress = registryContract.address
const factory = ContractFactory.fromSolidity(EthereumDIDRegistry).connect(await browserProvider.getSigner(0))
registryContract = await (await factory.deploy()).waitForDeployment()
const registryAddress = await registryContract.getAddress()
accounts = await web3Provider.listAccounts()
const accountSigners = await browserProvider.listAccounts()
accounts = accountSigners.map((signer) => signer.address)

@@ -56,4 +56,4 @@ identity = accounts[1]

networks: [
{ name: 'legacy', provider: web3Provider, registry: legacyRegistryAddress },
{ name: 'dev', provider: web3Provider, registry: registryAddress },
{ name: 'legacy', provider: browserProvider, registry: legacyRegistryAddress },
{ name: 'dev', provider: browserProvider, registry: registryAddress },
],

@@ -76,4 +76,4 @@ })

const originalOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000002')
const nextOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000003')
const originalOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000002')
const nextOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000003')

@@ -83,3 +83,3 @@ const ethrController = new EthrDidController(

registryContract,
web3Provider.getSigner(signer),
await browserProvider.getSigner(signer),
undefined,

@@ -93,3 +93,3 @@ undefined,

const hash = await ethrController.createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)
const signature = new SigningKey(originalOwnerPrivateKey).sign(hash)

@@ -103,3 +103,3 @@ await ethrController.changeOwnerSigned(nextOwner, {

const hash2 = await ethrController.createChangeOwnerHash(finalOwner)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)
const signature2 = new SigningKey(nextOwnerPrivateKey).sign(hash2)

@@ -112,6 +112,6 @@ await ethrController.changeOwnerSigned(finalOwner, {

const originalNonce = await registryContract.functions.nonce(originalOwner)
const signerNonce = await registryContract.functions.nonce(nextOwner)
expect(originalNonce[0]._hex).toEqual('0x01')
expect(signerNonce[0]._hex).toEqual('0x01')
const originalNonce: bigint = await registryContract.nonce(originalOwner)
const signerNonce: bigint = await registryContract.nonce(nextOwner)
expect(originalNonce).toEqual(1n)
expect(signerNonce).toEqual(1n)
})

@@ -131,4 +131,4 @@

const originalOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000005')
const nextOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000006')
const originalOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000005')
const nextOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000006')

@@ -138,3 +138,3 @@ const ethrController = new EthrDidController(

registryContract,
web3Provider.getSigner(signer),
await browserProvider.getSigner(signer),
undefined,

@@ -148,3 +148,3 @@ undefined,

const hash = await ethrController.createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)
const signature = new SigningKey(originalOwnerPrivateKey).sign(hash)

@@ -158,3 +158,3 @@ await ethrController.changeOwnerSigned(nextOwner, {

const hash2 = await ethrController.createSetAttributeHash(attributeName, attributeValue, attributeExpiration)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)
const signature2 = new SigningKey(nextOwnerPrivateKey).sign(hash2)

@@ -167,6 +167,6 @@ await ethrController.setAttributeSigned(attributeName, attributeValue, attributeExpiration, {

const originalNonce = await registryContract.functions.nonce(originalOwner)
const signerNonce = await registryContract.functions.nonce(nextOwner)
expect(originalNonce[0]._hex).toEqual('0x01')
expect(signerNonce[0]._hex).toEqual('0x01')
const originalNonce = await registryContract.nonce(originalOwner)
const signerNonce = await registryContract.nonce(nextOwner)
expect(originalNonce).toEqual(1n)
expect(signerNonce).toEqual(1n)
})

@@ -187,35 +187,37 @@ })

const originalOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000002')
const nextOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000003')
const originalOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000002')
const nextOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000003')
const hash = await new EthrDidController(identifier, legacyRegistryContract).createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)
const signature = new SigningKey(originalOwnerPrivateKey).sign(hash)
await new EthrDidController(identifier, legacyRegistryContract, web3Provider.getSigner(signer)).changeOwnerSigned(
nextOwner,
{
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
}
)
await new EthrDidController(
identifier,
legacyRegistryContract,
await browserProvider.getSigner(signer)
).changeOwnerSigned(nextOwner, {
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
})
const hash2 = await new EthrDidController(identifier, legacyRegistryContract).createChangeOwnerHash(finalOwner)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)
const signature2 = new SigningKey(nextOwnerPrivateKey).sign(hash2)
await new EthrDidController(identifier, legacyRegistryContract, web3Provider.getSigner(signer)).changeOwnerSigned(
finalOwner,
{
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
}
)
await new EthrDidController(
identifier,
legacyRegistryContract,
await browserProvider.getSigner(signer)
).changeOwnerSigned(finalOwner, {
sigV: signature2.v,
sigR: signature2.r,
sigS: signature2.s,
})
// Expect the nonce of the original identity to equal 2 as the nonce tracking in the legacy contract is
// done on an identity basis
const originalNonce = await legacyRegistryContract.functions.nonce(originalOwner)
const signerNonce = await legacyRegistryContract.functions.nonce(nextOwner)
expect(originalNonce[0]._hex).toEqual('0x02')
expect(signerNonce[0]._hex).toEqual('0x00')
const originalNonce = await legacyRegistryContract.nonce(originalOwner)
const signerNonce = await legacyRegistryContract.nonce(nextOwner)
expect(originalNonce).toEqual(2n)
expect(signerNonce).toEqual(0n)
})

@@ -235,16 +237,17 @@

const originalOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000005')
const nextOwnerPrivateKey = arrayify('0x0000000000000000000000000000000000000000000000000000000000000006')
const originalOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000005')
const nextOwnerPrivateKey = getBytes('0x0000000000000000000000000000000000000000000000000000000000000006')
const hash = await new EthrDidController(identifier, legacyRegistryContract).createChangeOwnerHash(nextOwner)
const signature = new SigningKey(originalOwnerPrivateKey).signDigest(hash)
const signature = new SigningKey(originalOwnerPrivateKey).sign(hash)
await new EthrDidController(identifier, legacyRegistryContract, web3Provider.getSigner(signer)).changeOwnerSigned(
nextOwner,
{
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
}
)
await new EthrDidController(
identifier,
legacyRegistryContract,
await browserProvider.getSigner(signer)
).changeOwnerSigned(nextOwner, {
sigV: signature.v,
sigR: signature.r,
sigS: signature.s,
})

@@ -256,3 +259,3 @@ const hash2 = await new EthrDidController(identifier, legacyRegistryContract).createSetAttributeHash(

)
const signature2 = new SigningKey(nextOwnerPrivateKey).signDigest(hash2)
const signature2 = new SigningKey(nextOwnerPrivateKey).sign(hash2)

@@ -262,3 +265,3 @@ await new EthrDidController(

legacyRegistryContract,
web3Provider.getSigner(signer)
await browserProvider.getSigner(signer)
).setAttributeSigned(attributeName, attributeValue, attributeExpiration, {

@@ -270,7 +273,7 @@ sigV: signature2.v,

const nonce = await legacyRegistryContract.functions.nonce(originalOwner)
const nonce = await legacyRegistryContract.nonce(originalOwner)
expect(nonce[0]._hex).toEqual('0x02')
expect(nonce).toEqual(2n)
})
})
})

@@ -1,6 +0,6 @@

import { ExternalProvider, JsonRpcProvider, Web3Provider } from '@ethersproject/providers'
import { BrowserProvider } from 'ethers'
import ganache from 'ganache'
export function createProvider(): JsonRpcProvider {
return new Web3Provider(
export function createProvider() {
return new BrowserProvider(
ganache.provider({

@@ -90,3 +90,3 @@ logging: { quiet: true },

],
}) as unknown as ExternalProvider
})
)

@@ -98,7 +98,7 @@ }

}
export async function stopMining(provider: JsonRpcProvider): Promise<unknown> {
export async function stopMining(provider: BrowserProvider): Promise<unknown> {
return provider.send('miner_stop', [])
}
export async function startMining(provider: JsonRpcProvider): Promise<unknown> {
export async function startMining(provider: BrowserProvider): Promise<unknown> {
return provider.send('miner_start', [1])
}

@@ -13,3 +13,3 @@ /**

*/
chainId: number
chainId: number | bigint
/**

@@ -50,4 +50,9 @@ * The ERC1056 contract address on this network

{ chainId: 30, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rsk', legacyNonce: true },
{ chainId: 31, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'rsk:testnet', legacyNonce: true },
{
chainId: 31,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
name: 'rsk:testnet',
legacyNonce: true,
},
{
chainId: 246,

@@ -66,8 +71,33 @@ registry: '0xE29672f34e92b56C9169f9D485fFc8b9A136BCE4',

},
{ chainId: 246785, registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B', name: 'artis:tau1', legacyNonce: true },
{ chainId: 246529, registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B', name: 'artis:sigma1', legacyNonce: true },
{
chainId: 246785,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:tau1',
legacyNonce: true,
},
{
chainId: 246529,
registry: '0xdCa7EF03e98e0DC2B855bE647C39ABe984fcF21B',
name: 'artis:sigma1',
legacyNonce: true,
},
{ chainId: 137, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'polygon', legacyNonce: true },
{ chainId: 80001, registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b', name: 'polygon:test', legacyNonce: true },
{ chainId: 1313161554, registry: '0x63eD58B671EeD12Bc1652845ba5b2CDfBff198e0', name: 'aurora', legacyNonce: true },
{ chainId: 59140, registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818', name: 'linea:goerli', legacyNonce: false },
{
chainId: 80001,
registry: '0xdca7ef03e98e0dc2b855be647c39abe984fcf21b',
name: 'polygon:test',
legacyNonce: true,
},
{
chainId: 1313161554,
registry: '0x63eD58B671EeD12Bc1652845ba5b2CDfBff198e0',
name: 'aurora',
legacyNonce: true,
},
{
chainId: 59140,
registry: '0x03d5003bf0e79C5F5223588F347ebA39AfbC3818',
name: 'linea:goerli',
legacyNonce: false,
},
]

@@ -1,4 +0,2 @@

import { BigNumber } from '@ethersproject/bignumber'
import { Contract, ContractFactory } from '@ethersproject/contracts'
import { JsonRpcProvider, Provider } from '@ethersproject/providers'
import { Contract, ContractFactory, JsonRpcProvider, Provider } from 'ethers'
import { DEFAULT_REGISTRY_ADDRESS } from './helpers'

@@ -29,4 +27,4 @@ import { deployments, EthrDidRegistryDeployment } from './config/deployments'

export interface ProviderConfiguration extends Omit<EthrDidRegistryDeployment, 'chainId'> {
provider?: Provider
chainId?: string | number
provider?: Provider | null
chainId?: string | number | bigint
// eslint-disable-next-line @typescript-eslint/no-explicit-any

@@ -72,3 +70,3 @@ web3?: any

const chainIdRaw = conf.chainId ? conf.chainId : deployments.find((d) => d.name === conf.name)?.chainId
const chainId = chainIdRaw ? BigNumber.from(chainIdRaw).toNumber() : chainIdRaw
const chainId = chainIdRaw ? BigInt(chainIdRaw) : chainIdRaw
provider = new JsonRpcProvider(conf.rpcUrl, chainId || 'any')

@@ -79,6 +77,6 @@ } else {

}
const contract: Contract = ContractFactory.fromSolidity(EthereumDIDRegistry)
const contract = ContractFactory.fromSolidity(EthereumDIDRegistry)
.attach(conf.registry || DEFAULT_REGISTRY_ADDRESS)
.connect(provider)
return contract
return contract as Contract
}

@@ -94,3 +92,3 @@

}
const id = typeof chainId === 'number' ? `0x${chainId.toString(16)}` : chainId
const id = typeof chainId === 'bigint' || typeof chainId === 'number' ? `0x${chainId.toString(16)}` : chainId
networks[id] = getContractForNetwork(net)

@@ -97,0 +95,0 @@ } else if (net.provider || net.web3 || net.rpcUrl) {

@@ -1,4 +0,20 @@

import { Signer } from '@ethersproject/abstract-signer'
import { CallOverrides, Contract } from '@ethersproject/contracts'
import { BlockTag, JsonRpcProvider, Provider, TransactionReceipt } from '@ethersproject/providers'
import {
Signer,
Contract,
BlockTag,
JsonRpcProvider,
Provider,
TransactionReceipt,
getBytes,
concat,
toBeHex,
isHexString,
zeroPadValue,
toUtf8Bytes,
keccak256,
encodeBytes32String,
Overrides,
AddressLike,
Addressable,
} from 'ethers'
import { getContractForNetwork } from './configuration'

@@ -13,5 +29,2 @@ import {

} from './helpers'
import { arrayify, concat, hexConcat, hexlify, isHexString, zeroPad } from '@ethersproject/bytes'
import { keccak256 } from '@ethersproject/keccak256'
import { formatBytes32String, toUtf8Bytes } from '@ethersproject/strings'

@@ -78,15 +91,21 @@ /**

async getOwner(address: address, blockTag?: BlockTag): Promise<string> {
const result = await this.contract.functions.identityOwner(address, { blockTag })
return result[0]
return this.contract.identityOwner(address, { blockTag })
}
async attachContract(controller?: address | Promise<address>): Promise<Contract> {
const currentOwner = controller ? await controller : await this.getOwner(this.address, 'latest')
const signer = this.signer
? this.signer
: (<JsonRpcProvider>this.contract.provider).getSigner(currentOwner) || this.contract.signer
return this.contract.connect(signer)
async attachContract(controller?: AddressLike): Promise<Contract> {
let currentOwner = controller ? await controller : await this.getOwner(this.address, 'latest')
if (typeof currentOwner !== 'string') currentOwner = await (controller as Addressable).getAddress()
let signer
if (this.signer) {
signer = this.signer
} else {
if (!this.contract) throw new Error(`No contract configured`)
if (!this.contract.runner) throw new Error(`No runner configured for contract`)
if (!this.contract.runner.provider) throw new Error(`No provider configured for runner in contract`)
signer = (await (<JsonRpcProvider>this.contract.runner.provider).getSigner(currentOwner)) || this.contract.signer
}
return this.contract.connect(signer) as Contract // Needed because ethers attach returns a BaseContract
}
async changeOwner(newOwner: address, options: CallOverrides = {}): Promise<TransactionReceipt> {
async changeOwner(newOwner: address, options: Overrides = {}): Promise<TransactionReceipt> {
// console.log(`changing owner for ${oldOwner} on registry at ${registryContract.address}`)

@@ -96,8 +115,7 @@ const overrides = {

...options,
}
const contract = await this.attachContract(overrides.from)
} as Overrides
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const ownerChange = await contract.functions.changeOwner(this.address, newOwner, overrides)
const ownerChange = await contract.changeOwner(this.address, newOwner, overrides)
return await ownerChange.wait()

@@ -109,8 +127,8 @@ }

const dataToHash = hexConcat([
const dataToHash = concat([
MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
concat([toUtf8Bytes('changeOwner'), newOwner]),
getBytes(concat([toUtf8Bytes('changeOwner'), newOwner])),
])

@@ -123,3 +141,3 @@ return keccak256(dataToHash)

metaSignature: MetaSignature,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -131,6 +149,6 @@ const overrides = {

const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const ownerChange = await contract.functions.changeOwnerSigned(
const ownerChange = await contract.changeOwnerSigned(
this.address,

@@ -150,3 +168,3 @@ metaSignature.sigV,

exp: number,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -157,13 +175,7 @@ const overrides = {

}
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const delegateTypeBytes = stringToBytes32(delegateType)
const addDelegateTx = await contract.functions.addDelegate(
this.address,
delegateTypeBytes,
delegateAddress,
exp,
overrides
)
const addDelegateTx = await contract.addDelegate(this.address, delegateTypeBytes, delegateAddress, exp, overrides)
return await addDelegateTx.wait()

@@ -175,5 +187,5 @@ }

const dataToHash = hexConcat([
const dataToHash = concat([
MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,

@@ -183,5 +195,5 @@ this.address,

toUtf8Bytes('addDelegate'),
formatBytes32String(delegateType),
encodeBytes32String(delegateType),
delegateAddress,
zeroPad(hexlify(exp), 32),
zeroPadValue(toBeHex(exp), 32),
]),

@@ -197,3 +209,3 @@ ])

metaSignature: MetaSignature,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -204,7 +216,7 @@ const overrides = {

}
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const delegateTypeBytes = stringToBytes32(delegateType)
const addDelegateTx = await contract.functions.addDelegateSigned(
const addDelegateTx = await contract.addDelegateSigned(
this.address,

@@ -225,3 +237,3 @@ metaSignature.sigV,

delegateAddress: address,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -233,10 +245,5 @@ const overrides = {

delegateType = delegateType.startsWith('0x') ? delegateType : stringToBytes32(delegateType)
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const addDelegateTx = await contract.functions.revokeDelegate(
this.address,
delegateType,
delegateAddress,
overrides
)
const addDelegateTx = await contract.revokeDelegate(this.address, delegateType, delegateAddress, overrides)
return await addDelegateTx.wait()

@@ -248,8 +255,8 @@ }

const dataToHash = hexConcat([
const dataToHash = concat([
MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
concat([toUtf8Bytes('revokeDelegate'), formatBytes32String(delegateType), delegateAddress]),
getBytes(concat([toUtf8Bytes('revokeDelegate'), encodeBytes32String(delegateType), delegateAddress])),
])

@@ -263,3 +270,3 @@ return keccak256(dataToHash)

metaSignature: MetaSignature,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -271,5 +278,5 @@ const overrides = {

delegateType = delegateType.startsWith('0x') ? delegateType : stringToBytes32(delegateType)
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const addDelegateTx = await contract.functions.revokeDelegateSigned(
const addDelegateTx = await contract.revokeDelegateSigned(
this.address,

@@ -290,3 +297,3 @@ metaSignature.sigV,

exp: number,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -300,5 +307,5 @@ const overrides = {

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const setAttrTx = await contract.functions.setAttribute(this.address, attrName, attrValue, exp, overrides)
const setAttrTx = await contract.setAttribute(this.address, attrName, attrValue, exp, overrides)
return await setAttrTx.wait()

@@ -313,8 +320,13 @@ }

const dataToHash = hexConcat([
const dataToHash = concat([
MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
concat([toUtf8Bytes('setAttribute'), formatBytes32String(attrName), encodedValue, zeroPad(hexlify(exp), 32)]),
concat([
toUtf8Bytes('setAttribute'),
encodeBytes32String(attrName),
encodedValue,
zeroPadValue(toBeHex(exp), 32),
]),
])

@@ -329,3 +341,3 @@ return keccak256(dataToHash)

metaSignature: MetaSignature,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -339,5 +351,5 @@ const overrides = {

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const setAttrTx = await contract.functions.setAttributeSigned(
const setAttrTx = await contract.setAttributeSigned(
this.address,

@@ -355,3 +367,3 @@ metaSignature.sigV,

async revokeAttribute(attrName: string, attrValue: string, options: CallOverrides = {}): Promise<TransactionReceipt> {
async revokeAttribute(attrName: string, attrValue: string, options: Overrides = {}): Promise<TransactionReceipt> {
// console.log(`revoking attribute ${attrName}(${attrValue}) for ${identity}`)

@@ -364,5 +376,5 @@ const overrides = {

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const revokeAttributeTX = await contract.functions.revokeAttribute(this.address, attrName, attrValue, overrides)
const revokeAttributeTX = await contract.revokeAttribute(this.address, attrName, attrValue, overrides)
return await revokeAttributeTX.wait()

@@ -374,8 +386,8 @@ }

const dataToHash = hexConcat([
const dataToHash = concat([
MESSAGE_PREFIX,
this.contract.address,
await this.contract.getAddress(),
paddedNonce,
this.address,
concat([toUtf8Bytes('revokeAttribute'), formatBytes32String(attrName), toUtf8Bytes(attrValue)]),
getBytes(concat([toUtf8Bytes('revokeAttribute'), encodeBytes32String(attrName), toUtf8Bytes(attrValue)])),
])

@@ -399,3 +411,3 @@ return keccak256(dataToHash)

}
return zeroPad(arrayify(await this.contract.nonce(nonceKey)), 32)
return zeroPadValue(toBeHex(await this.contract.nonce(nonceKey)), 32)
}

@@ -407,3 +419,3 @@

metaSignature: MetaSignature,
options: CallOverrides = {}
options: Overrides = {}
): Promise<TransactionReceipt> {

@@ -417,5 +429,5 @@ // console.log(`revoking attribute ${attrName}(${attrValue}) for ${identity}`)

attrValue = attrValue.startsWith('0x') ? attrValue : '0x' + Buffer.from(attrValue, 'utf-8').toString('hex')
const contract = await this.attachContract(overrides.from)
const contract = await this.attachContract(overrides.from ?? undefined)
delete overrides.from
const revokeAttributeTX = await contract.functions.revokeAttributeSigned(
const revokeAttributeTX = await contract.revokeAttributeSigned(
this.address,

@@ -422,0 +434,0 @@ metaSignature.sigV,

@@ -1,9 +0,3 @@

import { getAddress } from '@ethersproject/address'
import { BigNumber } from '@ethersproject/bignumber'
import { computeAddress } from '@ethersproject/transactions'
import { VerificationMethod } from 'did-resolver'
import { Contract } from '@ethersproject/contracts'
import { keccak256 } from '@ethersproject/keccak256'
import { arrayify, hexConcat, zeroPad } from '@ethersproject/bytes'
import { SigningKey } from '@ethersproject/signing-key'
import { keccak256, getAddress, computeAddress, Contract, SigningKey, concat, toBeHex, zeroPadValue } from 'ethers'

@@ -17,3 +11,3 @@ export const identifierMatcher = /^(.*)?(0x[0-9a-fA-F]{40}|0x[0-9a-fA-F]{66})$/

export type address = string
export type uint256 = BigNumber
export type uint256 = bigint
export type bytes32 = string

@@ -25,3 +19,3 @@ export type bytes = string

previousChange: uint256
validTo?: uint256
validTo?: bigint
_eventName: string

@@ -140,6 +134,6 @@ blockNumber: number

const nonce = await didReg.nonce(signerAddress)
const paddedNonce = zeroPad(arrayify(nonce), 32)
const dataToSign = hexConcat(['0x1900', didReg.address, paddedNonce, identity, dataBytes])
const paddedNonce = zeroPadValue(toBeHex(nonce), 32)
const dataToSign = concat(['0x1900', await didReg.getAddress(), paddedNonce, identity, dataBytes])
const hash = keccak256(dataToSign)
return new SigningKey(privateKeyBytes).signDigest(hash)
return new SigningKey(privateKeyBytes).sign(hash)
}

@@ -146,0 +140,0 @@

@@ -1,5 +0,2 @@

import { BigNumber } from '@ethersproject/bignumber'
import { Contract } from '@ethersproject/contracts'
import { Log } from '@ethersproject/providers'
import { LogDescription } from '@ethersproject/abi'
import { Log, LogDescription, Contract } from 'ethers'
import { bytes32toString, ERC1056Event } from './helpers'

@@ -10,9 +7,9 @@

const result: Record<string, any> = {}
if (logResult.eventFragment.inputs.length !== logResult.args.length) {
if (logResult.fragment.inputs.length !== logResult.args.length) {
throw new TypeError('malformed event input. wrong number of arguments')
}
logResult.eventFragment.inputs.forEach((input, index) => {
logResult.fragment.inputs.forEach((input, index) => {
let val = logResult.args[index]
if (typeof val === 'object') {
val = BigNumber.from(val)
val = BigInt(val)
}

@@ -30,8 +27,13 @@ if (input.type === 'bytes32') {

export function logDecoder(contract: Contract, logs: Log[]): ERC1056Event[] {
const results: ERC1056Event[] = logs.map((log: Log) => {
const res = contract.interface.parseLog(log)
const results: (ERC1056Event | undefined)[] = logs.map((log: Log) => {
const res = contract.interface.parseLog({ topics: [...log.topics], data: log.data })
if (!res) return
const event = populateEventMetaClass(res, log.blockNumber)
return event
})
return results
const cleanResults: (ERC1056Event | undefined)[] = results.filter((result) => result !== undefined)
// THIS IS THE GIGA HACK JUST TO REMOVE THE POSSIBLE UNDEFINED FROM THE ARRAY
// THAT IS INTRODUCED BY THE .MAP ABOVE
type cleanResult = Exclude<typeof results[0], undefined>
return cleanResults as Array<cleanResult>
}

@@ -1,4 +0,2 @@

import { Base58 } from '@ethersproject/basex'
import { BigNumber } from '@ethersproject/bignumber'
import { Block, BlockTag } from '@ethersproject/providers'
import { BlockTag, encodeBase58 } from 'ethers'
import { ConfigurationOptions, ConfiguredNetworks, configureResolverWithNetworks } from './configuration'

@@ -60,10 +58,16 @@ import { EthrDidController } from './controller'

*/
async previousChange(address: string, networkId: string, blockTag?: BlockTag): Promise<BigNumber> {
const result = await this.contracts[networkId].functions.changed(address, { blockTag })
async previousChange(address: string, networkId: string, blockTag?: BlockTag): Promise<bigint> {
const result = await this.contracts[networkId].changed(address, { blockTag })
// console.log(`last change result: '${BigNumber.from(result['0'])}'`)
return BigNumber.from(result['0'])
return result
}
async getBlockMetadata(blockHeight: number, networkId: string): Promise<{ height: string; isoDate: string }> {
const block: Block = await this.contracts[networkId].provider.getBlock(blockHeight)
const networkContract = this.contracts[networkId]
if (!networkContract) throw new Error(`No contract configured for network ${networkId}`)
if (!networkContract.runner) throw new Error(`No runner configured for contract with network ${networkId}`)
if (!networkContract.runner.provider)
throw new Error(`No provider configured for runner in contract with network ${networkId}`)
const block = await networkContract.runner.provider.getBlock(blockHeight)
if (!block) throw new Error(`Block at height ${blockHeight} not found`)
return {

@@ -79,20 +83,24 @@ height: block.number.toString(),

blockTag: BlockTag = 'latest'
): Promise<{ address: string; history: ERC1056Event[]; controllerKey?: string; chainId: number }> {
): Promise<{ address: string; history: ERC1056Event[]; controllerKey?: string; chainId: bigint }> {
const contract = this.contracts[networkId]
const provider = contract.provider
if (!contract) throw new Error(`No contract configured for network ${networkId}`)
if (!contract.runner) throw new Error(`No runner configured for contract with network ${networkId}`)
if (!contract.runner.provider)
throw new Error(`No provider configured for runner in contract with network ${networkId}`)
const provider = contract.runner.provider
const hexChainId = networkId.startsWith('0x') ? networkId : undefined
//TODO: this can be used to check if the configuration is ok
const chainId = hexChainId ? BigNumber.from(hexChainId).toNumber() : (await provider.getNetwork()).chainId
const chainId = hexChainId ? BigInt(hexChainId) : (await provider.getNetwork()).chainId
const history: ERC1056Event[] = []
const { address, publicKey } = interpretIdentifier(identity)
const controllerKey = publicKey
let previousChange: BigNumber | null = await this.previousChange(address, networkId, blockTag)
let previousChange: bigint | null = await this.previousChange(address, networkId, blockTag)
while (previousChange) {
const blockNumber = previousChange
const logs = await provider.getLogs({
address: contract.address, // networks[networkId].registryAddress,
address: await contract.getAddress(), // networks[networkId].registryAddress,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
topics: [null as any, `0x000000000000000000000000${address.slice(2)}`],
fromBlock: previousChange.toHexString(),
toBlock: previousChange.toHexString(),
fromBlock: previousChange,
toBlock: previousChange,
})

@@ -104,3 +112,3 @@ const events: ERC1056Event[] = logDecoder(contract, logs)

history.unshift(event)
if (event.previousChange.lt(blockNumber)) {
if (event.previousChange < blockNumber) {
previousChange = event.previousChange

@@ -118,5 +126,5 @@ }

history: ERC1056Event[],
chainId: number,
chainId: bigint,
blockHeight: string | number,
now: BigNumber
now: bigint
): { didDocument: DIDDocument; deactivated: boolean; versionId: number; nextVersionId: number } {

@@ -157,7 +165,7 @@ const baseDIDDocument: DIDDocument = {

}
const validTo = event.validTo || BigNumber.from(0)
const validTo = event.validTo || BigInt(0)
const eventIndex = `${event._eventName}-${
(<DIDDelegateChanged>event).delegateType || (<DIDAttributeChanged>event).name
}-${(<DIDDelegateChanged>event).delegate || (<DIDAttributeChanged>event).value}`
if (validTo && validTo.gte(now)) {
if (validTo && validTo >= now) {
if (event._eventName === eventNames.DIDDelegateChanged) {

@@ -208,3 +216,3 @@ const currentEvent = <DIDDelegateChanged>event

case 'base58':
pk.publicKeyBase58 = Base58.encode(Buffer.from(currentEvent.value.slice(2), 'hex'))
pk.publicKeyBase58 = encodeBase58(Buffer.from(currentEvent.value.slice(2), 'hex'))
break

@@ -333,7 +341,7 @@ case 'pem':

blockTag = qParams.get('versionId') ?? blockTag
try {
blockTag = Number.parseInt(<string>blockTag)
} catch (e) {
const parsedBlockTag = Number.parseInt(blockTag as string)
if (!Number.isNaN(parsedBlockTag)) {
blockTag = parsedBlockTag
} else {
blockTag = 'latest'
// invalid versionId parameters are ignored
}

@@ -353,7 +361,7 @@ }

let now = BigNumber.from(Math.floor(new Date().getTime() / 1000))
let now = BigInt(Math.floor(new Date().getTime() / 1000))
if (typeof blockTag === 'number') {
const block = await this.getBlockMetadata(blockTag, networkId)
now = BigNumber.from(Date.parse(block.isoDate) / 1000)
now = BigInt(Date.parse(block.isoDate) / 1000)
} else {

@@ -360,0 +368,0 @@ // 'latest'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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