Skip to content

Commit 32950ce

Browse files
arthurgeronhelciofrancoLuizAsFight
authored
feat: support gasless transactions (#1774)
<!-- - Closes #0 --> - Closes FE-1205 - Fuel SDK updated to 0.98.0, breaking changes (e.g. Provide.create, async provider calls, removal of AbstractAddress) are covered. Read [here](https://github.com/fuellabs/fuels-ts/releases/tag/v0.98.0) for more info. - Gasless transactions are now supported via the `skipCustomFee` param # Checklist - [x] I've added error handling for all actions/requests. - [x] I've reviewed how my changes will display in the UI. - [x] I've checked all the copy (text) changes or additions in this PR. - [x] I've included references to the issues being closed on GitHub and/or Linear. - [x] I've ensured that the documentation is up to date and reflects any changes. - [x] I've added documentation links where it may be helpful. - [x] I **reviewed** the **entire PR** myself. --------- Co-authored-by: Hélcio Franco <github@helciofranco.com> Co-authored-by: LuizAsFight <felipebolsonigomes@gmail.com> Co-authored-by: Luiz Gomes <8636507+LuizAsFight@users.noreply.github.com>
1 parent 118f4f4 commit 32950ce

File tree

69 files changed

+1928
-623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1928
-623
lines changed

.changeset/cyan-dancers-shop.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@fuel-wallet/connections": patch
3+
"@fuel-wallet/types": patch
4+
"fuels-wallet": patch
5+
---
6+
7+
Gasless transactions are now supported via the `skipCustomFee` param

.changeset/tricky-colts-pump.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@fuels/playwright-utils": minor
3+
"@fuel-wallet/connections": minor
4+
"@fuel-wallet/types": minor
5+
"fuels-wallet": minor
6+
---
7+
8+
Fuel SDK updated to 0.98.0, breaking changes (e.g. Provide.create, async provider calls, removal of AbstractAddress) are covered. Read [here](https://github.com/fuellabs/fuels-ts/releases/tag/v0.98.0) for more info.

docker/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
WALLET_SECRET_KEY: ${WALLET_SECRET}
3333
DISPENSE_AMOUNT: ${DISPENSE_AMOUNT}
3434
FUEL_NODE_URL: http://${PROJECT:-fuel-node}_fuel-core:4000/v1/graphql
35-
image: ghcr.io/fuellabs/faucet:4f7bec0
35+
image: ghcr.io/fuellabs/faucet:474768d
3636
ports:
3737
- '${FUEL_FAUCET_PORT:-4040}:3000'
3838
links:

docker/fuel-core/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# We should be supporting always the same fuel-core version as the fuels (ts-sdk)
88
# https://github.com/FuelLabs/fuels-ts/blob/master/internal/fuel-core/VERSION
9-
FROM ghcr.io/fuellabs/fuel-core:v0.40.0
9+
FROM ghcr.io/fuellabs/fuel-core:v0.40.2
1010

1111
# dependencies
1212
ENV DEBIAN_FRONTEND=noninteractive
@@ -17,17 +17,20 @@ WORKDIR /fuel
1717

1818
COPY ./genesis_coins.json .
1919

20+
# Fuel Core 0.40.2, needs to be changed when core version is updated
2021
RUN git clone \
2122
https://github.com/FuelLabs/chain-configuration.git \
22-
/chain-configuration
23+
/chain-configuration && \
24+
cd /chain-configuration && \
25+
git checkout b2a9fd7ae37a33b45b2407eadf9c870ef2027c07
2326

2427
# Copy the base local configuration
2528
RUN cp -R /chain-configuration/local/* ./
2629

2730
# Copy the testnet consensus parameters and state transition bytecode
28-
RUN cp /chain-configuration/upgradelog/ignition-devnet/consensus_parameters/13.json \
31+
RUN cp /chain-configuration/upgradelog/ignition-devnet/consensus_parameters/14.json \
2932
./latest_consensus_parameters.json
30-
RUN cp /chain-configuration/upgradelog/ignition-devnet/state_transition_function/16.wasm \
33+
RUN cp /chain-configuration/upgradelog/ignition-devnet/state_transition_function/17.wasm \
3134
./state_transition_bytecode.wasm
3235

3336
# update local state_config with custom genesis coins config

examples/cra-dapp/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"start": "vite"
88
},
99
"dependencies": {
10-
"@fuels/connectors": "0.35.1",
11-
"@fuels/react": "0.35.1",
10+
"@fuels/connectors": "0.39.0-main-5f9794e",
11+
"@fuels/react": "0.39.0-main-5f9794e",
1212
"@tanstack/react-query": "5.28.4",
13-
"fuels": "0.96.1",
13+
"fuels": "0.98.0",
1414
"react": "18.3.1",
1515
"react-dom": "18.3.1"
1616
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"send@<0.19.0": ">=0.19.0",
125125
"serve-static@<1.16.0": ">=1.16.0",
126126
"rollup@>=4.0.0 <4.22.4": ">=4.22.4",
127-
"fuels": "0.96.1",
127+
"fuels": "0.98.0",
128128
"secp256k1@=5.0.0": ">=5.0.1",
129129
"elliptic@<6.6.0": ">=6.6.0",
130130
"cross-spawn@<7.0.5": ">=7.0.5",

packages/app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"events": "3.3.0",
4444
"fake-indexeddb": "4.0.2",
4545
"framer-motion": "10.16.4",
46-
"fuels": "0.96.1",
46+
"fuels": "0.98.0",
4747
"json-edit-react": "1.13.3",
4848
"json-rpc-2.0": "1.7.0",
4949
"lodash.debounce": "4.0.8",
@@ -63,7 +63,7 @@
6363
"devDependencies": {
6464
"@crxjs/vite-plugin": "2.0.0-beta.31",
6565
"@fuel-wallet/types": "workspace:*",
66-
"@fuels/connectors": "0.35.1",
66+
"@fuels/connectors": "0.39.0-main-5f9794e",
6767
"@playwright/test": "1.46.1",
6868
"@sentry/cli": "2.33.1",
6969
"@storybook/addon-a11y": "7.4.6",

packages/app/playwright/commons/seedWallet.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export async function seedCurrentAccount(page: Page, amount: BN) {
1212
}
1313

1414
export async function seedWallet(address: string, amount: BN) {
15-
const provider = await Provider.create(VITE_FUEL_PROVIDER_URL);
15+
const provider = new Provider(VITE_FUEL_PROVIDER_URL);
1616
const genesisWallet = Wallet.fromPrivateKey(GENESIS_SECRET, provider);
1717

1818
const transfETH = await genesisWallet.transfer(
1919
Address.fromString(address),
2020
amount,
21-
provider.getBaseAssetId()
21+
await provider.getBaseAssetId()
2222
);
2323
await transfETH.wait();
2424

packages/app/playwright/crx/crx.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test.describe('FuelWallet Extension', () => {
9898
});
9999

100100
test('SDK operations', async ({ context, baseURL, extensionId }) => {
101-
const provider = await Provider.create(process.env.VITE_FUEL_PROVIDER_URL);
101+
const provider = new Provider(process.env.VITE_FUEL_PROVIDER_URL);
102102
// Use a single instance of the page to avoid
103103
// multiple waiting times, and window.fuel checking.
104104
const blankPage = await context.newPage();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function shortAddress(address = '') {
2+
return address.length > 10
3+
? `${address.slice(0, 6)}...${address.slice(-4)}`
4+
: address;
5+
}

packages/app/playwright/e2e/Accounts.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,15 @@ test.describe('Existing Accounts', () => {
267267
test('can add accounts using correct derivation path after importing from private key', async () => {
268268
// at this point 2 accounts have already been created
269269
const fuelAddress1 =
270-
'fuel1kfnz04g7k8wjw22s03s3kk46wxr63he3v5v6kyrv76m7wzh7x9jqvqffua';
270+
'0xb26627d51eb1dd2729507c611b5aba7187a8df316519ab106cf6b7e70afe3164';
271271
const fuelAddress2 =
272-
'fuel1kyxzyv5z39fuxnr6k9ncxujxn4y07fu6pf73vslmemgpex325vrsytpqks';
272+
'0xb10c2232828953c34c7ab1678372469d48ff279a0a7d1643fbced01c9a2aa307';
273273
const fuelAddress3 =
274-
'fuel152720qgc5wthxu4g7a2g6s7xy9d8wjgtffl489k706xyd2fas0wqyv0vsw';
274+
'0xa2bca78118a3977372a8f7548d43c6215a77490b4a7f5396de7e8c46a93d83dc';
275275
const fuelPrivKey =
276276
'0x7f802a2a277872af1204140bd2c77c2193309c366e3c71ff1c4c31cea0a53f38';
277277
const fuelAddPriv =
278-
'fuel1szu0uagadwpgl0fuz2thrtzn7artghvhexg5d9at4t76nzeesqasrdmjxy';
278+
'0x80b8fe751d6b828fbd3c129771ac53f746b45d97c9914697abaafda98b39803b';
279279

280280
// import account from private key
281281
await createAccountFromPrivateKey(page, fuelPrivKey, 'Account 3');

packages/app/playwright/e2e/RecoverWallet.test.ts

+18
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ test.describe('RecoverWallet', () => {
9191

9292
/** Confirm Mnemonic */
9393
const words = WORDS_24.split(' ');
94+
await expect
95+
.poll(
96+
async () => {
97+
const _locator = await page.locator('input').all();
98+
return _locator.length;
99+
},
100+
{ timeout: 1000 }
101+
)
102+
.toBe(words.length);
94103
const inputs = await page.locator('input').all();
95104
words.forEach((word, i) => {
96105
expect(inputs[i]).toHaveValue(word);
@@ -143,6 +152,15 @@ test.describe('RecoverWallet', () => {
143152

144153
/** Confirm Mnemonic */
145154
const words = WORDS_13.split(' ');
155+
await expect
156+
.poll(
157+
async () => {
158+
const _locator = await page.locator('input').all();
159+
return _locator.length;
160+
},
161+
{ timeout: 1000 }
162+
)
163+
.toBeGreaterThanOrEqual(12);
146164
const inputs = await page.locator('input').all();
147165
words.forEach((word, i) => {
148166
expect(inputs[i]).toHaveValue(word);

packages/app/playwright/e2e/SendTransaction.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test.describe('SendTransaction', () => {
2727
const { accounts } = await mockData(page);
2828
account = accounts[0];
2929
await seedWallet(account.address, bn(100_000_000));
30-
provider = await Provider.create(process.env.VITE_FUEL_PROVIDER_URL);
30+
provider = new Provider(process.env.VITE_FUEL_PROVIDER_URL);
3131
});
3232

3333
test('Send transaction', async () => {
@@ -358,7 +358,7 @@ test.describe('SendTransaction', () => {
358358
});
359359

360360
test('Send transaction to an asset address should fail', async () => {
361-
const assetAddress = provider.getBaseAssetId();
361+
const assetAddress = await provider.getBaseAssetId();
362362
await visit(page, '/send');
363363
await getInputByName(page, 'address').fill(assetAddress);
364364
await getInputByName(page, 'amount').fill('0.001');

packages/app/src/systems/Account/__mocks__/accounts.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const MOCK_ACCOUNTS = [
2727
},
2828
{
2929
name: 'Account 4',
30-
address: 'fuel10va6297tkerdcn5u8mxjm9emudsmkj85pq5x7t7stkmzmc4nvs3qvn99qz',
30+
address:
31+
'0x7b3ba517cbb646dc4e9c3ecd2d973be361bb48f408286f2fd05db62de2b36422',
3132
publicKey: '0x00',
3233
},
3334
];

packages/app/src/systems/Account/components/EthAddress/EthAddress.tsx

+3-17
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,10 @@ export const EthAddress = ({ address, css }: EthAddressProps) => {
1414
const ethAddress = isValidAddress ? bn(address).toHex(20) : '';
1515

1616
return (
17-
<Box.Flex css={styles.root}>
18-
<Copyable value={address} aria-label={address}>
19-
<Tooltip content={address} className="address_tooltip" side="top">
20-
<Text css={css}>{shortAddress(ethAddress)}</Text>
21-
</Tooltip>
17+
<Box.Flex>
18+
<Copyable value={ethAddress} aria-label={address}>
19+
<Text css={css}>{shortAddress(ethAddress)}</Text>
2220
</Copyable>
2321
</Box.Flex>
2422
);
2523
};
26-
27-
const styles = {
28-
root: {
29-
'.address_tooltip': cssObj({
30-
fontSize: '$xs',
31-
lineHeight: '$4',
32-
maxWidth: 125,
33-
textAlign: 'center',
34-
wordWrap: 'break-word',
35-
}),
36-
},
37-
};

packages/app/src/systems/Account/components/FuelAddress/FuelAddress.test.tsx

-27
This file was deleted.

packages/app/src/systems/Account/components/FuelAddress/FuelAddress.tsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
import type { ThemeUtilsCSS } from '@fuel-ui/css';
22
import { cssObj } from '@fuel-ui/css';
33
import { Box, Copyable, Icon, IconButton, Text } from '@fuel-ui/react';
4-
import {
5-
Address,
6-
type B256Address,
7-
type Bech32Address,
8-
type ChecksumAddress,
9-
} from 'fuels';
4+
import { Address, type B256Address, type ChecksumAddress } from 'fuels';
105
import { useMemo } from 'react';
116
import { shortAddress } from '~/systems/Core';
127
import { useExplorerLink } from '../../hooks/useExplorerLink';
138

149
export type AddressProps = {
15-
address: ChecksumAddress | Bech32Address | B256Address;
10+
address: string;
1611
canOpenExplorer?: boolean;
1712
css?: ThemeUtilsCSS;
1813
isContract?: boolean;
1914
};
2015

2116
export const FuelAddress = ({
2217
address,
23-
isContract,
2418
canOpenExplorer = false,
19+
isContract,
2520
css,
2621
}: AddressProps) => {
2722
const account = useMemo<string>(() => {
2823
if (!address) return '';
29-
if (isContract) return Address.fromDynamicInput(address).toB256();
30-
return Address.fromDynamicInput(address).toString();
24+
const fuelAddress = Address.fromDynamicInput(address);
25+
if (isContract) return fuelAddress.toB256();
26+
return fuelAddress.toString();
3127
}, [isContract, address]);
3228

3329
const { openExplorer, href } = useExplorerLink(account);

packages/app/src/systems/Account/services/account.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class AccountService {
8282
const { address } = input;
8383
const account = await db.transaction('r', db.accounts, async () => {
8484
return db.accounts.get({
85-
address: Address.fromString(address).toString(),
85+
address: Address.fromDynamicInput(address).toString(),
8686
});
8787
});
8888

@@ -112,7 +112,7 @@ export class AccountService {
112112
string,
113113
{ value: number; formatted: string } | undefined
114114
> = {};
115-
const chainId = provider.getChainId();
115+
const chainId = await provider.getChainId();
116116

117117
const balanceAssets = await AssetsCache.fetchAllAssets(
118118
chainId,
@@ -164,7 +164,7 @@ export class AccountService {
164164
});
165165

166166
// includes eth balance info, centralizing the complexity here instead of in rest of UI
167-
const baseAssetId = provider.getBaseAssetId();
167+
const baseAssetId = await provider.getBaseAssetId();
168168
const ethAsset = balances.find(
169169
(balance) => balance.assetId === baseAssetId.toString()
170170
);

packages/app/src/systems/Asset/machines/assetsMachine.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const assetsMachine = createMachine(
185185
services: {
186186
setListedAssets: FetchMachine.create<null, void>({
187187
showError: true,
188-
async fetch() {
188+
fetch: async () => {
189189
await AssetService.setListedAssets();
190190
},
191191
}),

0 commit comments

Comments
 (0)