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

fix: handle encoding and fn_selector resolving of raw untyped ptr #565

Merged
merged 7 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions .changeset/tender-bags-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/abi-coder": patch
"forc-bin": patch
---

Adapted to forc v0.28.0+ with respect to vectors now using an untyped raw ptr instead of a u64 for the vec ptr.
6 changes: 3 additions & 3 deletions packages/abi-coder/src/abi-coder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('AbiCoder', () => {
components: [
{
name: 'ptr',
type: 'u64',
type: 'raw untyped ptr',
isParamType: true,
},
{
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('AbiCoder', () => {
components: [
{
name: 'ptr',
type: 'u64',
type: 'raw untyped ptr',
isParamType: true,
},
{
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('AbiCoder', () => {
components: [
{
name: 'ptr',
type: 'u64',
type: 'raw untyped ptr',
isParamType: true,
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/abi-coder/src/abi-coder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class AbiCoder {
case 'u32':
return new NumberCoder(param.type);
case 'u64':
case 'raw untyped ptr':
return new U64Coder();
case 'bool':
return new BooleanCoder();
Expand Down
4 changes: 4 additions & 0 deletions packages/abi-coder/src/fragments/param-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export class ParamType implements ParamTypeProps {
getSignatureContent(): string {
const type = this.type || '';

if (type === 'raw untyped ptr') {
return 'rawptr';
}

const arrayMatch = arrayRegEx.exec(type)?.groups;
if (arrayMatch) {
return `[${this.components ? this.components[0].getSighash() : arrayMatch.item};${
Expand Down
2 changes: 1 addition & 1 deletion packages/forc-bin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"forc": "./forc.js"
},
"config": {
"forcVersion": "0.26.0"
"forcVersion": "0.28.1"
},
"dependencies": {
"node-fetch": "^2.6.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::vec::Vec;
use std::option::Option;
use std::assert::assert;
use std::logging::log;
use std::mem::addr_of;

pub struct U8Struct {
i: u8,
Expand Down Expand Up @@ -154,7 +153,7 @@ impl CoverageContract for Contract {
log("vector.len");
log(vector.len);
log("addr_of vector");
log(addr_of(vector));
log(__addr_of(vector));
true
},
}
Expand Down