Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting #537

Merged
merged 2 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading