From de22b73d4971d4ff3af624a40c0844f2fbb2ff03 Mon Sep 17 00:00:00 2001 From: Jason <61184127+jasmcaus@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:08:02 +0530 Subject: [PATCH 1/2] fix: Update encoding/decoding according to new specs (#1783) --- .changeset/curvy-owls-think.md | 5 +++++ packages/transactions/src/coders/input.ts | 14 +++++++------- packages/transactions/src/coders/transaction.ts | 12 ++++++------ packages/transactions/src/coders/witness.ts | 4 ++-- 4 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 .changeset/curvy-owls-think.md diff --git a/.changeset/curvy-owls-think.md b/.changeset/curvy-owls-think.md new file mode 100644 index 00000000000..46339800896 --- /dev/null +++ b/.changeset/curvy-owls-think.md @@ -0,0 +1,5 @@ +--- +"@fuel-ts/transactions": patch +--- + +Fixed encoding/decoding of specific parts of a transaction and its inputs diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index 2ee9d694725..beb37a857b3 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -284,9 +284,9 @@ export class InputMessageCoder extends Coder { parts.push(new ByteArrayCoder(32).encode(value.nonce)); parts.push(new NumberCoder('u8').encode(value.witnessIndex)); parts.push(new U64Coder().encode(value.predicateGasUsed)); - parts.push(new NumberCoder('u16').encode(data.length)); - parts.push(new NumberCoder('u16').encode(value.predicateLength)); - parts.push(new NumberCoder('u16').encode(value.predicateDataLength)); + parts.push(new NumberCoder('u32').encode(data.length)); + parts.push(new NumberCoder('u32').encode(value.predicateLength)); + parts.push(new NumberCoder('u32').encode(value.predicateDataLength)); parts.push(new ByteArrayCoder(data.length).encode(data)); parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate)); parts.push(new ByteArrayCoder(value.predicateDataLength).encode(value.predicateData)); @@ -318,11 +318,11 @@ export class InputMessageCoder extends Coder { const witnessIndex = Number(decoded); [decoded, o] = new U64Coder().decode(data, o); const predicateGasUsed = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); - const predicateLength = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u32').decode(data, o); const dataLength = decoded; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u32').decode(data, o); + const predicateLength = decoded; + [decoded, o] = new NumberCoder('u32').decode(data, o); const predicateDataLength = decoded; [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o); const messageData = decoded; diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 37ec4b3598d..6f18b37956b 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -80,8 +80,8 @@ export class TransactionScriptCoder extends Coder { encode(value: Witness): Uint8Array { const parts: Uint8Array[] = []; - parts.push(new NumberCoder('u16').encode(value.dataLength)); + parts.push(new NumberCoder('u32').encode(value.dataLength)); parts.push(new ByteArrayCoder(value.dataLength).encode(value.data)); return concat(parts); @@ -33,7 +33,7 @@ export class WitnessCoder extends Coder { let decoded; let o = offset; - [decoded, o] = new NumberCoder('u16').decode(data, o); + [decoded, o] = new NumberCoder('u32').decode(data, o); const dataLength = decoded; [decoded, o] = new ByteArrayCoder(dataLength).decode(data, o); const witnessData = decoded; From bade56c4785bece58bddef8e36546988ce29faf4 Mon Sep 17 00:00:00 2001 From: Anderson Arboleya Date: Thu, 22 Feb 2024 08:23:17 -0300 Subject: [PATCH 2/2] chore: deleting obsolete workflow (#1789) --- .changeset/wet-knives-reflect.md | 2 + .github/workflows/rc-release.yaml | 69 ------------------------------- 2 files changed, 2 insertions(+), 69 deletions(-) create mode 100644 .changeset/wet-knives-reflect.md delete mode 100644 .github/workflows/rc-release.yaml diff --git a/.changeset/wet-knives-reflect.md b/.changeset/wet-knives-reflect.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/wet-knives-reflect.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/workflows/rc-release.yaml b/.github/workflows/rc-release.yaml deleted file mode 100644 index e50d9082af2..00000000000 --- a/.github/workflows/rc-release.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: Release to @rc- tag on npm - -on: - pull_request: - branches: - - "master" - -jobs: - release-pr: - # Switch to `true` for release candidates - if: ${{ true && startsWith(github.head_ref, 'rc/') }} - name: "Release RC to npm" - runs-on: ubuntu-latest - permissions: write-all - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - - - name: CI Setup - uses: ./.github/actions/ci-setup - - - name: Ensure NPM access - run: npm whoami - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Build - run: pnpm build - - - name: Get RC name - uses: frabert/replace-string-action@v2 - id: rc_name - with: - string: ${{ github.head_ref }} - pattern: "rc/" - replace-with: "rc-" - - - name: Release to @${{ steps.rc_name.outputs.replaced }} tag on npm - id: release - run: | - echo "${{ steps.rc_name.outputs.replaced }}" - pnpm changeset:next - git add .changeset/fuel-labs-ci.md - pnpm changeset version --snapshot ${{ steps.rc_name.outputs.replaced }} - changetsets=$(pnpm changeset publish --tag ${{ steps.rc_name.outputs.replaced }}) - published_version=$(echo "$changetsets" | grep -oP '@\K([0-9]+\.){2}[0-9]+-${{ steps.rc_name.outputs.replaced }}-\d+' | head -1) - echo "published_version=$published_version" >> $GITHUB_OUTPUT - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Add PR comment - uses: mshick/add-pr-comment@v2 - with: - message: | - RC published under the `${{ steps.rc_name.outputs.replaced }}` tag. - - Install it: - ```bash - pnpm add fuels@${{ steps.rc_name.outputs.replaced }} - pnpm add fuels@${{ steps.release.outputs.published_version }} - ``` - Check it out: - - https://www.npmjs.com/package/fuels/v/${{ steps.rc_name.outputs.replaced }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}