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: support [email protected] #2685

Merged
merged 29 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6ce5c61
chore: upgrade forc version
danielbate Jun 20, 2024
d9392a0
feat: enable raw slice in scripts
danielbate Jun 20, 2024
68e64ba
Merge branch 'master' into db/chore/forc-0.61.0
danielbate Jun 20, 2024
f288ff9
docs: remove redundant str slice doc
danielbate Jun 20, 2024
8c03e5e
fix: fixes for str slice typegen
danielbate Jun 20, 2024
9b6cce7
feat: feature test support for str slice
danielbate Jun 20, 2024
7fdfe98
feat: type for str slice
danielbate Jun 20, 2024
0a2127f
Merge branch 'db/chore/forc-0.61.0' of https://github.com/FuelLabs/fu…
danielbate Jun 20, 2024
c24c7d9
chore: add missing test group
danielbate Jun 20, 2024
1c35f82
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 20, 2024
ec1d19b
chore: forc upgrade bytecode changes in tests
danielbate Jun 20, 2024
8fe12bd
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 20, 2024
1f4b07a
chore: forc format
danielbate Jun 20, 2024
9249cbb
Merge branch 'master' into db/chore/forc-0.61.0
danielbate Jun 20, 2024
09cc650
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 21, 2024
2d503a3
Merge branch 'db/chore/forc-0.61.0' of https://github.com/FuelLabs/fu…
danielbate Jun 21, 2024
a47738d
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 24, 2024
9d59e33
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 25, 2024
d3b20e0
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jun 28, 2024
b56cc83
Merge branch 'master' into db/chore/forc-0.61.0
arboleya Jun 29, 2024
fba010e
Merge branch 'master' into db/chore/forc-0.61.0
danielbate Jul 1, 2024
1fccede
Merge branch 'db/chore/forc-0.61.0' of https://github.com/FuelLabs/fu…
danielbate Jul 3, 2024
e7ece89
chore: upgrade [email protected]
danielbate Jul 3, 2024
0a80808
test: fix bytecode and version tests
danielbate Jul 3, 2024
a794f60
Merge branch 'master' of https://github.com/FuelLabs/fuels-ts into db…
danielbate Jul 3, 2024
474954d
chore: lint
danielbate Jul 3, 2024
59a6e15
chore: changeset
danielbate Jul 3, 2024
00ef33d
chore: add typegen test for st
danielbate Jul 3, 2024
6ee4d09
chore: convert str slice test to use test node
danielbate Jul 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('Transaction Request', () => {
// #endregion transaction-request-7

expect(transactionId).toBe(
'0x8c1e78a1c6efc2301eea8a50c653ce1d936144af0948f911eb95e53254ccc721'
'0xdc83dc7d36caaaacd96e4bf4649c3ef5c372a87c3fb49b14d218e3d8a5b8d240'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"type": 0,
"typeArguments": null,
},
"offset": 784,
"offset": 824,
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ impl EchoValues for Contract {
value
}

// Avoid executing this function; it is currently unsupported.
// Refer to: https://github.com/FuelLabs/sway/issues/5110 for more details.
// The function is defined here to include the type 'str' in the ABI,
// ensuring Typegen can accurately interpret it.
// For further information, see: https://github.com/FuelLabs/fuels-ts/issues/1469
fn echo_str(value: str) -> str {
value
}
Expand Down
2 changes: 1 addition & 1 deletion internal/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.60.0
0.61.1
9 changes: 7 additions & 2 deletions packages/abi-typegen/src/abi/types/StrSliceType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ export class StrSliceType extends AType implements IType {
}

public parseComponentsAttributes(_params: { types: IType[] }) {
const capitalizedName = 'StrSlice';

this.attributes = {
inputLabel: 'StrSlice',
outputLabel: 'StrSlice',
inputLabel: capitalizedName,
outputLabel: capitalizedName,
};

this.requiredFuelsMembersImports = [capitalizedName];
nedsalk marked this conversation as resolved.
Show resolved Hide resolved

return this.attributes;
}
}
2 changes: 1 addition & 1 deletion packages/abi-typegen/src/abi/types/StrSlicesType.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ describe('StrSlicesType.ts', () => {

expect(strSlices.attributes.inputLabel).toEqual('StrSlice');
expect(strSlices.attributes.outputLabel).toEqual('StrSlice');
expect(strSlices.requiredFuelsMembersImports).toStrictEqual([]);
expect(strSlices.requiredFuelsMembersImports).toStrictEqual(['StrSlice']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
Fuel-Core version: 33.33.33
*/

export default '0x1af030007400000200000000000005605dffc00110ffff00740000001aec5000910002005d43f009104100c01a4460005d4bf001104514801ae9100020f8330058fbe00250fbe004740000c61a47d0005fed10355fec00365053b1a85d47b0355d4bb0361b481480104514805d4bb0365d4ff002104924c05d4510005fed2036504bb0f81ae940001ae510001ae1200020f8330058fbe00250fbe004740000bc1a4bd000504fb1e072500010284d2500504bb1e0504fb17872500010284d25001ae9300020f8330058fbe00250fbe004740001121a4bd000504fb0105fed20025fed10035047b19872480010284534805047b1985fed00005d43f0035fed00015043b068724800102843b480504bb128724c0010284914c01ae9200020f8330058fbe00250fbe004740000b71a4bd000504fb13872500010284d05001ae9300020f8330058fbe00250fbe004740000ae1a4fd000134924c0134920001a4c00007648001c504bb158724c0010284914c01ae9200020f8330058fbe00250fbe004740000b11a4bd000504fb16872500010284d05001ae9300020f8330058fbe00250fbe004740000a81a43d000504fb14872500010284d15001ae9300020f8330058fbe00250fbe0047400008f1a47d000294d2411764c0001740000601a4060005d47f004104104401ae9000020f8330058fbe00250fbe0047400005a1a43d0005fed00375fec00385043b1b85047b1081ae900001ae5100020f8330058fbe00250fbe004740000985047b1181ae900001ae5100020f8330058fbe00250fbe004740000915d43f005264000001a4070005047b0505fed000a5d43f0055fed000b5fec000c5043b07872480018284114805047b0b872480018284504805043b02072480018284114805d47b004504100085d4bb006104d14805c53f0305e4d400010492040504fb0905fed10125045300872500008284505005fed20145d4130005d4530015d4930025fed00395fed103a5fed203b5043b1c85047b0d072480018284504805043b03872480018284114805d47b00750410010504bb0a85fed101550452008724c0008284504c05043b1f072440010284124405043b1f05047b18872480010284504801ae9100020f8330058fbe00250fbe004740000781a43d0005047b1f0504bb0e8724c0010284914c05d45200112451040254110005d43f0073640000095000003960800001aec50001a43a0001a47e0005d4100001af500001af9100098080000970000034af800009500007f960800001aec5000910000201a43a0001a4790001a4b80001a4fe0005d510001105144405d5500005d5900011b581580105555805fed50005fed10011a47b0005057b01072580010285515805f4140015043b01072440010284904401af52000920000201af93000980800009700007f4af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100011af50000920000101af9100098080000970000074af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af800009500001f960800001aec5000910000301a43a0001a4790001a4be0001ae900005d43f0081ae500001ae3b00020f8330058fbe00250fbe0047500004b1a43d000504fb02072500010284d05005043b020504fb01072500010284d05001ae9300020f8330058fbe00250fbe004740000091a43d000724c0010284504c01af51000920000301af92000980800009700001f4af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af80000470000006d61696e00000000000000000000024800000000000000080000000000000004000000000000025000000000000004000100000000000000000000000000007b000000000000000a0000000000000538'
export default '0x1af030007400000200000000000005f05dffc00110ffff00740000001aec5000910002885d43f001104100c01a44600072480250104514801ae9100020f8330058fbe00250fbe004740000e51a47d000504bb0105fed10025047b210724c0008284524c01a44600072480248104514801ae9100020f8330058fbe00250fbe004740000d71a47d000504bb0405fed10085047b258724c0008284524c05047b2585d4bb04b5d4920005d4fb04b72500008104d35005fed304b504fb1501ae910001ae520001ae1300020f8330058fbe00250fbe004740000cd1a47d000504fb27872500010284d15005047b278504fb18072500010284d15001ae9300020f8330058fbe00250fbe004740000db1a47d000504fb0185fed10035fed20045047b21872480010284534805047b2185fed0000724000045fed00015043b0a8724800102843b480504bb1a0724c0010284914c01ae9200020f8330058fbe00250fbe004740000d51a4bd000504fb1b072500010284d05001ae9300020f8330058fbe00250fbe004740000cc1a4fd000134924c0134920001a4c00007648001c504bb1d0724c0010284914c01ae9200020f8330058fbe00250fbe004740000cf1a4bd000504fb1e072500010284d05001ae9300020f8330058fbe00250fbe004740000c61a43d000504fb1c072500010284d15001ae9300020f8330058fbe00250fbe004740000ad1a47d000294d2411764c0001740000715043b2105047b1601ae900001ae5100020f8330058fbe00250fbe004740000c11a47d000504bb1701ae900001ae5200020f8330058fbe00250fbe004740000b91a43d000504bb060724c0010284914c050452010724c0010284504c05043b23872440020284124405043b2385047b23850451010504bb1f0724c0010284904c05043b200724c0010284114c01ae920001ae5000020f8330058fbe00250fbe004740000c51a53d00072400400264000001a4070005047b0805fed0010724004005fed00115fec00125043b0b872480018284114805047b1107248001828450480504bb02872400018284914005d43b005504520085d4bb007104d04805e4d400010492040504fb0d05fed001a5041300872500008284115005fed201c5043b0f872440018284134405047b26072480018284504805043b2605047b12872480018284504805043b04872480018284114805d47b00950410010504bb0e85fed101d50452008724c0008284504c05043b22872440010284124405043b2285047b19072480010284504801ae9100020f8330058fbe00250fbe004740000321a43d0005047b228504bb140724c0010284914c05047b098724c0010284524c05d47b014254110007240007b3640000095000003960800001aec50001a43a0001a47e0005d4100001af500001af9100098080000970000034af800009500007f960800001aec5000910000201a43a0001a4790001a4b80001a4fe0007250000828ed05005fed10011a53b0005057b01072580010285545805d510000104544405f4110005043b01072440010284904401af52000920000201af93000980800009700007f4af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100011af50000920000101af9100098080000970000074af8000095000007960800001aec5000910000101a43a0001a47e0007248001028ed04801a43b0005d4100001af50000920000101af9100098080000970000074af800009500001f960800001aec5000910000301a43a0001a4790001a4be0001ae900007240000a1ae500001ae3b00020f8330058fbe00250fbe004750000581a43d000504fb02072500010284d05005043b020504fb01072500010284d05001ae9300020f8330058fbe00250fbe0047500004a1a43d000724c0010284504c01af51000920000301af92000980800009700001f4af8000095000001960800001aec50001a43e0001af410001af9000098080000970000014af800006d61696e0000000000000000000005c8'
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const _abi = {
"type": 2,
"typeArguments": null
},
"offset": 1152
"offset": 904
},
{
"name": "ADDRESS",
Expand All @@ -87,7 +87,7 @@ const _abi = {
"type": 0,
"typeArguments": null
},
"offset": 1168
"offset": 872
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const _abi = {
"type": 0,
"typeArguments": null
},
"offset": 536
"offset": 616
}
]
}
Expand Down
7 changes: 3 additions & 4 deletions packages/fuel-gauge/src/raw-slice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ describe('Raw Slice Tests', () => {
expect(isStatusSuccess);
});

// see https://github.com/FuelLabs/fuels-ts/issues/1344
it.skip('should test raw slice input [script-raw-slice]', async () => {
it('should test raw slice input [script-raw-slice]', async () => {
const wallet = await setup();
type MainArgs = [number, Wrapper];
const scriptInstance = getScript<MainArgs, void>('script-raw-slice', wallet);
Expand All @@ -124,7 +123,7 @@ describe('Raw Slice Tests', () => {
inner_enum: { Second: bytes },
};

const { value } = await scriptInstance.functions.main(1, INPUT).call<BN[]>();
expect(value).toStrictEqual([1, 2, 3]);
const { value } = await scriptInstance.functions.main(3, INPUT).call<BN[]>();
expect(value).toStrictEqual([0, 1, 2]);
});
});
64 changes: 64 additions & 0 deletions packages/fuel-gauge/src/str-slice.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { generateTestWallet } from '@fuel-ts/account/test-utils';
import type { WalletUnlocked } from 'fuels';
import { Wallet, bn, Provider, FUEL_NETWORK_URL } from 'fuels';

import type { PredicateStrSliceAbiInputs } from '../test/typegen';
import {
PredicateStrSliceAbi__factory,
ScriptStrSliceAbi__factory,
StrSliceAbi__factory,
} from '../test/typegen';
import contractBytes from '../test/typegen/contracts/StrSliceAbi.hex';

/**
* @group node
*/
describe('str slice', () => {
let provider: Provider;
let baseAssetId: string;
let sender: WalletUnlocked;

beforeAll(async () => {
provider = await Provider.create(FUEL_NETWORK_URL);
baseAssetId = provider.getBaseAssetId();
sender = await generateTestWallet(provider, [[500_000, baseAssetId]]);
});

it('echoes a str slice [CONTRACT]', async () => {
const contract = await StrSliceAbi__factory.deployContract(contractBytes, sender);
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
const input = 'contract-input';
const output = 'contract-return';
const { value } = await contract.functions.echoes_str_slice(input).call();
expect(value).toEqual(output);
});

it('validates a str slice [PREDICATE]', async () => {
const receiver = Wallet.generate({ provider });
const input: PredicateStrSliceAbiInputs = ['predicate-input'];
const predicate = PredicateStrSliceAbi__factory.createInstance(provider, input);

const amountToPredicate = 250_000;
const amountToReceiver = 50_000;

const setupTx = await sender.transfer(predicate.address, amountToPredicate, baseAssetId);
await setupTx.waitForResult();

const initialReceiverBalance = await receiver.getBalance();

const tx = await predicate.transfer(receiver.address, amountToReceiver, baseAssetId);
const { isStatusSuccess } = await tx.waitForResult();
const finalReceiverBalance = await receiver.getBalance();
expect(bn(initialReceiverBalance).add(amountToReceiver).toHex()).toEqual(
finalReceiverBalance.toHex()
);
expect(isStatusSuccess).toBe(true);
});

it('echoes a str slice [SCRIPT]', async () => {
const script = await ScriptStrSliceAbi__factory.createInstance(sender);
const input = 'script-input';
const output = 'script-return';
const { value } = await script.functions.main(input).call();
expect(value).toEqual(output);
});
});
5 changes: 4 additions & 1 deletion packages/fuel-gauge/test/fixtures/forc-projects/Forc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"predicate-main-args-vector",
"predicate-multi-args",
"predicate-raw-slice",
"predicate-str-slice",
"predicate-std-lib-string",
"predicate-input-data",
"predicate-triple-sig",
Expand All @@ -37,6 +38,7 @@ members = [
"complex-predicate",
"complex-script",
"raw-slice",
"str-slice",
"reentrant-bar",
"reentrant-foo",
"reentrant-foobar-abi",
Expand All @@ -47,7 +49,8 @@ members = [
"script-main-args",
"script-main-return-struct",
"script-main-two-args",
# "script-raw-slice", see https://github.com/FuelLabs/fuels-ts/issues/1344
"script-raw-slice",
"script-str-slice",
"script-std-lib-string",
"script-with-array",
"script-with-configurable",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "predicate-str-slice"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
predicate;

fn main(input: str) -> bool {
input == "predicate-input"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Wrapper<T> {
}

fn validate_raw_slice(input: raw_slice) {
let vec: Vec<u64> = Vec::from(input);
let vec: Vec<u8> = Vec::from(input);
require(vec.len() == 3, "raw slice len is not 3");
require(
vec
Expand Down Expand Up @@ -40,7 +40,7 @@ fn validate_vec(vec: Vec<raw_slice>) {
validate_raw_slice(vec.get(1).unwrap());
}

fn main(_arg: u64, wrapper: Wrapper<Vec<raw_slice>>) -> raw_slice {
fn main(length: u8, wrapper: Wrapper<Vec<raw_slice>>) -> raw_slice {
if let SomeEnum::Second(enum_raw_slice) = wrapper.inner_enum
{
validate_raw_slice(enum_raw_slice);
Expand All @@ -50,10 +50,11 @@ fn main(_arg: u64, wrapper: Wrapper<Vec<raw_slice>>) -> raw_slice {

validate_vec(wrapper.inner);

let mut rtn: Vec<u64> = Vec::new();
rtn.push(1);
rtn.push(2);
rtn.push(3);

rtn.as_raw_slice()
let mut vec = Vec::new();
let mut counter = 0u8;
while counter < length {
vec.push(counter);
counter = counter + 1;
}
vec.as_raw_slice()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "script-str-slice"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
script;

fn main(input: str) -> str {
assert_eq(input, "script-input");

"script-return"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[project]
authors = ["Fuel Labs <[email protected]>"]
entry = "main.sw"
license = "Apache-2.0"
name = "str-slice"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
contract;

abi MyContract {
fn echoes_str_slice(arg: str) -> str;
}

impl MyContract for Contract {
fn echoes_str_slice(arg: str) -> str {
assert_eq(arg, "contract-input");

"contract-return"
}
}
1 change: 1 addition & 0 deletions packages/interfaces/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type AssetId = {
};

export type StdString = string;
export type StrSlice = string;

/**
* @hidden
Expand Down
2 changes: 1 addition & 1 deletion packages/versions/src/lib/getBuiltinVersions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function getBuiltinVersions() {
return {
FORC: '0.60.0',
FORC: '0.61.1',
FUEL_CORE: '0.30.0',
FUELS: '0.90.0',
};
Expand Down
2 changes: 1 addition & 1 deletion templates/nextjs/sway-programs/fuel-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
channel = "testnet"

[components]
forc = "0.60.0"
forc = "0.61.1"
fuel-core = "0.30.0"
Loading