Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump ethers.js version #490

Merged
merged 3 commits into from
Apr 18, 2023
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
2 changes: 1 addition & 1 deletion contracts-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.12.0",
"ethereum-waffle": "^3.2.0",
"ethers": "5.6.9",
"ethers": "5.7.2",
"fs-extra": "^9.0.1",
"hardhat": "^2.6.8",
"hardhat-gas-reporter": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@web3-onboard/walletconnect": "^2.2.2",
"bnc-notify": "^1.5.1",
"core-js": "^3.6.5",
"ethers": "5.6.9",
"ethers": "5.7.2",
"quasar": "2.10.2",
"vue-i18n": "^9.2.2",
"vue-router": "4.1.6",
Expand Down
2 changes: 1 addition & 1 deletion umbra-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@noble/secp256k1": "^1.7.1",
"@unstoppabledomains/resolution": "8.3.1",
"ethers": "5.6.9"
"ethers": "5.7.2"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.2",
Expand Down
10 changes: 7 additions & 3 deletions umbra-js/src/classes/StealthKeyRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { KeyPair } from '../classes/KeyPair';
import { StealthKeyRegistry as StealthKeyRegistryContract } from '@umbra/contracts-core/typechain';
import { Contract, JsonRpcSigner } from '../ethers';
import { Contract, JsonRpcSigner, TransactionResponse } from '../ethers';
import type { EthersProvider } from '../types';

