-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.ts
More file actions
46 lines (45 loc) · 1.33 KB
/
index.ts
File metadata and controls
46 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { IStorageProvider, Validator } from "../../index.js";
import { Arweave } from "./Arweave.js";
import { Bundlr } from "./Bundlr.js";
import { Kyve } from "./Kyve.js";
import { Turbo } from "./Turbo.js";
import { Load } from "./Load.js";
import { Shelby } from "./Shelby.js";
import { Walrus } from "./Walrus.js";
import { NoStorageProvider } from "./NoStorageProvider.js";
/**
* storageProviderFactory creates the correct storage provider class
* from the specified id. Current storage providers are:
*
* 0 - NoStorageProvider
* 2 - Bundlr
* 3 - Kyve
* 4 - Turbo
* 5 - Load
* 6 - Walrus
* 7 - Shelby
* x - NoStorageProvider (default)
*
* @method storageProviderFactory
* @return {IStorageProvider}
*/
export function storageProviderFactory(this: Validator): IStorageProvider {
switch (this.pool.data?.current_storage_provider_id ?? 0) {
case 1:
return new Arweave(this.storagePriv);
case 2:
return new Bundlr(this.storagePriv);
case 3:
return new Kyve(this.chainId, this.poolId, this.staker, this.poolAccount);
case 4:
return new Turbo(this.storagePriv || this.poolAccount);
case 5:
return new Load(this.storagePriv);
case 6:
return new Walrus(this.storagePriv);
case 7:
return new Shelby(this.storagePriv);
default:
return new NoStorageProvider();
}
}