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

chore: skip fee changes #1724

Closed
wants to merge 10 commits into from
Closed
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
2 changes: 1 addition & 1 deletion examples/cra-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/systems/Core/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) {
}

function request(input: TxInputs['request']) {
console.log('request', input);
service.send('START', { input });
}

Expand Down
220 changes: 110 additions & 110 deletions packages/app/src/systems/DApp/machines/transactionRequestMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<never, EstimateGasLimitReturn>({
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<never, EstimateGasLimitReturn>({
// showError: false,
// maxAttempts: 1,
// async fetch() {
// const gasLimit = await TxService.estimateGasLimit();
// return gasLimit;
// },
// }),
simulateTransaction: FetchMachine.create<
TxInputs['simulateTransaction'],
SimulateTransactionReturn
Expand All @@ -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;
Expand Down Expand Up @@ -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;
// },
// }),
},
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,33 @@ const schema = yup
tip: yup.object({
amount: yup
.mixed<BN>()
.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<BN>()
.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'),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -93,13 +95,15 @@ export function TransactionRequest() {
errors={errors.simulateTxErrors}
isConfirm
fees={fees}
skipCustomFee={txRequest.input.skipCustomFee}
/>
)}
{shouldShowTxExecuted && (
<TxContent.Info
showDetails
tx={txSummaryExecuted}
txStatus={executedStatus()}
skipCustomFee={txRequest.input.skipCustomFee}
footer={
status('failed') && (
<Button
Expand Down
Loading
Loading