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: remove data heavy unused parts of the receipts in gql queries #1709

Closed
wants to merge 15 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
11 changes: 11 additions & 0 deletions .changeset/witty-hounds-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@fuel-ts/abi-typegen": patch
"@fuel-ts/forc": patch
"@fuel-ts/fuel-core": patch
"fuels": patch
"@fuel-ts/script": patch
"@fuel-ts/transactions": patch
"@fuel-ts/versions": patch
---

Upgrading `forc` to `0.49.2`
2 changes: 2 additions & 0 deletions .github/actions/ci-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ runs:
apps/docs/.typedoc
apps/docs/src/api
packages/providers/src/__generated__
templates/src/sway-api
key: ${{ runner.os }}-generated-${{ github.sha }}

- name: Cache Build
Expand All @@ -37,6 +38,7 @@ runs:
apps/docs/.typedoc
apps/docs/src/api
packages/providers/src/__generated__
templates/src/sway-api
key: ${{ runner.os }}-generated-${{ github.sha }}

- name: Setup Node.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
contract;

use std::{
asset::{
mint_to_address,
transfer_to_address,
},
call_frames::{
msg_asset_id,
},
context::msg_amount,
token::{
mint_to_address,
transfer_to_address,
},
};
use std::constants::ZERO_B256;

Expand All @@ -20,9 +20,7 @@ abi LiquidityPool {
fn withdraw(recipient: Address);
}

const BASE_TOKEN: AssetId = AssetId::from(
0x0000000000000000000000000000000000000000000000000000000000000000,
);
const BASE_TOKEN: AssetId = AssetId::from(0x0000000000000000000000000000000000000000000000000000000000000000);

