@notifi-network/fusion-sdk 0.0.1-canary10 → 0.0.2
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/dist/fusion_wrappers/blockchain_proxies.d.ts +72 -8
- package/dist/fusion_wrappers/blockchain_proxies.js +85 -19
- package/dist/fusion_wrappers/fetch_proxy.d.ts +17 -0
- package/dist/fusion_wrappers/fetch_proxy.js +18 -1
- package/dist/fusion_wrappers/storage.d.ts +93 -0
- package/dist/fusion_wrappers/storage.js +233 -0
- package/dist/fusion_wrappers/subscriptions.d.ts +22 -0
- package/dist/fusion_wrappers/subscriptions.js +39 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
|
@@ -1,24 +1,88 @@
|
|
|
1
1
|
import { EthCallRequest, EthCallResponse, GetAccountBalanceRequest, GetAccountBalanceResponse, BcmGetSuiAccountBalanceRequest, BcmGetSuiAccountBalanceResponse, BcmRunSuiTransactionCallRequest, BcmRunSuiTransactionCallResponse, BcmGetSuiObjectRequest, BcmGetSuiObjectResponse, BcmGetSolanaBalanceRequest, BcmGetSolanaBalanceResponse, BcmGetSolanaAccountInfoRequest, BcmGetSolanaAccountInfoResponse, BcmGetSolanaSlotRequest, BcmGetSolanaSlotResponse } from "../protos_gen/services/blockchain_manager/v1/blockchain_manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* Class for interacting with the Fusion EVM RPC service.
|
|
4
|
+
* Provides methods to perform Ethereum-specific blockchain operations.
|
|
5
|
+
*/
|
|
2
6
|
export declare class FusionEvmRpcWrapper {
|
|
3
7
|
private client;
|
|
4
8
|
private contextId;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of FusionEvmRpc.
|
|
11
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
12
|
+
*/
|
|
5
13
|
constructor(contextId: string);
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Executes an Ethereum call operation.
|
|
16
|
+
* @param request - The request object containing Ethereum call details.
|
|
17
|
+
* @returns A promise that resolves to the Ethereum call response.
|
|
18
|
+
*/
|
|
19
|
+
runEthCall(request: Omit<EthCallRequest, 'contextId'>): Promise<EthCallResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the account balance for an Ethereum address.
|
|
22
|
+
* @param request - The request object containing the Ethereum address.
|
|
23
|
+
* @returns A promise that resolves to the account balance response.
|
|
24
|
+
*/
|
|
25
|
+
getAccountBalance(request: Omit<GetAccountBalanceRequest, 'contextId'>): Promise<GetAccountBalanceResponse>;
|
|
8
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Wrapper class for interacting with the Fusion Sui RPC service.
|
|
29
|
+
* Provides methods to perform Sui-specific blockchain operations.
|
|
30
|
+
*/
|
|
9
31
|
export declare class FusionSuiRpcWrapper {
|
|
10
32
|
private client;
|
|
11
33
|
private contextId;
|
|
34
|
+
/**
|
|
35
|
+
* Creates an instance of FusionSuiRpc.
|
|
36
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
37
|
+
*/
|
|
12
38
|
constructor(contextId: string);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the account balance for a Sui address.
|
|
41
|
+
* @param request - The request object containing the Sui address.
|
|
42
|
+
* @returns A promise that resolves to the account balance response.
|
|
43
|
+
*/
|
|
44
|
+
getSuiAccountBalance(request: Omit<BcmGetSuiAccountBalanceRequest, 'contextId'>): Promise<BcmGetSuiAccountBalanceResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Executes a Sui transaction.
|
|
47
|
+
* @param request - The request object containing Sui transaction details.
|
|
48
|
+
* @returns A promise that resolves to the transaction response.
|
|
49
|
+
*/
|
|
50
|
+
runSuiTransaction(request: Omit<BcmRunSuiTransactionCallRequest, 'contextId'>): Promise<BcmRunSuiTransactionCallResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a Sui object.
|
|
53
|
+
* @param request - The request object containing Sui object details.
|
|
54
|
+
* @returns A promise that resolves to the Sui object response.
|
|
55
|
+
*/
|
|
56
|
+
getSuiObject(request: Omit<BcmGetSuiObjectRequest, 'contextId'>): Promise<BcmGetSuiObjectResponse>;
|
|
16
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Wrapper class for interacting with the Fusion Solana RPC service.
|
|
60
|
+
* Provides methods to perform Solana-specific blockchain operations.
|
|
61
|
+
*/
|
|
17
62
|
export declare class FusionSolanaRpcWrapper {
|
|
18
63
|
private client;
|
|
19
64
|
private contextId;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an instance of FusionSolanaRpc.
|
|
67
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
68
|
+
*/
|
|
20
69
|
constructor(contextId: string);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the balance for a Solana address.
|
|
72
|
+
* @param request - The request object containing the Solana address.
|
|
73
|
+
* @returns A promise that resolves to the balance response.
|
|
74
|
+
*/
|
|
75
|
+
getSolanaBalance(request: Omit<BcmGetSolanaBalanceRequest, 'contextId'>): Promise<BcmGetSolanaBalanceResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves account information for a Solana address.
|
|
78
|
+
* @param request - The request object containing the Solana address.
|
|
79
|
+
* @returns A promise that resolves to the account information response.
|
|
80
|
+
*/
|
|
81
|
+
getSolanaAccountInfo(request: Omit<BcmGetSolanaAccountInfoRequest, 'contextId'>): Promise<BcmGetSolanaAccountInfoResponse>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves the current Solana slot.
|
|
84
|
+
* @param request - The request object containing slot query details.
|
|
85
|
+
* @returns A promise that resolves to the slot response.
|
|
86
|
+
*/
|
|
87
|
+
getSolanaSlot(request: Omit<BcmGetSolanaSlotRequest, 'contextId'>): Promise<BcmGetSolanaSlotResponse>;
|
|
24
88
|
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { FusionEvmRpcClient, FusionSuiRpcClient, FusionSolanaRpcClient } from "../protos_gen/services/blockchain_manager/v1/blockchain_manager.js";
|
|
2
2
|
import { Metadata, credentials } from "@grpc/grpc-js";
|
|
3
3
|
const DEFAULT_ADDRESS = process.env.BLOCKCHAIN_MANAGER_ADDRESS || "localhost:50051";
|
|
4
|
+
/**
|
|
5
|
+
* Class for interacting with the Fusion EVM RPC service.
|
|
6
|
+
* Provides methods to perform Ethereum-specific blockchain operations.
|
|
7
|
+
*/
|
|
4
8
|
export class FusionEvmRpcWrapper {
|
|
5
9
|
client;
|
|
6
10
|
contextId;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of FusionEvmRpc.
|
|
13
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
14
|
+
*/
|
|
7
15
|
constructor(contextId) {
|
|
8
16
|
this.contextId = contextId;
|
|
9
|
-
|
|
17
|
+
// Only use insecure connection for local development
|
|
18
|
+
// Check DEFAULT_ADDRESS if it contains "localhost", and if so, use insecure connection
|
|
19
|
+
this.client = new FusionEvmRpcClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
10
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Executes an Ethereum call operation.
|
|
23
|
+
* @param request - The request object containing Ethereum call details.
|
|
24
|
+
* @returns A promise that resolves to the Ethereum call response.
|
|
25
|
+
*/
|
|
11
26
|
async runEthCall(request) {
|
|
12
|
-
request
|
|
27
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
13
28
|
return new Promise((resolve, reject) => {
|
|
14
|
-
this.client.runEthCall(
|
|
29
|
+
this.client.runEthCall(modifiedRequest, new Metadata(), (error, response) => {
|
|
15
30
|
if (error) {
|
|
16
31
|
reject(error);
|
|
17
32
|
}
|
|
@@ -21,10 +36,15 @@ export class FusionEvmRpcWrapper {
|
|
|
21
36
|
});
|
|
22
37
|
});
|
|
23
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the account balance for an Ethereum address.
|
|
41
|
+
* @param request - The request object containing the Ethereum address.
|
|
42
|
+
* @returns A promise that resolves to the account balance response.
|
|
43
|
+
*/
|
|
24
44
|
async getAccountBalance(request) {
|
|
25
|
-
request
|
|
45
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
26
46
|
return new Promise((resolve, reject) => {
|
|
27
|
-
this.client.getAccountBalance(
|
|
47
|
+
this.client.getAccountBalance(modifiedRequest, new Metadata(), (error, response) => {
|
|
28
48
|
if (error) {
|
|
29
49
|
reject(error);
|
|
30
50
|
}
|
|
@@ -35,17 +55,30 @@ export class FusionEvmRpcWrapper {
|
|
|
35
55
|
});
|
|
36
56
|
}
|
|
37
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Wrapper class for interacting with the Fusion Sui RPC service.
|
|
60
|
+
* Provides methods to perform Sui-specific blockchain operations.
|
|
61
|
+
*/
|
|
38
62
|
export class FusionSuiRpcWrapper {
|
|
39
63
|
client;
|
|
40
64
|
contextId;
|
|
65
|
+
/**
|
|
66
|
+
* Creates an instance of FusionSuiRpc.
|
|
67
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
68
|
+
*/
|
|
41
69
|
constructor(contextId) {
|
|
42
70
|
this.contextId = contextId;
|
|
43
|
-
this.client = new FusionSuiRpcClient(DEFAULT_ADDRESS, credentials.createInsecure());
|
|
71
|
+
this.client = new FusionSuiRpcClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
44
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves the account balance for a Sui address.
|
|
75
|
+
* @param request - The request object containing the Sui address.
|
|
76
|
+
* @returns A promise that resolves to the account balance response.
|
|
77
|
+
*/
|
|
45
78
|
async getSuiAccountBalance(request) {
|
|
46
|
-
request
|
|
79
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
47
80
|
return new Promise((resolve, reject) => {
|
|
48
|
-
this.client.getSuiAccountBalance(
|
|
81
|
+
this.client.getSuiAccountBalance(modifiedRequest, new Metadata(), (error, response) => {
|
|
49
82
|
if (error) {
|
|
50
83
|
reject(error);
|
|
51
84
|
}
|
|
@@ -55,10 +88,15 @@ export class FusionSuiRpcWrapper {
|
|
|
55
88
|
});
|
|
56
89
|
});
|
|
57
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Executes a Sui transaction.
|
|
93
|
+
* @param request - The request object containing Sui transaction details.
|
|
94
|
+
* @returns A promise that resolves to the transaction response.
|
|
95
|
+
*/
|
|
58
96
|
async runSuiTransaction(request) {
|
|
59
|
-
request
|
|
97
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
60
98
|
return new Promise((resolve, reject) => {
|
|
61
|
-
this.client.runSuiTransaction(
|
|
99
|
+
this.client.runSuiTransaction(modifiedRequest, new Metadata(), (error, response) => {
|
|
62
100
|
if (error) {
|
|
63
101
|
reject(error);
|
|
64
102
|
}
|
|
@@ -68,10 +106,15 @@ export class FusionSuiRpcWrapper {
|
|
|
68
106
|
});
|
|
69
107
|
});
|
|
70
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a Sui object.
|
|
111
|
+
* @param request - The request object containing Sui object details.
|
|
112
|
+
* @returns A promise that resolves to the Sui object response.
|
|
113
|
+
*/
|
|
71
114
|
async getSuiObject(request) {
|
|
72
|
-
request
|
|
115
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
73
116
|
return new Promise((resolve, reject) => {
|
|
74
|
-
this.client.getSuiObject(
|
|
117
|
+
this.client.getSuiObject(modifiedRequest, new Metadata(), (error, response) => {
|
|
75
118
|
if (error) {
|
|
76
119
|
reject(error);
|
|
77
120
|
}
|
|
@@ -82,17 +125,30 @@ export class FusionSuiRpcWrapper {
|
|
|
82
125
|
});
|
|
83
126
|
}
|
|
84
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Wrapper class for interacting with the Fusion Solana RPC service.
|
|
130
|
+
* Provides methods to perform Solana-specific blockchain operations.
|
|
131
|
+
*/
|
|
85
132
|
export class FusionSolanaRpcWrapper {
|
|
86
133
|
client;
|
|
87
134
|
contextId;
|
|
135
|
+
/**
|
|
136
|
+
* Creates an instance of FusionSolanaRpc.
|
|
137
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
138
|
+
*/
|
|
88
139
|
constructor(contextId) {
|
|
89
140
|
this.contextId = contextId;
|
|
90
|
-
this.client = new FusionSolanaRpcClient(DEFAULT_ADDRESS, credentials.createInsecure());
|
|
141
|
+
this.client = new FusionSolanaRpcClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
91
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves the balance for a Solana address.
|
|
145
|
+
* @param request - The request object containing the Solana address.
|
|
146
|
+
* @returns A promise that resolves to the balance response.
|
|
147
|
+
*/
|
|
92
148
|
async getSolanaBalance(request) {
|
|
93
|
-
request
|
|
149
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
94
150
|
return new Promise((resolve, reject) => {
|
|
95
|
-
this.client.getSolanaBalance(
|
|
151
|
+
this.client.getSolanaBalance(modifiedRequest, new Metadata(), (error, response) => {
|
|
96
152
|
if (error) {
|
|
97
153
|
reject(error);
|
|
98
154
|
}
|
|
@@ -102,10 +158,15 @@ export class FusionSolanaRpcWrapper {
|
|
|
102
158
|
});
|
|
103
159
|
});
|
|
104
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Retrieves account information for a Solana address.
|
|
163
|
+
* @param request - The request object containing the Solana address.
|
|
164
|
+
* @returns A promise that resolves to the account information response.
|
|
165
|
+
*/
|
|
105
166
|
async getSolanaAccountInfo(request) {
|
|
106
|
-
request
|
|
167
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
107
168
|
return new Promise((resolve, reject) => {
|
|
108
|
-
this.client.getSolanaAccountInfo(
|
|
169
|
+
this.client.getSolanaAccountInfo(modifiedRequest, new Metadata(), (error, response) => {
|
|
109
170
|
if (error) {
|
|
110
171
|
reject(error);
|
|
111
172
|
}
|
|
@@ -115,10 +176,15 @@ export class FusionSolanaRpcWrapper {
|
|
|
115
176
|
});
|
|
116
177
|
});
|
|
117
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Retrieves the current Solana slot.
|
|
181
|
+
* @param request - The request object containing slot query details.
|
|
182
|
+
* @returns A promise that resolves to the slot response.
|
|
183
|
+
*/
|
|
118
184
|
async getSolanaSlot(request) {
|
|
119
|
-
request
|
|
185
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
120
186
|
return new Promise((resolve, reject) => {
|
|
121
|
-
this.client.getSolanaSlot(
|
|
187
|
+
this.client.getSolanaSlot(modifiedRequest, new Metadata(), (error, response) => {
|
|
122
188
|
if (error) {
|
|
123
189
|
reject(error);
|
|
124
190
|
}
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import { FetchResponse, HttpMethod, Region } from "../protos_gen/services/fetch_proxy/v1/fetch_proxy.js";
|
|
2
|
+
/**
|
|
3
|
+
* Class for interacting with the Fusion Fetch Proxy service.
|
|
4
|
+
* Provides methods to perform HTTP requests via gRPC.
|
|
5
|
+
*/
|
|
2
6
|
export declare class FetchProxyWrapper {
|
|
3
7
|
private client;
|
|
4
8
|
private contextId;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of FetchProxy.
|
|
11
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
12
|
+
*/
|
|
5
13
|
constructor(contextId: string);
|
|
14
|
+
/**
|
|
15
|
+
* Performs an HTTP request using the Fetch Proxy service.
|
|
16
|
+
* @param url - The URL to fetch.
|
|
17
|
+
* @param headers - HTTP headers as key-value pairs.
|
|
18
|
+
* @param httpMethod - The HTTP method (e.g., GET, POST).
|
|
19
|
+
* @param bodyJson - Optional JSON body as a Uint8Array.
|
|
20
|
+
* @param region - Optional region for the request.
|
|
21
|
+
* @returns A promise that resolves to the FetchResponse.
|
|
22
|
+
*/
|
|
6
23
|
fetch(url: string, headers: {
|
|
7
24
|
[key: string]: string;
|
|
8
25
|
}, httpMethod: HttpMethod, bodyJson?: Uint8Array, region?: Region): Promise<FetchResponse>;
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { FusionFetchProxyClient } from "../protos_gen/services/fetch_proxy/v1/fetch_proxy.js";
|
|
2
2
|
import { Metadata, credentials } from "@grpc/grpc-js";
|
|
3
|
+
/**
|
|
4
|
+
* Class for interacting with the Fusion Fetch Proxy service.
|
|
5
|
+
* Provides methods to perform HTTP requests via gRPC.
|
|
6
|
+
*/
|
|
3
7
|
export class FetchProxyWrapper {
|
|
4
8
|
client;
|
|
5
9
|
contextId;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an instance of FetchProxy.
|
|
12
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
13
|
+
*/
|
|
6
14
|
constructor(contextId) {
|
|
7
15
|
this.contextId = contextId;
|
|
8
16
|
const address = process.env.FUSION_FETCH_PROXY_ADDRESS || "localhost:50051";
|
|
9
|
-
this.client = new FusionFetchProxyClient(address, credentials.createInsecure());
|
|
17
|
+
this.client = new FusionFetchProxyClient(address, address.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
10
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Performs an HTTP request using the Fetch Proxy service.
|
|
21
|
+
* @param url - The URL to fetch.
|
|
22
|
+
* @param headers - HTTP headers as key-value pairs.
|
|
23
|
+
* @param httpMethod - The HTTP method (e.g., GET, POST).
|
|
24
|
+
* @param bodyJson - Optional JSON body as a Uint8Array.
|
|
25
|
+
* @param region - Optional region for the request.
|
|
26
|
+
* @returns A promise that resolves to the FetchResponse.
|
|
27
|
+
*/
|
|
11
28
|
async fetch(url, headers, httpMethod, bodyJson, region) {
|
|
12
29
|
const request = {
|
|
13
30
|
url,
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { FusionPutStringRequest, FusionPutStringResponse, FusionStorageGetRequest, FusionStorageGetResponse, FusionStorageDeleteRequest, FusionStorageDeleteResponse, FusionStoragePeekRequest, FusionStoragePeekResponse, FusionStorageEnqueueRequest, FusionStorageEnqueueResponse, FusionStorageDequeueRequest, FusionStorageDequeueResponse, GetModuleExecutionParamsRequest, GetModuleExecutionParamsResponse, GetOnChainBlockRequest, FusionBlockStorageResponse } from "../protos_gen/services/storage_manager/v1/storage_manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* Class for interacting with the Fusion Persistent Storage service.
|
|
4
|
+
* Provides methods to perform CRUD operations on persistent storage.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PersistentStorageWrapper {
|
|
7
|
+
private client;
|
|
8
|
+
private contextId;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of PersistentStorage.
|
|
11
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
12
|
+
*/
|
|
13
|
+
constructor(contextId: string);
|
|
14
|
+
/**
|
|
15
|
+
* Stores a string value in persistent storage.
|
|
16
|
+
* @param request - The request object containing key-value data to store.
|
|
17
|
+
* @returns A promise that resolves to the response of the put operation.
|
|
18
|
+
*/
|
|
19
|
+
put(request: Omit<FusionPutStringRequest, 'contextId'>): Promise<FusionPutStringResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves a value from persistent storage.
|
|
22
|
+
* @param request - The request object containing the key to retrieve.
|
|
23
|
+
* @returns A promise that resolves to the response of the get operation.
|
|
24
|
+
*/
|
|
25
|
+
get(request: Omit<FusionStorageGetRequest, 'contextId'>): Promise<FusionStorageGetResponse>;
|
|
26
|
+
/**
|
|
27
|
+
* Deletes a value from persistent storage.
|
|
28
|
+
* @param request - The request object containing the key to delete.
|
|
29
|
+
* @returns A promise that resolves to the response of the delete operation.
|
|
30
|
+
*/
|
|
31
|
+
delete(request: Omit<FusionStorageDeleteRequest, 'contextId'>): Promise<FusionStorageDeleteResponse>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wrapper class for interacting with the Fusion Ephemeral Storage service.
|
|
35
|
+
* Provides methods to perform operations on ephemeral storage.
|
|
36
|
+
*/
|
|
37
|
+
export declare class EphemeralStorageWrapper {
|
|
38
|
+
private client;
|
|
39
|
+
private contextId;
|
|
40
|
+
/**
|
|
41
|
+
* Creates an instance of EphemeralStorage.
|
|
42
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
43
|
+
*/
|
|
44
|
+
constructor(contextId: string);
|
|
45
|
+
/**
|
|
46
|
+
* Stores a string value in ephemeral storage.
|
|
47
|
+
* @param request - The request object containing key-value data to store.
|
|
48
|
+
* @returns A promise that resolves to the response of the put operation.
|
|
49
|
+
*/
|
|
50
|
+
put(request: Omit<FusionPutStringRequest, 'contextId'>): Promise<FusionPutStringResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a value from ephemeral storage.
|
|
53
|
+
* @param request - The request object containing the key to retrieve.
|
|
54
|
+
* @returns A promise that resolves to the response of the get operation.
|
|
55
|
+
*/
|
|
56
|
+
get(request: Omit<FusionStorageGetRequest, 'contextId'>): Promise<FusionStorageGetResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Deletes a value from ephemeral storage.
|
|
59
|
+
* @param request - The request object containing the key to delete.
|
|
60
|
+
* @returns A promise that resolves to the response of the delete operation.
|
|
61
|
+
*/
|
|
62
|
+
delete(request: Omit<FusionStorageDeleteRequest, 'contextId'>): Promise<FusionStorageDeleteResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Peeks at the next value in a queue in ephemeral storage.
|
|
65
|
+
* @param request - The request object containing the queue name.
|
|
66
|
+
* @returns A promise that resolves to the response of the peek operation.
|
|
67
|
+
*/
|
|
68
|
+
peek(request: Omit<FusionStoragePeekRequest, 'contextId'>): Promise<FusionStoragePeekResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Enqueues a value into a queue in ephemeral storage.
|
|
71
|
+
* @param request - The request object containing the queue name and value.
|
|
72
|
+
* @returns A promise that resolves to the response of the enqueue operation.
|
|
73
|
+
*/
|
|
74
|
+
enqueue(request: Omit<FusionStorageEnqueueRequest, 'contextId'>): Promise<FusionStorageEnqueueResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Dequeues a value from a queue in ephemeral storage.
|
|
77
|
+
* @param request - The request object containing the queue name.
|
|
78
|
+
* @returns A promise that resolves to the response of the dequeue operation.
|
|
79
|
+
*/
|
|
80
|
+
dequeue(request: Omit<FusionStorageDequeueRequest, 'contextId'>): Promise<FusionStorageDequeueResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves module execution parameters.
|
|
83
|
+
* @param request - The request object containing module details.
|
|
84
|
+
* @returns A promise that resolves to the module execution parameters.
|
|
85
|
+
*/
|
|
86
|
+
getModuleExecutionParams(request: Omit<GetModuleExecutionParamsRequest, 'contextId'>): Promise<GetModuleExecutionParamsResponse>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves an on-chain block.
|
|
89
|
+
* @param request - The request object containing block details.
|
|
90
|
+
* @returns A promise that resolves to the on-chain block response.
|
|
91
|
+
*/
|
|
92
|
+
getOnChainBlock(request: Omit<GetOnChainBlockRequest, 'contextId'>): Promise<FusionBlockStorageResponse>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { FusionPersistentStorageClient, FusionEphemeralStorageClient } from "../protos_gen/services/storage_manager/v1/storage_manager.js";
|
|
2
|
+
import { Metadata, credentials } from "@grpc/grpc-js";
|
|
3
|
+
const DEFAULT_ADDRESS = process.env.STORAGE_MANAGER_ADDRESS || "localhost:50051";
|
|
4
|
+
/**
|
|
5
|
+
* Class for interacting with the Fusion Persistent Storage service.
|
|
6
|
+
* Provides methods to perform CRUD operations on persistent storage.
|
|
7
|
+
*/
|
|
8
|
+
export class PersistentStorageWrapper {
|
|
9
|
+
client;
|
|
10
|
+
contextId;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of PersistentStorage.
|
|
13
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
14
|
+
*/
|
|
15
|
+
constructor(contextId) {
|
|
16
|
+
this.contextId = contextId;
|
|
17
|
+
this.client = new FusionPersistentStorageClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stores a string value in persistent storage.
|
|
21
|
+
* @param request - The request object containing key-value data to store.
|
|
22
|
+
* @returns A promise that resolves to the response of the put operation.
|
|
23
|
+
*/
|
|
24
|
+
async put(request) {
|
|
25
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
this.client.put(modifiedRequest, new Metadata(), (error, response) => {
|
|
28
|
+
if (error) {
|
|
29
|
+
reject(error);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolve(response);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves a value from persistent storage.
|
|
39
|
+
* @param request - The request object containing the key to retrieve.
|
|
40
|
+
* @returns A promise that resolves to the response of the get operation.
|
|
41
|
+
*/
|
|
42
|
+
async get(request) {
|
|
43
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
this.client.get(modifiedRequest, new Metadata(), (error, response) => {
|
|
46
|
+
if (error) {
|
|
47
|
+
reject(error);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
resolve(response);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Deletes a value from persistent storage.
|
|
57
|
+
* @param request - The request object containing the key to delete.
|
|
58
|
+
* @returns A promise that resolves to the response of the delete operation.
|
|
59
|
+
*/
|
|
60
|
+
async delete(request) {
|
|
61
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
this.client.delete(modifiedRequest, new Metadata(), (error, response) => {
|
|
64
|
+
if (error) {
|
|
65
|
+
reject(error);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
resolve(response);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Wrapper class for interacting with the Fusion Ephemeral Storage service.
|
|
76
|
+
* Provides methods to perform operations on ephemeral storage.
|
|
77
|
+
*/
|
|
78
|
+
export class EphemeralStorageWrapper {
|
|
79
|
+
client;
|
|
80
|
+
contextId;
|
|
81
|
+
/**
|
|
82
|
+
* Creates an instance of EphemeralStorage.
|
|
83
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
84
|
+
*/
|
|
85
|
+
constructor(contextId) {
|
|
86
|
+
this.contextId = contextId;
|
|
87
|
+
this.client = new FusionEphemeralStorageClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Stores a string value in ephemeral storage.
|
|
91
|
+
* @param request - The request object containing key-value data to store.
|
|
92
|
+
* @returns A promise that resolves to the response of the put operation.
|
|
93
|
+
*/
|
|
94
|
+
async put(request) {
|
|
95
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
this.client.put(modifiedRequest, new Metadata(), (error, response) => {
|
|
98
|
+
if (error) {
|
|
99
|
+
reject(error);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
resolve(response);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Retrieves a value from ephemeral storage.
|
|
109
|
+
* @param request - The request object containing the key to retrieve.
|
|
110
|
+
* @returns A promise that resolves to the response of the get operation.
|
|
111
|
+
*/
|
|
112
|
+
async get(request) {
|
|
113
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
114
|
+
return new Promise((resolve, reject) => {
|
|
115
|
+
this.client.get(modifiedRequest, new Metadata(), (error, response) => {
|
|
116
|
+
if (error) {
|
|
117
|
+
reject(error);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
resolve(response);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Deletes a value from ephemeral storage.
|
|
127
|
+
* @param request - The request object containing the key to delete.
|
|
128
|
+
* @returns A promise that resolves to the response of the delete operation.
|
|
129
|
+
*/
|
|
130
|
+
async delete(request) {
|
|
131
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
this.client.delete(modifiedRequest, new Metadata(), (error, response) => {
|
|
134
|
+
if (error) {
|
|
135
|
+
reject(error);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
resolve(response);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Peeks at the next value in a queue in ephemeral storage.
|
|
145
|
+
* @param request - The request object containing the queue name.
|
|
146
|
+
* @returns A promise that resolves to the response of the peek operation.
|
|
147
|
+
*/
|
|
148
|
+
async peek(request) {
|
|
149
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
150
|
+
return new Promise((resolve, reject) => {
|
|
151
|
+
this.client.peek(modifiedRequest, new Metadata(), (error, response) => {
|
|
152
|
+
if (error) {
|
|
153
|
+
reject(error);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
resolve(response);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Enqueues a value into a queue in ephemeral storage.
|
|
163
|
+
* @param request - The request object containing the queue name and value.
|
|
164
|
+
* @returns A promise that resolves to the response of the enqueue operation.
|
|
165
|
+
*/
|
|
166
|
+
async enqueue(request) {
|
|
167
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
168
|
+
return new Promise((resolve, reject) => {
|
|
169
|
+
this.client.enqueue(modifiedRequest, new Metadata(), (error, response) => {
|
|
170
|
+
if (error) {
|
|
171
|
+
reject(error);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
resolve(response);
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Dequeues a value from a queue in ephemeral storage.
|
|
181
|
+
* @param request - The request object containing the queue name.
|
|
182
|
+
* @returns A promise that resolves to the response of the dequeue operation.
|
|
183
|
+
*/
|
|
184
|
+
async dequeue(request) {
|
|
185
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
this.client.dequeue(modifiedRequest, new Metadata(), (error, response) => {
|
|
188
|
+
if (error) {
|
|
189
|
+
reject(error);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
resolve(response);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Retrieves module execution parameters.
|
|
199
|
+
* @param request - The request object containing module details.
|
|
200
|
+
* @returns A promise that resolves to the module execution parameters.
|
|
201
|
+
*/
|
|
202
|
+
async getModuleExecutionParams(request) {
|
|
203
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
204
|
+
return new Promise((resolve, reject) => {
|
|
205
|
+
this.client.getModuleExecutionParams(modifiedRequest, new Metadata(), (error, response) => {
|
|
206
|
+
if (error) {
|
|
207
|
+
reject(error);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
resolve(response);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Retrieves an on-chain block.
|
|
217
|
+
* @param request - The request object containing block details.
|
|
218
|
+
* @returns A promise that resolves to the on-chain block response.
|
|
219
|
+
*/
|
|
220
|
+
async getOnChainBlock(request) {
|
|
221
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
222
|
+
return new Promise((resolve, reject) => {
|
|
223
|
+
this.client.getOnChainBlock(modifiedRequest, new Metadata(), (error, response) => {
|
|
224
|
+
if (error) {
|
|
225
|
+
reject(error);
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
resolve(response);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GetSubscriptionsRequest, GetSubscriptionsResponse } from "../protos_gen/services/subscription_manager/v1/subscription_manager.js";
|
|
2
|
+
/**
|
|
3
|
+
* Class for interacting with the Fusion Subscriptions service.
|
|
4
|
+
* Provides methods to manage and retrieve subscription data.
|
|
5
|
+
* Subscription data retrieved is from Alert creation by end users.
|
|
6
|
+
* See https://docs.notifi.network/docs/getting-started for more details.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SubscriptionsWrapper {
|
|
9
|
+
private client;
|
|
10
|
+
private contextId;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of Subscriptions.
|
|
13
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
14
|
+
*/
|
|
15
|
+
constructor(contextId: string);
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves subscription data.
|
|
18
|
+
* @param request - The request object containing subscription query parameters.
|
|
19
|
+
* @returns A promise that resolves to the subscription data response.
|
|
20
|
+
*/
|
|
21
|
+
getSubscriptions(request: Omit<GetSubscriptionsRequest, 'contextId'>): Promise<GetSubscriptionsResponse>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FusionSubscriptionsClient } from "../protos_gen/services/subscription_manager/v1/subscription_manager.js";
|
|
2
|
+
import { Metadata, credentials } from "@grpc/grpc-js";
|
|
3
|
+
const DEFAULT_ADDRESS = process.env.SUBSCRIPTION_MANAGER_ADDRESS || "localhost:50051";
|
|
4
|
+
/**
|
|
5
|
+
* Class for interacting with the Fusion Subscriptions service.
|
|
6
|
+
* Provides methods to manage and retrieve subscription data.
|
|
7
|
+
* Subscription data retrieved is from Alert creation by end users.
|
|
8
|
+
* See https://docs.notifi.network/docs/getting-started for more details.
|
|
9
|
+
*/
|
|
10
|
+
export class SubscriptionsWrapper {
|
|
11
|
+
client;
|
|
12
|
+
contextId;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of Subscriptions.
|
|
15
|
+
* @param contextId - The context ID for the gRPC requests.
|
|
16
|
+
*/
|
|
17
|
+
constructor(contextId) {
|
|
18
|
+
this.contextId = contextId;
|
|
19
|
+
this.client = new FusionSubscriptionsClient(DEFAULT_ADDRESS, DEFAULT_ADDRESS.startsWith("localhost") ? credentials.createInsecure() : credentials.createSsl());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves subscription data.
|
|
23
|
+
* @param request - The request object containing subscription query parameters.
|
|
24
|
+
* @returns A promise that resolves to the subscription data response.
|
|
25
|
+
*/
|
|
26
|
+
async getSubscriptions(request) {
|
|
27
|
+
const modifiedRequest = { ...request, contextId: this.contextId };
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
this.client.getSubscriptions(modifiedRequest, new Metadata(), (error, response) => {
|
|
30
|
+
if (error) {
|
|
31
|
+
reject(error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
resolve(response);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare function test(arg: string): void;
|
|
2
1
|
export { FetchProxyWrapper as FetchProxy } from './fusion_wrappers/fetch_proxy.js';
|
|
3
2
|
export { FusionEvmRpcWrapper as EvmRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
4
3
|
export { FusionSuiRpcWrapper as SuiRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
5
4
|
export { FusionSolanaRpcWrapper as SolanaRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
5
|
+
export { PersistentStorageWrapper as PersistentStorage } from './fusion_wrappers/storage.js';
|
|
6
|
+
export { EphemeralStorageWrapper as EphemeralStorage } from './fusion_wrappers/storage.js';
|
|
7
|
+
export { SubscriptionsWrapper as Subscriptions } from './fusion_wrappers/subscriptions.js';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function test(arg) {
|
|
2
|
-
console.log(arg);
|
|
3
|
-
}
|
|
4
1
|
export { FetchProxyWrapper as FetchProxy } from './fusion_wrappers/fetch_proxy.js';
|
|
5
2
|
export { FusionEvmRpcWrapper as EvmRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
6
3
|
export { FusionSuiRpcWrapper as SuiRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
7
4
|
export { FusionSolanaRpcWrapper as SolanaRpc } from './fusion_wrappers/blockchain_proxies.js';
|
|
5
|
+
export { PersistentStorageWrapper as PersistentStorage } from './fusion_wrappers/storage.js';
|
|
6
|
+
export { EphemeralStorageWrapper as EphemeralStorage } from './fusion_wrappers/storage.js';
|
|
7
|
+
export { SubscriptionsWrapper as Subscriptions } from './fusion_wrappers/subscriptions.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notifi-network/fusion-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "SDK utils for Notifi Fusion parser development. This includes types and helpers for accessing ephemeral/persistent storage, RPCs for different chains, and other utilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|