Skip to content

Commit

Permalink
Fixed/removed buffer usage for compression (#93)
Browse files Browse the repository at this point in the history
* Remove usage of Buffer

* Fix for packed_trx

* Use bytes instead of regex match
  • Loading branch information
aaroncox authored Nov 13, 2023
1 parent 2986618 commit 4a453e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/v1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class TrxVariant implements ABISerializableObject {
if (this.extra.packed_trx) {
switch (this.extra.compression) {
case 'zlib': {
const inflated = pako.inflate(Buffer.from(this.extra.packed_trx, 'hex'))
const inflated = pako.inflate(Bytes.from(this.extra.packed_trx, 'hex').array)
return Serializer.decode({data: inflated, type: Transaction})
}
case 'none': {
Expand Down
6 changes: 3 additions & 3 deletions src/chain/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ export class PackedTransaction extends Struct {
switch (compression) {
case CompressionType.zlib: {
// compress data
packed_trx = pako.deflate(Buffer.from(packed_trx.array))
packed_context_free_data = pako.deflate(Buffer.from(packed_context_free_data.array))
packed_trx = pako.deflate(packed_trx.array)
packed_context_free_data = pako.deflate(packed_context_free_data.array)
break
}
case CompressionType.none: {
Expand All @@ -265,7 +265,7 @@ export class PackedTransaction extends Struct {
}
// zlib compressed
case CompressionType.zlib: {
const inflated = pako.inflate(Buffer.from(this.packed_trx.array))
const inflated = pako.inflate(this.packed_trx.array)
return abiDecode({data: inflated, type: Transaction})
}
default: {
Expand Down

0 comments on commit 4a453e7

Please sign in to comment.