Skip to content

Commit c9e0c5a

Browse files
authored
feat: add support for fuel-core v0.47.1 (#3950)
1 parent 7d78325 commit c9e0c5a

File tree

18 files changed

+485
-66
lines changed

18 files changed

+485
-66
lines changed

.changeset/sour-humans-judge.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@fuel-ts/transactions": patch
3+
"@internal/fuel-core": patch
4+
"@fuel-ts/versions": patch
5+
"@fuel-ts/account": patch
6+
---
7+
8+
feat: add support for fuel-core v0.47.1

.github/workflows/pr-validate-changesets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
exit 0
134134
fi
135135
136-
STATUS_CODE=$(curl -s -w '%{http_code}\n' "https://www.npmjs.com/package/fuels/v/$NEW_VERSION" | tail -n1)
136+
STATUS_CODE=$(curl -s -o /dev/null -w '%{http_code}\n' "https://registry.npmjs.org/fuels/$NEW_VERSION")
137137
if [[ $STATUS_CODE != 404 ]]; then
138138
echo "Release for version $NEW_VERSION already exists or curl received an unexpected result (result is $STATUS_CODE). Exiting."
139139
exit 1

.github/workflows/publish-preview.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
99

1010
env:
1111
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
12-
VERCEL_TS_DOCS_PROJECT_ID: 'prj_iBhTlkv2hj2E6BiA3GeacxgNHIEL'
13-
VERCEL_TS_DOCS_API_PROJECT_ID: 'prj_hBydWalwFfqTPkpKTIy82abixInS'
14-
VERCEL_TS_TEMPLATE_PROJECT_ID: 'prj_syuKtl2KTIU4OvO2mRccdbIt55BN'
12+
VERCEL_TS_DOCS_PROJECT_ID: "prj_iBhTlkv2hj2E6BiA3GeacxgNHIEL"
13+
VERCEL_TS_DOCS_API_PROJECT_ID: "prj_hBydWalwFfqTPkpKTIy82abixInS"
14+
VERCEL_TS_TEMPLATE_PROJECT_ID: "prj_syuKtl2KTIU4OvO2mRccdbIt55BN"
1515

1616
jobs:
1717
publish-to-vercel:
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: CI Setup
2727
uses: ./.github/actions/ci-setup
28-
28+
2929
- name: Install Vercel
3030
run: pnpm install --global vercel@latest
3131

@@ -74,4 +74,4 @@ jobs:
7474
uses: actions/github-script@v3
7575
with:
7676
script: |
77-
core.setFailed('One of the Vercel deployments failed')
77+
core.setFailed('One of the Vercel deployments failed')

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
1010

1111
env:
1212
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
13-
VERCEL_TS_DOCS_PROJECT_ID: 'prj_iBhTlkv2hj2E6BiA3GeacxgNHIEL'
14-
VERCEL_TS_DOCS_API_PROJECT_ID: 'prj_hBydWalwFfqTPkpKTIy82abixInS'
15-
VERCEL_TS_TEMPLATE_PROJECT_ID: 'prj_syuKtl2KTIU4OvO2mRccdbIt55BN'
13+
VERCEL_TS_DOCS_PROJECT_ID: "prj_iBhTlkv2hj2E6BiA3GeacxgNHIEL"
14+
VERCEL_TS_DOCS_API_PROJECT_ID: "prj_hBydWalwFfqTPkpKTIy82abixInS"
15+
VERCEL_TS_TEMPLATE_PROJECT_ID: "prj_syuKtl2KTIU4OvO2mRccdbIt55BN"
1616

1717
jobs:
1818
release:

apps/create-fuels-counter-guide/fuel-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ channel = "testnet"
33

44
[components]
55
forc = "0.68.7"
6-
fuel-core = "0.44.0"
6+
fuel-core = "0.47.1"

internal/fuel-core/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.44.0
1+
0.47.1

link-check.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
{
2727
"pattern": "^modules/_fuel_ts",
2828
"replacement": "http://localhost:9876/modules/_fuel_ts"
29+
},
30+
{
31+
"pattern": "^https://www\\.npmjs\\.com/package/(.*)$",
32+
"replacement": "https://registry.npmjs.org/$1"
2933
}
3034
]
3135
}

