Skip to content

Commit

Permalink
chore: bump ethers.js version
Browse files Browse the repository at this point in the history
enables support for ENS names with emojis, ref ethers-io/ethers.js#2376
  • Loading branch information
mds1 authored and apbendi committed Apr 18, 2023
1 parent d98984f commit 930b3f5
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion contracts-core/package.json
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
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
10 changes: 7 additions & 3 deletions umbra-js/src/classes/StealthKeyRegistry.ts
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
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
12 changes: 6 additions & 6 deletions umbra-js/test/Umbra.test.ts
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
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

0 comments on commit 930b3f5

Please sign in to comment.