Skip to content

Commit

Permalink
Merge branch 'master' into st/chore/add-latency-detection-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Jan 24, 2025
2 parents 7e700a7 + 68e4b5a commit aaf8330
Show file tree
Hide file tree
Showing 45 changed files with 105 additions and 150 deletions.
7 changes: 7 additions & 0 deletions .changeset/lemon-avocados-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@internal/forc": patch
"create-fuels": patch
"@fuel-ts/versions": patch
---

chore: bump `forc` to `0.66.6`
6 changes: 6 additions & 0 deletions .changeset/pink-mails-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/account": patch
"@fuel-ts/utils": patch
---

chore: update `amountPerCoin` prop in `WalletConfig` to accept BN
6 changes: 6 additions & 0 deletions .changeset/six-moles-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/abi-typegen": patch
"@fuel-ts/recipes": patch
---

chore: prevent naming collisions on typegen
2 changes: 1 addition & 1 deletion apps/create-fuels-counter-guide/fuel-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
channel = "testnet"

[components]
forc = "0.66.5"
forc = "0.66.6"
fuel-core = "0.40.2"
10 changes: 1 addition & 9 deletions apps/docs/sway/liquidity-pool/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
// #region deposit-and-withdraw-cookbook-1
contract;

use std::{asset::{mint_to, transfer,}, call_frames::{msg_asset_id,}, context::msg_amount,};
use std::{asset::{mint_to, transfer}, call_frames::msg_asset_id, context::msg_amount};
use std::constants::ZERO_B256;

abi LiquidityPool {
#[payable]
fn deposit(recipient: Address);
#[payable]
fn withdraw(recipient: Address);
}

configurable {
TOKEN: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000000),
}

