Skip to content

Commit

Permalink
Merge branch 'master' into dp/numbers-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbate authored Feb 22, 2024
2 parents 1926798 + bade56c commit 8877468
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 84 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-owls-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/transactions": patch
---

Fixed encoding/decoding of specific parts of a transaction and its inputs
2 changes: 2 additions & 0 deletions .changeset/wet-knives-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
69 changes: 0 additions & 69 deletions .github/workflows/rc-release.yaml

This file was deleted.

14 changes: 7 additions & 7 deletions packages/transactions/src/coders/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ export class InputMessageCoder extends Coder<InputMessage, InputMessage> {
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));
Expand Down Expand Up @@ -318,11 +318,11 @@ export class InputMessageCoder extends Coder<InputMessage, InputMessage> {
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;
Expand Down
12 changes: 6 additions & 6 deletions packages/transactions/src/coders/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export class TransactionScriptCoder extends Coder<TransactionScript, Transaction
const parts: Uint8Array[] = [];

parts.push(new U64Coder().encode(value.scriptGasLimit));
parts.push(new NumberCoder('u16').encode(value.scriptLength));
parts.push(new NumberCoder('u16').encode(value.scriptDataLength));
parts.push(new NumberCoder('u32').encode(value.scriptLength));
parts.push(new NumberCoder('u32').encode(value.scriptDataLength));
parts.push(new NumberCoder('u32').encode(value.policyTypes));
parts.push(new NumberCoder('u8').encode(value.inputsCount));
parts.push(new NumberCoder('u8').encode(value.outputsCount));
Expand All @@ -102,9 +102,9 @@ export class TransactionScriptCoder extends Coder<TransactionScript, Transaction
let o = offset;
[decoded, o] = new U64Coder().decode(data, o);
const scriptGasLimit = decoded;
[decoded, o] = new NumberCoder('u16').decode(data, o);
[decoded, o] = new NumberCoder('u32').decode(data, o);
const scriptLength = decoded;
[decoded, o] = new NumberCoder('u16').decode(data, o);
[decoded, o] = new NumberCoder('u32').decode(data, o);
const scriptDataLength = decoded;
[decoded, o] = new NumberCoder('u32').decode(data, o);
const policyTypes = decoded;
Expand Down Expand Up @@ -203,7 +203,7 @@ export class TransactionCreateCoder extends Coder<TransactionCreate, Transaction
encode(value: TransactionCreate): Uint8Array {
const parts: Uint8Array[] = [];

parts.push(new NumberCoder('u16').encode(value.bytecodeLength));
parts.push(new NumberCoder('u32').encode(value.bytecodeLength));
parts.push(new NumberCoder('u8').encode(value.bytecodeWitnessIndex));
parts.push(new NumberCoder('u32').encode(value.policyTypes));
parts.push(new NumberCoder('u16').encode(value.storageSlotsCount));
Expand All @@ -226,7 +226,7 @@ export class TransactionCreateCoder extends Coder<TransactionCreate, Transaction
let decoded;
let o = offset;

[decoded, o] = new NumberCoder('u16').decode(data, o);
[decoded, o] = new NumberCoder('u32').decode(data, o);
const bytecodeLength = decoded;
[decoded, o] = new NumberCoder('u8').decode(data, o);
const bytecodeWitnessIndex = decoded;
Expand Down
4 changes: 2 additions & 2 deletions packages/transactions/src/coders/witness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class WitnessCoder extends Coder<Witness, Witness> {
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);
Expand All @@ -33,7 +33,7 @@ export class WitnessCoder extends Coder<Witness, Witness> {
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;
Expand Down

0 comments on commit 8877468

Please sign in to comment.