// Address of the StealthKeyRegistry is the same on all supported networks
Expand All @@ -29,7 +29,7 @@ export class StealthKeyRegistry {
* @param signerOrProvider signer or provider to use
*/
constructor(signerOrProvider: JsonRpcSigner | EthersProvider) {
this._registry = new Contract(stealthKeyRegistry, abi, signerOrProvider) as StealthKeyRegistryContract;
this._registry = new Contract(stealthKeyRegistry, abi, signerOrProvider) as unknown as StealthKeyRegistryContract;
}

/**
Expand Down Expand Up @@ -60,7 +60,11 @@ export class StealthKeyRegistry {
* attached to `this.registry` is used
* @returns Transaction
*/
async setStealthKeys(spendingPublicKey: string, viewingPublicKey: string, signer: JsonRpcSigner | null = null) {
async setStealthKeys(
spendingPublicKey: string,
viewingPublicKey: string,
signer: JsonRpcSigner | null = null
): Promise<TransactionResponse> {
// Get instance of StealthKeyRegistry contract
const registry = signer ? this._registry.connect(signer) : this._registry;

Expand Down
6 changes: 3 additions & 3 deletions umbra-js/src/classes/Umbra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class Umbra {
*/
constructor(readonly provider: EthersProvider, chainConfig: ChainConfig | number) {
this.chainConfig = parseChainConfig(chainConfig);
this.umbraContract = new Contract(this.chainConfig.umbraAddress, umbraAbi, provider) as UmbraContract;
this.umbraContract = new Contract(this.chainConfig.umbraAddress, umbraAbi, provider) as unknown as UmbraContract;
this.fallbackProvider = new StaticJsonRpcProvider(
infuraUrl(this.chainConfig.chainId, String(process.env.INFURA_ID))
);
Expand Down Expand Up @@ -194,7 +194,7 @@ export class Umbra {
// If applicable, check that sender has sufficient token balance. ETH balance is checked on send. The isEth
// method also serves to validate the token input
if (!isEth(token)) {
const tokenContract = new Contract(token, ERC20_ABI, signer) as ERC20;
const tokenContract = new Contract(token, ERC20_ABI, signer) as unknown as ERC20;
const tokenBalance = await tokenContract.balanceOf(await signer.getAddress());
if (tokenBalance.lt(amount)) {
const providedAmount = BigNumber.from(amount).toString();
Expand Down Expand Up @@ -321,7 +321,7 @@ export class Umbra {
r: string,
s: string,
overrides: Overrides = {}
) {
): Promise<TransactionResponse> {
// Address input validations
stealthAddr = getAddress(stealthAddr);
destination = getAddress(destination);
Expand Down
6 changes: 3 additions & 3 deletions umbra-js/test/KeyPair.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,13 @@ describe('KeyPair class', () => {
it('throws when getUncompressedFromX is provided bad inputs', async () => {
// @ts-expect-error
expect(() => KeyPair.getUncompressedFromX(Number.MAX_SAFE_INTEGER)).to.throw(
'overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.6.2)'
'overflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-overflow ] (fault="overflow", operation="BigNumber.from", value=9007199254740991, code=NUMERIC_FAULT, version=bignumber/5.7.0)'
);
expect(() => KeyPair.getUncompressedFromX('0x')).to.throw(
'invalid BigNumber string (argument="value", value="0x", code=INVALID_ARGUMENT, version=bignumber/5.6.2)'
'invalid BigNumber string (argument="value", value="0x", code=INVALID_ARGUMENT, version=bignumber/5.7.0)'
);
expect(() => KeyPair.getUncompressedFromX('abc')).to.throw(
'invalid BigNumber string (argument="value", value="abc", code=INVALID_ARGUMENT, version=bignumber/5.6.2)'
'invalid BigNumber string (argument="value", value="abc", code=INVALID_ARGUMENT, version=bignumber/5.7.0)'
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion umbra-js/test/StealthKeyRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('StealthKeyRegistry class', () => {
it('setStealthKeys: throws if registry has no signer and a signer is not specified', async () => {
// this error comes from ethers, but useful to test to ensure a default signer isn't somehow used
const pubkey = ethers.Wallet.createRandom().publicKey;
const errorMsg = 'sending a transaction requires a signer (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=contracts/5.6.2)'; // prettier-ignore
const errorMsg = 'sending a transaction requires a signer (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=contracts/5.5.0)'; // prettier-ignore
await expectRejection(stealthKeyRegistry.setStealthKeys(pubkey, pubkey), errorMsg);
});

Expand Down
12 changes: 6 additions & 6 deletions umbra-js/test/Umbra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,20 +373,20 @@ describe('Umbra class', () => {
expect(() => new Umbra(ethersProvider, { umbraAddress: '123', startBlock: 1, chainId: 1 })).to.throw(errorMsg4);
// @ts-expect-error
expect(() => new Umbra(ethersProvider, { startBlock: 0, chainId: 4, subgraphUrl: false })).to.throw(
'invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0)'
);
});

it('throws when isEth is passed a bad address', async () => {
// These error messages come from ethers
await expectRejection(
umbra.send(sender, '123', '1', ETH_ADDRESS),
'invalid address (argument="address", value="123", code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value="123", code=INVALID_ARGUMENT, version=address/5.7.0)'
);
await expectRejection(
// @ts-expect-error
umbra.send(sender, 123, '1', ETH_ADDRESS),
'invalid address (argument="address", value=123, code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value=123, code=INVALID_ARGUMENT, version=address/5.7.0)'
);
});

Expand All @@ -399,15 +399,15 @@ describe('Umbra class', () => {
// These error messages come from ethers
await expectRejection(
Umbra.signWithdraw(privateKey, 4, umbra.umbraContract.address, badAddress, tokenAddress, goodAddress, '1'),
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.7.0)'
);
await expectRejection(
Umbra.signWithdraw(privateKey, 4, umbra.umbraContract.address, goodAddress, tokenAddress, badAddress, '1'),
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.7.0)'
);
await expectRejection(
Umbra.signWithdraw(privateKey, 4, badAddress, goodAddress, tokenAddress, goodAddress, '1'),
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.6.1)'
'invalid address (argument="address", value="0x123", code=INVALID_ARGUMENT, version=address/5.7.0)'
);
});

Expand Down
6 changes: 3 additions & 3 deletions umbra-js/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('Utilities', () => {
});

it('throws when looking up recipients by public key without explicitly allowing it', async () => {
const errorMsg = `invalid address (argument="address", value="${publicKey}", code=INVALID_ARGUMENT, version=address/5.6.1)`; // prettier-ignore
const errorMsg = `invalid address (argument="address", value="${publicKey}", code=INVALID_ARGUMENT, version=address/5.7.0)`; // prettier-ignore
await expectRejection(utils.lookupRecipient(publicKey, ethersProvider), errorMsg);
});

Expand All @@ -99,7 +99,7 @@ describe('Utilities', () => {

it('throws when looking up recipients by transaction hash without explicitly allowing it', async () => {
const hash = '0xfe80fe73b195eed3874aac3acf8ce7e4b199622bc209bdbdb30b0533bcff5439';
const errorMsg = `invalid address (argument="address", value="${hash}", code=INVALID_ARGUMENT, version=address/5.6.1)`; // prettier-ignore
const errorMsg = `invalid address (argument="address", value="${hash}", code=INVALID_ARGUMENT, version=address/5.7.0)`; // prettier-ignore
await expectRejection(utils.lookupRecipient(hash, ethersProvider), errorMsg);
});

Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Utilities', () => {

it('throws when provided an invalid identifier', async () => {
const id = '123';
const errMsg = 'invalid address (argument="address", value="123", code=INVALID_ARGUMENT, version=address/5.6.1)';
const errMsg = 'invalid address (argument="address", value="123", code=INVALID_ARGUMENT, version=address/5.7.0)';
await expectRejection(utils.lookupRecipient(id, ethersProvider), errMsg);
});
});
Expand Down
Loading
Loading