Skip to content

Commit

Permalink
initial commit for migrating ethers to v6. FunctionsLocalTestnet not …
Browse files Browse the repository at this point in the history
…initiating. Tests that depends on it are failing
  • Loading branch information
zeuslawyer committed May 16, 2024
1 parent a0a9157 commit ba327a1
Show file tree
Hide file tree
Showing 15 changed files with 1,503 additions and 391 deletions.
173 changes: 131 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
"@types/jest": "^29.5.1",
"@types/node": "^18.16.3",
"@types/prettier": "^2.7.3",
"babel-loader": "9.1.2",
"browserify": "17.0.0",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"babel-loader": "9.1.2",
"browserify": "17.0.0",
"cpy-cli": "^5.0.0",
"esmify": "2.1.1",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"esmify": "2.1.1",
"jest": "^29.5.0",
"nock": "^13.3.1",
"prettier": "^3.0.3",
Expand All @@ -76,7 +76,7 @@
"bcrypto": "^5.4.0",
"cbor": "^9.0.1",
"eth-crypto": "^2.6.0",
"ethers": "^5.7.2",
"ethers": "^6.12.1",
"ganache": "^7.9.1",
"uniq": "^1.0.1"
}
Expand Down
16 changes: 8 additions & 8 deletions src/ResponseListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { Contract } from 'ethers'

import { FunctionsRouterSource } from './v1_contract_sources'

import type { BigNumber, providers } from 'ethers'
import type { BigNumberish, Provider } from 'ethers'

import { FulfillmentCode, type FunctionsResponse } from './types'

export class ResponseListener {
private functionsRouter: Contract
private provider: providers.Provider
private provider: Provider

constructor({
provider,
functionsRouterAddress,
}: {
provider: providers.Provider
provider: Provider
functionsRouterAddress: string
}) {
this.provider = provider
Expand All @@ -32,8 +32,8 @@ export class ResponseListener {
'RequestProcessed',
(
_requestId: string,
subscriptionId: BigNumber,
totalCostJuels: BigNumber,
subscriptionId: BigNumberish,
totalCostJuels: BigNumberish,
_,
resultCode: number,
response: string,
Expand Down Expand Up @@ -77,7 +77,7 @@ export class ResponseListener {

const check = async () => {
const receipt = await this.provider.waitForTransaction(txHash, confirmations, timeout)
const updatedId = receipt.logs[0].topics[1]
const updatedId = receipt!.logs[0].topics[1]
if (updatedId !== requestId) {
requestId = updatedId
const response = await this.listenForResponse(requestId, timeout)
Expand Down Expand Up @@ -111,8 +111,8 @@ export class ResponseListener {
'RequestProcessed',
(
requestId: string,
_subscriptionId: BigNumber,
totalCostJuels: BigNumber,
_subscriptionId: BigNumberish,
totalCostJuels: BigNumberish,
_,
resultCode: number,
response: string,
Expand Down
8 changes: 4 additions & 4 deletions src/SecretsManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios'
import cbor from 'cbor'
import { Contract, utils } from 'ethers'
import { Contract, encodeBytes32String, isHexString } from 'ethers'
import EthCrypto from 'eth-crypto'

import { encrypt } from './tdh2.js'
Expand Down Expand Up @@ -44,7 +44,7 @@ export class SecretsManager {
}

public async initialize(): Promise<void> {
const donIdBytes32 = utils.formatBytes32String(this.donId!)
const donIdBytes32 = encodeBytes32String(this.donId!)

let functionsCoordinatorAddress: string
try {
Expand Down Expand Up @@ -121,7 +121,7 @@ export class SecretsManager {
throw Error(`URL ${url} did not return a JSON object with an encryptedSecrets field`)
}

if (!utils.isHexString(response.data.encryptedSecrets)) {
if (isHexString(response.data.encryptedSecrets)) {
throw Error(`URL ${url} did not return a valid hex string for the encryptedSecrets field`)
}

Expand Down Expand Up @@ -197,7 +197,7 @@ export class SecretsManager {
this.isInitialized()
this.validateGatewayUrls(gatewayUrls)

if (!utils.isHexString(encryptedSecretsHexstring)) {
if (isHexString(encryptedSecretsHexstring)) {
throw Error('encryptedSecretsHexstring must be a valid hex string')
}

Expand Down
Loading

0 comments on commit ba327a1

Please sign in to comment.