diff --git a/examples/cra-dapp/package.json b/examples/cra-dapp/package.json index adfaecf44b..c8ef60b8a5 100644 --- a/examples/cra-dapp/package.json +++ b/examples/cra-dapp/package.json @@ -10,7 +10,7 @@ "@fuels/connectors": "0.35.1", "@fuels/react": "0.35.1", "@tanstack/react-query": "5.28.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "react": "18.3.1", "react-dom": "18.3.1" }, diff --git a/package.json b/package.json index 640880ce2a..a4a7c860a6 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "send@<0.19.0": ">=0.19.0", "serve-static@<1.16.0": ">=1.16.0", "rollup@>=4.0.0 <4.22.4": ">=4.22.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "secp256k1@=5.0.0": ">=5.0.1", "elliptic@<6.6.0": ">=6.6.0", "cross-spawn@<7.0.5": ">=7.0.5", diff --git a/packages/app/package.json b/packages/app/package.json index b524d4492f..8b017b7fee 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -21,6 +21,8 @@ }, "dependencies": { "@fontsource/source-code-pro": "5.0.13", + "@fuel-ts/math": "0.97.2", + "@fuel-ts/providers": "0.73.0", "@fuel-ui/css": "0.23.3", "@fuel-ui/icons": "0.23.3", "@fuel-ui/react": "0.23.3", @@ -44,7 +46,7 @@ "events": "3.3.0", "fake-indexeddb": "4.0.2", "framer-motion": "10.16.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "json-edit-react": "1.13.3", "json-rpc-2.0": "1.7.0", "lodash.debounce": "4.0.8", diff --git a/packages/app/src/systems/Core/utils/wallet.ts b/packages/app/src/systems/Core/utils/wallet.ts index 1c212b861d..d69cd7596d 100644 --- a/packages/app/src/systems/Core/utils/wallet.ts +++ b/packages/app/src/systems/Core/utils/wallet.ts @@ -45,9 +45,9 @@ export class WalletLockedCustom extends WalletLocked { const txRequestToSend = await this.populateTransactionWitnessesSignature(transactionRequest); - await this.simulateTransaction(txRequestToSend, { - estimateTxDependencies: false, - }); + // await this.simulateTransaction(transactionRequestLike, { + // estimateTxDependencies: false, + // }); return this.provider.sendTransaction(txRequestToSend, { estimateTxDependencies: false, }); diff --git a/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx b/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx index 6ff1ba477f..f4d7aa3915 100644 --- a/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx +++ b/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx @@ -142,6 +142,7 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) { } function request(input: TxInputs['request']) { + console.log('request', input); service.send('START', { input }); } diff --git a/packages/app/src/systems/DApp/machines/transactionRequestMachine.tsx b/packages/app/src/systems/DApp/machines/transactionRequestMachine.tsx index f8c68c5279..f589485ac6 100644 --- a/packages/app/src/systems/DApp/machines/transactionRequestMachine.tsx +++ b/packages/app/src/systems/DApp/machines/transactionRequestMachine.tsx @@ -113,61 +113,61 @@ export const transactionRequestMachine = createMachine( on: { START: { actions: ['assignTxRequestData'], - target: 'estimatingInitialTips', - }, - }, - }, - estimatingInitialTips: { - tags: ['loading'], - invoke: { - src: 'estimateDefaultTips', - onDone: [ - { - cond: FetchMachine.hasError, - target: 'failed', - }, - { - actions: ['assignDefaultTips'], - target: 'estimatingGasLimit', - }, - ], - }, - }, - estimatingGasLimit: { - invoke: { - src: 'estimateGasLimit', - onDone: [ - { - cond: FetchMachine.hasError, - target: 'failed', - }, - { - actions: ['assignGasLimit'], - target: 'fetchingAccount', - }, - ], - }, - }, - fetchingAccount: { - entry: ['openDialog'], - tags: ['loading'], - invoke: { - src: 'fetchAccount', - data: { - input: (ctx: MachineContext) => ctx.input, + target: 'simulatingTransaction', }, - onDone: [ - { - cond: FetchMachine.hasError, - target: 'failed', - }, - { - actions: ['assignAccount'], - target: 'simulatingTransaction', - }, - ], }, }, + // estimatingInitialTips: { + // tags: ['loading'], + // invoke: { + // src: 'estimateDefaultTips', + // onDone: [ + // { + // cond: FetchMachine.hasError, + // target: 'failed', + // }, + // { + // actions: ['assignDefaultTips'], + // target: 'estimatingGasLimit', + // }, + // ], + // }, + // }, + // estimatingGasLimit: { + // invoke: { + // src: 'estimateGasLimit', + // onDone: [ + // { + // cond: FetchMachine.hasError, + // target: 'failed', + // }, + // { + // actions: ['assignGasLimit'], + // target: 'fetchingAccount', + // }, + // ], + // }, + // }, + // fetchingAccount: { + // entry: ['openDialog'], + // tags: ['loading'], + // invoke: { + // src: 'fetchAccount', + // data: { + // input: (ctx: MachineContext) => ctx.input, + // }, + // onDone: [ + // { + // cond: FetchMachine.hasError, + // target: 'failed', + // }, + // { + // actions: ['assignAccount'], + // target: 'simulatingTransaction', + // }, + // ], + // }, + // }, simulatingTransaction: { tags: ['loading'], invoke: { @@ -270,25 +270,25 @@ export const transactionRequestMachine = createMachine( delays: { TIMEOUT: 1300 }, actions: { reset: assign(() => ({})), - assignDefaultTips: assign((ctx, ev) => ({ - fees: { - ...ctx.fees, - regularTip: ev.data.regularTip, - fastTip: ev.data.fastTip, - }, - })), - assignGasLimit: assign((ctx, ev) => ({ - fees: { - ...ctx.fees, - maxGasLimit: ev.data.maxGasLimit, - }, - })), - assignAccount: assign({ - input: (ctx, ev) => ({ - ...ctx.input, - account: ev.data, - }), - }), + // assignDefaultTips: assign((ctx, ev) => ({ + // fees: { + // ...ctx.fees, + // regularTip: ev.data.regularTip, + // fastTip: ev.data.fastTip, + // }, + // })), + // assignGasLimit: assign((ctx, ev) => ({ + // fees: { + // ...ctx.fees, + // maxGasLimit: ev.data.maxGasLimit, + // }, + // })), + // assignAccount: assign({ + // input: (ctx, ev) => ({ + // ...ctx.input, + // account: ev.data, + // }), + // }), assignTxRequestData: assign({ input: (ctx, ev) => { const { @@ -385,25 +385,25 @@ export const transactionRequestMachine = createMachine( }), }, services: { - estimateDefaultTips: FetchMachine.create< - never, - EstimateDefaultTipsReturn - >({ - showError: false, - maxAttempts: 1, - async fetch() { - const defaultTips = await TxService.estimateDefaultTips(); - return defaultTips; - }, - }), - estimateGasLimit: FetchMachine.create({ - showError: false, - maxAttempts: 1, - async fetch() { - const gasLimit = await TxService.estimateGasLimit(); - return gasLimit; - }, - }), + // estimateDefaultTips: FetchMachine.create< + // never, + // EstimateDefaultTipsReturn + // >({ + // showError: false, + // maxAttempts: 1, + // async fetch() { + // const defaultTips = await TxService.estimateDefaultTips(); + // return defaultTips; + // }, + // }), + // estimateGasLimit: FetchMachine.create({ + // showError: false, + // maxAttempts: 1, + // async fetch() { + // const gasLimit = await TxService.estimateGasLimit(); + // return gasLimit; + // }, + // }), simulateTransaction: FetchMachine.create< TxInputs['simulateTransaction'], SimulateTransactionReturn @@ -417,7 +417,7 @@ export const transactionRequestMachine = createMachine( // Enforce a minimum delay to show the loading state // this creates a better experience for the user as the // screen doesn't flash between states - await delay(600); + // await delay(600); const simulatedInfo = await TxService.simulateTransaction(input); return simulatedInfo; @@ -448,26 +448,26 @@ export const transactionRequestMachine = createMachine( }; }, }), - fetchAccount: FetchMachine.create< - { address: string; providerUrl: string }, - Account - >({ - showError: true, - async fetch({ input }) { - if (!input?.address || !input?.providerUrl) { - throw new Error('Invalid fetchAccount input'); - } - const account = await AccountService.fetchAccount({ - address: input.address, - }); - const accountWithBalances = await AccountService.fetchBalance({ - account, - providerUrl: input.providerUrl, - }); + // fetchAccount: FetchMachine.create< + // { address: string; providerUrl: string }, + // Account + // >({ + // showError: true, + // async fetch({ input }) { + // if (!input?.address || !input?.providerUrl) { + // throw new Error('Invalid fetchAccount input'); + // } + // const account = await AccountService.fetchAccount({ + // address: input.address, + // }); + // const accountWithBalances = await AccountService.fetchBalance({ + // account, + // providerUrl: input.providerUrl, + // }); - return accountWithBalances; - }, - }), + // return accountWithBalances; + // }, + // }), }, } ); diff --git a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.FormProvider.tsx b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.FormProvider.tsx index 792099af80..c054fdc420 100644 --- a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.FormProvider.tsx +++ b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.FormProvider.tsx @@ -38,33 +38,33 @@ const schema = yup tip: yup.object({ amount: yup .mixed() - .test('min', 'Tip must be greater than or equal to 0', (value) => { - return value?.gte(0); - }) + // .test('min', 'Tip must be greater than or equal to 0', (value) => { + // return value?.gte(0); + // }) .required('Tip is required'), text: yup.string().required('Tip is required'), }), gasLimit: yup.object({ amount: yup .mixed() - .test({ - name: 'max', - test: (value, ctx) => { - const { maxGasLimit } = ctx.options.context as SchemaOptions; - if (!maxGasLimit) return false; + // .test({ + // name: 'max', + // test: (value, ctx) => { + // const { maxGasLimit } = ctx.options.context as SchemaOptions; + // if (!maxGasLimit) return false; - if (value?.lte(maxGasLimit)) { - return true; - } + // if (value?.lte(maxGasLimit)) { + // return true; + // } - return ctx.createError({ - path: 'fees.gasLimit', - message: `Gas limit must be lower than or equal to ${formatGasLimit( - maxGasLimit - )}.`, - }); - }, - }) + // return ctx.createError({ + // path: 'fees.gasLimit', + // message: `Gas limit must be lower than or equal to ${formatGasLimit( + // maxGasLimit + // )}.`, + // }); + // }, + // }) .required('Gas limit is required'), text: yup.string().required('Gas limit is required'), }), diff --git a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx index 433923442c..1e993c8356 100644 --- a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx +++ b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx @@ -9,6 +9,8 @@ import { TxContent, getGasLimitFromTxRequest } from '~/systems/Transaction'; import { formatTip } from '~/systems/Transaction/components/TxFeeOptions/TxFeeOptions.utils'; import { useTransactionRequest } from '../../hooks/useTransactionRequest'; import { AutoSubmit } from './TransactionRequest.AutoSubmit'; + +import { networkProviders } from '~/systems/Network/services/networkProviders'; import { FormProvider, type TransactionRequestFormData, @@ -93,6 +95,7 @@ export function TransactionRequest() { errors={errors.simulateTxErrors} isConfirm fees={fees} + skipCustomFee={txRequest.input.skipCustomFee} /> )} {shouldShowTxExecuted && ( @@ -100,6 +103,7 @@ export function TransactionRequest() { showDetails tx={txSummaryExecuted} txStatus={executedStatus()} + skipCustomFee={txRequest.input.skipCustomFee} footer={ status('failed') && (