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

Update to latest contracts #8

Merged
merged 5 commits into from
Sep 11, 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
5 changes: 5 additions & 0 deletions .changeset/fifty-flowers-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/functions-toolkit': minor
---

Updated to latest Functions contracts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ const estimatedCostInJuels: BigInt = await subscriptionManager.estimateFunctions
donId, // ID of the DON to which the Functions request will be sent
subscriptionId, // Subscription ID
callbackGasLimit, // Total gas used by the consumer contract's callback
gasPriceGwei, // Gas price in gWei
gasPriceWei, // Gas price in wei
})
```

Expand Down
8 changes: 4 additions & 4 deletions src/SubscriptionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class SubscriptionManager {
donId,
subscriptionId,
callbackGasLimit,
gasPriceGwei,
gasPriceWei,
}: EstimateCostConfig): Promise<BigInt> {
if (typeof donId !== 'string') {
throw Error('donId has invalid type')
Expand All @@ -488,8 +488,8 @@ export class SubscriptionManager {
throw Error('Invalid callbackGasLimit')
}

if (typeof gasPriceGwei !== 'bigint' || gasPriceGwei <= 0) {
throw Error('Invalid gasPriceGwei')
if (typeof gasPriceWei !== 'bigint' || gasPriceWei <= 0) {
throw Error('Invalid gasPriceWei')
}

let functionsCoordinatorAddress: string
Expand Down Expand Up @@ -520,7 +520,7 @@ export class SubscriptionManager {
subscriptionId,
[],
callbackGasLimit,
gasPriceGwei,
gasPriceWei,
)
return BigInt(estimatedCostInJuels.toString())
} catch (error) {
Expand Down
13 changes: 4 additions & 9 deletions src/localFunctionsTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
LinkTokenSource,
MockV3AggregatorSource,
FunctionsRouterSource,
MockFunctionsCoordinatorSource,
FunctionsCoordinatorTestHelperSource,
TermsOfServiceAllowListSource,
FunctionsClientExampleSource,
} from './v1_contract_sources'
Expand Down Expand Up @@ -173,13 +173,9 @@ const handleOracleRequest = async (
errorHexstring,
)

const transmitters31AddressArray = Array(31).fill('0x0000000000000000000000000000000000000000')
simulatedTransmitters.forEach((transmitter, i) => {
transmitters31AddressArray[i] = transmitter
})
const reportTx = await mockCoordinator
.connect(admin)
.callReport(encodedReport, transmitters31AddressArray, { gasLimit: callReportGasLimit })
.callReport(encodedReport, { gasLimit: callReportGasLimit })
await reportTx.wait(1)
}

Expand Down Expand Up @@ -288,8 +284,8 @@ export const deployFunctionsOracle = async (deployer: Wallet): Promise<Functions
.deploy(linkToken.address, simulatedRouterConfig)

const mockCoordinatorFactory = new ContractFactory(
MockFunctionsCoordinatorSource.abi,
MockFunctionsCoordinatorSource.bytecode,
FunctionsCoordinatorTestHelperSource.abi,
FunctionsCoordinatorTestHelperSource.bytecode,
deployer,
)
const mockCoordinator = await mockCoordinatorFactory
Expand Down Expand Up @@ -332,7 +328,6 @@ export const deployFunctionsOracle = async (deployer: Wallet): Promise<Functions
.setThresholdPublicKey(
'0x' + Buffer.from(simulatedSecretsKeys.thresholdKeys.publicKey).toString('hex'),
)
await mockCoordinator.connect(deployer).setTransmitters(simulatedTransmitters)

return { linkToken, router, mockCoordinator, exampleClient }
}
2 changes: 2 additions & 0 deletions src/simulationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const simulatedRouterConfig = {
handleOracleFulfillmentSelector: '0x0ca76175', // handleOracleFulfillment(bytes32 requestId, bytes memory response, bytes memory err)
gasForCallExactCheck: 5000,
maxCallbackGasLimits: [300_000, 500_000, 1_000_000],
subscriptionDepositMinimumRequests: 0,
subscriptionDepositJuels: 0,
}

export const simulatedCoordinatorConfig = {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export type EstimateCostConfig = {
donId: string
subscriptionId: BigInt | number | string
callbackGasLimit: number
gasPriceGwei: BigInt
gasPriceWei: BigInt
}

export type SubscriptionInfo = {
Expand Down
89 changes: 7 additions & 82 deletions src/v1_contract_sources/FunctionsCoordinator.ts

Large diffs are not rendered by default.

Loading