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

Commit

Permalink
Merge pull request #537 from metaplex-foundation/febo/fix-formatting
Browse files Browse the repository at this point in the history
Fix formatting
  • Loading branch information
febo committed Nov 9, 2023
2 parents e484b77 + 1067c0b commit 46aa86a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-paws-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@metaplex-foundation/js': patch
---

Fix formatting
49 changes: 28 additions & 21 deletions packages/js/src/plugins/irysStorage/IrysStorageDriver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { default as NodeIrys, WebIrys } from '@irys/sdk';


import BigNumber from 'bignumber.js';
import {
Connection,
Expand Down Expand Up @@ -30,7 +29,10 @@ import {
toBigNumber,
} from '@/types';
import {
AssetUploadFailedError, FailedToConnectToIrysAddressError, FailedToInitializeIrysError, IrysWithdrawError,
AssetUploadFailedError,
FailedToConnectToIrysAddressError,
FailedToInitializeIrysError,
IrysWithdrawError,
} from '@/errors';
import { _removeDoubleDefault } from '@/utils';

Expand Down Expand Up @@ -104,8 +106,10 @@ export class IrysStorageDriver implements StorageDriver {
await this.fund(amount);

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

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

Expand Down Expand Up @@ -162,10 +166,12 @@ export class IrysStorageDriver implements StorageDriver {

async withdraw(amount: Amount): Promise<void> {
const irys = await this.irys();
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 @@ -203,12 +209,7 @@ export class IrysStorageDriver implements StorageDriver {
Keypair.fromSecretKey((identity as KeypairSigner).secretKey)
);

irys = await this.initWebirys(
address,
currency,
identitySigner,
options
);
irys = await this.initWebirys(address, currency, identitySigner, options);
}

try {
Expand All @@ -227,10 +228,13 @@ export class IrysStorageDriver implements StorageDriver {
keypair: KeypairSigner,
options: any
): Promise<NodeIrys> {
const bPackage = _removeDoubleDefault(
await import('@irys/sdk')
);
return new bPackage.default({url: address, token: currency, key: keypair.secretKey, config: options});
const bPackage = _removeDoubleDefault(await import('@irys/sdk'));
return new bPackage.default({
url: address,
token: currency,
key: keypair.secretKey,
config: options,
});
}

async initWebirys(
Expand Down Expand Up @@ -259,10 +263,13 @@ export class IrysStorageDriver implements StorageDriver {
},
};

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

0 comments on commit 46aa86a

Please sign in to comment.