Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
feat: ⬆️ Upgrade to @irys/arweave 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTheRobot committed Oct 3, 2023
1 parent 5601d99 commit 2aa97e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -151,4 +151,4 @@
"multistream": "^4.1.0",
"tmp-promise": "^3.0.2"
}
}
}
10 changes: 9 additions & 1 deletion src/__tests__/fileBundle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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", () => {
Expand All @@ -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", () => {
Expand Down
6 changes: 3 additions & 3 deletions src/file/FileBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -94,7 +94,7 @@ export class FileBundle implements BundleInterface {
return buff;
}

async toTransaction(attributes: Partial<Omit<CreateTransactionInterface, "data">>, arweave: Arweave, jwk: JWKInterface): Promise<Transaction> {
async toTransaction(attributes: Partial<Omit<CreateTransactionInterface, "data">>, arweave: NodeArweave, jwk: JWKInterface): Promise<Transaction> {
const streams = [createReadStream(this.headerFile), ...this.txs.map((t) => createReadStream(t))];

const stream = MultiStream.obj(streams);
Expand All @@ -106,7 +106,7 @@ export class FileBundle implements BundleInterface {
return tx;
}

async signAndSubmit(arweave: Arweave, jwk: JWKInterface, tags: { name: string; value: string }[] = []): Promise<Transaction> {
async signAndSubmit(arweave: NodeArweave, jwk: JWKInterface, tags: { name: string; value: string }[] = []): Promise<Transaction> {
const tx = await this.toTransaction({}, arweave, jwk);
// tx.addTag("Bundle-Format", "binary");
// tx.addTag("Bundle-Version", "2.0.0");
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2aa97e2

Please sign in to comment.