impl LiquidityPool for Contract {
#[payable]
fn deposit(recipient: Address) {
assert(TOKEN == msg_asset_id());
assert(0 < msg_amount());

// Mint two times the amount.
let amount_to_mint = msg_amount() * 2;

// Mint some LP token based upon the amount of the base token.
mint_to(Identity::Address(recipient), ZERO_B256, amount_to_mint);
}

#[payable]
fn withdraw(recipient: Address) {
assert(0 < msg_amount());

// Amount to withdraw.
let amount_to_transfer = msg_amount() / 2;

// Transfer base token to recipient.
transfer(Identity::Address(recipient), TOKEN, amount_to_transfer);
}
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/sway/simple-token/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// #region inter-contract-calls-1
contract;

use ::simple_token_abi::SimpleToken;

use std::hash::*;
use simple_token_abi::SimpleToken;

storage {
balances: StorageMap<b256, u64> = StorageMap {},
}

impl SimpleToken for Contract {
#[storage(read, write)]
fn deposit(address: b256, amount: u64) {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/sway/token-depositor/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ contract;

use std::auth::msg_sender;

use ::simple_token_abi::SimpleToken;
use simple_token_abi::SimpleToken;

abi TokenDepositor {
fn deposit_to_simple_token(contract_id: b256, amount: u64);
Expand Down
2 changes: 1 addition & 1 deletion internal/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.66.5
0.66.6
4 changes: 2 additions & 2 deletions packages/abi-typegen/src/templates/contract/factory.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{header}}

import { ContractFactory, decompressBytecode } from "fuels";
import { ContractFactory as __ContractFactory, decompressBytecode } from "fuels";
import type { Provider, Account, DeployContractOptions } from "fuels";

import { {{capitalizedName}} } from "./{{capitalizedName}}";

const bytecode = decompressBytecode("{{compressedBytecode}}");

export class {{capitalizedName}}Factory extends ContractFactory<{{capitalizedName}}> {
export class {{capitalizedName}}Factory extends __ContractFactory<{{capitalizedName}}> {

static readonly bytecode = bytecode;

Expand Down
4 changes: 2 additions & 2 deletions packages/abi-typegen/src/templates/contract/main.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{header}}

import { Contract, Interface } from "fuels";
import { Contract as __Contract, Interface } from "fuels";
{{#if imports}}
import type {
Provider,
Expand Down Expand Up @@ -69,7 +69,7 @@ export class {{capitalizedName}}Interface extends Interface {
};
}

export class {{capitalizedName}} extends Contract {
export class {{capitalizedName}} extends __Contract {
static readonly abi = abi;
static readonly storageSlots = storageSlots;

Expand Down
2 changes: 1 addition & 1 deletion packages/abi-typegen/src/templates/predicate/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const abi = {{abiJsonString}};

const bytecode = decompressBytecode('{{compressedBytecode}}');

export class {{capitalizedName}} extends Predicate<
export class {{capitalizedName}} extends __Predicate<
{{capitalizedName}}Inputs,
{{capitalizedName}}Configurables
> {
Expand Down
8 changes: 7 additions & 1 deletion packages/abi-typegen/src/templates/predicate/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export function renderMainTemplate(params: { abi: Abi; versions: BinaryVersions
const { structs } = formatStructs({ types });
const { imports } = formatImports({
types,
baseMembers: ['Predicate', 'Provider', 'InputValue', 'PredicateParams', 'decompressBytecode'],
baseMembers: [
'Predicate as __Predicate',
'Provider',
'InputValue',
'PredicateParams',
'decompressBytecode',
],
});

const { prefixedInputs: inputs, output } = func.attributes;
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-typegen/src/templates/script/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const abi = {{abiJsonString}};

const bytecode = decompressBytecode('{{compressedBytecode}}');

export class {{capitalizedName}} extends Script<{{capitalizedName}}Inputs, {{capitalizedName}}Output> {
export class {{capitalizedName}} extends __Script<{{capitalizedName}}Inputs, {{capitalizedName}}Output> {

static readonly abi = abi;
static readonly bytecode = bytecode;
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-typegen/src/templates/script/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function renderMainTemplate(params: { abi: Abi; versions: BinaryVersions
const { structs } = formatStructs({ types });
const { imports } = formatImports({
types,
baseMembers: ['Script', 'Account', 'decompressBytecode'],
baseMembers: ['Script as __Script', 'Account', 'decompressBytecode'],
});

const { prefixedInputs: inputs, output } = func.attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Fuel-Core version: 33.33.33
*/

import { Contract, Interface } from "fuels";
import { Contract as __Contract, Interface } from "fuels";
import type {
Provider,
Account,
Expand Down Expand Up @@ -160,17 +160,17 @@ const abi = {
{
"name": "SHOULD_RETURN",
"concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"offset": 2816
"offset": 2584
},
{
"name": "AN_OPTION",
"concreteTypeId": "2da102c46c7263beeed95818cd7bee801716ba8303dddafdcd0f6c9efda4a0f1",
"offset": 2792
"offset": 2560
},
{
"name": "A_GENERIC_STRUCT",
"concreteTypeId": "71df88006611ffff852cf617defb70f77adaf507305088cedd41d276c783aab0",
"offset": 2808
"offset": 2576
}
]
};
Expand All @@ -187,7 +187,7 @@ export class MyContractInterface extends Interface {
};
}

export class MyContract extends Contract {
export class MyContract extends __Contract {
static readonly abi = abi;
static readonly storageSlots = storageSlots;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
Fuel-Core version: 33.33.33
*/

import { ContractFactory, decompressBytecode } from "fuels";
import { ContractFactory as __ContractFactory, decompressBytecode } from "fuels";
import type { Provider, Account, DeployContractOptions } from "fuels";

import { MyContract } from "./MyContract";

const bytecode = decompressBytecode("0x-bytecode-here");

export class MyContractFactory extends ContractFactory<MyContract> {
export class MyContractFactory extends __ContractFactory<MyContract> {

static readonly bytecode = bytecode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Fuel-Core version: 33.33.33
*/

import { Contract, Interface } from "fuels";
import { Contract as __Contract, Interface } from "fuels";
import type {
Provider,
Account,
Expand Down Expand Up @@ -1199,7 +1199,7 @@ export class MyContractInterface extends Interface {
};
}

export class MyContract extends Contract {
export class MyContract extends __Contract {
static readonly abi = abi;
static readonly storageSlots = storageSlots;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
BigNumberish,
decompressBytecode,
InputValue,
Predicate,
Predicate as __Predicate,
PredicateParams,
Provider,
} from 'fuels';
Expand Down Expand Up @@ -73,19 +73,19 @@ const abi = {
{
"name": "FEE",
"concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b",
"offset": 936
"offset": 888
},
{
"name": "ADDRESS",
"concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b",
"offset": 904
"offset": 856
}
]
};

const bytecode = decompressBytecode('0x-bytecode-here');

export class MyPredicate extends Predicate<
export class MyPredicate extends __Predicate<
MyPredicateInputs,
MyPredicateConfigurables
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
BN,
decompressBytecode,
InputValue,
Predicate,
Predicate as __Predicate,
PredicateParams,
Provider,
} from 'fuels';
Expand Down Expand Up @@ -276,7 +276,7 @@ const abi = {

const bytecode = decompressBytecode('0x-bytecode-here');

export class MyPredicate extends Predicate<
export class MyPredicate extends __Predicate<
MyPredicateInputs,
MyPredicateConfigurables
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Account,
BigNumberish,
decompressBytecode,
Script,
Script as __Script,
} from 'fuels';

export type ScoreInput = { user: BigNumberish, points: BigNumberish };
Expand Down Expand Up @@ -81,14 +81,14 @@ const abi = {
{
"name": "SHOULD_RETURN",
"concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"offset": 768
"offset": 696
}
]
};

const bytecode = decompressBytecode('0x-bytecode-here');

export class MyScript extends Script<MyScriptInputs, MyScriptOutput> {
export class MyScript extends __Script<MyScriptInputs, MyScriptOutput> {

static readonly abi = abi;
static readonly bytecode = bytecode;
Expand Down
4 changes: 2 additions & 2 deletions packages/abi-typegen/test/fixtures/templates/script/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
BigNumberish,
BN,
decompressBytecode,
Script,
Script as __Script,
} from 'fuels';

import type { Option, Enum, Vec, Result } from "./common";
Expand Down Expand Up @@ -268,7 +268,7 @@ const abi = {

const bytecode = decompressBytecode('0x-bytecode-here');

export class MyScript extends Script<MyScriptInputs, MyScriptOutput> {
export class MyScript extends __Script<MyScriptInputs, MyScriptOutput> {

static readonly abi = abi;
static readonly bytecode = bytecode;
Expand Down
9 changes: 5 additions & 4 deletions packages/account/src/test-utils/wallet-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { randomBytes } from '@fuel-ts/crypto';
import { FuelError } from '@fuel-ts/errors';
import { bn, type BigNumberish } from '@fuel-ts/math';
import { defaultSnapshotConfigs, hexlify, type SnapshotConfigs } from '@fuel-ts/utils';
import type { PartialDeep } from 'type-fest';

Expand Down Expand Up @@ -29,7 +30,7 @@ export interface WalletsConfigOptions {
/**
* For each coin, the amount it'll contain.
*/
amountPerCoin: number;
amountPerCoin: BigNumberish;

/**
* Messages that are supposed to be on the wallet.
Expand Down Expand Up @@ -105,7 +106,7 @@ export class WalletsConfig {
baseAssetId: string,
assets: number | TestAssetId[],
coinsPerAsset: number,
amountPerCoin: number
amountPerCoin: BigNumberish
) {
const coins: SnapshotConfigs['stateConfig']['coins'] = [];

Expand All @@ -122,7 +123,7 @@ export class WalletsConfig {
assetIds.forEach((assetId) => {
for (let index = 0; index < coinsPerAsset; index++) {
coins.push({
amount: amountPerCoin,
amount: bn(amountPerCoin).toString(),
asset_id: assetId,
owner: walletAddress,
tx_pointer_block_height: 0,
Expand Down Expand Up @@ -167,7 +168,7 @@ export class WalletsConfig {
'Number of coins per asset must be greater than zero.'
);
}
if (amountPerCoin < 0) {
if (bn(amountPerCoin).lt(0)) {
throw new FuelError(
FuelError.CODES.INVALID_INPUT_PARAMETERS,
'Amount per coin must be greater than or equal to zero.'
Expand Down
2 changes: 1 addition & 1 deletion packages/create-fuels/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('CLI', { timeout: 15_000 }, () => {

expect(toolchain).toEqual({ channel: 'testnet' });
expect(components).toEqual({
forc: '0.66.5',
forc: '0.66.6',
'fuel-core': '0.40.2',
});
});
Expand Down
Loading

0 comments on commit aaf8330

Please sign in to comment.