@sip-protocol/sdk 0.7.0 → 0.7.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/browser.d.mts +2 -1
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +5717 -4963
- package/dist/browser.mjs +94 -46
- package/dist/chunk-6WGN57S2.mjs +218 -0
- package/dist/chunk-DLDWZFYC.mjs +1495 -0
- package/dist/chunk-E6SZWREQ.mjs +57 -0
- package/dist/chunk-G33LB27A.mjs +16166 -0
- package/dist/chunk-HOR7PM3M.mjs +15 -0
- package/dist/chunk-L2K34JCU.mjs +1496 -0
- package/dist/chunk-SN4ZDTVW.mjs +16166 -0
- package/dist/constants-VOI7BSLK.mjs +27 -0
- package/dist/index-CHB3KuOB.d.mts +11859 -0
- package/dist/index-CzWPI6Le.d.ts +11859 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5684 -4933
- package/dist/index.mjs +91 -43
- package/dist/proofs/noir.mjs +4 -2
- package/dist/solana-5EMCTPTS.mjs +46 -0
- package/dist/solana-Q4NAVBTS.mjs +46 -0
- package/package.json +18 -16
- package/src/chains/solana/constants.ts +101 -0
- package/src/chains/solana/index.ts +87 -0
- package/src/chains/solana/scan.ts +382 -0
- package/src/chains/solana/transfer.ts +266 -0
- package/src/chains/solana/types.ts +169 -0
- package/src/executors/index.ts +18 -0
- package/src/executors/same-chain.ts +154 -0
- package/src/index.ts +58 -1
- package/src/sip.ts +127 -0
- package/LICENSE +0 -21
package/dist/browser.mjs
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
SettlementRegistry,
|
|
53
53
|
SettlementRegistryError,
|
|
54
54
|
SmartRouter,
|
|
55
|
+
SolanaSameChainExecutor,
|
|
55
56
|
SolanaWalletAdapter,
|
|
56
57
|
SuiStealthService,
|
|
57
58
|
SwapStatus,
|
|
@@ -74,9 +75,7 @@ import {
|
|
|
74
75
|
base58ToHex,
|
|
75
76
|
bytesToHex,
|
|
76
77
|
checkAptosStealthAddress,
|
|
77
|
-
checkEd25519StealthAddress,
|
|
78
78
|
checkMobileWASMCompatibility,
|
|
79
|
-
checkStealthAddress,
|
|
80
79
|
checkSuiStealthAddress,
|
|
81
80
|
commit,
|
|
82
81
|
commitZero,
|
|
@@ -101,6 +100,7 @@ import {
|
|
|
101
100
|
createPrivateVoting,
|
|
102
101
|
createProductionSIP,
|
|
103
102
|
createSIP,
|
|
103
|
+
createSameChainExecutor,
|
|
104
104
|
createSealedBidAuction,
|
|
105
105
|
createShieldedIntent,
|
|
106
106
|
createShieldedPayment,
|
|
@@ -113,14 +113,11 @@ import {
|
|
|
113
113
|
createZcashNativeBackend,
|
|
114
114
|
createZcashShieldedService,
|
|
115
115
|
createZcashSwapService,
|
|
116
|
-
decodeStealthMetaAddress,
|
|
117
116
|
decodeTaprootAddress,
|
|
118
117
|
decryptMemo,
|
|
119
118
|
decryptWithViewing,
|
|
120
119
|
deriveAptosStealthPrivateKey,
|
|
121
|
-
deriveEd25519StealthPrivateKey,
|
|
122
120
|
deriveOracleId,
|
|
123
|
-
deriveStealthPrivateKey,
|
|
124
121
|
deriveSuiStealthPrivateKey,
|
|
125
122
|
deriveViewingKey,
|
|
126
123
|
deserializeAttestationMessage,
|
|
@@ -131,10 +128,7 @@ import {
|
|
|
131
128
|
detectMobilePlatform,
|
|
132
129
|
detectSolanaWallets,
|
|
133
130
|
ed25519PublicKeyToAptosAddress,
|
|
134
|
-
ed25519PublicKeyToNearAddress,
|
|
135
|
-
ed25519PublicKeyToSolanaAddress,
|
|
136
131
|
ed25519PublicKeyToSuiAddress,
|
|
137
|
-
encodeStealthMetaAddress,
|
|
138
132
|
encryptForViewing,
|
|
139
133
|
featureNotSupportedError,
|
|
140
134
|
formatStablecoinAmount,
|
|
@@ -144,13 +138,9 @@ import {
|
|
|
144
138
|
generateBlinding,
|
|
145
139
|
generateCosmosStealthAddress,
|
|
146
140
|
generateCosmosStealthMetaAddress,
|
|
147
|
-
generateEd25519StealthAddress,
|
|
148
|
-
generateEd25519StealthMetaAddress,
|
|
149
141
|
generateIntentId,
|
|
150
142
|
generatePdfReport,
|
|
151
143
|
generateRandomBytes,
|
|
152
|
-
generateStealthAddress,
|
|
153
|
-
generateStealthMetaAddress,
|
|
154
144
|
generateSuiStealthAddress,
|
|
155
145
|
generateViewingKey,
|
|
156
146
|
getActiveOracles,
|
|
@@ -159,7 +149,6 @@ import {
|
|
|
159
149
|
getBrowserVersion,
|
|
160
150
|
getChainNumericId,
|
|
161
151
|
getChainsForStablecoin,
|
|
162
|
-
getCurveForChain,
|
|
163
152
|
getDefaultRpcEndpoint,
|
|
164
153
|
getDerivationPath,
|
|
165
154
|
getEthereumProvider,
|
|
@@ -175,6 +164,7 @@ import {
|
|
|
175
164
|
getStablecoin,
|
|
176
165
|
getStablecoinInfo,
|
|
177
166
|
getStablecoinsForChain,
|
|
167
|
+
getSupportedSameChainChains,
|
|
178
168
|
getSupportedStablecoins,
|
|
179
169
|
getTimeRemaining,
|
|
180
170
|
getXOnlyPublicKey,
|
|
@@ -184,52 +174,32 @@ import {
|
|
|
184
174
|
hexToBytes,
|
|
185
175
|
hexToNumber,
|
|
186
176
|
isBrowser,
|
|
187
|
-
isEd25519Chain,
|
|
188
177
|
isExpired,
|
|
189
|
-
isNonNegativeAmount,
|
|
190
178
|
isPaymentExpired,
|
|
191
179
|
isPrivate,
|
|
192
180
|
isPrivateWalletAdapter,
|
|
181
|
+
isSameChainSupported,
|
|
193
182
|
isStablecoin,
|
|
194
183
|
isStablecoinOnChain,
|
|
195
184
|
isTablet,
|
|
196
|
-
isValidAmount,
|
|
197
185
|
isValidAptosAddress,
|
|
198
|
-
isValidChainId,
|
|
199
|
-
isValidCompressedPublicKey,
|
|
200
186
|
isValidCosmosAddress,
|
|
201
|
-
isValidEd25519PublicKey,
|
|
202
|
-
isValidHex,
|
|
203
|
-
isValidHexLength,
|
|
204
|
-
isValidNearAccountId,
|
|
205
|
-
isValidNearImplicitAddress,
|
|
206
|
-
isValidPrivacyLevel,
|
|
207
|
-
isValidPrivateKey,
|
|
208
|
-
isValidScalar,
|
|
209
|
-
isValidSlippage,
|
|
210
|
-
isValidSolanaAddress,
|
|
211
|
-
isValidStealthMetaAddress,
|
|
212
187
|
isValidSuiAddress,
|
|
213
188
|
isValidTaprootAddress,
|
|
214
|
-
nearAddressToEd25519PublicKey,
|
|
215
189
|
normalizeAddress,
|
|
216
190
|
normalizeSuiAddress,
|
|
217
191
|
notConnectedError,
|
|
218
192
|
proveOwnership,
|
|
219
|
-
publicKeyToEthAddress,
|
|
220
193
|
registerWallet,
|
|
221
194
|
removeOracle,
|
|
222
195
|
schnorrSign,
|
|
223
196
|
schnorrSignHex,
|
|
224
197
|
schnorrVerify,
|
|
225
198
|
schnorrVerifyHex,
|
|
226
|
-
secureWipe,
|
|
227
|
-
secureWipeAll,
|
|
228
199
|
serializeAttestationMessage,
|
|
229
200
|
serializeIntent,
|
|
230
201
|
serializePayment,
|
|
231
202
|
signAttestationMessage,
|
|
232
|
-
solanaAddressToEd25519PublicKey,
|
|
233
203
|
solanaPublicKeyToHex,
|
|
234
204
|
stealthKeyToCosmosAddress,
|
|
235
205
|
subtractBlindings,
|
|
@@ -249,26 +219,73 @@ import {
|
|
|
249
219
|
trackIntent,
|
|
250
220
|
trackPayment,
|
|
251
221
|
updateOracleStatus,
|
|
252
|
-
validateAsset,
|
|
253
|
-
validateCreateIntentParams,
|
|
254
|
-
validateIntentInput,
|
|
255
|
-
validateIntentOutput,
|
|
256
|
-
validateScalar,
|
|
257
|
-
validateViewingKey,
|
|
258
222
|
verifyAttestation,
|
|
259
223
|
verifyCommitment,
|
|
260
224
|
verifyOpening,
|
|
261
225
|
verifyOracleSignature,
|
|
262
226
|
verifyOwnership,
|
|
263
|
-
walletRegistry
|
|
264
|
-
|
|
265
|
-
withSecureBufferSync
|
|
266
|
-
} from "./chunk-3OVABDRH.mjs";
|
|
227
|
+
walletRegistry
|
|
228
|
+
} from "./chunk-G33LB27A.mjs";
|
|
267
229
|
import {
|
|
268
230
|
fulfillment_proof_default,
|
|
269
231
|
funding_proof_default,
|
|
270
232
|
validity_proof_default
|
|
271
233
|
} from "./chunk-3INS3PR5.mjs";
|
|
234
|
+
import {
|
|
235
|
+
ProofGenerationError
|
|
236
|
+
} from "./chunk-HOR7PM3M.mjs";
|
|
237
|
+
import {
|
|
238
|
+
checkEd25519StealthAddress,
|
|
239
|
+
checkStealthAddress,
|
|
240
|
+
claimStealthPayment,
|
|
241
|
+
createAnnouncementMemo,
|
|
242
|
+
decodeStealthMetaAddress,
|
|
243
|
+
deriveEd25519StealthPrivateKey,
|
|
244
|
+
deriveStealthPrivateKey,
|
|
245
|
+
ed25519PublicKeyToNearAddress,
|
|
246
|
+
ed25519PublicKeyToSolanaAddress,
|
|
247
|
+
encodeStealthMetaAddress,
|
|
248
|
+
estimatePrivateTransferFee,
|
|
249
|
+
generateEd25519StealthAddress,
|
|
250
|
+
generateEd25519StealthMetaAddress,
|
|
251
|
+
generateStealthAddress,
|
|
252
|
+
generateStealthMetaAddress,
|
|
253
|
+
getCurveForChain,
|
|
254
|
+
getStealthBalance,
|
|
255
|
+
hasTokenAccount,
|
|
256
|
+
isEd25519Chain,
|
|
257
|
+
isNonNegativeAmount,
|
|
258
|
+
isValidAmount,
|
|
259
|
+
isValidChainId,
|
|
260
|
+
isValidCompressedPublicKey,
|
|
261
|
+
isValidEd25519PublicKey,
|
|
262
|
+
isValidHex,
|
|
263
|
+
isValidHexLength,
|
|
264
|
+
isValidNearAccountId,
|
|
265
|
+
isValidNearImplicitAddress,
|
|
266
|
+
isValidPrivacyLevel,
|
|
267
|
+
isValidPrivateKey,
|
|
268
|
+
isValidScalar,
|
|
269
|
+
isValidSlippage,
|
|
270
|
+
isValidSolanaAddress,
|
|
271
|
+
isValidStealthMetaAddress,
|
|
272
|
+
nearAddressToEd25519PublicKey,
|
|
273
|
+
parseAnnouncement,
|
|
274
|
+
publicKeyToEthAddress,
|
|
275
|
+
scanForPayments,
|
|
276
|
+
secureWipe,
|
|
277
|
+
secureWipeAll,
|
|
278
|
+
sendPrivateSPLTransfer,
|
|
279
|
+
solanaAddressToEd25519PublicKey,
|
|
280
|
+
validateAsset,
|
|
281
|
+
validateCreateIntentParams,
|
|
282
|
+
validateIntentInput,
|
|
283
|
+
validateIntentOutput,
|
|
284
|
+
validateScalar,
|
|
285
|
+
validateViewingKey,
|
|
286
|
+
withSecureBuffer,
|
|
287
|
+
withSecureBufferSync
|
|
288
|
+
} from "./chunk-L2K34JCU.mjs";
|
|
272
289
|
import {
|
|
273
290
|
CryptoError,
|
|
274
291
|
EncryptionNotImplementedError,
|
|
@@ -276,7 +293,6 @@ import {
|
|
|
276
293
|
IntentError,
|
|
277
294
|
NetworkError,
|
|
278
295
|
ProofError,
|
|
279
|
-
ProofGenerationError,
|
|
280
296
|
ProofNotImplementedError,
|
|
281
297
|
SIPError,
|
|
282
298
|
ValidationError,
|
|
@@ -284,7 +300,18 @@ import {
|
|
|
284
300
|
hasErrorCode,
|
|
285
301
|
isSIPError,
|
|
286
302
|
wrapError
|
|
287
|
-
} from "./chunk-
|
|
303
|
+
} from "./chunk-6WGN57S2.mjs";
|
|
304
|
+
import {
|
|
305
|
+
MEMO_PROGRAM_ID,
|
|
306
|
+
SIP_MEMO_PREFIX,
|
|
307
|
+
SOLANA_EXPLORER_URLS,
|
|
308
|
+
SOLANA_RPC_ENDPOINTS,
|
|
309
|
+
SOLANA_TOKEN_DECIMALS,
|
|
310
|
+
SOLANA_TOKEN_MINTS,
|
|
311
|
+
getExplorerUrl,
|
|
312
|
+
getTokenDecimals,
|
|
313
|
+
getTokenMint
|
|
314
|
+
} from "./chunk-E6SZWREQ.mjs";
|
|
288
315
|
import "./chunk-UJCSKKID.mjs";
|
|
289
316
|
|
|
290
317
|
// src/proofs/browser.ts
|
|
@@ -1781,6 +1808,7 @@ export {
|
|
|
1781
1808
|
IntentError,
|
|
1782
1809
|
IntentStatus,
|
|
1783
1810
|
LedgerWalletAdapter,
|
|
1811
|
+
MEMO_PROGRAM_ID,
|
|
1784
1812
|
MockEthereumAdapter,
|
|
1785
1813
|
MockLedgerAdapter,
|
|
1786
1814
|
MockProofProvider,
|
|
@@ -1811,7 +1839,12 @@ export {
|
|
|
1811
1839
|
ReportStatus,
|
|
1812
1840
|
SIP,
|
|
1813
1841
|
SIPError,
|
|
1842
|
+
SIP_MEMO_PREFIX,
|
|
1814
1843
|
SIP_VERSION,
|
|
1844
|
+
SOLANA_EXPLORER_URLS,
|
|
1845
|
+
SOLANA_RPC_ENDPOINTS,
|
|
1846
|
+
SOLANA_TOKEN_DECIMALS,
|
|
1847
|
+
SOLANA_TOKEN_MINTS,
|
|
1815
1848
|
STABLECOIN_ADDRESSES,
|
|
1816
1849
|
STABLECOIN_DECIMALS,
|
|
1817
1850
|
STABLECOIN_INFO,
|
|
@@ -1819,6 +1852,7 @@ export {
|
|
|
1819
1852
|
SettlementRegistry,
|
|
1820
1853
|
SettlementRegistryError,
|
|
1821
1854
|
SmartRouter,
|
|
1855
|
+
SolanaSameChainExecutor,
|
|
1822
1856
|
SolanaWalletAdapter,
|
|
1823
1857
|
SuiStealthService,
|
|
1824
1858
|
SwapStatus,
|
|
@@ -1847,10 +1881,12 @@ export {
|
|
|
1847
1881
|
checkMobileWASMCompatibility,
|
|
1848
1882
|
checkStealthAddress,
|
|
1849
1883
|
checkSuiStealthAddress,
|
|
1884
|
+
claimStealthPayment,
|
|
1850
1885
|
commit,
|
|
1851
1886
|
commitZero,
|
|
1852
1887
|
computeAttestationHash,
|
|
1853
1888
|
computeTweakedKey,
|
|
1889
|
+
createAnnouncementMemo,
|
|
1854
1890
|
createCommitment,
|
|
1855
1891
|
createEthereumAdapter,
|
|
1856
1892
|
createKeySpendOnlyOutput,
|
|
@@ -1870,6 +1906,7 @@ export {
|
|
|
1870
1906
|
createPrivateVoting,
|
|
1871
1907
|
createProductionSIP,
|
|
1872
1908
|
createSIP,
|
|
1909
|
+
createSameChainExecutor,
|
|
1873
1910
|
createSealedBidAuction,
|
|
1874
1911
|
createShieldedIntent,
|
|
1875
1912
|
createShieldedPayment,
|
|
@@ -1906,6 +1943,7 @@ export {
|
|
|
1906
1943
|
ed25519PublicKeyToSuiAddress,
|
|
1907
1944
|
encodeStealthMetaAddress,
|
|
1908
1945
|
encryptForViewing,
|
|
1946
|
+
estimatePrivateTransferFee,
|
|
1909
1947
|
featureNotSupportedError,
|
|
1910
1948
|
formatStablecoinAmount,
|
|
1911
1949
|
fromHex,
|
|
@@ -1942,16 +1980,22 @@ export {
|
|
|
1942
1980
|
getPaymentTimeRemaining,
|
|
1943
1981
|
getPrivacyConfig,
|
|
1944
1982
|
getPrivacyDescription,
|
|
1983
|
+
getExplorerUrl as getSolanaExplorerUrl,
|
|
1945
1984
|
getSolanaProvider,
|
|
1946
1985
|
getStablecoin,
|
|
1947
1986
|
getStablecoinInfo,
|
|
1948
1987
|
getStablecoinsForChain,
|
|
1988
|
+
getStealthBalance,
|
|
1989
|
+
getSupportedSameChainChains,
|
|
1949
1990
|
getSupportedStablecoins,
|
|
1950
1991
|
getTimeRemaining,
|
|
1992
|
+
getTokenDecimals,
|
|
1993
|
+
getTokenMint,
|
|
1951
1994
|
getXOnlyPublicKey,
|
|
1952
1995
|
hasEnoughOracles,
|
|
1953
1996
|
hasErrorCode,
|
|
1954
1997
|
hasRequiredProofs,
|
|
1998
|
+
hasTokenAccount,
|
|
1955
1999
|
hash,
|
|
1956
2000
|
hexToNumber,
|
|
1957
2001
|
isBrowser,
|
|
@@ -1962,6 +2006,7 @@ export {
|
|
|
1962
2006
|
isPrivate,
|
|
1963
2007
|
isPrivateWalletAdapter,
|
|
1964
2008
|
isSIPError,
|
|
2009
|
+
isSameChainSupported,
|
|
1965
2010
|
isStablecoin,
|
|
1966
2011
|
isStablecoinOnChain,
|
|
1967
2012
|
isTablet,
|
|
@@ -1987,16 +2032,19 @@ export {
|
|
|
1987
2032
|
normalizeAddress,
|
|
1988
2033
|
normalizeSuiAddress,
|
|
1989
2034
|
notConnectedError,
|
|
2035
|
+
parseAnnouncement,
|
|
1990
2036
|
proveOwnership,
|
|
1991
2037
|
publicKeyToEthAddress,
|
|
1992
2038
|
registerWallet,
|
|
1993
2039
|
removeOracle,
|
|
2040
|
+
scanForPayments,
|
|
1994
2041
|
schnorrSign,
|
|
1995
2042
|
schnorrSignHex,
|
|
1996
2043
|
schnorrVerify,
|
|
1997
2044
|
schnorrVerifyHex,
|
|
1998
2045
|
secureWipe,
|
|
1999
2046
|
secureWipeAll,
|
|
2047
|
+
sendPrivateSPLTransfer,
|
|
2000
2048
|
serializeAttestationMessage,
|
|
2001
2049
|
serializeIntent,
|
|
2002
2050
|
serializePayment,
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
3
|
+
ErrorCode2["UNKNOWN"] = "SIP_1000";
|
|
4
|
+
ErrorCode2["INTERNAL"] = "SIP_1001";
|
|
5
|
+
ErrorCode2["NOT_IMPLEMENTED"] = "SIP_1002";
|
|
6
|
+
ErrorCode2["VALIDATION_FAILED"] = "SIP_2000";
|
|
7
|
+
ErrorCode2["INVALID_INPUT"] = "SIP_2001";
|
|
8
|
+
ErrorCode2["INVALID_CHAIN"] = "SIP_2002";
|
|
9
|
+
ErrorCode2["INVALID_PRIVACY_LEVEL"] = "SIP_2003";
|
|
10
|
+
ErrorCode2["INVALID_AMOUNT"] = "SIP_2004";
|
|
11
|
+
ErrorCode2["INVALID_HEX"] = "SIP_2005";
|
|
12
|
+
ErrorCode2["INVALID_KEY"] = "SIP_2006";
|
|
13
|
+
ErrorCode2["INVALID_ADDRESS"] = "SIP_2007";
|
|
14
|
+
ErrorCode2["MISSING_REQUIRED"] = "SIP_2008";
|
|
15
|
+
ErrorCode2["OUT_OF_RANGE"] = "SIP_2009";
|
|
16
|
+
ErrorCode2["CRYPTO_FAILED"] = "SIP_3000";
|
|
17
|
+
ErrorCode2["ENCRYPTION_FAILED"] = "SIP_3001";
|
|
18
|
+
ErrorCode2["DECRYPTION_FAILED"] = "SIP_3002";
|
|
19
|
+
ErrorCode2["KEY_DERIVATION_FAILED"] = "SIP_3003";
|
|
20
|
+
ErrorCode2["COMMITMENT_FAILED"] = "SIP_3004";
|
|
21
|
+
ErrorCode2["SIGNATURE_FAILED"] = "SIP_3005";
|
|
22
|
+
ErrorCode2["INVALID_CURVE_POINT"] = "SIP_3006";
|
|
23
|
+
ErrorCode2["INVALID_SCALAR"] = "SIP_3007";
|
|
24
|
+
ErrorCode2["INVALID_KEY_SIZE"] = "SIP_3008";
|
|
25
|
+
ErrorCode2["INVALID_ENCRYPTED_DATA"] = "SIP_3009";
|
|
26
|
+
ErrorCode2["INVALID_COMMITMENT"] = "SIP_3010";
|
|
27
|
+
ErrorCode2["INVALID_TIME_LOCK"] = "SIP_3011";
|
|
28
|
+
ErrorCode2["INVALID_SHARE"] = "SIP_3012";
|
|
29
|
+
ErrorCode2["INVALID_THRESHOLD"] = "SIP_3013";
|
|
30
|
+
ErrorCode2["CRYPTO_OPERATION_FAILED"] = "SIP_3014";
|
|
31
|
+
ErrorCode2["INVALID_FORMAT"] = "SIP_3015";
|
|
32
|
+
ErrorCode2["PROOF_FAILED"] = "SIP_4000";
|
|
33
|
+
ErrorCode2["PROOF_GENERATION_FAILED"] = "SIP_4001";
|
|
34
|
+
ErrorCode2["PROOF_VERIFICATION_FAILED"] = "SIP_4002";
|
|
35
|
+
ErrorCode2["PROOF_NOT_IMPLEMENTED"] = "SIP_4003";
|
|
36
|
+
ErrorCode2["PROOF_PROVIDER_NOT_READY"] = "SIP_4004";
|
|
37
|
+
ErrorCode2["INVALID_PROOF_PARAMS"] = "SIP_4005";
|
|
38
|
+
ErrorCode2["INTENT_FAILED"] = "SIP_5000";
|
|
39
|
+
ErrorCode2["INTENT_EXPIRED"] = "SIP_5001";
|
|
40
|
+
ErrorCode2["INTENT_CANCELLED"] = "SIP_5002";
|
|
41
|
+
ErrorCode2["INTENT_NOT_FOUND"] = "SIP_5003";
|
|
42
|
+
ErrorCode2["INTENT_INVALID_STATE"] = "SIP_5004";
|
|
43
|
+
ErrorCode2["PROOFS_REQUIRED"] = "SIP_5005";
|
|
44
|
+
ErrorCode2["QUOTE_EXPIRED"] = "SIP_5006";
|
|
45
|
+
ErrorCode2["NETWORK_FAILED"] = "SIP_6000";
|
|
46
|
+
ErrorCode2["NETWORK_TIMEOUT"] = "SIP_6001";
|
|
47
|
+
ErrorCode2["NETWORK_UNAVAILABLE"] = "SIP_6002";
|
|
48
|
+
ErrorCode2["RPC_ERROR"] = "SIP_6003";
|
|
49
|
+
ErrorCode2["API_ERROR"] = "SIP_6004";
|
|
50
|
+
ErrorCode2["RATE_LIMITED"] = "SIP_6005";
|
|
51
|
+
ErrorCode2["WALLET_ERROR"] = "SIP_7000";
|
|
52
|
+
ErrorCode2["WALLET_NOT_CONNECTED"] = "SIP_7001";
|
|
53
|
+
ErrorCode2["WALLET_CONNECTION_FAILED"] = "SIP_7002";
|
|
54
|
+
ErrorCode2["WALLET_SIGNING_FAILED"] = "SIP_7003";
|
|
55
|
+
ErrorCode2["WALLET_TRANSACTION_FAILED"] = "SIP_7004";
|
|
56
|
+
return ErrorCode2;
|
|
57
|
+
})(ErrorCode || {});
|
|
58
|
+
var SIPError = class extends Error {
|
|
59
|
+
/** Machine-readable error code */
|
|
60
|
+
code;
|
|
61
|
+
/** Additional debugging context */
|
|
62
|
+
context;
|
|
63
|
+
/** Timestamp when error was created */
|
|
64
|
+
timestamp;
|
|
65
|
+
constructor(message, code = "SIP_1000" /* UNKNOWN */, options) {
|
|
66
|
+
super(message, { cause: options?.cause });
|
|
67
|
+
this.name = "SIPError";
|
|
68
|
+
this.code = code;
|
|
69
|
+
this.context = options?.context;
|
|
70
|
+
this.timestamp = /* @__PURE__ */ new Date();
|
|
71
|
+
if (Error.captureStackTrace) {
|
|
72
|
+
Error.captureStackTrace(this, this.constructor);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Serialize error for logging or transmission
|
|
77
|
+
*/
|
|
78
|
+
toJSON() {
|
|
79
|
+
return {
|
|
80
|
+
name: this.name,
|
|
81
|
+
code: this.code,
|
|
82
|
+
message: this.message,
|
|
83
|
+
context: this.context,
|
|
84
|
+
cause: this.cause instanceof Error ? this.cause.message : void 0,
|
|
85
|
+
stack: this.stack,
|
|
86
|
+
timestamp: this.timestamp.toISOString()
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a string representation for logging
|
|
91
|
+
*/
|
|
92
|
+
toString() {
|
|
93
|
+
let result = `[${this.code}] ${this.name}: ${this.message}`;
|
|
94
|
+
if (this.cause instanceof Error) {
|
|
95
|
+
result += `
|
|
96
|
+
Caused by: ${this.cause.message}`;
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var ValidationError = class extends SIPError {
|
|
102
|
+
/** The field that failed validation (if applicable) */
|
|
103
|
+
field;
|
|
104
|
+
constructor(message, field, context, code = "SIP_2000" /* VALIDATION_FAILED */) {
|
|
105
|
+
const fullMessage = field ? `Validation failed for '${field}': ${message}` : `Validation failed: ${message}`;
|
|
106
|
+
super(fullMessage, code, { context });
|
|
107
|
+
this.name = "ValidationError";
|
|
108
|
+
this.field = field;
|
|
109
|
+
}
|
|
110
|
+
toJSON() {
|
|
111
|
+
return {
|
|
112
|
+
...super.toJSON(),
|
|
113
|
+
field: this.field
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var CryptoError = class extends SIPError {
|
|
118
|
+
/** The cryptographic operation that failed */
|
|
119
|
+
operation;
|
|
120
|
+
constructor(message, code = "SIP_3000" /* CRYPTO_FAILED */, options) {
|
|
121
|
+
super(message, code, options);
|
|
122
|
+
this.name = "CryptoError";
|
|
123
|
+
this.operation = options?.operation;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var EncryptionNotImplementedError = class extends CryptoError {
|
|
127
|
+
/** The type of encryption operation */
|
|
128
|
+
operationType;
|
|
129
|
+
/** Reference to the specification document */
|
|
130
|
+
specReference;
|
|
131
|
+
constructor(operation, specReference) {
|
|
132
|
+
const message = `${operation.charAt(0).toUpperCase() + operation.slice(1)}ion is not implemented. Real authenticated encryption (ChaCha20-Poly1305) is required. See specification: ${specReference}`;
|
|
133
|
+
super(message, "SIP_1002" /* NOT_IMPLEMENTED */, {
|
|
134
|
+
context: { operation, specReference }
|
|
135
|
+
});
|
|
136
|
+
this.name = "EncryptionNotImplementedError";
|
|
137
|
+
this.operationType = operation;
|
|
138
|
+
this.specReference = specReference;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var ProofError = class extends SIPError {
|
|
142
|
+
/** The type of proof involved */
|
|
143
|
+
proofType;
|
|
144
|
+
constructor(message, code = "SIP_4000" /* PROOF_FAILED */, options) {
|
|
145
|
+
super(message, code, options);
|
|
146
|
+
this.name = "ProofError";
|
|
147
|
+
this.proofType = options?.proofType;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
var ProofNotImplementedError = class extends ProofError {
|
|
151
|
+
/** Reference to the specification document */
|
|
152
|
+
specReference;
|
|
153
|
+
constructor(proofType, specReference) {
|
|
154
|
+
const message = `${proofType.charAt(0).toUpperCase() + proofType.slice(1)} proof generation is not implemented. Real ZK proofs are required for production use. See specification: ${specReference}`;
|
|
155
|
+
super(message, "SIP_4003" /* PROOF_NOT_IMPLEMENTED */, {
|
|
156
|
+
context: { specReference },
|
|
157
|
+
proofType
|
|
158
|
+
});
|
|
159
|
+
this.name = "ProofNotImplementedError";
|
|
160
|
+
this.specReference = specReference;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var IntentError = class extends SIPError {
|
|
164
|
+
/** The intent ID involved (if available) */
|
|
165
|
+
intentId;
|
|
166
|
+
constructor(message, code = "SIP_5000" /* INTENT_FAILED */, options) {
|
|
167
|
+
super(message, code, options);
|
|
168
|
+
this.name = "IntentError";
|
|
169
|
+
this.intentId = options?.intentId;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
var NetworkError = class extends SIPError {
|
|
173
|
+
/** The endpoint that failed (if applicable) */
|
|
174
|
+
endpoint;
|
|
175
|
+
/** HTTP status code (if applicable) */
|
|
176
|
+
statusCode;
|
|
177
|
+
constructor(message, code = "SIP_6000" /* NETWORK_FAILED */, options) {
|
|
178
|
+
super(message, code, options);
|
|
179
|
+
this.name = "NetworkError";
|
|
180
|
+
this.endpoint = options?.endpoint;
|
|
181
|
+
this.statusCode = options?.statusCode;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
function isSIPError(error) {
|
|
185
|
+
return error instanceof SIPError;
|
|
186
|
+
}
|
|
187
|
+
function hasErrorCode(error, code) {
|
|
188
|
+
return isSIPError(error) && error.code === code;
|
|
189
|
+
}
|
|
190
|
+
function wrapError(error, message, code = "SIP_1001" /* INTERNAL */, context) {
|
|
191
|
+
if (error instanceof SIPError) {
|
|
192
|
+
return error;
|
|
193
|
+
}
|
|
194
|
+
const cause = error instanceof Error ? error : new Error(String(error));
|
|
195
|
+
return new SIPError(message, code, { cause, context });
|
|
196
|
+
}
|
|
197
|
+
function getErrorMessage(error) {
|
|
198
|
+
if (error instanceof Error) {
|
|
199
|
+
return error.message;
|
|
200
|
+
}
|
|
201
|
+
return String(error);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export {
|
|
205
|
+
ErrorCode,
|
|
206
|
+
SIPError,
|
|
207
|
+
ValidationError,
|
|
208
|
+
CryptoError,
|
|
209
|
+
EncryptionNotImplementedError,
|
|
210
|
+
ProofError,
|
|
211
|
+
ProofNotImplementedError,
|
|
212
|
+
IntentError,
|
|
213
|
+
NetworkError,
|
|
214
|
+
isSIPError,
|
|
215
|
+
hasErrorCode,
|
|
216
|
+
wrapError,
|
|
217
|
+
getErrorMessage
|
|
218
|
+
};
|