@deserialize/multi-vm-wallet 1.3.2 → 1.3.3
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/.claude/settings.local.json +2 -1
- package/dist/constant.js +60 -16
- package/dist/constant.js.map +1 -1
- package/dist/evm/aa-service/index.d.ts +1 -1
- package/dist/evm/aa-service/index.js +1 -2
- package/dist/evm/aa-service/index.js.map +1 -1
- package/dist/evm/aa-service/lib/kernel-account.d.ts +1 -1
- package/dist/evm/aa-service/lib/kernel-account.js +22 -6
- package/dist/evm/aa-service/lib/kernel-account.js.map +1 -1
- package/dist/evm/aa-service/lib/session-keys.d.ts +14 -17
- package/dist/evm/aa-service/lib/session-keys.js +40 -58
- package/dist/evm/aa-service/lib/session-keys.js.map +1 -1
- package/dist/evm/aa-service/lib/type.d.ts +2 -1
- package/dist/evm/aa-service/lib/type.js.map +1 -1
- package/dist/evm/aa-service/services/account-abstraction.d.ts +3 -29
- package/dist/evm/aa-service/services/account-abstraction.js +3 -67
- package/dist/evm/aa-service/services/account-abstraction.js.map +1 -1
- package/dist/evm/aa-service/services/bundler.js +2 -1
- package/dist/evm/aa-service/services/bundler.js.map +1 -1
- package/dist/evm/evm.d.ts +161 -1
- package/dist/evm/evm.js +247 -0
- package/dist/evm/evm.js.map +1 -1
- package/dist/evm/smartWallet.d.ts +11 -43
- package/dist/evm/smartWallet.js +136 -116
- package/dist/evm/smartWallet.js.map +1 -1
- package/dist/evm/utils.js +0 -1
- package/dist/evm/utils.js.map +1 -1
- package/dist/privacy/artifact-manager.d.ts +117 -0
- package/dist/privacy/artifact-manager.js +251 -0
- package/dist/privacy/artifact-manager.js.map +1 -0
- package/dist/privacy/broadcaster-client.d.ts +166 -0
- package/dist/privacy/broadcaster-client.js +261 -0
- package/dist/privacy/broadcaster-client.js.map +1 -0
- package/dist/privacy/index.d.ts +34 -0
- package/dist/privacy/index.js +56 -0
- package/dist/privacy/index.js.map +1 -0
- package/dist/privacy/network-config.d.ts +57 -0
- package/dist/privacy/network-config.js +118 -0
- package/dist/privacy/network-config.js.map +1 -0
- package/dist/privacy/poi-helper.d.ts +161 -0
- package/dist/privacy/poi-helper.js +249 -0
- package/dist/privacy/poi-helper.js.map +1 -0
- package/dist/privacy/railgun-engine.d.ts +135 -0
- package/dist/privacy/railgun-engine.js +205 -0
- package/dist/privacy/railgun-engine.js.map +1 -0
- package/dist/privacy/railgun-privacy-wallet.d.ts +288 -0
- package/dist/privacy/railgun-privacy-wallet.js +539 -0
- package/dist/privacy/railgun-privacy-wallet.js.map +1 -0
- package/dist/privacy/types.d.ts +229 -0
- package/dist/privacy/types.js +26 -0
- package/dist/privacy/types.js.map +1 -0
- package/dist/savings/savings-manager.d.ts +126 -0
- package/dist/savings/savings-manager.js +234 -0
- package/dist/savings/savings-manager.js.map +1 -0
- package/dist/savings/smart-savings.d.ts +74 -0
- package/dist/savings/smart-savings.js +152 -0
- package/dist/savings/smart-savings.js.map +1 -0
- package/dist/savings/types.d.ts +125 -0
- package/dist/savings/types.js +9 -0
- package/dist/savings/types.js.map +1 -0
- package/dist/svm/svm.d.ts +16 -0
- package/dist/svm/svm.js +23 -0
- package/dist/svm/svm.js.map +1 -1
- package/dist/test.js +53 -15
- package/dist/test.js.map +1 -1
- package/dist/vm.d.ts +14 -0
- package/dist/vm.js.map +1 -1
- package/package.json +2 -1
- package/utils/constant.ts +63 -16
- package/utils/evm/aa-service/index.ts +0 -1
- package/utils/evm/aa-service/lib/kernel-account.ts +23 -8
- package/utils/evm/aa-service/lib/session-keys.ts +58 -60
- package/utils/evm/aa-service/lib/type.ts +2 -1
- package/utils/evm/aa-service/services/account-abstraction.ts +10 -76
- package/utils/evm/aa-service/services/bundler.ts +2 -1
- package/utils/evm/evm.ts +300 -0
- package/utils/evm/smartWallet.ts +118 -128
- package/utils/evm/utils.ts +1 -1
- package/utils/savings/savings-manager.ts +271 -0
- package/utils/savings/smart-savings.ts +184 -0
- package/utils/savings/types.ts +135 -0
- package/utils/svm/svm.ts +27 -0
- package/utils/test.ts +82 -18
- package/utils/vm.ts +10 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAILGUN Privacy Module
|
|
3
|
+
*
|
|
4
|
+
* Provides zero-knowledge privacy features for the wallet SDK.
|
|
5
|
+
* Completely independent from savings features.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { RailgunEngine, RailgunPrivacyWallet } from './privacy';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize engine once
|
|
12
|
+
* await RailgunEngine.initialize({
|
|
13
|
+
* walletSource: 'mywallet',
|
|
14
|
+
* db,
|
|
15
|
+
* artifactStore,
|
|
16
|
+
* poiNodeURLs: ['...']
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* // Create privacy wallet
|
|
20
|
+
* const walletInfo = await RailgunPrivacyWallet.create(encryptionKey, mnemonic);
|
|
21
|
+
*
|
|
22
|
+
* // Use privacy features
|
|
23
|
+
* const wallet = await RailgunPrivacyWallet.load(encryptionKey, walletInfo.railgunWalletID);
|
|
24
|
+
* const shieldTx = await wallet.buildShield(...);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export { RailgunEngine } from './railgun-engine';
|
|
28
|
+
export { RailgunPrivacyWallet } from './railgun-privacy-wallet';
|
|
29
|
+
export { ArtifactManager } from './artifact-manager';
|
|
30
|
+
export { POIHelper } from './poi-helper';
|
|
31
|
+
export { BroadcasterClient, createBroadcasterFeeCallback } from './broadcaster-client';
|
|
32
|
+
export { RAILGUN_NETWORKS, DEFAULT_POI_NODES, POI_STANDBY_PERIODS, getNetworkConfig, getNetworkConfigByChainId, isNetworkSupported, isChainIdSupported, getSupportedNetworks, getSupportedChainIds, getPOIStandbyPeriod, } from './network-config';
|
|
33
|
+
export type { RailgunDatabase, ArtifactStore, RailgunEngineConfig, PreloadedArtifacts, RailgunWalletInfo, PrivateBalance, BalanceUpdateCallback, ScanProgressCallback, BaseRailgunTransaction, ShieldTransaction, UnshieldTransaction, PrivateTransferTransaction, ShieldOptions, UnshieldOptions, PrivateTransferOptions, POISpendabilityResult, ArtifactDownloadProgress, ArtifactDownloadCallback, ArtifactSyncResult, RailgunNetworkConfig, BroadcasterInfo, BroadcasterFeeCallback, NetworkFees, } from './types';
|
|
34
|
+
export { BalanceBucket } from './types';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RAILGUN Privacy Module
|
|
4
|
+
*
|
|
5
|
+
* Provides zero-knowledge privacy features for the wallet SDK.
|
|
6
|
+
* Completely independent from savings features.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { RailgunEngine, RailgunPrivacyWallet } from './privacy';
|
|
11
|
+
*
|
|
12
|
+
* // Initialize engine once
|
|
13
|
+
* await RailgunEngine.initialize({
|
|
14
|
+
* walletSource: 'mywallet',
|
|
15
|
+
* db,
|
|
16
|
+
* artifactStore,
|
|
17
|
+
* poiNodeURLs: ['...']
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Create privacy wallet
|
|
21
|
+
* const walletInfo = await RailgunPrivacyWallet.create(encryptionKey, mnemonic);
|
|
22
|
+
*
|
|
23
|
+
* // Use privacy features
|
|
24
|
+
* const wallet = await RailgunPrivacyWallet.load(encryptionKey, walletInfo.railgunWalletID);
|
|
25
|
+
* const shieldTx = await wallet.buildShield(...);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.BalanceBucket = exports.getPOIStandbyPeriod = exports.getSupportedChainIds = exports.getSupportedNetworks = exports.isChainIdSupported = exports.isNetworkSupported = exports.getNetworkConfigByChainId = exports.getNetworkConfig = exports.POI_STANDBY_PERIODS = exports.DEFAULT_POI_NODES = exports.RAILGUN_NETWORKS = exports.createBroadcasterFeeCallback = exports.BroadcasterClient = exports.POIHelper = exports.ArtifactManager = exports.RailgunPrivacyWallet = exports.RailgunEngine = void 0;
|
|
30
|
+
// Core classes
|
|
31
|
+
var railgun_engine_1 = require("./railgun-engine");
|
|
32
|
+
Object.defineProperty(exports, "RailgunEngine", { enumerable: true, get: function () { return railgun_engine_1.RailgunEngine; } });
|
|
33
|
+
var railgun_privacy_wallet_1 = require("./railgun-privacy-wallet");
|
|
34
|
+
Object.defineProperty(exports, "RailgunPrivacyWallet", { enumerable: true, get: function () { return railgun_privacy_wallet_1.RailgunPrivacyWallet; } });
|
|
35
|
+
var artifact_manager_1 = require("./artifact-manager");
|
|
36
|
+
Object.defineProperty(exports, "ArtifactManager", { enumerable: true, get: function () { return artifact_manager_1.ArtifactManager; } });
|
|
37
|
+
var poi_helper_1 = require("./poi-helper");
|
|
38
|
+
Object.defineProperty(exports, "POIHelper", { enumerable: true, get: function () { return poi_helper_1.POIHelper; } });
|
|
39
|
+
var broadcaster_client_1 = require("./broadcaster-client");
|
|
40
|
+
Object.defineProperty(exports, "BroadcasterClient", { enumerable: true, get: function () { return broadcaster_client_1.BroadcasterClient; } });
|
|
41
|
+
Object.defineProperty(exports, "createBroadcasterFeeCallback", { enumerable: true, get: function () { return broadcaster_client_1.createBroadcasterFeeCallback; } });
|
|
42
|
+
// Network configuration
|
|
43
|
+
var network_config_1 = require("./network-config");
|
|
44
|
+
Object.defineProperty(exports, "RAILGUN_NETWORKS", { enumerable: true, get: function () { return network_config_1.RAILGUN_NETWORKS; } });
|
|
45
|
+
Object.defineProperty(exports, "DEFAULT_POI_NODES", { enumerable: true, get: function () { return network_config_1.DEFAULT_POI_NODES; } });
|
|
46
|
+
Object.defineProperty(exports, "POI_STANDBY_PERIODS", { enumerable: true, get: function () { return network_config_1.POI_STANDBY_PERIODS; } });
|
|
47
|
+
Object.defineProperty(exports, "getNetworkConfig", { enumerable: true, get: function () { return network_config_1.getNetworkConfig; } });
|
|
48
|
+
Object.defineProperty(exports, "getNetworkConfigByChainId", { enumerable: true, get: function () { return network_config_1.getNetworkConfigByChainId; } });
|
|
49
|
+
Object.defineProperty(exports, "isNetworkSupported", { enumerable: true, get: function () { return network_config_1.isNetworkSupported; } });
|
|
50
|
+
Object.defineProperty(exports, "isChainIdSupported", { enumerable: true, get: function () { return network_config_1.isChainIdSupported; } });
|
|
51
|
+
Object.defineProperty(exports, "getSupportedNetworks", { enumerable: true, get: function () { return network_config_1.getSupportedNetworks; } });
|
|
52
|
+
Object.defineProperty(exports, "getSupportedChainIds", { enumerable: true, get: function () { return network_config_1.getSupportedChainIds; } });
|
|
53
|
+
Object.defineProperty(exports, "getPOIStandbyPeriod", { enumerable: true, get: function () { return network_config_1.getPOIStandbyPeriod; } });
|
|
54
|
+
var types_1 = require("./types");
|
|
55
|
+
Object.defineProperty(exports, "BalanceBucket", { enumerable: true, get: function () { return types_1.BalanceBucket; } });
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/privacy/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,eAAe;AACf,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,2DAAuF;AAA9E,uHAAA,iBAAiB,OAAA;AAAE,kIAAA,4BAA4B,OAAA;AAExD,wBAAwB;AACxB,mDAW0B;AAVxB,kHAAA,gBAAgB,OAAA;AAChB,mHAAA,iBAAiB,OAAA;AACjB,qHAAA,mBAAmB,OAAA;AACnB,kHAAA,gBAAgB,OAAA;AAChB,2HAAA,yBAAyB,OAAA;AACzB,oHAAA,kBAAkB,OAAA;AAClB,oHAAA,kBAAkB,OAAA;AAClB,sHAAA,oBAAoB,OAAA;AACpB,sHAAA,oBAAoB,OAAA;AACpB,qHAAA,mBAAmB,OAAA;AA8BrB,iCAAwC;AAA/B,sGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAILGUN Network Configurations
|
|
3
|
+
*
|
|
4
|
+
* Defines all supported RAILGUN networks with their deployment information.
|
|
5
|
+
* Based on official RAILGUN deployments as of 2024.
|
|
6
|
+
*
|
|
7
|
+
* Supported Networks:
|
|
8
|
+
* - Ethereum Mainnet
|
|
9
|
+
* - Polygon (Matic)
|
|
10
|
+
* - BNB Chain (BSC)
|
|
11
|
+
* - Arbitrum One
|
|
12
|
+
*/
|
|
13
|
+
import { NetworkName } from '@railgun-community/shared-models';
|
|
14
|
+
import { RailgunNetworkConfig } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* All RAILGUN supported networks
|
|
17
|
+
*/
|
|
18
|
+
export declare const RAILGUN_NETWORKS: Record<string, RailgunNetworkConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Get RAILGUN network config by NetworkName
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNetworkConfig(network: NetworkName): RailgunNetworkConfig | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get RAILGUN network config by chain ID
|
|
25
|
+
*/
|
|
26
|
+
export declare function getNetworkConfigByChainId(chainId: number): RailgunNetworkConfig | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a network is supported by RAILGUN
|
|
29
|
+
*/
|
|
30
|
+
export declare function isNetworkSupported(network: NetworkName): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a chain ID is supported by RAILGUN
|
|
33
|
+
*/
|
|
34
|
+
export declare function isChainIdSupported(chainId: number): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get all supported NetworkName values
|
|
37
|
+
*/
|
|
38
|
+
export declare function getSupportedNetworks(): NetworkName[];
|
|
39
|
+
/**
|
|
40
|
+
* Get all supported chain IDs
|
|
41
|
+
*/
|
|
42
|
+
export declare function getSupportedChainIds(): number[];
|
|
43
|
+
/**
|
|
44
|
+
* Default POI (Proof of Innocence) aggregator nodes
|
|
45
|
+
*/
|
|
46
|
+
export declare const DEFAULT_POI_NODES: string[];
|
|
47
|
+
/**
|
|
48
|
+
* POI standby periods (in milliseconds)
|
|
49
|
+
*/
|
|
50
|
+
export declare const POI_STANDBY_PERIODS: {
|
|
51
|
+
mainnet: number;
|
|
52
|
+
testnet: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Get POI standby period for a network
|
|
56
|
+
*/
|
|
57
|
+
export declare function getPOIStandbyPeriod(network: NetworkName): number;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RAILGUN Network Configurations
|
|
4
|
+
*
|
|
5
|
+
* Defines all supported RAILGUN networks with their deployment information.
|
|
6
|
+
* Based on official RAILGUN deployments as of 2024.
|
|
7
|
+
*
|
|
8
|
+
* Supported Networks:
|
|
9
|
+
* - Ethereum Mainnet
|
|
10
|
+
* - Polygon (Matic)
|
|
11
|
+
* - BNB Chain (BSC)
|
|
12
|
+
* - Arbitrum One
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.POI_STANDBY_PERIODS = exports.DEFAULT_POI_NODES = exports.RAILGUN_NETWORKS = void 0;
|
|
16
|
+
exports.getNetworkConfig = getNetworkConfig;
|
|
17
|
+
exports.getNetworkConfigByChainId = getNetworkConfigByChainId;
|
|
18
|
+
exports.isNetworkSupported = isNetworkSupported;
|
|
19
|
+
exports.isChainIdSupported = isChainIdSupported;
|
|
20
|
+
exports.getSupportedNetworks = getSupportedNetworks;
|
|
21
|
+
exports.getSupportedChainIds = getSupportedChainIds;
|
|
22
|
+
exports.getPOIStandbyPeriod = getPOIStandbyPeriod;
|
|
23
|
+
const shared_models_1 = require("@railgun-community/shared-models");
|
|
24
|
+
/**
|
|
25
|
+
* All RAILGUN supported networks
|
|
26
|
+
*/
|
|
27
|
+
exports.RAILGUN_NETWORKS = {
|
|
28
|
+
ethereum: {
|
|
29
|
+
name: shared_models_1.NetworkName.Ethereum,
|
|
30
|
+
chainId: 1,
|
|
31
|
+
publicName: 'Ethereum',
|
|
32
|
+
deploymentBlock: 15725700, // Approximate RAILGUN deployment block
|
|
33
|
+
},
|
|
34
|
+
polygon: {
|
|
35
|
+
name: shared_models_1.NetworkName.Polygon,
|
|
36
|
+
chainId: 137,
|
|
37
|
+
publicName: 'Polygon',
|
|
38
|
+
deploymentBlock: 34715800, // Approximate RAILGUN deployment block
|
|
39
|
+
},
|
|
40
|
+
bsc: {
|
|
41
|
+
name: shared_models_1.NetworkName.BNBChain,
|
|
42
|
+
chainId: 56,
|
|
43
|
+
publicName: 'BNB Chain',
|
|
44
|
+
deploymentBlock: 22550000, // Approximate RAILGUN deployment block
|
|
45
|
+
},
|
|
46
|
+
arbitrum: {
|
|
47
|
+
name: shared_models_1.NetworkName.Arbitrum,
|
|
48
|
+
chainId: 42161,
|
|
49
|
+
publicName: 'Arbitrum One',
|
|
50
|
+
deploymentBlock: 36070000, // Approximate RAILGUN deployment block
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Get RAILGUN network config by NetworkName
|
|
55
|
+
*/
|
|
56
|
+
function getNetworkConfig(network) {
|
|
57
|
+
return Object.values(exports.RAILGUN_NETWORKS).find(config => config.name === network);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get RAILGUN network config by chain ID
|
|
61
|
+
*/
|
|
62
|
+
function getNetworkConfigByChainId(chainId) {
|
|
63
|
+
return Object.values(exports.RAILGUN_NETWORKS).find(config => config.chainId === chainId);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check if a network is supported by RAILGUN
|
|
67
|
+
*/
|
|
68
|
+
function isNetworkSupported(network) {
|
|
69
|
+
return !!getNetworkConfig(network);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if a chain ID is supported by RAILGUN
|
|
73
|
+
*/
|
|
74
|
+
function isChainIdSupported(chainId) {
|
|
75
|
+
return !!getNetworkConfigByChainId(chainId);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get all supported NetworkName values
|
|
79
|
+
*/
|
|
80
|
+
function getSupportedNetworks() {
|
|
81
|
+
return Object.values(exports.RAILGUN_NETWORKS).map(config => config.name);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get all supported chain IDs
|
|
85
|
+
*/
|
|
86
|
+
function getSupportedChainIds() {
|
|
87
|
+
return Object.values(exports.RAILGUN_NETWORKS).map(config => config.chainId);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Default POI (Proof of Innocence) aggregator nodes
|
|
91
|
+
*/
|
|
92
|
+
exports.DEFAULT_POI_NODES = [
|
|
93
|
+
'https://ppoi-agg.horsewithsixlegs.xyz', // Test/development node
|
|
94
|
+
// Add production POI nodes here when available
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* POI standby periods (in milliseconds)
|
|
98
|
+
*/
|
|
99
|
+
exports.POI_STANDBY_PERIODS = {
|
|
100
|
+
mainnet: 60 * 60 * 1000, // 1 hour
|
|
101
|
+
testnet: 5 * 60 * 1000, // 5 minutes
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Get POI standby period for a network
|
|
105
|
+
*/
|
|
106
|
+
function getPOIStandbyPeriod(network) {
|
|
107
|
+
// Testnets have shorter periods
|
|
108
|
+
const testnets = [
|
|
109
|
+
shared_models_1.NetworkName.EthereumGoerli,
|
|
110
|
+
shared_models_1.NetworkName.EthereumSepolia,
|
|
111
|
+
shared_models_1.NetworkName.PolygonMumbai,
|
|
112
|
+
shared_models_1.NetworkName.ArbitrumGoerli,
|
|
113
|
+
];
|
|
114
|
+
return testnets.includes(network)
|
|
115
|
+
? exports.POI_STANDBY_PERIODS.testnet
|
|
116
|
+
: exports.POI_STANDBY_PERIODS.mainnet;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=network-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-config.js","sourceRoot":"","sources":["../../utils/privacy/network-config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAyCH,4CAEC;AAKD,8DAEC;AAKD,gDAEC;AAKD,gDAEC;AAKD,oDAEC;AAKD,oDAEC;AAqBD,kDAYC;AA7GD,oEAA+D;AAG/D;;GAEG;AACU,QAAA,gBAAgB,GAAyC;IACpE,QAAQ,EAAE;QACR,IAAI,EAAE,2BAAW,CAAC,QAAQ;QAC1B,OAAO,EAAE,CAAC;QACV,UAAU,EAAE,UAAU;QACtB,eAAe,EAAE,QAAQ,EAAE,uCAAuC;KACnE;IAED,OAAO,EAAE;QACP,IAAI,EAAE,2BAAW,CAAC,OAAO;QACzB,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE,SAAS;QACrB,eAAe,EAAE,QAAQ,EAAE,uCAAuC;KACnE;IAED,GAAG,EAAE;QACH,IAAI,EAAE,2BAAW,CAAC,QAAQ;QAC1B,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,WAAW;QACvB,eAAe,EAAE,QAAQ,EAAE,uCAAuC;KACnE;IAED,QAAQ,EAAE;QACR,IAAI,EAAE,2BAAW,CAAC,QAAQ;QAC1B,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,cAAc;QAC1B,eAAe,EAAE,QAAQ,EAAE,uCAAuC;KACnE;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAoB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;AACjF,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,OAAe;IACvD,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAoB;IACrD,OAAO,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,CAAC,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,wBAAgB,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACvE,CAAC;AAED;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,uCAAuC,EAAE,wBAAwB;IACjE,+CAA+C;CAChD,CAAC;AAEF;;GAEG;AACU,QAAA,mBAAmB,GAAG;IACjC,OAAO,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,SAAS;IAClC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAG,YAAY;CACtC,CAAC;AAEF;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAAoB;IACtD,gCAAgC;IAChC,MAAM,QAAQ,GAAG;QACf,2BAAW,CAAC,cAAc;QAC1B,2BAAW,CAAC,eAAe;QAC3B,2BAAW,CAAC,aAAa;QACzB,2BAAW,CAAC,cAAc;KAC3B,CAAC;IAEF,OAAO,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/B,CAAC,CAAC,2BAAmB,CAAC,OAAO;QAC7B,CAAC,CAAC,2BAAmB,CAAC,OAAO,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RAILGUN POI (Proof of Innocence) Helper
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for checking POI status and fund spendability.
|
|
5
|
+
*
|
|
6
|
+
* Key Concepts:
|
|
7
|
+
* - After shielding, funds enter a 1-hour "standby period" on mainnet (5 min on testnets)
|
|
8
|
+
* - During standby, funds are "ShieldPending" and cannot be spent
|
|
9
|
+
* - After standby, funds become "Spendable" if POI is valid
|
|
10
|
+
* - Funds can also be in other states (ShieldBlocked, MissingPOI, etc.)
|
|
11
|
+
*/
|
|
12
|
+
import { NetworkName } from '@railgun-community/shared-models';
|
|
13
|
+
import { BalanceBucket, POISpendabilityResult, PrivateBalance } from './types';
|
|
14
|
+
/**
|
|
15
|
+
* POIHelper
|
|
16
|
+
*
|
|
17
|
+
* Stateless utilities for POI status checking.
|
|
18
|
+
*/
|
|
19
|
+
export declare class POIHelper {
|
|
20
|
+
/**
|
|
21
|
+
* Check if funds are spendable
|
|
22
|
+
*
|
|
23
|
+
* A balance is spendable if it's in the "Spendable" bucket.
|
|
24
|
+
*
|
|
25
|
+
* @param balance - Private balance to check
|
|
26
|
+
* @returns true if spendable, false otherwise
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
31
|
+
* const spendable = balances.filter(b => POIHelper.isSpendable(b));
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
static isSpendable(balance: PrivateBalance): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Check if funds are in standby period
|
|
37
|
+
*
|
|
38
|
+
* @param balance - Private balance to check
|
|
39
|
+
* @returns true if in ShieldPending state
|
|
40
|
+
*/
|
|
41
|
+
static isInStandby(balance: PrivateBalance): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if funds are blocked
|
|
44
|
+
*
|
|
45
|
+
* @param balance - Private balance to check
|
|
46
|
+
* @returns true if in ShieldBlocked state
|
|
47
|
+
*/
|
|
48
|
+
static isBlocked(balance: PrivateBalance): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Check if funds have POI issues
|
|
51
|
+
*
|
|
52
|
+
* @param balance - Private balance to check
|
|
53
|
+
* @returns true if missing internal or external POI
|
|
54
|
+
*/
|
|
55
|
+
static hasPOIIssue(balance: PrivateBalance): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get detailed spendability status
|
|
58
|
+
*
|
|
59
|
+
* Returns comprehensive information about whether funds can be spent
|
|
60
|
+
* and when they will become available.
|
|
61
|
+
*
|
|
62
|
+
* @param balance - Private balance to check
|
|
63
|
+
* @param network - Network name
|
|
64
|
+
* @param shieldTimestamp - When funds were shielded (milliseconds since epoch)
|
|
65
|
+
* @returns Detailed spendability result
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const result = POIHelper.getSpendabilityStatus(
|
|
70
|
+
* balance,
|
|
71
|
+
* NetworkName.Ethereum,
|
|
72
|
+
* Date.now() - (30 * 60 * 1000) // Shielded 30 minutes ago
|
|
73
|
+
* );
|
|
74
|
+
*
|
|
75
|
+
* if (!result.isSpendable && result.remainingTime) {
|
|
76
|
+
* console.log(`Wait ${result.remainingTime / 1000 / 60} more minutes`);
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
static getSpendabilityStatus(balance: PrivateBalance, network: NetworkName, shieldTimestamp?: number): POISpendabilityResult;
|
|
81
|
+
/**
|
|
82
|
+
* Filter balances to only spendable ones
|
|
83
|
+
*
|
|
84
|
+
* @param balances - Array of private balances
|
|
85
|
+
* @returns Only spendable balances
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const allBalances = await wallet.getBalances(NetworkName.Ethereum);
|
|
90
|
+
* const spendable = POIHelper.filterSpendable(allBalances);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
static filterSpendable(balances: PrivateBalance[]): PrivateBalance[];
|
|
94
|
+
/**
|
|
95
|
+
* Get total spendable amount for a token
|
|
96
|
+
*
|
|
97
|
+
* Sums up all spendable balances for a specific token address.
|
|
98
|
+
*
|
|
99
|
+
* @param balances - Array of private balances
|
|
100
|
+
* @param tokenAddress - Token contract address
|
|
101
|
+
* @returns Total spendable amount as bigint
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
106
|
+
* const usdcSpendable = POIHelper.getTotalSpendable(balances, USDC_ADDRESS);
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
static getTotalSpendable(balances: PrivateBalance[], tokenAddress: string): bigint;
|
|
110
|
+
/**
|
|
111
|
+
* Get total amount by bucket
|
|
112
|
+
*
|
|
113
|
+
* Sums balances grouped by bucket category.
|
|
114
|
+
*
|
|
115
|
+
* @param balances - Array of private balances
|
|
116
|
+
* @returns Map of bucket to total amount
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
121
|
+
* const byBucket = POIHelper.getTotalsByBucket(balances);
|
|
122
|
+
*
|
|
123
|
+
* console.log(`Spendable: ${byBucket.get(BalanceBucket.Spendable)}`);
|
|
124
|
+
* console.log(`Pending: ${byBucket.get(BalanceBucket.ShieldPending)}`);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
static getTotalsByBucket(balances: PrivateBalance[]): Map<BalanceBucket, bigint>;
|
|
128
|
+
/**
|
|
129
|
+
* Estimate time until all balances are spendable
|
|
130
|
+
*
|
|
131
|
+
* Calculates the maximum remaining standby time across all pending balances.
|
|
132
|
+
*
|
|
133
|
+
* @param balances - Array of private balances
|
|
134
|
+
* @param network - Network name
|
|
135
|
+
* @param shieldTimestamps - Map of balance index to shield timestamp
|
|
136
|
+
* @returns Milliseconds until last balance becomes spendable (0 if all spendable)
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* const maxWait = POIHelper.estimateTimeUntilSpendable(
|
|
141
|
+
* balances,
|
|
142
|
+
* NetworkName.Ethereum,
|
|
143
|
+
* shieldTimestamps
|
|
144
|
+
* );
|
|
145
|
+
*
|
|
146
|
+
* if (maxWait > 0) {
|
|
147
|
+
* console.log(`Wait ${maxWait / 1000 / 60} minutes for all funds`);
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
static estimateTimeUntilSpendable(balances: PrivateBalance[], network: NetworkName, shieldTimestamps: Map<number, number>): number;
|
|
152
|
+
/**
|
|
153
|
+
* Format bucket name for display
|
|
154
|
+
*
|
|
155
|
+
* Converts BalanceBucket enum to human-readable string.
|
|
156
|
+
*
|
|
157
|
+
* @param bucket - Balance bucket
|
|
158
|
+
* @returns Human-readable description
|
|
159
|
+
*/
|
|
160
|
+
static formatBucketName(bucket: BalanceBucket): string;
|
|
161
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* RAILGUN POI (Proof of Innocence) Helper
|
|
4
|
+
*
|
|
5
|
+
* Provides utilities for checking POI status and fund spendability.
|
|
6
|
+
*
|
|
7
|
+
* Key Concepts:
|
|
8
|
+
* - After shielding, funds enter a 1-hour "standby period" on mainnet (5 min on testnets)
|
|
9
|
+
* - During standby, funds are "ShieldPending" and cannot be spent
|
|
10
|
+
* - After standby, funds become "Spendable" if POI is valid
|
|
11
|
+
* - Funds can also be in other states (ShieldBlocked, MissingPOI, etc.)
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.POIHelper = void 0;
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
const network_config_1 = require("./network-config");
|
|
17
|
+
/**
|
|
18
|
+
* POIHelper
|
|
19
|
+
*
|
|
20
|
+
* Stateless utilities for POI status checking.
|
|
21
|
+
*/
|
|
22
|
+
class POIHelper {
|
|
23
|
+
/**
|
|
24
|
+
* Check if funds are spendable
|
|
25
|
+
*
|
|
26
|
+
* A balance is spendable if it's in the "Spendable" bucket.
|
|
27
|
+
*
|
|
28
|
+
* @param balance - Private balance to check
|
|
29
|
+
* @returns true if spendable, false otherwise
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
34
|
+
* const spendable = balances.filter(b => POIHelper.isSpendable(b));
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
static isSpendable(balance) {
|
|
38
|
+
return balance.bucket === types_1.BalanceBucket.Spendable;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if funds are in standby period
|
|
42
|
+
*
|
|
43
|
+
* @param balance - Private balance to check
|
|
44
|
+
* @returns true if in ShieldPending state
|
|
45
|
+
*/
|
|
46
|
+
static isInStandby(balance) {
|
|
47
|
+
return balance.bucket === types_1.BalanceBucket.ShieldPending;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if funds are blocked
|
|
51
|
+
*
|
|
52
|
+
* @param balance - Private balance to check
|
|
53
|
+
* @returns true if in ShieldBlocked state
|
|
54
|
+
*/
|
|
55
|
+
static isBlocked(balance) {
|
|
56
|
+
return balance.bucket === types_1.BalanceBucket.ShieldBlocked;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if funds have POI issues
|
|
60
|
+
*
|
|
61
|
+
* @param balance - Private balance to check
|
|
62
|
+
* @returns true if missing internal or external POI
|
|
63
|
+
*/
|
|
64
|
+
static hasPOIIssue(balance) {
|
|
65
|
+
return (balance.bucket === types_1.BalanceBucket.MissingInternalPOI ||
|
|
66
|
+
balance.bucket === types_1.BalanceBucket.MissingExternalPOI);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get detailed spendability status
|
|
70
|
+
*
|
|
71
|
+
* Returns comprehensive information about whether funds can be spent
|
|
72
|
+
* and when they will become available.
|
|
73
|
+
*
|
|
74
|
+
* @param balance - Private balance to check
|
|
75
|
+
* @param network - Network name
|
|
76
|
+
* @param shieldTimestamp - When funds were shielded (milliseconds since epoch)
|
|
77
|
+
* @returns Detailed spendability result
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const result = POIHelper.getSpendabilityStatus(
|
|
82
|
+
* balance,
|
|
83
|
+
* NetworkName.Ethereum,
|
|
84
|
+
* Date.now() - (30 * 60 * 1000) // Shielded 30 minutes ago
|
|
85
|
+
* );
|
|
86
|
+
*
|
|
87
|
+
* if (!result.isSpendable && result.remainingTime) {
|
|
88
|
+
* console.log(`Wait ${result.remainingTime / 1000 / 60} more minutes`);
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
static getSpendabilityStatus(balance, network, shieldTimestamp) {
|
|
93
|
+
const bucket = balance.bucket;
|
|
94
|
+
// Already spendable
|
|
95
|
+
if (bucket === types_1.BalanceBucket.Spendable) {
|
|
96
|
+
return {
|
|
97
|
+
isSpendable: true,
|
|
98
|
+
bucket,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
// In standby period
|
|
102
|
+
if (bucket === types_1.BalanceBucket.ShieldPending && shieldTimestamp) {
|
|
103
|
+
const standbyPeriod = (0, network_config_1.getPOIStandbyPeriod)(network);
|
|
104
|
+
const elapsed = Date.now() - shieldTimestamp;
|
|
105
|
+
const remainingTime = Math.max(0, standbyPeriod - elapsed);
|
|
106
|
+
const estimatedSpendableAt = new Date(shieldTimestamp + standbyPeriod);
|
|
107
|
+
return {
|
|
108
|
+
isSpendable: false,
|
|
109
|
+
bucket,
|
|
110
|
+
remainingTime,
|
|
111
|
+
estimatedSpendableAt,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Other states (blocked, missing POI, etc.)
|
|
115
|
+
return {
|
|
116
|
+
isSpendable: false,
|
|
117
|
+
bucket,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Filter balances to only spendable ones
|
|
122
|
+
*
|
|
123
|
+
* @param balances - Array of private balances
|
|
124
|
+
* @returns Only spendable balances
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const allBalances = await wallet.getBalances(NetworkName.Ethereum);
|
|
129
|
+
* const spendable = POIHelper.filterSpendable(allBalances);
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
static filterSpendable(balances) {
|
|
133
|
+
return balances.filter(b => this.isSpendable(b));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get total spendable amount for a token
|
|
137
|
+
*
|
|
138
|
+
* Sums up all spendable balances for a specific token address.
|
|
139
|
+
*
|
|
140
|
+
* @param balances - Array of private balances
|
|
141
|
+
* @param tokenAddress - Token contract address
|
|
142
|
+
* @returns Total spendable amount as bigint
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
147
|
+
* const usdcSpendable = POIHelper.getTotalSpendable(balances, USDC_ADDRESS);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
static getTotalSpendable(balances, tokenAddress) {
|
|
151
|
+
return balances
|
|
152
|
+
.filter(b => b.tokenAddress.toLowerCase() === tokenAddress.toLowerCase())
|
|
153
|
+
.filter(b => this.isSpendable(b))
|
|
154
|
+
.reduce((sum, b) => sum + b.amount, 0n);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get total amount by bucket
|
|
158
|
+
*
|
|
159
|
+
* Sums balances grouped by bucket category.
|
|
160
|
+
*
|
|
161
|
+
* @param balances - Array of private balances
|
|
162
|
+
* @returns Map of bucket to total amount
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const balances = await wallet.getBalances(NetworkName.Ethereum);
|
|
167
|
+
* const byBucket = POIHelper.getTotalsByBucket(balances);
|
|
168
|
+
*
|
|
169
|
+
* console.log(`Spendable: ${byBucket.get(BalanceBucket.Spendable)}`);
|
|
170
|
+
* console.log(`Pending: ${byBucket.get(BalanceBucket.ShieldPending)}`);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
static getTotalsByBucket(balances) {
|
|
174
|
+
const totals = new Map();
|
|
175
|
+
for (const balance of balances) {
|
|
176
|
+
const current = totals.get(balance.bucket) || 0n;
|
|
177
|
+
totals.set(balance.bucket, current + balance.amount);
|
|
178
|
+
}
|
|
179
|
+
return totals;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Estimate time until all balances are spendable
|
|
183
|
+
*
|
|
184
|
+
* Calculates the maximum remaining standby time across all pending balances.
|
|
185
|
+
*
|
|
186
|
+
* @param balances - Array of private balances
|
|
187
|
+
* @param network - Network name
|
|
188
|
+
* @param shieldTimestamps - Map of balance index to shield timestamp
|
|
189
|
+
* @returns Milliseconds until last balance becomes spendable (0 if all spendable)
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* const maxWait = POIHelper.estimateTimeUntilSpendable(
|
|
194
|
+
* balances,
|
|
195
|
+
* NetworkName.Ethereum,
|
|
196
|
+
* shieldTimestamps
|
|
197
|
+
* );
|
|
198
|
+
*
|
|
199
|
+
* if (maxWait > 0) {
|
|
200
|
+
* console.log(`Wait ${maxWait / 1000 / 60} minutes for all funds`);
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
static estimateTimeUntilSpendable(balances, network, shieldTimestamps) {
|
|
205
|
+
let maxRemaining = 0;
|
|
206
|
+
balances.forEach((balance, index) => {
|
|
207
|
+
if (balance.bucket === types_1.BalanceBucket.ShieldPending) {
|
|
208
|
+
const shieldTime = shieldTimestamps.get(index);
|
|
209
|
+
if (shieldTime) {
|
|
210
|
+
const status = this.getSpendabilityStatus(balance, network, shieldTime);
|
|
211
|
+
if (status.remainingTime) {
|
|
212
|
+
maxRemaining = Math.max(maxRemaining, status.remainingTime);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return maxRemaining;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Format bucket name for display
|
|
221
|
+
*
|
|
222
|
+
* Converts BalanceBucket enum to human-readable string.
|
|
223
|
+
*
|
|
224
|
+
* @param bucket - Balance bucket
|
|
225
|
+
* @returns Human-readable description
|
|
226
|
+
*/
|
|
227
|
+
static formatBucketName(bucket) {
|
|
228
|
+
switch (bucket) {
|
|
229
|
+
case types_1.BalanceBucket.Spendable:
|
|
230
|
+
return 'Ready to spend';
|
|
231
|
+
case types_1.BalanceBucket.ShieldPending:
|
|
232
|
+
return 'Pending (standby period)';
|
|
233
|
+
case types_1.BalanceBucket.ShieldBlocked:
|
|
234
|
+
return 'Blocked';
|
|
235
|
+
case types_1.BalanceBucket.ProofSubmitted:
|
|
236
|
+
return 'Proof submitted';
|
|
237
|
+
case types_1.BalanceBucket.MissingInternalPOI:
|
|
238
|
+
return 'Missing internal POI';
|
|
239
|
+
case types_1.BalanceBucket.MissingExternalPOI:
|
|
240
|
+
return 'Missing external POI';
|
|
241
|
+
case types_1.BalanceBucket.Spent:
|
|
242
|
+
return 'Already spent';
|
|
243
|
+
default:
|
|
244
|
+
return 'Unknown status';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.POIHelper = POIHelper;
|
|
249
|
+
//# sourceMappingURL=poi-helper.js.map
|