Skip to content

Commit

Permalink
chore: skip transaction changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Dec 26, 2024
1 parent a4ce748 commit 841937a
Show file tree
Hide file tree
Showing 4 changed files with 1,982 additions and 325 deletions.
2 changes: 1 addition & 1 deletion examples/cra-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"@fuels/connectors": "0.35.1",
"@fuels/react": "0.39.0-pr-446-73",
"@fuels/react": "0.35.1",
"@tanstack/react-query": "5.28.4",
"fuels": "0.0.0-pr-3487-20241220190150",
"react": "18.3.1",
Expand Down
218 changes: 109 additions & 109 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 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 @@ -180,19 +180,21 @@ export class TxService {
}

static async simulateTransaction({
skipCustomFee,
skipCustomFee: _,
transactionRequest: inputTransactionRequest,
providerUrl,
tip: inputCustomTip,
gasLimit: inputCustomGasLimit,
}: TxInputs['simulateTransaction']) {
const skipCustomFee = true;
console.log('simulateTransaction', {
skipCustomFee,
inputTransactionRequest,
providerUrl,
inputCustomTip,
inputCustomGasLimit,
});

const [provider, account] = await Promise.all([
createProvider(providerUrl || ''),
AccountService.getCurrentAccount(),
Expand Down
Loading

0 comments on commit 841937a

Please sign in to comment.