packages/account/src/providers/fuel-core-schema.graphql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ type Query {
10311031
ID of the Asset
10321032
"""
10331033
id: AssetId!
1034-
): AssetInfoDetails!
1034+
): AssetInfoDetails
10351035

10361036
"""
10371037
Read register value by index.
@@ -1528,6 +1528,7 @@ type Subscription {
15281528
"""
15291529
includePreconfirmation: Boolean
15301530
): TransactionStatus!
1531+
alpha__preconfirmations: TransactionStatus!
15311532

15321533
"""
15331534
Submits transaction to the `TxPool` and await either success or failure.
@@ -1549,6 +1550,7 @@ type Subscription {
15491550
): TransactionStatus!
15501551
contractStorageSlots(contractId: ContractId!): StorageSlot!
15511552
contractStorageBalances(contractId: ContractId!): ContractBalance!
1553+
alpha__new_blocks: HexString!
15521554
}
15531555

15541556
type SuccessStatus {

packages/account/src/providers/provider.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ export default class Provider {
10581058
* @param assetId - The unique identifier of the asset.
10591059
* @returns A promise that resolves to an object containing the asset details.
10601060
*/
1061-
async getAssetDetails(assetId: string): Promise<GetAssetDetailsResponse> {
1061+
async getAssetDetails(assetId: string): Promise<GetAssetDetailsResponse | null> {
10621062
const { assetMetadata } = await this.getNodeFeatures();
10631063

10641064
if (!assetMetadata) {
@@ -1070,11 +1070,15 @@ export default class Provider {
10701070

10711071
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
10721072

1073-
const { contractId, subId, totalSupply } = assetDetails;
1073+
if (!assetDetails) {
1074+
return null;
1075+
}
1076+
1077+
const { contractId, subId, totalSupply } = assetDetails ?? {};
10741078

10751079
return {
1076-
subId,
1077-
contractId,
1080+
subId: subId ?? '',
1081+
contractId: contractId ?? '',
10781082
totalSupply: bn(totalSupply),
10791083
};
10801084
}

packages/account/src/providers/transaction-request/transaction-request.test.ts

Lines changed: 161 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Address } from '@fuel-ts/address';
22
import { ZeroBytes32 } from '@fuel-ts/address/configs';
33
import { randomBytes } from '@fuel-ts/crypto';
44
import { bn, toNumber } from '@fuel-ts/math';
5-
import { TransactionType, UpgradePurposeTypeEnum } from '@fuel-ts/transactions';
5+
import { PolicyType, TransactionType, UpgradePurposeTypeEnum } from '@fuel-ts/transactions';
66
import { concat, hexlify } from '@fuel-ts/utils';
77
import { ASSET_A, ASSET_B } from '@fuel-ts/utils/test-utils';
88

@@ -13,6 +13,7 @@ import Provider from '../provider';
1313

1414
import type { CoinTransactionRequestInput } from './input';
1515
import { ScriptTransactionRequest } from './script-transaction-request';
16+
import { BaseTransactionRequest } from './transaction-request';
1617
import type { TransactionRequestLike } from './types';
1718
import type { UpgradeTransactionRequest } from './upgrade-transaction-request';
1819
import type { UploadTransactionRequest } from './upload-transaction-request';
@@ -147,6 +148,165 @@ describe('TransactionRequest', () => {
147148
expect(signTxSpy).toHaveBeenCalledTimes(7);
148149
expect(createWitnessSpy).toHaveBeenCalledTimes(7);
149150
});
151+
152+
describe('getPolicyMeta', () => {
153+
it('should return MaxFee policy by default', () => {
154+
const txRequest = new ScriptTransactionRequest({
155+
maxFee: 1000,
156+
});
157+
158+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
159+
160+
expect(result.policyTypes).toBe(PolicyType.MaxFee);
161+
expect(result.policies).toHaveLength(1);
162+
expect(result.policies[0]).toEqual({
163+
type: PolicyType.MaxFee,
164+
data: bn(1000),
165+
});
166+
});
167+
168+
it('should include Owner policy when ownerInputIndex is provided', () => {
169+
const txRequest = new ScriptTransactionRequest({
170+
maxFee: 1000,
171+
ownerInputIndex: 5,
172+
});
173+
174+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
175+
176+
expect(result.policyTypes).toBe(PolicyType.MaxFee + PolicyType.Owner);
177+
expect(result.policies).toHaveLength(2);
178+
179+
const maxFeePolicy = result.policies.find((p) => p.type === PolicyType.MaxFee);
180+
expect(maxFeePolicy?.data.toNumber()).toBe(1000);
181+
182+
const ownerPolicy = result.policies.find((p) => p.type === PolicyType.Owner);
183+
expect(ownerPolicy?.data.toNumber()).toBe(5);
184+
});
185+
186+
it('should not include Owner policy when ownerInputIndex is undefined', () => {
187+
const txRequest = new ScriptTransactionRequest({
188+
maxFee: 1000,
189+
ownerInputIndex: undefined,
190+
});
191+
192+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
193+
194+
expect(result.policyTypes).toBe(PolicyType.MaxFee);
195+
expect(result.policies).toHaveLength(1);
196+
expect(result.policies[0].type).not.toBe(PolicyType.Owner);
197+
});
198+
199+
it('should include Owner policy with tip and other policies', () => {
200+
const txRequest = new ScriptTransactionRequest({
201+
maxFee: 2000,
202+
tip: 100,
203+
ownerInputIndex: 3,
204+
maturity: 10,
205+
});
206+
207+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
208+
209+
expect(result.policyTypes).toBe(
210+
PolicyType.MaxFee + PolicyType.Tip + PolicyType.Maturity + PolicyType.Owner
211+
);
212+
expect(result.policies).toHaveLength(4);
213+
214+
const maxFeePolicy = result.policies.find((p) => p.type === PolicyType.MaxFee);
215+
expect(maxFeePolicy?.data.toNumber()).toBe(2000);
216+
217+
const tipPolicy = result.policies.find((p) => p.type === PolicyType.Tip);
218+
expect(tipPolicy?.data.toNumber()).toBe(100);
219+
220+
const maturityPolicy = result.policies.find((p) => p.type === PolicyType.Maturity);
221+
expect(maturityPolicy?.data).toBe(10);
222+
223+
const ownerPolicy = result.policies.find((p) => p.type === PolicyType.Owner);
224+
expect(ownerPolicy?.data.toNumber()).toBe(3);
225+
});
226+
227+
it('should include Owner policy with all possible policies', () => {
228+
const txRequest = new ScriptTransactionRequest({
229+
maxFee: 2000,
230+
tip: 100,
231+
ownerInputIndex: 2,
232+
maturity: 10,
233+
expiration: 100,
234+
witnessLimit: 500,
235+
});
236+
237+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
238+
239+
expect(result.policyTypes).toBe(
240+
PolicyType.MaxFee +
241+
PolicyType.Tip +
242+
PolicyType.Maturity +
243+
PolicyType.Expiration +
244+
PolicyType.WitnessLimit +
245+
PolicyType.Owner
246+
);
247+
expect(result.policies).toHaveLength(6);
248+
249+
// Check that all policy types are present
250+
const policyTypes = result.policies.map((p) => p.type);
251+
expect(policyTypes).toContain(PolicyType.MaxFee);
252+
expect(policyTypes).toContain(PolicyType.Tip);
253+
expect(policyTypes).toContain(PolicyType.Maturity);
254+
expect(policyTypes).toContain(PolicyType.Expiration);
255+
expect(policyTypes).toContain(PolicyType.WitnessLimit);
256+
expect(policyTypes).toContain(PolicyType.Owner);
257+
258+
// Check the values
259+
const maxFeePolicy = result.policies.find((p) => p.type === PolicyType.MaxFee);
260+
expect(maxFeePolicy?.data.toNumber()).toBe(2000);
261+
262+
const tipPolicy = result.policies.find((p) => p.type === PolicyType.Tip);
263+
expect(tipPolicy?.data.toNumber()).toBe(100);
264+
265+
const maturityPolicy = result.policies.find((p) => p.type === PolicyType.Maturity);
266+
expect(maturityPolicy?.data).toBe(10);
267+
268+
const expirationPolicy = result.policies.find((p) => p.type === PolicyType.Expiration);
269+
expect(expirationPolicy?.data).toBe(100);
270+
271+
const witnessLimitPolicy = result.policies.find((p) => p.type === PolicyType.WitnessLimit);
272+
expect(witnessLimitPolicy?.data.toNumber()).toBe(500);
273+
274+
const ownerPolicy = result.policies.find((p) => p.type === PolicyType.Owner);
275+
expect(ownerPolicy?.data.toNumber()).toBe(2);
276+
});
277+
278+
it('should handle ownerInputIndex with different numeric values', () => {
279+
const testCases = [1, 10, 100, 255, 1000, 65535];
280+
281+
testCases.forEach((ownerInputIndex) => {
282+
const txRequest = new ScriptTransactionRequest({
283+
maxFee: 1000,
284+
ownerInputIndex,
285+
});
286+
287+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
288+
289+
const ownerPolicy = result.policies.find((p) => p.type === PolicyType.Owner);
290+
expect(ownerPolicy).toBeDefined();
291+
expect(ownerPolicy?.data.toNumber()).toBe(ownerInputIndex);
292+
});
293+
});
294+
295+
it('should serialize ownerInputIndex as BN in owner policy', () => {
296+
const txRequest = new ScriptTransactionRequest({
297+
maxFee: 1000,
298+
ownerInputIndex: 999,
299+
});
300+
301+
const result = BaseTransactionRequest.getPolicyMeta(txRequest);
302+
303+
const ownerPolicy = result.policies.find((p) => p.type === PolicyType.Owner);
304+
expect(ownerPolicy).toBeDefined();
305+
expect(ownerPolicy?.type).toBe(PolicyType.Owner);
306+
expect(ownerPolicy?.data.toNumber()).toBe(999);
307+
expect(ownerPolicy?.data.constructor.name).toBe('BN');
308+
});
309+
});
150310
});
151311

152312
describe('transactionRequestify', () => {

0 commit comments

Comments
 (0)