diff --git a/.changeset/fifty-flowers-reflect.md b/.changeset/fifty-flowers-reflect.md new file mode 100644 index 0000000..0e519b3 --- /dev/null +++ b/.changeset/fifty-flowers-reflect.md @@ -0,0 +1,5 @@ +--- +'@chainlink/functions-toolkit': minor +--- + +Updated to latest Functions contracts diff --git a/README.md b/README.md index 5f0a237..a20f86c 100644 --- a/README.md +++ b/README.md @@ -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 }) ``` diff --git a/src/SubscriptionManager.ts b/src/SubscriptionManager.ts index f3c3800..a8a9c30 100644 --- a/src/SubscriptionManager.ts +++ b/src/SubscriptionManager.ts @@ -472,7 +472,7 @@ export class SubscriptionManager { donId, subscriptionId, callbackGasLimit, - gasPriceGwei, + gasPriceWei, }: EstimateCostConfig): Promise { if (typeof donId !== 'string') { throw Error('donId has invalid type') @@ -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 @@ -520,7 +520,7 @@ export class SubscriptionManager { subscriptionId, [], callbackGasLimit, - gasPriceGwei, + gasPriceWei, ) return BigInt(estimatedCostInJuels.toString()) } catch (error) { diff --git a/src/localFunctionsTestnet.ts b/src/localFunctionsTestnet.ts index 2723b81..39c4be4 100644 --- a/src/localFunctionsTestnet.ts +++ b/src/localFunctionsTestnet.ts @@ -18,7 +18,7 @@ import { LinkTokenSource, MockV3AggregatorSource, FunctionsRouterSource, - MockFunctionsCoordinatorSource, + FunctionsCoordinatorTestHelperSource, TermsOfServiceAllowListSource, FunctionsClientExampleSource, } from './v1_contract_sources' @@ -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) } @@ -288,8 +284,8 @@ export const deployFunctionsOracle = async (deployer: Wallet): Promise { const estimatedCostInJuels = await subscriptionManager.estimateFunctionsRequestCost({ subscriptionId, callbackGasLimit: 300_000, - gasPriceGwei: 1n, + gasPriceWei: 100000000000n, // 100 gWei donId, }) - expect(estimatedCostInJuels.toString()).toBe(BigInt('389230000').toString()) + expect(estimatedCostInJuels.toString()).toBe(BigInt('38923000000000000000').toString()) }) it('Throws an error for missing donId', async () => { @@ -1235,7 +1235,7 @@ describe('Functions toolkit classes', () => { donId: undefined, subscriptionId, callbackGasLimit: 300_000, - gasPriceGwei: 1n, + gasPriceWei: 100000000000n, }) }).rejects.toThrowError(/donId has invalid type/) }) @@ -1253,7 +1253,7 @@ describe('Functions toolkit classes', () => { donId, subscriptionId: 0, callbackGasLimit: 300_000, - gasPriceGwei: 1n, + gasPriceWei: 100000000000n, }) }).rejects.toThrowError(/Error fetching information for subscription ID/) }) @@ -1274,12 +1274,12 @@ describe('Functions toolkit classes', () => { donId, subscriptionId, callbackGasLimit: -1, - gasPriceGwei: 1n, + gasPriceWei: 100000000000n, }) }).rejects.toThrowError(/Invalid callbackGasLimit/) }) - it('Throws an error for invalid gasPriceGwei', async () => { + it('Throws an error for invalid gasPriceWei', async () => { const subscriptionManager = new SubscriptionManager({ signer: allowlistedUser_A, linkTokenAddress, @@ -1295,9 +1295,9 @@ describe('Functions toolkit classes', () => { donId, subscriptionId, callbackGasLimit: 300_000, - gasPriceGwei: -1n, + gasPriceWei: -1n, }) - }).rejects.toThrowError(/Invalid gasPriceGwei/) + }).rejects.toThrowError(/Invalid gasPriceWei/) }) it('Throws an error for incorrect donId', async () => { @@ -1316,7 +1316,7 @@ describe('Functions toolkit classes', () => { donId: 'wrong', subscriptionId, callbackGasLimit: 300_000, - gasPriceGwei: 1n, + gasPriceWei: 100000000000n, }) }).rejects.toThrowError( /Error encountered when attempting to fetch the FunctionsCoordinator address/,