diff --git a/packages/umi-uploader-irys/src/createIrysUploader.ts b/packages/umi-uploader-irys/src/createIrysUploader.ts index a3a790f..99d5602 100644 --- a/packages/umi-uploader-irys/src/createIrysUploader.ts +++ b/packages/umi-uploader-irys/src/createIrysUploader.ts @@ -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, @@ -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); } @@ -205,10 +206,12 @@ export function createIrysUploader( const withdraw = async (amount: SolAmount): Promise => { 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() + ); } }; @@ -271,11 +274,14 @@ export function createIrysUploader( keypair: Keypair, options: any ): Promise => { - 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 ( @@ -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. diff --git a/packages/umi-uploader-irys/src/plugin.ts b/packages/umi-uploader-irys/src/plugin.ts index f5f0cbd..c9980d7 100644 --- a/packages/umi-uploader-irys/src/plugin.ts +++ b/packages/umi-uploader-irys/src/plugin.ts @@ -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) { diff --git a/packages/umi-uploader-irys/test/IrysUploader.test.ts b/packages/umi-uploader-irys/test/IrysUploader.test.ts index 7931c57..7dcd016 100644 --- a/packages/umi-uploader-irys/test/IrysUploader.test.ts +++ b/packages/umi-uploader-irys/test/IrysUploader.test.ts @@ -11,7 +11,7 @@ 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'); @@ -19,9 +19,7 @@ test('example test', async (t) => { // TODO(loris): Unskip these tests when we can mock the Irys API. -const getContext = async ( - options?: IrysUploaderOptions -): Promise => { +const getContext = async (options?: IrysUploaderOptions): Promise => { const context = createUmi().use({ install(umi) { umi.use(web3JsRpc('https://metaplex.devnet.rpcpool.com/'));