diff --git a/package.json b/package.json index a33bc66..17d4879 100755 --- a/package.json +++ b/package.json @@ -137,7 +137,7 @@ "@ethersproject/signing-key": "^5.7.0", "@ethersproject/transactions": "^5.7.0", "@ethersproject/wallet": "^5.7.0", - "@irys/arweave": "^0.0.1", + "@irys/arweave": "^0.0.2", "@noble/ed25519": "^1.6.1", "base64url": "^3.0.1", "bs58": "^4.0.1", @@ -151,4 +151,4 @@ "multistream": "^4.1.0", "tmp-promise": "^3.0.2" } -} +} \ No newline at end of file diff --git a/src/__tests__/fileBundle.spec.ts b/src/__tests__/fileBundle.spec.ts index 5649a0f..00a6ac7 100644 --- a/src/__tests__/fileBundle.spec.ts +++ b/src/__tests__/fileBundle.spec.ts @@ -287,7 +287,7 @@ describe.each(testDataVariations)("given we have $description FileDataItems", ({ getTransactionAnchor: jest.fn().mockReturnValue("testAnchor"), getPrice: jest.fn().mockReturnValue(123), } as any as Transactions, - } as any as Arweave; + } as any as typeof Arweave; const jwkInterfaceMock = { k: "k", @@ -297,6 +297,7 @@ describe.each(testDataVariations)("given we have $description FileDataItems", ({ } as any as JWKInterface; beforeEach(async () => { + // @ts-expect-error types tx = await bundle.signAndSubmit(arweaveMock, jwkInterfaceMock, tags); }); it("should return a transaction", () => { @@ -319,9 +320,16 @@ describe.each(testDataVariations)("given we have $description FileDataItems", ({ expect(tx.data_size).toBe((await bundle.getRaw()).length.toString()); }); it("should call the api", () => { + // @ts-expect-error types expect(arweaveMock.api.post).toHaveBeenCalled(); + + // @ts-expect-error types expect(arweaveMock.transactions.sign).toHaveBeenCalled(); + + // @ts-expect-error types expect(arweaveMock.transactions.getTransactionAnchor).toHaveBeenCalled(); + + // @ts-expect-error types expect(arweaveMock.transactions.getPrice).toHaveBeenCalled(); }); it("should set the correct tags", () => { diff --git a/src/file/FileBundle.ts b/src/file/FileBundle.ts index 39fd8d6..6ac1284 100644 --- a/src/file/FileBundle.ts +++ b/src/file/FileBundle.ts @@ -3,7 +3,7 @@ import FileDataItem from "./FileDataItem"; import type { PathLike } from "fs"; import { createReadStream, promises } from "fs"; import { byteArrayToLong } from "../utils"; -import type Arweave from "@irys/arweave"; +import type NodeArweave from "@irys/arweave/node"; import { read as FSRead } from "fs"; import MultiStream from "multistream"; // import { pipeline } from 'stream/promises'; @@ -94,7 +94,7 @@ export class FileBundle implements BundleInterface { return buff; } - async toTransaction(attributes: Partial>, arweave: Arweave, jwk: JWKInterface): Promise { + async toTransaction(attributes: Partial>, arweave: NodeArweave, jwk: JWKInterface): Promise { const streams = [createReadStream(this.headerFile), ...this.txs.map((t) => createReadStream(t))]; const stream = MultiStream.obj(streams); @@ -106,7 +106,7 @@ export class FileBundle implements BundleInterface { return tx; } - async signAndSubmit(arweave: Arweave, jwk: JWKInterface, tags: { name: string; value: string }[] = []): Promise { + async signAndSubmit(arweave: NodeArweave, jwk: JWKInterface, tags: { name: string; value: string }[] = []): Promise { const tx = await this.toTransaction({}, arweave, jwk); // tx.addTag("Bundle-Format", "binary"); // tx.addTag("Bundle-Version", "2.0.0"); diff --git a/yarn.lock b/yarn.lock index 0afb5e4..5fdee8d 100755 --- a/yarn.lock +++ b/yarn.lock @@ -651,10 +651,10 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== -"@irys/arweave@^0.0.1": - version "0.0.1" - resolved "https://registry.yarnpkg.com/@irys/arweave/-/arweave-0.0.1.tgz#3b8ca0dd6eb5ef5edd8abb67dd673f28f3f473f4" - integrity sha512-yzM3g2hEa0f33aRQJZi8OFjSUu80gxj1VGHYDBNCnRTKyBB5YqJG5xBr0sh8Uh5Q6ROJYtlVMBDtrdDn+3sjUQ== +"@irys/arweave@^0.0.2": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@irys/arweave/-/arweave-0.0.2.tgz#c0e73eb8c15e323342d33ea92701d4036fd22ae3" + integrity sha512-ddE5h4qXbl0xfGlxrtBIwzflaxZUDlDs43TuT0u1OMfyobHul4AA1VEX72Rpzw2bOh4vzoytSqA1jCM7x9YtHg== dependencies: asn1.js "^5.4.1" async-retry "^1.3.3"