Skip to content

Commit

Permalink
chore: 🎨 Apply linting & formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseTheRobot committed Nov 9, 2023
1 parent 4a356fa commit 4f5653f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
39 changes: 24 additions & 15 deletions packages/umi-uploader-irys/src/createIrysUploader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line import/no-named-default
import type { default as NodeIrys, WebIrys } from '@irys/sdk';
import type { default as NodeIrys, WebIrys } from '@irys/sdk';
import {
Commitment,
Context,
Expand Down Expand Up @@ -138,12 +138,13 @@ export function createIrysUploader(

const promises = files.map(async (file) => {
const buffer = Buffer.from(file.buffer);
const irysTx = irys.createTransaction(buffer, { tags: getGenericFileTagsWithContentType(file)})
await irysTx.sign()
const irysTx = irys.createTransaction(buffer, {
tags: getGenericFileTagsWithContentType(file),
});
await irysTx.sign();

const { status, data } = await irys.uploader.uploadTransaction(irysTx);


if (status >= 300) {
throw new AssetUploadFailedError(status);
}
Expand Down Expand Up @@ -205,10 +206,12 @@ export function createIrysUploader(

const withdraw = async (amount: SolAmount): Promise<void> => {
const irys = await getIrys();
try{
try {
await irys.withdrawBalance(amountToBigNumber(amount));
}catch(e: any){
throw new IrysWithdrawError( (e instanceof Error) ? e.message : e.toString());
} catch (e: any) {
throw new IrysWithdrawError(
e instanceof Error ? e.message : e.toString()
);
}
};

Expand Down Expand Up @@ -271,11 +274,14 @@ export function createIrysUploader(
keypair: Keypair,
options: any
): Promise<NodeIrys> => {
const bPackage = _removeDoubleDefault(
await import('@irys/sdk')
);
const bPackage = _removeDoubleDefault(await import('@irys/sdk'));
// eslint-disable-next-line new-cap
return new bPackage.default({url: address, token: currency, key: keypair.secretKey, config: options});
return new bPackage.default({
url: address,
token: currency,
key: keypair.secretKey,
config: options,
});
};

const initWebIrys = async (
Expand Down Expand Up @@ -329,10 +335,13 @@ export function createIrysUploader(
},
};

const bPackage = _removeDoubleDefault(
await import('@irys/sdk')
);
const irys = new bPackage.WebIrys({url: address, token: currency, wallet: {provider: wallet}, config: options});
const bPackage = _removeDoubleDefault(await import('@irys/sdk'));
const irys = new bPackage.WebIrys({
url: address,
token: currency,
wallet: { provider: wallet },
config: options,
});

try {
// Try to initiate irys.
Expand Down
5 changes: 1 addition & 4 deletions packages/umi-uploader-irys/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type { UmiPlugin } from '@metaplex-foundation/umi';
import {
IrysUploaderOptions,
createIrysUploader,
} from './createIrysUploader';
import { IrysUploaderOptions, createIrysUploader } from './createIrysUploader';

export const irysUploader = (options?: IrysUploaderOptions): UmiPlugin => ({
install(umi) {
Expand Down
6 changes: 2 additions & 4 deletions packages/umi-uploader-irys/test/IrysUploader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ import { web3JsEddsa } from '@metaplex-foundation/umi-eddsa-web3js';
import { fetchHttp } from '@metaplex-foundation/umi-http-fetch';
import { web3JsRpc } from '@metaplex-foundation/umi-rpc-web3js';
import test from 'ava';
import { irysUploader, IrysUploaderOptions } from '../src';
import { irysUploader, IrysUploaderOptions } from '../src';

test('example test', async (t) => {
t.is(typeof irysUploader, 'function');
});

// TODO(loris): Unskip these tests when we can mock the Irys API.

const getContext = async (
options?: IrysUploaderOptions
): Promise<Context> => {
const getContext = async (options?: IrysUploaderOptions): Promise<Context> => {
const context = createUmi().use({
install(umi) {
umi.use(web3JsRpc('https://metaplex.devnet.rpcpool.com/'));
Expand Down

0 comments on commit 4f5653f

Please sign in to comment.