Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

using deflate and inflate raw method for meta #683

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions scripts/getContractMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from "fs";
import * as path from "path";
import { format } from "prettier";
import { argv } from "process";
import { deflateSync } from "zlib";
import { deflateRawSync } from "zlib";
import ContractMetaSchema from "../schema/meta/v0/contract.meta.schema.json";

const readFile = (_path: string) => {
Expand Down Expand Up @@ -125,7 +125,7 @@ const main = async () => {

let contractMetaHexString = "0x";
const opmetaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(contractMeta, null, 4), { parser: "json" })
)
);
Expand All @@ -136,7 +136,9 @@ const main = async () => {

let schemaHexString = "0x";
const schemaBytes = Uint8Array.from(
deflateSync(format(JSON.stringify(schema, null, 4), { parser: "json" }))
deflateRawSync(
format(JSON.stringify(schema, null, 4), { parser: "json" })
)
);
for (let i = 0; i < schemaBytes.length; i++) {
schemaHexString =
Expand Down
8 changes: 5 additions & 3 deletions scripts/getOpmeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as fs from "fs";
import * as path from "path";
import { format } from "prettier";
import { argv } from "process";
import { deflateSync } from "zlib";
import { deflateRawSync } from "zlib";
import OpmetaSchema from "../schema/meta/v0/op.meta.schema.json";

const readFile = (_path: string) => {
Expand Down Expand Up @@ -126,7 +126,7 @@ const main = async () => {

let opmetaHexString = "0x";
const opmetaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(opmetas, null, 4), { parser: "json" })
)
);
Expand All @@ -137,7 +137,9 @@ const main = async () => {

let schemaHexString = "0x";
const schemaBytes = Uint8Array.from(
deflateSync(format(JSON.stringify(schema, null, 4), { parser: "json" }))
deflateRawSync(
format(JSON.stringify(schema, null, 4), { parser: "json" })
)
);
for (let i = 0; i < schemaBytes.length; i++) {
schemaHexString =
Expand Down
8 changes: 5 additions & 3 deletions scripts/getRainContractMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from "fs";
import * as path from "path";
import { format } from "prettier";
import { argv } from "process";
import { deflateSync } from "zlib";
import { deflateRawSync } from "zlib";
import ContractMetaSchema from "../schema/meta/v0/contract.meta.schema.json";
import FlowERC20 from "../contracts/flow/erc20/FlowERC20.meta.json";
import FlowERC721 from "../contracts/flow/erc721/FlowERC721.meta.json";
Expand Down Expand Up @@ -109,7 +109,7 @@ const main = async () => {

let contractMetaHexString = "0x";
const opmetaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(contractMeta, null, 4), { parser: "json" })
)
);
Expand All @@ -120,7 +120,9 @@ const main = async () => {

let schemaHexString = "0x";
const schemaBytes = Uint8Array.from(
deflateSync(format(JSON.stringify(schema, null, 4), { parser: "json" }))
deflateRawSync(
format(JSON.stringify(schema, null, 4), { parser: "json" })
)
);
for (let i = 0; i < schemaBytes.length; i++) {
schemaHexString =
Expand Down
6 changes: 3 additions & 3 deletions scripts/getRainterpreterOpmeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as fs from "fs";
import * as path from "path";
import { argv } from "process";
import { deflateSync } from "zlib";
import { deflateRawSync } from "zlib";
import { format } from "prettier";
import OpmetaSchema from "../schema/meta/v0/op.meta.schema.json";
import { rainterpreterOpmeta } from "../utils/meta/op/allStandardOpMeta";
Expand Down Expand Up @@ -38,7 +38,7 @@ const main = async () => {
} else {
let opmetaHexString = "0x";
const opmetaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(rainterpreterOpmeta, null, 4), { parser: "json" })
)
);
Expand All @@ -49,7 +49,7 @@ const main = async () => {

let schemaHexString = "0x";
const schemaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(OpmetaSchema, null, 4), { parser: "json" })
)
);
Expand Down
6 changes: 3 additions & 3 deletions utils/meta/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "fs";
import { resolve } from "path";
import { format } from "prettier";
import stringMath from "string-math";
import { deflateSync, inflateSync } from "zlib";
import { deflateRawSync, inflateRawSync } from "zlib";
import { arrayify, BytesLike, isBytesLike } from "ethers/lib/utils";

/**
Expand Down Expand Up @@ -321,7 +321,7 @@ export const metaFromBytes = (
export const deflateJson = (data_: any): string => {
const content = format(JSON.stringify(data_, null, 4), { parser: "json" });

return "0x" + deflateSync(content).toString("hex");
return "0x" + deflateRawSync(content).toString("hex");
};

/**
Expand All @@ -334,5 +334,5 @@ export const deflateJson = (data_: any): string => {
export const inflateJson = (bytes: BytesLike): string => {
if (!isBytesLike(bytes)) throw new Error("invalid bytes");
const _uint8Arr = arrayify(bytes, { allowMissingPrefix: true });
return format(inflateSync(_uint8Arr).toString(), { parser: "json" });
return format(inflateRawSync(_uint8Arr).toString(), { parser: "json" });
};
4 changes: 2 additions & 2 deletions utils/meta/op/allStandardOpMeta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OpMetaSchema from "../../../schema/meta/v0/op.meta.schema.json";
import path from "path";
import { deflateSync } from "zlib";
import { deflateRawSync } from "zlib";
import fs from "fs";
import { resolve } from "path";
import { format } from "prettier";
Expand Down Expand Up @@ -83,7 +83,7 @@ export const getRainterpreterOpMetaBytes = (): string => {
if (!validateMeta(rainterpreterOpmeta, OpMetaSchema))
throw new Error("invalid op meta");
const opmetaBytes = Uint8Array.from(
deflateSync(
deflateRawSync(
format(JSON.stringify(rainterpreterOpmeta, null, 4), { parser: "json" })
)
);
Expand Down
Loading