Skip to content

Commit

Permalink
fix: handle encoding and fn_selector resolving of raw untyped ptr (#…
Browse files Browse the repository at this point in the history
…565)

forc changed the internal structure of the Vec type, the SDK needed to adapt accordingly.
  • Loading branch information
segfault-magnet authored Oct 31, 2022
1 parent 0e91213 commit bdfa9d6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
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

1 comment on commit bdfa9d6

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 90.14% 3558/3947
🟡 Branches 72.58% 696/959
🟢 Functions 87.99% 718/816
🟢 Lines 90.16% 3408/3780

Test suite run success

541 tests passing in 49 suites.

Report generated by 🧪jest coverage report action from bdfa9d6

Please sign in to comment.