@metaplex-foundation/umi-uploader-irys 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/errors.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { UmiError } from '@metaplex-foundation/umi';
2
+
3
+ export class IrysError extends UmiError {
4
+ readonly name: string = 'IrysError';
5
+
6
+ constructor(message: string, cause?: Error) {
7
+ super(message, 'plugin', 'Irys', cause);
8
+ }
9
+ }
10
+
11
+ export class FailedToInitializeIrysError extends IrysError {
12
+ readonly name: string = 'FailedToInitializeIrysError';
13
+
14
+ constructor(cause: Error) {
15
+ const message =
16
+ 'Irys could not be initialized. ' +
17
+ 'Please check the underlying error below for more details.';
18
+ super(message, cause);
19
+ }
20
+ }
21
+
22
+ export class FailedToConnectToIrysAddressError extends IrysError {
23
+ readonly name: string = 'FailedToConnectToIrysAddressError';
24
+
25
+ constructor(address: string, cause: Error) {
26
+ const message =
27
+ `Irys could not connect to the provided address [${address}]. ` +
28
+ 'Please ensure the provided address is valid. Some valid addresses include: ' +
29
+ '"https://node1.irys.xyz" for mainnet and "https://devnet.irys.xyz" for devnet';
30
+ super(message, cause);
31
+ }
32
+ }
33
+
34
+ export class AssetUploadFailedError extends IrysError {
35
+ readonly name: string = 'AssetUploadFailedError';
36
+
37
+ constructor(status: number) {
38
+ const message =
39
+ `The asset could not be uploaded to the Irys network and ` +
40
+ `returned the following status code [${status}].`;
41
+ super(message);
42
+ }
43
+ }
44
+
45
+ export class IrysWithdrawError extends IrysError {
46
+ readonly name: string = 'IrysWithdrawError';
47
+
48
+ constructor(error: string) {
49
+ const message =
50
+ `The balance could not be withdrawn from the Irys network and ` +
51
+ `returned the following error: ${error}.`;
52
+ super(message);
53
+ }
54
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './createIrysUploader';
2
+ export * from './errors';
3
+ export * from './plugin';
package/src/plugin.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { UmiPlugin } from '@metaplex-foundation/umi';
2
+ import { IrysUploaderOptions, createIrysUploader } from './createIrysUploader';
3
+
4
+ export const irysUploader = (options?: IrysUploaderOptions): UmiPlugin => ({
5
+ install(umi) {
6
+ umi.uploader = createIrysUploader(umi, options);
7
+ },
8
+ });