shogun-core 1.2.7 → 1.2.8
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/README.md +0 -1
- package/dist/browser/shogun-core.js +1 -1
- package/dist/browser/shogun-core.js.LICENSE.txt +2 -0
- package/dist/browser/shogun-core.light.js +1 -1
- package/dist/browser/shogun-core.vendors.light.js +1 -1
- package/dist/core.js +31 -71
- package/dist/gundb/{instance.js → gunInstance.js} +135 -115
- package/dist/gundb/index.js +3 -20
- package/dist/plugins/index.js +23 -1
- package/dist/plugins/nostr/index.js +1 -0
- package/dist/plugins/nostr/nostrChain.js +128 -0
- package/dist/plugins/nostr/nostrConnector.js +42 -7
- package/dist/plugins/nostr/nostrConnectorPlugin.js +157 -1
- package/dist/plugins/nostr/nostrSigner.js +343 -0
- package/dist/plugins/oauth/index.js +13 -0
- package/dist/plugins/oauth/oauthChain.js +161 -0
- package/dist/plugins/oauth/oauthConnector.js +542 -0
- package/dist/plugins/oauth/oauthPlugin.js +302 -0
- package/dist/plugins/oauth/types.js +2 -0
- package/dist/plugins/web3/index.js +1 -0
- package/dist/plugins/web3/web3Chain.js +77 -2
- package/dist/plugins/web3/web3Connector.js +159 -37
- package/dist/plugins/web3/web3ConnectorPlugin.js +157 -1
- package/dist/plugins/web3/web3Signer.js +268 -0
- package/dist/plugins/webauthn/webauthnChain.js +78 -0
- package/dist/plugins/webauthn/webauthnPlugin.js +154 -1
- package/dist/plugins/webauthn/webauthnSigner.js +318 -0
- package/dist/storage/storage.js +0 -8
- package/dist/types/core.d.ts +10 -34
- package/dist/types/gundb/gun-es/gun-es.d.ts +1 -0
- package/dist/types/gundb/{instance.d.ts → gunInstance.d.ts} +2 -2
- package/dist/types/gundb/index.d.ts +1 -4
- package/dist/types/plugins/index.d.ts +4 -0
- package/dist/types/plugins/nostr/index.d.ts +1 -0
- package/dist/types/plugins/nostr/nostrConnector.d.ts +3 -2
- package/dist/types/plugins/nostr/nostrConnectorPlugin.d.ts +82 -0
- package/dist/types/plugins/nostr/nostrSigner.d.ts +104 -0
- package/dist/types/plugins/oauth/index.d.ts +4 -0
- package/dist/types/plugins/oauth/oauthChain.d.ts +2 -0
- package/dist/types/plugins/oauth/oauthConnector.d.ts +100 -0
- package/dist/types/plugins/oauth/oauthPlugin.d.ts +89 -0
- package/dist/types/plugins/oauth/types.d.ts +106 -0
- package/dist/types/plugins/web3/index.d.ts +1 -0
- package/dist/types/plugins/web3/types.d.ts +1 -0
- package/dist/types/plugins/web3/web3Connector.d.ts +8 -2
- package/dist/types/plugins/web3/web3ConnectorPlugin.d.ts +82 -0
- package/dist/types/plugins/web3/web3Signer.d.ts +93 -0
- package/dist/types/plugins/webauthn/webauthnPlugin.d.ts +81 -0
- package/dist/types/plugins/webauthn/webauthnSigner.d.ts +90 -0
- package/dist/types/shogun.js +1 -28
- package/dist/types/types/events.d.ts +2 -2
- package/dist/types/types/shogun.d.ts +13 -49
- package/package.json +2 -1
- package/dist/browser.js +0 -107
- package/dist/contracts/base.js +0 -152
- package/dist/contracts/entryPoint.js +0 -407
- package/dist/contracts/index.js +0 -47
- package/dist/contracts/registry.js +0 -259
- package/dist/contracts/relay.js +0 -494
- package/dist/contracts/utils.js +0 -582
- package/dist/types/browser.d.ts +0 -27
- package/dist/types/contracts/base.d.ts +0 -82
- package/dist/types/contracts/entryPoint.d.ts +0 -138
- package/dist/types/contracts/index.d.ts +0 -17
- package/dist/types/contracts/registry.d.ts +0 -97
- package/dist/types/contracts/relay.d.ts +0 -165
- package/dist/types/contracts/utils.d.ts +0 -173
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EntryPoint Class - Provides interaction with the Shogun Protocol EntryPoint contract
|
|
3
|
-
*/
|
|
4
|
-
import { ethers } from "ethers";
|
|
5
|
-
import { BaseContract, ContractConfig, EntryPointStats, SubscriptionDetails } from "./base";
|
|
6
|
-
export interface EntryPointConfig extends ContractConfig {
|
|
7
|
-
entryPointAddress: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* EntryPoint - A class to interact with the Shogun Protocol EntryPoint contract
|
|
11
|
-
*/
|
|
12
|
-
export declare class EntryPoint extends BaseContract {
|
|
13
|
-
/**
|
|
14
|
-
* Create a new EntryPoint instance
|
|
15
|
-
* @param config - Configuration for the EntryPoint
|
|
16
|
-
*/
|
|
17
|
-
constructor(config: EntryPointConfig);
|
|
18
|
-
/**
|
|
19
|
-
* Get the registry address
|
|
20
|
-
* @returns The registry address or null if the call fails
|
|
21
|
-
*/
|
|
22
|
-
getRegistryAddress(): Promise<string | null>;
|
|
23
|
-
/**
|
|
24
|
-
* Get the service fee percentage
|
|
25
|
-
* @returns The fee percentage or null if the call fails
|
|
26
|
-
*/
|
|
27
|
-
getServiceFeePercentage(): Promise<number | null>;
|
|
28
|
-
/**
|
|
29
|
-
* Calculate fee amount
|
|
30
|
-
* @param amount - The amount to calculate fee on
|
|
31
|
-
* @returns The fee amount or null if the call fails
|
|
32
|
-
*/
|
|
33
|
-
calculateFee(amount: bigint): Promise<bigint | null>;
|
|
34
|
-
/**
|
|
35
|
-
* Check if a user has an active subscription on a relay
|
|
36
|
-
* @param userAddress - The address of the user
|
|
37
|
-
* @param relayAddress - The address of the relay
|
|
38
|
-
* @returns True if the user has an active subscription, false otherwise
|
|
39
|
-
*/
|
|
40
|
-
checkSubscription(userAddress: string, relayAddress: string): Promise<boolean>;
|
|
41
|
-
/**
|
|
42
|
-
* Check if a user has a registered public key on a relay
|
|
43
|
-
* @param userAddress - The address of the user
|
|
44
|
-
* @param relayAddress - The address of the relay
|
|
45
|
-
* @returns True if the user has a registered public key, false otherwise
|
|
46
|
-
*/
|
|
47
|
-
hasRegisteredPubKey(userAddress: string, relayAddress: string): Promise<boolean>;
|
|
48
|
-
/**
|
|
49
|
-
* Check if a specific public key is subscribed on a relay
|
|
50
|
-
* @param relayAddress - The address of the relay
|
|
51
|
-
* @param pubKey - The public key to check (hex string or Uint8Array)
|
|
52
|
-
* @returns True if the public key is subscribed, false otherwise
|
|
53
|
-
*/
|
|
54
|
-
isPubKeySubscribed(relayAddress: string, pubKey: string | Uint8Array): Promise<boolean>;
|
|
55
|
-
/**
|
|
56
|
-
* Check if public keys are subscribed on multiple relays
|
|
57
|
-
* @param relayAddresses - Array of relay addresses
|
|
58
|
-
* @param pubKeys - Array of public keys (hex strings or Uint8Arrays)
|
|
59
|
-
* @returns Array of booleans indicating subscription status for each relay/pubkey pair
|
|
60
|
-
*/
|
|
61
|
-
batchCheckPubKeySubscription(relayAddresses: string[], pubKeys: (string | Uint8Array)[]): Promise<boolean[]>;
|
|
62
|
-
/**
|
|
63
|
-
* Get detailed subscription information
|
|
64
|
-
* @param userAddress - The address of the user
|
|
65
|
-
* @param relayAddress - The address of the relay
|
|
66
|
-
* @returns The subscription details or null if not found
|
|
67
|
-
*/
|
|
68
|
-
getSubscriptionDetails(userAddress: string, relayAddress: string): Promise<SubscriptionDetails | null>;
|
|
69
|
-
/**
|
|
70
|
-
* Check if a user has active subscriptions on multiple relays
|
|
71
|
-
* @param userAddress - The address of the user
|
|
72
|
-
* @param relayAddresses - Array of relay addresses
|
|
73
|
-
* @returns Array of booleans indicating subscription status for each relay
|
|
74
|
-
*/
|
|
75
|
-
batchCheckSubscriptions(userAddress: string, relayAddresses: string[]): Promise<boolean[]>;
|
|
76
|
-
/**
|
|
77
|
-
* Check if a user has registered public keys on multiple relays
|
|
78
|
-
* @param userAddress - The address of the user
|
|
79
|
-
* @param relayAddresses - Array of relay addresses
|
|
80
|
-
* @returns Array of booleans indicating if public keys are registered for each relay
|
|
81
|
-
*/
|
|
82
|
-
batchCheckPubKeys(userAddress: string, relayAddresses: string[]): Promise<boolean[]>;
|
|
83
|
-
/**
|
|
84
|
-
* Get EntryPoint statistics
|
|
85
|
-
* @returns The EntryPoint statistics or null if the call fails
|
|
86
|
-
*/
|
|
87
|
-
getStatistics(): Promise<EntryPointStats | null>;
|
|
88
|
-
/**
|
|
89
|
-
* Subscribe to a relay via URL
|
|
90
|
-
* @param relayUrl - The URL of the relay
|
|
91
|
-
* @param months - Number of months to subscribe for
|
|
92
|
-
* @param pubKey - The public key to register (hex string or Uint8Array)
|
|
93
|
-
* @param value - The payment amount (will be calculated if not provided)
|
|
94
|
-
* @returns The transaction response or null if the call fails
|
|
95
|
-
*/
|
|
96
|
-
subscribeViaUrl(relayUrl: string, months: number, pubKey: string | Uint8Array, value?: bigint): Promise<ethers.TransactionResponse | null>;
|
|
97
|
-
/**
|
|
98
|
-
* Subscribe directly to a relay
|
|
99
|
-
* @param relayAddress - The address of the relay
|
|
100
|
-
* @param months - Number of months to subscribe for
|
|
101
|
-
* @param pubKey - The public key to register (hex string or Uint8Array)
|
|
102
|
-
* @param value - The payment amount (will be calculated if not provided)
|
|
103
|
-
* @returns The transaction response or null if the call fails
|
|
104
|
-
*/
|
|
105
|
-
subscribeDirect(relayAddress: string, months: number, pubKey: string | Uint8Array, value?: bigint): Promise<ethers.TransactionResponse | null>;
|
|
106
|
-
/**
|
|
107
|
-
* Subscribe to multiple relays in a single transaction
|
|
108
|
-
* @param relayAddresses - Array of relay addresses
|
|
109
|
-
* @param months - Number of months to subscribe for
|
|
110
|
-
* @param pubKeys - Array of public keys (hex strings or Uint8Arrays)
|
|
111
|
-
* @param value - The payment amount (will be calculated if not provided)
|
|
112
|
-
* @returns The transaction response or null if the call fails
|
|
113
|
-
*/
|
|
114
|
-
batchSubscribe(relayAddresses: string[], months: number, pubKeys: (string | Uint8Array)[], value?: bigint): Promise<ethers.TransactionResponse | null>;
|
|
115
|
-
/**
|
|
116
|
-
* Update the registry address (owner only)
|
|
117
|
-
* @param newRegistryAddress - The new registry address
|
|
118
|
-
* @returns The transaction response or null if the call fails
|
|
119
|
-
*/
|
|
120
|
-
updateRegistry(newRegistryAddress: string): Promise<ethers.TransactionResponse | null>;
|
|
121
|
-
/**
|
|
122
|
-
* Update the service fee percentage (owner only)
|
|
123
|
-
* @param newFeePercentage - The new fee percentage
|
|
124
|
-
* @returns The transaction response or null if the call fails
|
|
125
|
-
*/
|
|
126
|
-
updateServiceFee(newFeePercentage: number): Promise<ethers.TransactionResponse | null>;
|
|
127
|
-
/**
|
|
128
|
-
* Withdraw accumulated fees (owner only)
|
|
129
|
-
* @returns The transaction response or null if the call fails
|
|
130
|
-
*/
|
|
131
|
-
withdrawFees(): Promise<ethers.TransactionResponse | null>;
|
|
132
|
-
/**
|
|
133
|
-
* Check if a relay is in protocol mode
|
|
134
|
-
* @param relayAddress - The address of the relay
|
|
135
|
-
* @returns True if the relay is in protocol mode, false otherwise
|
|
136
|
-
*/
|
|
137
|
-
isRelayInProtocolMode(relayAddress: string): Promise<boolean>;
|
|
138
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Relay module - Provides interaction with the Shogun Protocol Relay system
|
|
3
|
-
*/
|
|
4
|
-
export * from "./base";
|
|
5
|
-
export * from "./registry";
|
|
6
|
-
export * from "./relay";
|
|
7
|
-
export * from "./entryPoint";
|
|
8
|
-
export { EntryPoint } from "./entryPoint";
|
|
9
|
-
export type { EntryPointConfig } from "./entryPoint";
|
|
10
|
-
export { Registry } from "./registry";
|
|
11
|
-
export type { RegistryConfig } from "./registry";
|
|
12
|
-
export { SimpleRelay } from "./relay";
|
|
13
|
-
export type { SimpleRelayConfig, SubscriptionInfo } from "./relay";
|
|
14
|
-
export type { RelayInfo, RelayPage, RelayConfig, BaseContract, ContractConfig, SubscriptionDetails, } from "./base";
|
|
15
|
-
export { getRelayUrls, getRegisteredPubKeys, getSubscriptionHistory, getRelayPerformance, getNetworkSummary, subscribeToRelayEvents, getUsageDataForChart, RelayEventType, } from "./utils";
|
|
16
|
-
export type { RegisteredPubKey, GroupedPubKeys, RelayPerformance, NetworkSummary, ChartDataPoint, ChartData, RelayEvent, } from "./utils";
|
|
17
|
-
export { RelayVerifier } from "./utils";
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry Class - Provides interaction with the Shogun Protocol Registry contract
|
|
3
|
-
*/
|
|
4
|
-
import { ethers } from "ethers";
|
|
5
|
-
import { BaseContract, ContractConfig, RelayInfo, RelayPage } from "./base";
|
|
6
|
-
export interface RegistryConfig extends ContractConfig {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Registry - A class to interact with the Shogun Protocol Registry contract
|
|
10
|
-
*/
|
|
11
|
-
export declare class Registry extends BaseContract {
|
|
12
|
-
/**
|
|
13
|
-
* Create a new Registry instance
|
|
14
|
-
* @param config - Configuration for the Registry
|
|
15
|
-
*/
|
|
16
|
-
constructor(config: RegistryConfig);
|
|
17
|
-
/**
|
|
18
|
-
* Check if a relay is registered
|
|
19
|
-
* @param relayAddress - The address of the relay to check
|
|
20
|
-
* @returns True if the relay is registered, false otherwise
|
|
21
|
-
*/
|
|
22
|
-
isRegisteredRelay(relayAddress: string): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Check if a relay is active
|
|
25
|
-
* @param relayAddress - The address of the relay to check
|
|
26
|
-
* @returns True if the relay is active, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
isRelayActive(relayAddress: string): Promise<boolean>;
|
|
29
|
-
/**
|
|
30
|
-
* Find a relay by its URL
|
|
31
|
-
* @param url - The URL of the relay to find
|
|
32
|
-
* @returns The address of the relay or zero address if not found
|
|
33
|
-
*/
|
|
34
|
-
findRelayByUrl(url: string): Promise<string>;
|
|
35
|
-
/**
|
|
36
|
-
* Get information about a specific relay
|
|
37
|
-
* @param relayAddress - The address of the relay
|
|
38
|
-
* @returns The relay information or null if not found
|
|
39
|
-
*/
|
|
40
|
-
getRelayInfo(relayAddress: string): Promise<RelayInfo | null>;
|
|
41
|
-
/**
|
|
42
|
-
* Get the number of relays owned by a specific address
|
|
43
|
-
* @param ownerAddress - The address of the owner
|
|
44
|
-
* @returns The number of relays or 0 if the call fails
|
|
45
|
-
*/
|
|
46
|
-
getRelayCountByOwner(ownerAddress: string): Promise<number>;
|
|
47
|
-
/**
|
|
48
|
-
* Get relays owned by a specific address with pagination
|
|
49
|
-
* @param ownerAddress - The address of the owner
|
|
50
|
-
* @param offset - Starting index for pagination
|
|
51
|
-
* @param limit - Maximum number of items to return
|
|
52
|
-
* @returns Page of relay addresses or null if the call fails
|
|
53
|
-
*/
|
|
54
|
-
getRelaysByOwner(ownerAddress: string, offset?: number, limit?: number): Promise<RelayPage | null>;
|
|
55
|
-
/**
|
|
56
|
-
* Get all relays with pagination
|
|
57
|
-
* @param onlyActive - If true, only return active relays
|
|
58
|
-
* @param offset - Starting index for pagination
|
|
59
|
-
* @param limit - Maximum number of items to return
|
|
60
|
-
* @returns Page of relay addresses or null if the call fails
|
|
61
|
-
*/
|
|
62
|
-
getAllRelays(onlyActive?: boolean, offset?: number, limit?: number): Promise<RelayPage | null>;
|
|
63
|
-
/**
|
|
64
|
-
* Register a new relay
|
|
65
|
-
* @param relayAddress - The address of the relay contract
|
|
66
|
-
* @param url - The URL of the relay
|
|
67
|
-
* @param metadata - Additional metadata for the relay (JSON string)
|
|
68
|
-
* @returns The transaction response or null if the call fails
|
|
69
|
-
*/
|
|
70
|
-
registerRelay(relayAddress: string, url: string, metadata: string): Promise<ethers.TransactionResponse | null>;
|
|
71
|
-
/**
|
|
72
|
-
* Update relay information
|
|
73
|
-
* @param relayAddress - The address of the relay to update
|
|
74
|
-
* @param newUrl - The new URL (empty to keep current)
|
|
75
|
-
* @param newMetadata - The new metadata (empty to keep current)
|
|
76
|
-
* @returns The transaction response or null if the call fails
|
|
77
|
-
*/
|
|
78
|
-
updateRelay(relayAddress: string, newUrl?: string, newMetadata?: string): Promise<ethers.TransactionResponse | null>;
|
|
79
|
-
/**
|
|
80
|
-
* Deactivate a relay
|
|
81
|
-
* @param relayAddress - The address of the relay to deactivate
|
|
82
|
-
* @returns The transaction response or null if the call fails
|
|
83
|
-
*/
|
|
84
|
-
deactivateRelay(relayAddress: string): Promise<ethers.TransactionResponse | null>;
|
|
85
|
-
/**
|
|
86
|
-
* Reactivate a relay
|
|
87
|
-
* @param relayAddress - The address of the relay to reactivate
|
|
88
|
-
* @returns The transaction response or null if the call fails
|
|
89
|
-
*/
|
|
90
|
-
reactivateRelay(relayAddress: string): Promise<ethers.TransactionResponse | null>;
|
|
91
|
-
/**
|
|
92
|
-
* Set whether registration is open
|
|
93
|
-
* @param isOpen - Whether registration should be open
|
|
94
|
-
* @returns The transaction response or null if the call fails
|
|
95
|
-
*/
|
|
96
|
-
setRegistrationOpen(isOpen: boolean): Promise<ethers.TransactionResponse | null>;
|
|
97
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SimpleRelay Class - Provides interaction with the Shogun Protocol SimpleRelay contract
|
|
3
|
-
*/
|
|
4
|
-
import { ethers } from "ethers";
|
|
5
|
-
import { BaseContract, ContractConfig, RelayConfig, RelayOperatingMode, RelayModeInfo } from "./base";
|
|
6
|
-
export interface SimpleRelayConfig extends ContractConfig {
|
|
7
|
-
relayAddress: string;
|
|
8
|
-
}
|
|
9
|
-
export interface SubscriptionInfo {
|
|
10
|
-
expires: bigint;
|
|
11
|
-
pubKey: string;
|
|
12
|
-
isActive: boolean;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* SimpleRelay - A class to interact with the Shogun Protocol SimpleRelay contract
|
|
16
|
-
*/
|
|
17
|
-
export declare class SimpleRelay extends BaseContract {
|
|
18
|
-
/**
|
|
19
|
-
* Create a new SimpleRelay instance
|
|
20
|
-
* @param config - Configuration for the SimpleRelay
|
|
21
|
-
*/
|
|
22
|
-
constructor(config: SimpleRelayConfig);
|
|
23
|
-
/**
|
|
24
|
-
* Check if a user's subscription is active
|
|
25
|
-
* @param userAddress - The address of the user
|
|
26
|
-
* @returns True if the subscription is active, false otherwise
|
|
27
|
-
*/
|
|
28
|
-
isSubscriptionActive(userAddress: string): Promise<boolean>;
|
|
29
|
-
/**
|
|
30
|
-
* Get detailed subscription information for a user
|
|
31
|
-
* @param userAddress - The address of the user
|
|
32
|
-
* @returns The subscription information or null if not found
|
|
33
|
-
*/
|
|
34
|
-
getUserSubscriptionInfo(userAddress: string): Promise<SubscriptionInfo | null>;
|
|
35
|
-
/**
|
|
36
|
-
* Check if a public key is authorized
|
|
37
|
-
* @param pubKey - The public key to check (hex string or Uint8Array)
|
|
38
|
-
* @returns True if the public key is authorized, false otherwise
|
|
39
|
-
*/
|
|
40
|
-
isAuthorizedByPubKey(pubKey: string | Uint8Array): Promise<boolean>;
|
|
41
|
-
/**
|
|
42
|
-
* Check if a public key is subscribed (alias for isAuthorizedByPubKey)
|
|
43
|
-
* @param pubKey - The public key to check (hex string or Uint8Array)
|
|
44
|
-
* @returns True if the public key is subscribed, false otherwise
|
|
45
|
-
*/
|
|
46
|
-
isSubscribed(pubKey: string | Uint8Array): Promise<boolean>;
|
|
47
|
-
/**
|
|
48
|
-
* Get the monthly subscription price
|
|
49
|
-
* @returns The price in wei or null if the call fails
|
|
50
|
-
*/
|
|
51
|
-
getPricePerMonth(): Promise<bigint | null>;
|
|
52
|
-
/**
|
|
53
|
-
* Get the number of days per month used for subscription calculations
|
|
54
|
-
* @returns The days per month or null if the call fails
|
|
55
|
-
*/
|
|
56
|
-
getDaysPerMonth(): Promise<number | null>;
|
|
57
|
-
/**
|
|
58
|
-
* Get the relay URL
|
|
59
|
-
* @returns The relay URL or null if the call fails
|
|
60
|
-
*/
|
|
61
|
-
getRelayUrl(): Promise<string | null>;
|
|
62
|
-
/**
|
|
63
|
-
* Get complete relay operational configuration
|
|
64
|
-
* @returns The relay configuration or null if the call fails
|
|
65
|
-
*/
|
|
66
|
-
getRelayOperationalConfig(): Promise<RelayConfig | null>;
|
|
67
|
-
/**
|
|
68
|
-
* Subscribe to the relay
|
|
69
|
-
* @param months - Number of months to subscribe for
|
|
70
|
-
* @param pubKey - The public key to register (hex string or Uint8Array)
|
|
71
|
-
* @returns The transaction response or null if the call fails
|
|
72
|
-
*/
|
|
73
|
-
subscribe(months: number, pubKey: string | Uint8Array): Promise<ethers.TransactionResponse | null>;
|
|
74
|
-
/**
|
|
75
|
-
* Set new price per month (owner only)
|
|
76
|
-
* @param newPrice - The new price in wei
|
|
77
|
-
* @returns The transaction response or null if the call fails
|
|
78
|
-
*/
|
|
79
|
-
setPrice(newPrice: bigint): Promise<ethers.TransactionResponse | null>;
|
|
80
|
-
/**
|
|
81
|
-
* Set new days per month for subscription calculations (owner only)
|
|
82
|
-
* @param days - The new number of days (1-31)
|
|
83
|
-
* @returns The transaction response or null if the call fails
|
|
84
|
-
*/
|
|
85
|
-
setDaysPerMonth(days: number): Promise<ethers.TransactionResponse | null>;
|
|
86
|
-
/**
|
|
87
|
-
* Update the relay URL (owner only)
|
|
88
|
-
* @param newUrl - The new URL
|
|
89
|
-
* @returns The transaction response or null if the call fails
|
|
90
|
-
*/
|
|
91
|
-
updateRelayUrl(newUrl: string): Promise<ethers.TransactionResponse | null>;
|
|
92
|
-
/**
|
|
93
|
-
* Withdraw accumulated funds (owner only)
|
|
94
|
-
* @returns The transaction response or null if the call fails
|
|
95
|
-
*/
|
|
96
|
-
withdrawFunds(): Promise<ethers.TransactionResponse | null>;
|
|
97
|
-
/**
|
|
98
|
-
* Decommission the relay and withdraw all funds (owner only)
|
|
99
|
-
* @returns The transaction response or null if the call fails
|
|
100
|
-
*/
|
|
101
|
-
decommissionAndWithdrawAllFunds(): Promise<ethers.TransactionResponse | null>;
|
|
102
|
-
/**
|
|
103
|
-
* Execute a generic transaction (owner only)
|
|
104
|
-
* @param to - The destination address
|
|
105
|
-
* @param value - The amount of ETH to send
|
|
106
|
-
* @param data - The calldata to send
|
|
107
|
-
* @returns The transaction response and result or null if the call fails
|
|
108
|
-
*/
|
|
109
|
-
execute(to: string, value: bigint, data: string): Promise<{
|
|
110
|
-
success: boolean;
|
|
111
|
-
result: string;
|
|
112
|
-
} | null>;
|
|
113
|
-
/**
|
|
114
|
-
* Get the current operating mode of the relay
|
|
115
|
-
* @returns The operating mode (SINGLE or PROTOCOL) or null if the call fails
|
|
116
|
-
*/
|
|
117
|
-
getOperatingMode(): Promise<RelayOperatingMode | null>;
|
|
118
|
-
/**
|
|
119
|
-
* Get the registry address set in the relay
|
|
120
|
-
* @returns The registry address or null if the call fails
|
|
121
|
-
*/
|
|
122
|
-
getRegistryAddress(): Promise<string | null>;
|
|
123
|
-
/**
|
|
124
|
-
* Get the entry point address set in the relay
|
|
125
|
-
* @returns The entry point address or null if the call fails
|
|
126
|
-
*/
|
|
127
|
-
getEntryPointAddress(): Promise<string | null>;
|
|
128
|
-
/**
|
|
129
|
-
* Check if the relay is registered in the registry
|
|
130
|
-
* @returns True if the relay is registered, false otherwise
|
|
131
|
-
*/
|
|
132
|
-
isRegisteredInRegistry(): Promise<boolean>;
|
|
133
|
-
/**
|
|
134
|
-
* Get complete relay mode information
|
|
135
|
-
* @returns The relay mode information or null if the call fails
|
|
136
|
-
*/
|
|
137
|
-
getRelayMode(): Promise<RelayModeInfo | null>;
|
|
138
|
-
/**
|
|
139
|
-
* Set the registry address for the relay
|
|
140
|
-
* @param registryAddress - The registry contract address
|
|
141
|
-
* @param autoRegister - Whether to automatically register the relay in the registry
|
|
142
|
-
* @param metadata - Metadata for registry registration (only used if autoRegister is true)
|
|
143
|
-
* @returns The transaction response or null if the call fails
|
|
144
|
-
*/
|
|
145
|
-
setRegistry(registryAddress: string, autoRegister?: boolean, metadata?: string): Promise<ethers.TransactionResponse | null>;
|
|
146
|
-
/**
|
|
147
|
-
* Set the entry point address for the relay
|
|
148
|
-
* @param entryPointAddress - The entry point contract address
|
|
149
|
-
* @param enableProtocolMode - Whether to enable PROTOCOL mode automatically
|
|
150
|
-
* @returns The transaction response or null if the call fails
|
|
151
|
-
*/
|
|
152
|
-
setEntryPoint(entryPointAddress: string, enableProtocolMode?: boolean): Promise<ethers.TransactionResponse | null>;
|
|
153
|
-
/**
|
|
154
|
-
* Set the operating mode for the relay
|
|
155
|
-
* @param mode - The new operating mode (SINGLE or PROTOCOL)
|
|
156
|
-
* @returns The transaction response or null if the call fails
|
|
157
|
-
*/
|
|
158
|
-
setOperatingMode(mode: RelayOperatingMode): Promise<ethers.TransactionResponse | null>;
|
|
159
|
-
/**
|
|
160
|
-
* Register the relay in the registry
|
|
161
|
-
* @param metadata - Metadata for registry registration
|
|
162
|
-
* @returns The transaction response or null if the call fails
|
|
163
|
-
*/
|
|
164
|
-
registerInRegistry(metadata?: string): Promise<ethers.TransactionResponse | null>;
|
|
165
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for working with the relay system
|
|
3
|
-
*/
|
|
4
|
-
import { Registry } from "./registry";
|
|
5
|
-
import { SimpleRelay } from "./relay";
|
|
6
|
-
import { EntryPoint } from "./entryPoint";
|
|
7
|
-
export interface RegisteredPubKey {
|
|
8
|
-
relayAddress: string;
|
|
9
|
-
relayUrl: string;
|
|
10
|
-
pubKey: string;
|
|
11
|
-
userAddress?: string;
|
|
12
|
-
expires?: bigint;
|
|
13
|
-
}
|
|
14
|
-
export interface GroupedPubKeys {
|
|
15
|
-
[pubKey: string]: {
|
|
16
|
-
pubKey: string;
|
|
17
|
-
relays: {
|
|
18
|
-
relayAddress: string;
|
|
19
|
-
relayUrl: string;
|
|
20
|
-
userAddress?: string;
|
|
21
|
-
expires?: bigint;
|
|
22
|
-
}[];
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export interface RelayPerformance {
|
|
26
|
-
uptime: number;
|
|
27
|
-
responseTime: number;
|
|
28
|
-
successRate: number;
|
|
29
|
-
lastChecked: string;
|
|
30
|
-
}
|
|
31
|
-
export interface NetworkSummary {
|
|
32
|
-
totalRelays: number;
|
|
33
|
-
activeRelays: number;
|
|
34
|
-
totalSubscriptions: number;
|
|
35
|
-
activeSubscriptions: number;
|
|
36
|
-
averagePrice: string;
|
|
37
|
-
totalProcessedAmount: string;
|
|
38
|
-
totalFeesCollected: string;
|
|
39
|
-
}
|
|
40
|
-
export interface ChartDataPoint {
|
|
41
|
-
label: string;
|
|
42
|
-
value: number;
|
|
43
|
-
}
|
|
44
|
-
export interface ChartData {
|
|
45
|
-
dataPoints: ChartDataPoint[];
|
|
46
|
-
title: string;
|
|
47
|
-
description: string;
|
|
48
|
-
}
|
|
49
|
-
export declare enum RelayEventType {
|
|
50
|
-
NEW_SUBSCRIPTION = "newSubscription",
|
|
51
|
-
SUBSCRIPTION_EXPIRED = "subscriptionExpired",
|
|
52
|
-
RELAY_REGISTERED = "relayRegistered",
|
|
53
|
-
RELAY_DEACTIVATED = "relayDeactivated",
|
|
54
|
-
RELAY_REACTIVATED = "relayReactivated"
|
|
55
|
-
}
|
|
56
|
-
export interface RelayEvent {
|
|
57
|
-
type: RelayEventType;
|
|
58
|
-
timestamp: number;
|
|
59
|
-
relayAddress?: string;
|
|
60
|
-
userAddress?: string;
|
|
61
|
-
transactionHash?: string;
|
|
62
|
-
data?: any;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Fetch all relay URLs from the registry
|
|
66
|
-
* @param registry - Registry instance
|
|
67
|
-
* @param onlyActive - Whether to only fetch active relays (default: true)
|
|
68
|
-
* @returns Array of relay URLs and addresses
|
|
69
|
-
*/
|
|
70
|
-
export declare function getRelayUrls(registry: Registry, onlyActive?: boolean): Promise<Array<{
|
|
71
|
-
url: string;
|
|
72
|
-
address: string;
|
|
73
|
-
}>>;
|
|
74
|
-
/**
|
|
75
|
-
* Retrieve all public keys registered in relays and group them
|
|
76
|
-
* @param registry - Registry instance
|
|
77
|
-
* @param entryPoint - EntryPoint instance
|
|
78
|
-
* @param userAddresses - Optional list of user addresses to check
|
|
79
|
-
* @param onlyActive - Whether to only fetch active relays (default: true)
|
|
80
|
-
* @returns Grouped public keys with their associated relays
|
|
81
|
-
*/
|
|
82
|
-
export declare function getRegisteredPubKeys(registry: Registry, entryPoint: EntryPoint, userAddresses?: string[], onlyActive?: boolean): Promise<GroupedPubKeys>;
|
|
83
|
-
/**
|
|
84
|
-
* Ottieni la cronologia delle sottoscrizioni nel periodo specificato
|
|
85
|
-
* @param entryPoint - Istanza di EntryPoint
|
|
86
|
-
* @param timeframe - Periodo di tempo ('day', 'week', 'month')
|
|
87
|
-
* @returns Array di oggetti con date e conteggio sottoscrizioni
|
|
88
|
-
*/
|
|
89
|
-
export declare function getSubscriptionHistory(entryPoint: EntryPoint, timeframe?: "day" | "week" | "month"): Promise<Array<{
|
|
90
|
-
date: string;
|
|
91
|
-
count: number;
|
|
92
|
-
}>>;
|
|
93
|
-
/**
|
|
94
|
-
* Ottieni le metriche di performance di un relay
|
|
95
|
-
* @param registry - Istanza di Registry
|
|
96
|
-
* @param relayAddress - Indirizzo del relay
|
|
97
|
-
* @returns Oggetto con metriche di performance
|
|
98
|
-
*/
|
|
99
|
-
export declare function getRelayPerformance(registry: Registry, relayAddress: string): Promise<RelayPerformance>;
|
|
100
|
-
/**
|
|
101
|
-
* Ottiene un riepilogo di tutte le informazioni della rete relay
|
|
102
|
-
* @param registry - Istanza di Registry
|
|
103
|
-
* @param entryPoint - Istanza di EntryPoint
|
|
104
|
-
* @returns Oggetto con statistiche di rete
|
|
105
|
-
*/
|
|
106
|
-
export declare function getNetworkSummary(registry: Registry, entryPoint: EntryPoint): Promise<NetworkSummary>;
|
|
107
|
-
/**
|
|
108
|
-
* Iscriviti agli eventi dei relay
|
|
109
|
-
* @param registry - Istanza di Registry
|
|
110
|
-
* @param callback - Funzione di callback da eseguire quando si verifica un evento
|
|
111
|
-
* @returns Funzione per annullare l'iscrizione
|
|
112
|
-
*/
|
|
113
|
-
export declare function subscribeToRelayEvents(registry: Registry, callback: (event: RelayEvent) => void): () => void;
|
|
114
|
-
/**
|
|
115
|
-
* Ottieni dati per grafici relativi all'utilizzo dei relay
|
|
116
|
-
* @param entryPoint - Istanza di EntryPoint
|
|
117
|
-
* @param metric - Metrica da visualizzare ('subscriptions', 'revenue', 'users')
|
|
118
|
-
* @param period - Periodo di tempo ('daily', 'weekly', 'monthly')
|
|
119
|
-
* @returns Dati formattati per grafici
|
|
120
|
-
*/
|
|
121
|
-
export declare function getUsageDataForChart(entryPoint: EntryPoint, metric: "subscriptions" | "revenue" | "users", period: "daily" | "weekly" | "monthly"): Promise<ChartData>;
|
|
122
|
-
/**
|
|
123
|
-
* Create a combined relay verifier that can check public key authorization across all contract types
|
|
124
|
-
*/
|
|
125
|
-
export declare class RelayVerifier {
|
|
126
|
-
private registry;
|
|
127
|
-
private entryPoint;
|
|
128
|
-
private simpleRelay;
|
|
129
|
-
/**
|
|
130
|
-
* Create a new RelayVerifier
|
|
131
|
-
* @param registry - Optional Registry instance
|
|
132
|
-
* @param entryPoint - Optional EntryPoint instance
|
|
133
|
-
* @param simpleRelay - Optional SimpleRelay instance
|
|
134
|
-
*/
|
|
135
|
-
constructor(registry?: Registry, entryPoint?: EntryPoint, simpleRelay?: SimpleRelay);
|
|
136
|
-
/**
|
|
137
|
-
* Check if a public key is authorized (subscribed) to any relay
|
|
138
|
-
* @param registryAddress - The address of the registry (or any value if checking directly)
|
|
139
|
-
* @param pubKey - The public key to check (hex string or Uint8Array)
|
|
140
|
-
* @returns True if the public key is authorized, false otherwise
|
|
141
|
-
*/
|
|
142
|
-
isPublicKeyAuthorized(registryAddress: string, pubKey: string | Uint8Array): Promise<boolean>;
|
|
143
|
-
/**
|
|
144
|
-
* Check if a user is subscribed to a specific relay
|
|
145
|
-
* @param relayAddress - The address of the relay
|
|
146
|
-
* @param pubKey - The public key to check (hex string or Uint8Array)
|
|
147
|
-
* @returns True if the user is subscribed, false otherwise
|
|
148
|
-
*/
|
|
149
|
-
isUserSubscribedToRelay(relayAddress: string, pubKey: string | Uint8Array): Promise<boolean>;
|
|
150
|
-
/**
|
|
151
|
-
* Get all relays from registry
|
|
152
|
-
* @param onlyActive - If true, only return active relays
|
|
153
|
-
* @param offset - Starting index for pagination
|
|
154
|
-
* @param limit - Maximum number of items to return
|
|
155
|
-
* @returns Array of relay addresses
|
|
156
|
-
*/
|
|
157
|
-
getAllRelays(onlyActive?: boolean, offset?: number, limit?: number): Promise<string[]>;
|
|
158
|
-
/**
|
|
159
|
-
* Set registry instance
|
|
160
|
-
* @param registry - The Registry instance
|
|
161
|
-
*/
|
|
162
|
-
setRegistry(registry: Registry): void;
|
|
163
|
-
/**
|
|
164
|
-
* Set entryPoint instance
|
|
165
|
-
* @param entryPoint - The EntryPoint instance
|
|
166
|
-
*/
|
|
167
|
-
setEntryPoint(entryPoint: EntryPoint): void;
|
|
168
|
-
/**
|
|
169
|
-
* Set simpleRelay instance
|
|
170
|
-
* @param simpleRelay - The SimpleRelay instance
|
|
171
|
-
*/
|
|
172
|
-
setSimpleRelay(simpleRelay: SimpleRelay): void;
|
|
173
|
-
}
|