impl LiquidityPool for Contract {
#[payable]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #region custom-transactions-1
script;

use std::token::force_transfer_to_contract;
use std::asset::force_transfer_to_contract;

fn main(
contract_address: b256,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #region contract-balance-2
contract;

use std::token::transfer_to_address;
use std::asset::transfer_to_address;

abi TransferToAddress {
#[payable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ impl MyContract for Contract {
x
}
fn types_evm_address(x: EvmAddress) -> EvmAddress {
EvmAddress::from(
0x0606060606060606060606060606060606060606060606060606060606060606,
)
EvmAddress::from(0x0606060606060606060606060606060606060606060606060606060606060606)
}
fn types_bytes(x: Bytes) -> Bytes {
x
Expand Down
2 changes: 1 addition & 1 deletion packages/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.48.1
git:xunilrj/v0.49.2
22 changes: 13 additions & 9 deletions packages/forc/lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import {
const pkgPlatform = getPkgPlatform();
const forcVersion = await getCurrentVersion();

// If a git branch is specified in the VERSION file, build from that branch
if (isGitBranch(forcVersion)) {
const branchName = forcVersion.split(':')[1];
buildFromGitBranch(branchName);
return;
}

const pkgName = `forc-binaries-${pkgPlatform}.tar.gz`;
const pkgUrl = `https://github.com/FuelLabs/sway/releases/download/v${forcVersion}/${pkgName}`;

Expand All @@ -42,13 +35,24 @@ import {
const binVersion = binRawVersion.match(/([.0-9]+)/)?.[0];

versionMatches = binVersion === forcVersion;
info({ expected: forcVersion, received: binVersion });
info({
expected: forcVersion,
received: binVersion,
isGitBranch: isGitBranch(forcVersion),
});
}

if (versionMatches) {
info(`Forc binary already installed, skipping.`);
} else {
// Download
// If a git branch is specified in the VERSION file, build from that branch
if (isGitBranch(forcVersion)) {
const branchName = forcVersion.split(':')[1];
buildFromGitBranch(branchName);
return;
}

// Otherwise, download
const buf = await fetch(pkgUrl).then((r) => r.buffer());
writeFileSync(pkgPath, buf);

Expand Down
44 changes: 28 additions & 16 deletions packages/forc/lib/shared.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { execSync } from 'child_process';
import { cpSync, mkdirSync, rmSync, readFileSync, writeFileSync } from 'fs';
import { cpSync, mkdirSync, rmSync, readFileSync, writeFileSync, existsSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';

// eslint-disable-next-line @typescript-eslint/naming-convention
export const __dirname = dirname(fileURLToPath(import.meta.url));

export const binPath = join(__dirname, '../forc-binaries/forc');
export const forcBinDirPath = join(__dirname, '..', 'forc-binaries');
export const binPath = join(forcBinDirPath, 'forc');

const platforms = {
darwin: {
Expand Down Expand Up @@ -50,18 +51,29 @@ export const isGitBranch = (versionFileContents) => versionFileContents.indexOf(
const swayRepoUrl = 'https://github.com/fuellabs/sway.git';

export const buildFromGitBranch = (branchName) => {
rmSync('sway-repo', { recursive: true, force: true });
rmSync('forc-binaries', { recursive: true, force: true });
execSync(`git clone --branch ${branchName} ${swayRepoUrl} sway-repo`);
execSync(`cd sway-repo && cargo build`);
mkdirSync('forc-binaries');
cpSync('sway-repo/target/debug/forc', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-deploy', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-doc', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-fmt', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-lsp', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-run', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-submit', 'forc-binaries');
cpSync('sway-repo/target/debug/forc-tx', 'forc-binaries');
rmSync('sway-repo', { recursive: true, force: true });
const swayRepoDir = join(__dirname, '..', 'sway-repo');
const swayRepoDebugDir = join(swayRepoDir, 'target', 'debug');
const stdioOpts = { stdio: 'inherit' };

if (existsSync(swayRepoDir)) {
execSync(`cd ${swayRepoDir} && git fetch origin && git checkout ${branchName}`, stdioOpts);
execSync(`cd ${swayRepoDir} && cargo build`, stdioOpts);
} else {
execSync(`git clone --branch ${branchName} ${swayRepoUrl} ${swayRepoDir}`, stdioOpts);
execSync(`cd ${swayRepoDir} && cargo build`, stdioOpts);
}

const [from, to] = [swayRepoDebugDir, forcBinDirPath];

rmSync(to, { recursive: true, force: true });
mkdirSync(to, { recursive: true });

cpSync(join(from, 'forc'), join(to, 'forc'));
cpSync(join(from, 'forc-deploy'), join(to, 'forc-deploy'));
cpSync(join(from, 'forc-doc'), join(to, 'forc-doc'));
cpSync(join(from, 'forc-fmt'), join(to, 'forc-fmt'));
cpSync(join(from, 'forc-lsp'), join(to, 'forc-lsp'));
cpSync(join(from, 'forc-run'), join(to, 'forc-run'));
cpSync(join(from, 'forc-submit'), join(to, 'forc-submit'));
cpSync(join(from, 'forc-tx'), join(to, 'forc-tx'));
};
30 changes: 13 additions & 17 deletions packages/fuel-core/lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ import {
const pkgPlatform = getPkgPlatform();
const fuelCoreVersion = await getCurrentVersion();

// If a git branch is specified in the VERSION file, build from that branch
if (isGitBranch(fuelCoreVersion)) {
const branchName = fuelCoreVersion.split(':')[1];
buildFromGitBranch(branchName);
return;
}

const fileName = `fuel-core-${fuelCoreVersion}-${pkgPlatform}`;
const pkgName = `${fileName}.tar.gz`;
const pkgUrl = `https://github.com/FuelLabs/fuel-core/releases/download/v${fuelCoreVersion}/${pkgName}`;
Expand All @@ -44,23 +37,26 @@ import {
const binVersion = binRawVersion.match(/([.0-9]+)/)?.[0];

versionMatches = binVersion === fuelCoreVersion;
info({ expected: fuelCoreVersion, received: binVersion });
info({
expected: fuelCoreVersion,
received: binVersion,
isGitBranch: isGitBranch(fuelCoreVersion),
});
}

if (versionMatches) {
info(`fuel-core binary already installed, skipping.`);
} else {
// Empty the `fuel-core-binaries` directory if it exists
if (existsSync(binDir)) {
rmSync(`${binDir}/*`, {
recursive: true,
force: true,
});
} else {
// Create the `fuel-core-binaries` directory if it doesn't exist
mkdirSync(binDir);
// If a git branch is specified in the VERSION file, build from that branch
if (isGitBranch(fuelCoreVersion)) {
const branchName = fuelCoreVersion.split(':')[1];
buildFromGitBranch(branchName);
return;
}

// Empty the `fuel-core-binaries` directory if it exists
rmSync(binDir, { recursive: true, force: true });

// Download
const buf = await fetch(pkgUrl).then((r) => r.buffer());
writeFileSync(pkgPath, buf);
Expand Down
31 changes: 22 additions & 9 deletions packages/fuel-core/lib/shared.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { execSync } from 'child_process';
import { cpSync, mkdirSync, rmSync, readFileSync, writeFileSync } from 'fs';
import { cpSync, mkdirSync, rmSync, readFileSync, writeFileSync, existsSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';

// eslint-disable-next-line @typescript-eslint/naming-convention
export const __dirname = dirname(fileURLToPath(import.meta.url));

export const binPath = join(__dirname, '../fuel-core-binaries/fuel-core');
export const fuelCoreBinDirPath = join(__dirname, '..', 'fuel-core-binaries');
export const binPath = join(fuelCoreBinDirPath, 'fuel-core');

const platforms = {
darwin: {
Expand Down Expand Up @@ -49,11 +50,23 @@ export const isGitBranch = (versionFileContents) => versionFileContents.indexOf(
const fuelCoreRepoUrl = 'https://github.com/fuellabs/fuel-core.git';

export const buildFromGitBranch = (branchName) => {
rmSync('fuel-core-repo', { recursive: true, force: true });
rmSync('fuel-core-binaries', { recursive: true, force: true });
execSync(`git clone --branch ${branchName} ${fuelCoreRepoUrl} fuel-core-repo`, { silent: true });
execSync(`cd fuel-core-repo && cargo build`, { silent: true });
mkdirSync('fuel-core-binaries');
cpSync('fuel-core-repo/target/debug/fuel-core', 'fuel-core-binaries/fuel-core');
rmSync('fuel-core-repo', { recursive: true, force: true });
const fuelCoreRepoDir = join(__dirname, '..', 'fuel-core-repo');
const fuelCoreRepoDebugDir = join(fuelCoreRepoDir, 'target', 'debug');
const stdioOpts = { stdio: 'inherit' };

if (existsSync(fuelCoreRepoDir)) {
execSync(`cd ${fuelCoreRepoDir} && git pull && git checkout ${branchName}`, stdioOpts);
execSync(`cd ${fuelCoreRepoDir} && cargo build`, stdioOpts);
} else {
execSync(`git clone --branch ${branchName} ${fuelCoreRepoUrl} ${fuelCoreRepoDir}`, stdioOpts);
execSync(`cd ${fuelCoreRepoDir} && cargo build`, stdioOpts);
}

const [from, to] = [fuelCoreRepoDebugDir, fuelCoreBinDirPath];

rmSync(to, { recursive: true, force: true });
mkdirSync(to, { recursive: true });

mkdirSync(join(from, 'fuel-core'), join(to, 'fuel-core'));
cpSync(join(from, 'fuel-core'), join(to, 'fuel-core'));
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ impl AdvancedLogging for Contract {
ammo: 10,
game_id: 10_11_12u64,
state: GameState::Playing(1),
contract_Id: ContractId::from(
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
),
contract_Id: ContractId::from(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF),
difficulty: Difficulty::Medium(true),
};

Expand Down Expand Up @@ -95,9 +93,7 @@ impl AdvancedLogging for Contract {
ammo: 10,
game_id: 10_11_12u64,
state: GameState::Playing(1),
contract_Id: ContractId::from(
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
),
contract_Id: ContractId::from(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF),
difficulty: Difficulty::Medium(true),
};
require(a == b, game_ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl TestContract for Contract {
value + 1
}
fn call_external_foo(param: u64, contract_id: b256) -> u64 {
let external_contract = abi(TestContract, contract_id().into());
let external_contract = abi(TestContract, contract_id);
let response = external_contract.foo(param);
response + 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ impl ConfigurableContract for Contract {
}

fn echo_configurables() -> (u8, u16, u32, u64, bool, b256, Colors, [[u32; 2]; 2], str[4], (u8, bool, str[2]), Struct1) {
(
U8,
U16, U32, U64, BOOL, B256, ENUM, ARRAY, STR_4, TUPLE,
STRUCT_1,
)
(U8, U16, U32, U64, BOOL, B256, ENUM, ARRAY, STR_4, TUPLE, STRUCT_1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
msg_asset_id,
},
context::msg_amount,
token::{
asset::{
mint_to_address,
transfer_to_address,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ contract;

use std::{
address::Address,
asset::*,
context::balance_of,
context::msg_amount,
contract_id::ContractId,
token::*,
};

use std::constants::ZERO_B256;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ fn main(

result = result && (u32_vec.get(1).unwrap() == 1u32);

result = result && (vec_in_vec
.get(0)
.unwrap()
.get(1)
.unwrap() == 1u32);
result = result && (vec_in_vec.get(0).unwrap().get(1).unwrap() == 1u32);

result = result && (struct_in_vec.get(0).unwrap().a == 0u32);

Expand Down Expand Up @@ -58,14 +54,15 @@ fn main(
let (tuple_a, tuple_b) = vec_in_tuple;
result = result && (tuple_a.get(1).unwrap() == 1u32);

result = result && (vec_in_a_vec_in_a_struct_in_a_vec
.get(1)
.unwrap()
.a
.get(1)
.unwrap()
.get(1)
.unwrap() == 10u32);
result = result
&& (vec_in_a_vec_in_a_struct_in_a_vec
.get(1)
.unwrap()
.a
.get(1)
.unwrap()
.get(1)
.unwrap() == 10u32);

result
}
Loading
Loading