@sip-protocol/sdk 0.1.9 → 0.2.1
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/LICENSE +21 -0
- package/dist/browser.d.mts +2 -0
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +12925 -0
- package/dist/browser.mjs +1037 -0
- package/dist/chunk-4VJHI66K.mjs +12120 -0
- package/dist/chunk-O4Y2ZUDL.mjs +12721 -0
- package/dist/index.d.mts +800 -91
- package/dist/index.d.ts +800 -91
- package/dist/index.js +1137 -266
- package/dist/index.mjs +260 -11114
- package/package.json +20 -14
- package/src/adapters/near-intents.ts +138 -30
- package/src/browser.ts +35 -0
- package/src/commitment.ts +4 -4
- package/src/index.ts +72 -0
- package/src/oracle/index.ts +12 -0
- package/src/oracle/serialization.ts +237 -0
- package/src/oracle/types.ts +257 -0
- package/src/oracle/verification.ts +257 -0
- package/src/proofs/browser-utils.ts +141 -0
- package/src/proofs/browser.ts +884 -0
- package/src/proofs/index.ts +19 -1
- package/src/stealth.ts +868 -12
- package/src/validation.ts +7 -0
package/dist/index.js
CHANGED
|
@@ -30,9 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
ATTESTATION_VERSION: () => ATTESTATION_VERSION,
|
|
33
34
|
BaseWalletAdapter: () => BaseWalletAdapter,
|
|
35
|
+
CHAIN_NUMERIC_IDS: () => CHAIN_NUMERIC_IDS,
|
|
34
36
|
ComplianceManager: () => ComplianceManager,
|
|
35
37
|
CryptoError: () => CryptoError,
|
|
38
|
+
DEFAULT_THRESHOLD: () => DEFAULT_THRESHOLD,
|
|
39
|
+
DEFAULT_TOTAL_ORACLES: () => DEFAULT_TOTAL_ORACLES,
|
|
36
40
|
DerivationPath: () => DerivationPath,
|
|
37
41
|
EncryptionNotImplementedError: () => EncryptionNotImplementedError,
|
|
38
42
|
ErrorCode: () => ErrorCode,
|
|
@@ -42,7 +46,7 @@ __export(index_exports, {
|
|
|
42
46
|
HardwareWalletError: () => HardwareWalletError,
|
|
43
47
|
IntentBuilder: () => IntentBuilder,
|
|
44
48
|
IntentError: () => IntentError,
|
|
45
|
-
IntentStatus: () =>
|
|
49
|
+
IntentStatus: () => import_types33.IntentStatus,
|
|
46
50
|
LedgerWalletAdapter: () => LedgerWalletAdapter,
|
|
47
51
|
MockEthereumAdapter: () => MockEthereumAdapter,
|
|
48
52
|
MockLedgerAdapter: () => MockLedgerAdapter,
|
|
@@ -51,26 +55,27 @@ __export(index_exports, {
|
|
|
51
55
|
MockSolver: () => MockSolver,
|
|
52
56
|
MockTrezorAdapter: () => MockTrezorAdapter,
|
|
53
57
|
MockWalletAdapter: () => MockWalletAdapter,
|
|
54
|
-
NATIVE_TOKENS: () =>
|
|
58
|
+
NATIVE_TOKENS: () => import_types33.NATIVE_TOKENS,
|
|
55
59
|
NEARIntentsAdapter: () => NEARIntentsAdapter,
|
|
56
60
|
NetworkError: () => NetworkError,
|
|
57
61
|
NoirProofProvider: () => NoirProofProvider,
|
|
62
|
+
ORACLE_DOMAIN: () => ORACLE_DOMAIN,
|
|
58
63
|
OneClickClient: () => OneClickClient,
|
|
59
|
-
OneClickDepositMode: () =>
|
|
60
|
-
OneClickErrorCode: () =>
|
|
61
|
-
OneClickSwapStatus: () =>
|
|
62
|
-
OneClickSwapType: () =>
|
|
64
|
+
OneClickDepositMode: () => import_types37.OneClickDepositMode,
|
|
65
|
+
OneClickErrorCode: () => import_types37.OneClickErrorCode,
|
|
66
|
+
OneClickSwapStatus: () => import_types37.OneClickSwapStatus,
|
|
67
|
+
OneClickSwapType: () => import_types37.OneClickSwapType,
|
|
63
68
|
PaymentBuilder: () => PaymentBuilder,
|
|
64
|
-
PaymentStatus: () =>
|
|
65
|
-
PrivacyLevel: () =>
|
|
69
|
+
PaymentStatus: () => import_types34.PaymentStatus,
|
|
70
|
+
PrivacyLevel: () => import_types33.PrivacyLevel,
|
|
66
71
|
ProofError: () => ProofError,
|
|
67
72
|
ProofGenerationError: () => ProofGenerationError,
|
|
68
73
|
ProofNotImplementedError: () => ProofNotImplementedError,
|
|
69
|
-
ProposalStatus: () =>
|
|
70
|
-
ReportStatus: () =>
|
|
74
|
+
ProposalStatus: () => import_types35.ProposalStatus,
|
|
75
|
+
ReportStatus: () => import_types36.ReportStatus,
|
|
71
76
|
SIP: () => SIP,
|
|
72
77
|
SIPError: () => SIPError,
|
|
73
|
-
SIP_VERSION: () =>
|
|
78
|
+
SIP_VERSION: () => import_types33.SIP_VERSION,
|
|
74
79
|
STABLECOIN_ADDRESSES: () => STABLECOIN_ADDRESSES,
|
|
75
80
|
STABLECOIN_DECIMALS: () => STABLECOIN_DECIMALS,
|
|
76
81
|
STABLECOIN_INFO: () => STABLECOIN_INFO,
|
|
@@ -79,18 +84,23 @@ __export(index_exports, {
|
|
|
79
84
|
TrezorWalletAdapter: () => TrezorWalletAdapter,
|
|
80
85
|
ValidationError: () => ValidationError,
|
|
81
86
|
WalletError: () => WalletError,
|
|
82
|
-
WalletErrorCode: () =>
|
|
83
|
-
ZcashErrorCode: () =>
|
|
87
|
+
WalletErrorCode: () => import_types32.WalletErrorCode,
|
|
88
|
+
ZcashErrorCode: () => import_types38.ZcashErrorCode,
|
|
84
89
|
ZcashRPCClient: () => ZcashRPCClient,
|
|
85
90
|
ZcashRPCError: () => ZcashRPCError,
|
|
86
91
|
ZcashShieldedService: () => ZcashShieldedService,
|
|
87
92
|
addBlindings: () => addBlindings,
|
|
88
93
|
addCommitments: () => addCommitments,
|
|
94
|
+
addOracle: () => addOracle,
|
|
89
95
|
attachProofs: () => attachProofs,
|
|
90
96
|
base58ToHex: () => base58ToHex,
|
|
97
|
+
browserBytesToHex: () => bytesToHex7,
|
|
98
|
+
browserHexToBytes: () => hexToBytes5,
|
|
99
|
+
checkEd25519StealthAddress: () => checkEd25519StealthAddress,
|
|
91
100
|
checkStealthAddress: () => checkStealthAddress,
|
|
92
101
|
commit: () => commit,
|
|
93
102
|
commitZero: () => commitZero,
|
|
103
|
+
computeAttestationHash: () => computeAttestationHash,
|
|
94
104
|
createCommitment: () => createCommitment,
|
|
95
105
|
createEthereumAdapter: () => createEthereumAdapter,
|
|
96
106
|
createLedgerAdapter: () => createLedgerAdapter,
|
|
@@ -103,6 +113,7 @@ __export(index_exports, {
|
|
|
103
113
|
createMockSolver: () => createMockSolver,
|
|
104
114
|
createMockTrezorAdapter: () => createMockTrezorAdapter,
|
|
105
115
|
createNEARIntentsAdapter: () => createNEARIntentsAdapter,
|
|
116
|
+
createOracleRegistry: () => createOracleRegistry,
|
|
106
117
|
createProductionSIP: () => createProductionSIP,
|
|
107
118
|
createSIP: () => createSIP,
|
|
108
119
|
createShieldedIntent: () => createShieldedIntent,
|
|
@@ -115,12 +126,17 @@ __export(index_exports, {
|
|
|
115
126
|
decodeStealthMetaAddress: () => decodeStealthMetaAddress,
|
|
116
127
|
decryptMemo: () => decryptMemo,
|
|
117
128
|
decryptWithViewing: () => decryptWithViewing,
|
|
129
|
+
deriveEd25519StealthPrivateKey: () => deriveEd25519StealthPrivateKey,
|
|
130
|
+
deriveOracleId: () => deriveOracleId,
|
|
118
131
|
deriveStealthPrivateKey: () => deriveStealthPrivateKey,
|
|
119
132
|
deriveViewingKey: () => deriveViewingKey,
|
|
133
|
+
deserializeAttestationMessage: () => deserializeAttestationMessage,
|
|
120
134
|
deserializeIntent: () => deserializeIntent,
|
|
121
135
|
deserializePayment: () => deserializePayment,
|
|
122
136
|
detectEthereumWallets: () => detectEthereumWallets,
|
|
123
137
|
detectSolanaWallets: () => detectSolanaWallets,
|
|
138
|
+
ed25519PublicKeyToNearAddress: () => ed25519PublicKeyToNearAddress,
|
|
139
|
+
ed25519PublicKeyToSolanaAddress: () => ed25519PublicKeyToSolanaAddress,
|
|
124
140
|
encodeStealthMetaAddress: () => encodeStealthMetaAddress,
|
|
125
141
|
encryptForViewing: () => encryptForViewing,
|
|
126
142
|
featureNotSupportedError: () => featureNotSupportedError,
|
|
@@ -128,13 +144,19 @@ __export(index_exports, {
|
|
|
128
144
|
fromHex: () => fromHex,
|
|
129
145
|
fromStablecoinUnits: () => fromStablecoinUnits,
|
|
130
146
|
generateBlinding: () => generateBlinding,
|
|
147
|
+
generateEd25519StealthAddress: () => generateEd25519StealthAddress,
|
|
148
|
+
generateEd25519StealthMetaAddress: () => generateEd25519StealthMetaAddress,
|
|
131
149
|
generateIntentId: () => generateIntentId,
|
|
132
150
|
generateRandomBytes: () => generateRandomBytes,
|
|
133
151
|
generateStealthAddress: () => generateStealthAddress,
|
|
134
152
|
generateStealthMetaAddress: () => generateStealthMetaAddress,
|
|
135
153
|
generateViewingKey: () => generateViewingKey,
|
|
154
|
+
getActiveOracles: () => getActiveOracles,
|
|
136
155
|
getAvailableTransports: () => getAvailableTransports,
|
|
156
|
+
getBrowserInfo: () => getBrowserInfo,
|
|
157
|
+
getChainNumericId: () => getChainNumericId,
|
|
137
158
|
getChainsForStablecoin: () => getChainsForStablecoin,
|
|
159
|
+
getCurveForChain: () => getCurveForChain,
|
|
138
160
|
getDefaultRpcEndpoint: () => getDefaultRpcEndpoint,
|
|
139
161
|
getDerivationPath: () => getDerivationPath,
|
|
140
162
|
getErrorMessage: () => getErrorMessage,
|
|
@@ -151,14 +173,17 @@ __export(index_exports, {
|
|
|
151
173
|
getStablecoinsForChain: () => getStablecoinsForChain,
|
|
152
174
|
getSupportedStablecoins: () => getSupportedStablecoins,
|
|
153
175
|
getTimeRemaining: () => getTimeRemaining,
|
|
176
|
+
hasEnoughOracles: () => hasEnoughOracles,
|
|
154
177
|
hasErrorCode: () => hasErrorCode,
|
|
155
178
|
hasRequiredProofs: () => hasRequiredProofs,
|
|
156
179
|
hash: () => hash,
|
|
157
180
|
hexToNumber: () => hexToNumber,
|
|
181
|
+
isBrowser: () => isBrowser,
|
|
182
|
+
isEd25519Chain: () => isEd25519Chain,
|
|
158
183
|
isExpired: () => isExpired,
|
|
159
184
|
isNonNegativeAmount: () => isNonNegativeAmount,
|
|
160
185
|
isPaymentExpired: () => isPaymentExpired,
|
|
161
|
-
isPrivate: () =>
|
|
186
|
+
isPrivate: () => import_types33.isPrivate,
|
|
162
187
|
isPrivateWalletAdapter: () => isPrivateWalletAdapter,
|
|
163
188
|
isSIPError: () => isSIPError,
|
|
164
189
|
isStablecoin: () => isStablecoin,
|
|
@@ -166,40 +191,54 @@ __export(index_exports, {
|
|
|
166
191
|
isValidAmount: () => isValidAmount,
|
|
167
192
|
isValidChainId: () => isValidChainId,
|
|
168
193
|
isValidCompressedPublicKey: () => isValidCompressedPublicKey,
|
|
194
|
+
isValidEd25519PublicKey: () => isValidEd25519PublicKey,
|
|
169
195
|
isValidHex: () => isValidHex,
|
|
170
196
|
isValidHexLength: () => isValidHexLength,
|
|
197
|
+
isValidNearAccountId: () => isValidNearAccountId,
|
|
198
|
+
isValidNearImplicitAddress: () => isValidNearImplicitAddress,
|
|
171
199
|
isValidPrivacyLevel: () => isValidPrivacyLevel,
|
|
172
200
|
isValidPrivateKey: () => isValidPrivateKey,
|
|
173
201
|
isValidScalar: () => isValidScalar,
|
|
174
202
|
isValidSlippage: () => isValidSlippage,
|
|
203
|
+
isValidSolanaAddress: () => isValidSolanaAddress,
|
|
175
204
|
isValidStealthMetaAddress: () => isValidStealthMetaAddress,
|
|
205
|
+
nearAddressToEd25519PublicKey: () => nearAddressToEd25519PublicKey,
|
|
176
206
|
normalizeAddress: () => normalizeAddress,
|
|
177
207
|
notConnectedError: () => notConnectedError,
|
|
178
208
|
publicKeyToEthAddress: () => publicKeyToEthAddress,
|
|
179
209
|
registerWallet: () => registerWallet,
|
|
210
|
+
removeOracle: () => removeOracle,
|
|
180
211
|
secureWipe: () => secureWipe,
|
|
181
212
|
secureWipeAll: () => secureWipeAll,
|
|
213
|
+
serializeAttestationMessage: () => serializeAttestationMessage,
|
|
182
214
|
serializeIntent: () => serializeIntent,
|
|
183
215
|
serializePayment: () => serializePayment,
|
|
216
|
+
signAttestationMessage: () => signAttestationMessage,
|
|
217
|
+
solanaAddressToEd25519PublicKey: () => solanaAddressToEd25519PublicKey,
|
|
184
218
|
solanaPublicKeyToHex: () => solanaPublicKeyToHex,
|
|
185
219
|
subtractBlindings: () => subtractBlindings,
|
|
186
220
|
subtractCommitments: () => subtractCommitments,
|
|
187
|
-
|
|
221
|
+
supportsSharedArrayBuffer: () => supportsSharedArrayBuffer,
|
|
222
|
+
supportsViewingKey: () => import_types33.supportsViewingKey,
|
|
188
223
|
supportsWebBluetooth: () => supportsWebBluetooth,
|
|
189
224
|
supportsWebHID: () => supportsWebHID,
|
|
190
225
|
supportsWebUSB: () => supportsWebUSB,
|
|
226
|
+
supportsWebWorkers: () => supportsWebWorkers,
|
|
191
227
|
toHex: () => toHex,
|
|
192
228
|
toStablecoinUnits: () => toStablecoinUnits,
|
|
193
229
|
trackIntent: () => trackIntent,
|
|
194
230
|
trackPayment: () => trackPayment,
|
|
231
|
+
updateOracleStatus: () => updateOracleStatus,
|
|
195
232
|
validateAsset: () => validateAsset,
|
|
196
233
|
validateCreateIntentParams: () => validateCreateIntentParams,
|
|
197
234
|
validateIntentInput: () => validateIntentInput,
|
|
198
235
|
validateIntentOutput: () => validateIntentOutput,
|
|
199
236
|
validateScalar: () => validateScalar,
|
|
200
237
|
validateViewingKey: () => validateViewingKey,
|
|
238
|
+
verifyAttestation: () => verifyAttestation,
|
|
201
239
|
verifyCommitment: () => verifyCommitment,
|
|
202
240
|
verifyOpening: () => verifyOpening,
|
|
241
|
+
verifyOracleSignature: () => verifyOracleSignature,
|
|
203
242
|
walletRegistry: () => walletRegistry,
|
|
204
243
|
withSecureBuffer: () => withSecureBuffer,
|
|
205
244
|
withSecureBufferSync: () => withSecureBufferSync,
|
|
@@ -410,7 +449,9 @@ var import_types = require("@sip-protocol/types");
|
|
|
410
449
|
|
|
411
450
|
// src/stealth.ts
|
|
412
451
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
|
452
|
+
var import_ed25519 = require("@noble/curves/ed25519");
|
|
413
453
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
454
|
+
var import_sha512 = require("@noble/hashes/sha512");
|
|
414
455
|
var import_sha3 = require("@noble/hashes/sha3");
|
|
415
456
|
var import_utils2 = require("@noble/hashes/utils");
|
|
416
457
|
|
|
@@ -463,6 +504,9 @@ function isValidCompressedPublicKey(key) {
|
|
|
463
504
|
const prefix = key.slice(2, 4);
|
|
464
505
|
return prefix === "02" || prefix === "03";
|
|
465
506
|
}
|
|
507
|
+
function isValidEd25519PublicKey(key) {
|
|
508
|
+
return isValidHexLength(key, 32);
|
|
509
|
+
}
|
|
466
510
|
function isValidPrivateKey(key) {
|
|
467
511
|
return isValidHexLength(key, 32);
|
|
468
512
|
}
|
|
@@ -837,17 +881,33 @@ function decodeStealthMetaAddress(encoded) {
|
|
|
837
881
|
"encoded.chain"
|
|
838
882
|
);
|
|
839
883
|
}
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
884
|
+
const chainId = chain;
|
|
885
|
+
if (isEd25519Chain(chainId)) {
|
|
886
|
+
if (!isValidEd25519PublicKey(spendingKey)) {
|
|
887
|
+
throw new ValidationError(
|
|
888
|
+
"spendingKey must be a valid 32-byte ed25519 public key",
|
|
889
|
+
"encoded.spendingKey"
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
if (!isValidEd25519PublicKey(viewingKey)) {
|
|
893
|
+
throw new ValidationError(
|
|
894
|
+
"viewingKey must be a valid 32-byte ed25519 public key",
|
|
895
|
+
"encoded.viewingKey"
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
} else {
|
|
899
|
+
if (!isValidCompressedPublicKey(spendingKey)) {
|
|
900
|
+
throw new ValidationError(
|
|
901
|
+
"spendingKey must be a valid compressed secp256k1 public key",
|
|
902
|
+
"encoded.spendingKey"
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
if (!isValidCompressedPublicKey(viewingKey)) {
|
|
906
|
+
throw new ValidationError(
|
|
907
|
+
"viewingKey must be a valid compressed secp256k1 public key",
|
|
908
|
+
"encoded.viewingKey"
|
|
909
|
+
);
|
|
910
|
+
}
|
|
851
911
|
}
|
|
852
912
|
return {
|
|
853
913
|
chain,
|
|
@@ -903,6 +963,396 @@ function toChecksumAddress(address) {
|
|
|
903
963
|
}
|
|
904
964
|
return checksummed;
|
|
905
965
|
}
|
|
966
|
+
var ED25519_ORDER = 2n ** 252n + 27742317777372353535851937790883648493n;
|
|
967
|
+
var ED25519_CHAINS = ["solana", "near"];
|
|
968
|
+
function isEd25519Chain(chain) {
|
|
969
|
+
return ED25519_CHAINS.includes(chain);
|
|
970
|
+
}
|
|
971
|
+
function getCurveForChain(chain) {
|
|
972
|
+
return isEd25519Chain(chain) ? "ed25519" : "secp256k1";
|
|
973
|
+
}
|
|
974
|
+
function validateEd25519StealthMetaAddress(metaAddress, field = "recipientMetaAddress") {
|
|
975
|
+
if (!metaAddress || typeof metaAddress !== "object") {
|
|
976
|
+
throw new ValidationError("must be an object", field);
|
|
977
|
+
}
|
|
978
|
+
if (!isValidChainId(metaAddress.chain)) {
|
|
979
|
+
throw new ValidationError(
|
|
980
|
+
`invalid chain '${metaAddress.chain}'`,
|
|
981
|
+
`${field}.chain`
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
if (!isEd25519Chain(metaAddress.chain)) {
|
|
985
|
+
throw new ValidationError(
|
|
986
|
+
`chain '${metaAddress.chain}' does not use ed25519, use secp256k1 functions instead`,
|
|
987
|
+
`${field}.chain`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
if (!isValidEd25519PublicKey(metaAddress.spendingKey)) {
|
|
991
|
+
throw new ValidationError(
|
|
992
|
+
"spendingKey must be a valid ed25519 public key (32 bytes)",
|
|
993
|
+
`${field}.spendingKey`
|
|
994
|
+
);
|
|
995
|
+
}
|
|
996
|
+
if (!isValidEd25519PublicKey(metaAddress.viewingKey)) {
|
|
997
|
+
throw new ValidationError(
|
|
998
|
+
"viewingKey must be a valid ed25519 public key (32 bytes)",
|
|
999
|
+
`${field}.viewingKey`
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
function validateEd25519StealthAddress(stealthAddress, field = "stealthAddress") {
|
|
1004
|
+
if (!stealthAddress || typeof stealthAddress !== "object") {
|
|
1005
|
+
throw new ValidationError("must be an object", field);
|
|
1006
|
+
}
|
|
1007
|
+
if (!isValidEd25519PublicKey(stealthAddress.address)) {
|
|
1008
|
+
throw new ValidationError(
|
|
1009
|
+
"address must be a valid ed25519 public key (32 bytes)",
|
|
1010
|
+
`${field}.address`
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
if (!isValidEd25519PublicKey(stealthAddress.ephemeralPublicKey)) {
|
|
1014
|
+
throw new ValidationError(
|
|
1015
|
+
"ephemeralPublicKey must be a valid ed25519 public key (32 bytes)",
|
|
1016
|
+
`${field}.ephemeralPublicKey`
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
if (typeof stealthAddress.viewTag !== "number" || !Number.isInteger(stealthAddress.viewTag) || stealthAddress.viewTag < 0 || stealthAddress.viewTag > 255) {
|
|
1020
|
+
throw new ValidationError(
|
|
1021
|
+
"viewTag must be an integer between 0 and 255",
|
|
1022
|
+
`${field}.viewTag`
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
function getEd25519Scalar(privateKey) {
|
|
1027
|
+
const hash2 = (0, import_sha512.sha512)(privateKey);
|
|
1028
|
+
const scalar = hash2.slice(0, 32);
|
|
1029
|
+
scalar[0] &= 248;
|
|
1030
|
+
scalar[31] &= 127;
|
|
1031
|
+
scalar[31] |= 64;
|
|
1032
|
+
return bytesToBigIntLE(scalar);
|
|
1033
|
+
}
|
|
1034
|
+
function bytesToBigIntLE(bytes) {
|
|
1035
|
+
let result = 0n;
|
|
1036
|
+
for (let i = bytes.length - 1; i >= 0; i--) {
|
|
1037
|
+
result = (result << 8n) + BigInt(bytes[i]);
|
|
1038
|
+
}
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
function bigIntToBytesLE(value, length) {
|
|
1042
|
+
const bytes = new Uint8Array(length);
|
|
1043
|
+
for (let i = 0; i < length; i++) {
|
|
1044
|
+
bytes[i] = Number(value & 0xffn);
|
|
1045
|
+
value >>= 8n;
|
|
1046
|
+
}
|
|
1047
|
+
return bytes;
|
|
1048
|
+
}
|
|
1049
|
+
function generateEd25519StealthMetaAddress(chain, label) {
|
|
1050
|
+
if (!isValidChainId(chain)) {
|
|
1051
|
+
throw new ValidationError(
|
|
1052
|
+
`invalid chain '${chain}', must be one of: solana, ethereum, near, zcash, polygon, arbitrum, optimism, base`,
|
|
1053
|
+
"chain"
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
if (!isEd25519Chain(chain)) {
|
|
1057
|
+
throw new ValidationError(
|
|
1058
|
+
`chain '${chain}' does not use ed25519, use generateStealthMetaAddress() for secp256k1 chains`,
|
|
1059
|
+
"chain"
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
const spendingPrivateKey = (0, import_utils2.randomBytes)(32);
|
|
1063
|
+
const viewingPrivateKey = (0, import_utils2.randomBytes)(32);
|
|
1064
|
+
try {
|
|
1065
|
+
const spendingKey = import_ed25519.ed25519.getPublicKey(spendingPrivateKey);
|
|
1066
|
+
const viewingKey = import_ed25519.ed25519.getPublicKey(viewingPrivateKey);
|
|
1067
|
+
const result = {
|
|
1068
|
+
metaAddress: {
|
|
1069
|
+
spendingKey: `0x${(0, import_utils2.bytesToHex)(spendingKey)}`,
|
|
1070
|
+
viewingKey: `0x${(0, import_utils2.bytesToHex)(viewingKey)}`,
|
|
1071
|
+
chain,
|
|
1072
|
+
label
|
|
1073
|
+
},
|
|
1074
|
+
spendingPrivateKey: `0x${(0, import_utils2.bytesToHex)(spendingPrivateKey)}`,
|
|
1075
|
+
viewingPrivateKey: `0x${(0, import_utils2.bytesToHex)(viewingPrivateKey)}`
|
|
1076
|
+
};
|
|
1077
|
+
return result;
|
|
1078
|
+
} finally {
|
|
1079
|
+
secureWipeAll(spendingPrivateKey, viewingPrivateKey);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
function generateEd25519StealthAddress(recipientMetaAddress) {
|
|
1083
|
+
validateEd25519StealthMetaAddress(recipientMetaAddress);
|
|
1084
|
+
const ephemeralPrivateKey = (0, import_utils2.randomBytes)(32);
|
|
1085
|
+
try {
|
|
1086
|
+
const ephemeralPublicKey = import_ed25519.ed25519.getPublicKey(ephemeralPrivateKey);
|
|
1087
|
+
const spendingKeyBytes = (0, import_utils2.hexToBytes)(recipientMetaAddress.spendingKey.slice(2));
|
|
1088
|
+
const viewingKeyBytes = (0, import_utils2.hexToBytes)(recipientMetaAddress.viewingKey.slice(2));
|
|
1089
|
+
const rawEphemeralScalar = getEd25519Scalar(ephemeralPrivateKey);
|
|
1090
|
+
const ephemeralScalar = rawEphemeralScalar % ED25519_ORDER;
|
|
1091
|
+
if (ephemeralScalar === 0n) {
|
|
1092
|
+
throw new Error("CRITICAL: Zero ephemeral scalar after reduction - investigate RNG");
|
|
1093
|
+
}
|
|
1094
|
+
const spendingPoint = import_ed25519.ed25519.ExtendedPoint.fromHex(spendingKeyBytes);
|
|
1095
|
+
const sharedSecretPoint = spendingPoint.multiply(ephemeralScalar);
|
|
1096
|
+
const sharedSecretHash = (0, import_sha256.sha256)(sharedSecretPoint.toRawBytes());
|
|
1097
|
+
const hashScalar = bytesToBigInt(sharedSecretHash) % ED25519_ORDER;
|
|
1098
|
+
if (hashScalar === 0n) {
|
|
1099
|
+
throw new Error("CRITICAL: Zero hash scalar after reduction - investigate hash computation");
|
|
1100
|
+
}
|
|
1101
|
+
const hashTimesG = import_ed25519.ed25519.ExtendedPoint.BASE.multiply(hashScalar);
|
|
1102
|
+
const viewingPoint = import_ed25519.ed25519.ExtendedPoint.fromHex(viewingKeyBytes);
|
|
1103
|
+
const stealthPoint = viewingPoint.add(hashTimesG);
|
|
1104
|
+
const stealthAddressBytes = stealthPoint.toRawBytes();
|
|
1105
|
+
const viewTag = sharedSecretHash[0];
|
|
1106
|
+
return {
|
|
1107
|
+
stealthAddress: {
|
|
1108
|
+
address: `0x${(0, import_utils2.bytesToHex)(stealthAddressBytes)}`,
|
|
1109
|
+
ephemeralPublicKey: `0x${(0, import_utils2.bytesToHex)(ephemeralPublicKey)}`,
|
|
1110
|
+
viewTag
|
|
1111
|
+
},
|
|
1112
|
+
sharedSecret: `0x${(0, import_utils2.bytesToHex)(sharedSecretHash)}`
|
|
1113
|
+
};
|
|
1114
|
+
} finally {
|
|
1115
|
+
secureWipe(ephemeralPrivateKey);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
function deriveEd25519StealthPrivateKey(stealthAddress, spendingPrivateKey, viewingPrivateKey) {
|
|
1119
|
+
validateEd25519StealthAddress(stealthAddress);
|
|
1120
|
+
if (!isValidPrivateKey(spendingPrivateKey)) {
|
|
1121
|
+
throw new ValidationError(
|
|
1122
|
+
"must be a valid 32-byte hex string",
|
|
1123
|
+
"spendingPrivateKey"
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
if (!isValidPrivateKey(viewingPrivateKey)) {
|
|
1127
|
+
throw new ValidationError(
|
|
1128
|
+
"must be a valid 32-byte hex string",
|
|
1129
|
+
"viewingPrivateKey"
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1132
|
+
const spendingPrivBytes = (0, import_utils2.hexToBytes)(spendingPrivateKey.slice(2));
|
|
1133
|
+
const viewingPrivBytes = (0, import_utils2.hexToBytes)(viewingPrivateKey.slice(2));
|
|
1134
|
+
const ephemeralPubBytes = (0, import_utils2.hexToBytes)(stealthAddress.ephemeralPublicKey.slice(2));
|
|
1135
|
+
try {
|
|
1136
|
+
const rawSpendingScalar = getEd25519Scalar(spendingPrivBytes);
|
|
1137
|
+
const spendingScalar = rawSpendingScalar % ED25519_ORDER;
|
|
1138
|
+
if (spendingScalar === 0n) {
|
|
1139
|
+
throw new Error("CRITICAL: Zero spending scalar after reduction - investigate key derivation");
|
|
1140
|
+
}
|
|
1141
|
+
const ephemeralPoint = import_ed25519.ed25519.ExtendedPoint.fromHex(ephemeralPubBytes);
|
|
1142
|
+
const sharedSecretPoint = ephemeralPoint.multiply(spendingScalar);
|
|
1143
|
+
const sharedSecretHash = (0, import_sha256.sha256)(sharedSecretPoint.toRawBytes());
|
|
1144
|
+
const rawViewingScalar = getEd25519Scalar(viewingPrivBytes);
|
|
1145
|
+
const viewingScalar = rawViewingScalar % ED25519_ORDER;
|
|
1146
|
+
if (viewingScalar === 0n) {
|
|
1147
|
+
throw new Error("CRITICAL: Zero viewing scalar after reduction - investigate key derivation");
|
|
1148
|
+
}
|
|
1149
|
+
const hashScalar = bytesToBigInt(sharedSecretHash) % ED25519_ORDER;
|
|
1150
|
+
if (hashScalar === 0n) {
|
|
1151
|
+
throw new Error("CRITICAL: Zero hash scalar after reduction - investigate hash computation");
|
|
1152
|
+
}
|
|
1153
|
+
const stealthPrivateScalar = (viewingScalar + hashScalar) % ED25519_ORDER;
|
|
1154
|
+
if (stealthPrivateScalar === 0n) {
|
|
1155
|
+
throw new Error("CRITICAL: Zero stealth scalar after reduction - investigate key derivation");
|
|
1156
|
+
}
|
|
1157
|
+
const stealthPrivateKey = bigIntToBytesLE(stealthPrivateScalar, 32);
|
|
1158
|
+
const result = {
|
|
1159
|
+
stealthAddress: stealthAddress.address,
|
|
1160
|
+
ephemeralPublicKey: stealthAddress.ephemeralPublicKey,
|
|
1161
|
+
privateKey: `0x${(0, import_utils2.bytesToHex)(stealthPrivateKey)}`
|
|
1162
|
+
};
|
|
1163
|
+
secureWipe(stealthPrivateKey);
|
|
1164
|
+
return result;
|
|
1165
|
+
} finally {
|
|
1166
|
+
secureWipeAll(spendingPrivBytes, viewingPrivBytes);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function checkEd25519StealthAddress(stealthAddress, spendingPrivateKey, viewingPrivateKey) {
|
|
1170
|
+
validateEd25519StealthAddress(stealthAddress);
|
|
1171
|
+
if (!isValidPrivateKey(spendingPrivateKey)) {
|
|
1172
|
+
throw new ValidationError(
|
|
1173
|
+
"must be a valid 32-byte hex string",
|
|
1174
|
+
"spendingPrivateKey"
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1177
|
+
if (!isValidPrivateKey(viewingPrivateKey)) {
|
|
1178
|
+
throw new ValidationError(
|
|
1179
|
+
"must be a valid 32-byte hex string",
|
|
1180
|
+
"viewingPrivateKey"
|
|
1181
|
+
);
|
|
1182
|
+
}
|
|
1183
|
+
const spendingPrivBytes = (0, import_utils2.hexToBytes)(spendingPrivateKey.slice(2));
|
|
1184
|
+
const viewingPrivBytes = (0, import_utils2.hexToBytes)(viewingPrivateKey.slice(2));
|
|
1185
|
+
const ephemeralPubBytes = (0, import_utils2.hexToBytes)(stealthAddress.ephemeralPublicKey.slice(2));
|
|
1186
|
+
try {
|
|
1187
|
+
const rawSpendingScalar = getEd25519Scalar(spendingPrivBytes);
|
|
1188
|
+
const spendingScalar = rawSpendingScalar % ED25519_ORDER;
|
|
1189
|
+
if (spendingScalar === 0n) {
|
|
1190
|
+
throw new Error("CRITICAL: Zero spending scalar after reduction - investigate key derivation");
|
|
1191
|
+
}
|
|
1192
|
+
const ephemeralPoint = import_ed25519.ed25519.ExtendedPoint.fromHex(ephemeralPubBytes);
|
|
1193
|
+
const sharedSecretPoint = ephemeralPoint.multiply(spendingScalar);
|
|
1194
|
+
const sharedSecretHash = (0, import_sha256.sha256)(sharedSecretPoint.toRawBytes());
|
|
1195
|
+
if (sharedSecretHash[0] !== stealthAddress.viewTag) {
|
|
1196
|
+
return false;
|
|
1197
|
+
}
|
|
1198
|
+
const rawViewingScalar = getEd25519Scalar(viewingPrivBytes);
|
|
1199
|
+
const viewingScalar = rawViewingScalar % ED25519_ORDER;
|
|
1200
|
+
if (viewingScalar === 0n) {
|
|
1201
|
+
throw new Error("CRITICAL: Zero viewing scalar after reduction - investigate key derivation");
|
|
1202
|
+
}
|
|
1203
|
+
const hashScalar = bytesToBigInt(sharedSecretHash) % ED25519_ORDER;
|
|
1204
|
+
if (hashScalar === 0n) {
|
|
1205
|
+
throw new Error("CRITICAL: Zero hash scalar after reduction - investigate hash computation");
|
|
1206
|
+
}
|
|
1207
|
+
const stealthPrivateScalar = (viewingScalar + hashScalar) % ED25519_ORDER;
|
|
1208
|
+
if (stealthPrivateScalar === 0n) {
|
|
1209
|
+
throw new Error("CRITICAL: Zero stealth scalar after reduction - investigate key derivation");
|
|
1210
|
+
}
|
|
1211
|
+
const expectedPubKey = import_ed25519.ed25519.ExtendedPoint.BASE.multiply(stealthPrivateScalar);
|
|
1212
|
+
const expectedPubKeyBytes = expectedPubKey.toRawBytes();
|
|
1213
|
+
const providedAddress = (0, import_utils2.hexToBytes)(stealthAddress.address.slice(2));
|
|
1214
|
+
return (0, import_utils2.bytesToHex)(expectedPubKeyBytes) === (0, import_utils2.bytesToHex)(providedAddress);
|
|
1215
|
+
} finally {
|
|
1216
|
+
secureWipeAll(spendingPrivBytes, viewingPrivBytes);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
var BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
1220
|
+
function bytesToBase58(bytes) {
|
|
1221
|
+
let leadingZeros = 0;
|
|
1222
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
1223
|
+
leadingZeros++;
|
|
1224
|
+
}
|
|
1225
|
+
let value = 0n;
|
|
1226
|
+
for (const byte of bytes) {
|
|
1227
|
+
value = value * 256n + BigInt(byte);
|
|
1228
|
+
}
|
|
1229
|
+
let result = "";
|
|
1230
|
+
while (value > 0n) {
|
|
1231
|
+
const remainder = value % 58n;
|
|
1232
|
+
value = value / 58n;
|
|
1233
|
+
result = BASE58_ALPHABET[Number(remainder)] + result;
|
|
1234
|
+
}
|
|
1235
|
+
return "1".repeat(leadingZeros) + result;
|
|
1236
|
+
}
|
|
1237
|
+
function base58ToBytes(str) {
|
|
1238
|
+
let leadingOnes = 0;
|
|
1239
|
+
for (let i = 0; i < str.length && str[i] === "1"; i++) {
|
|
1240
|
+
leadingOnes++;
|
|
1241
|
+
}
|
|
1242
|
+
let value = 0n;
|
|
1243
|
+
for (const char of str) {
|
|
1244
|
+
const index = BASE58_ALPHABET.indexOf(char);
|
|
1245
|
+
if (index === -1) {
|
|
1246
|
+
throw new ValidationError(`Invalid base58 character: ${char}`, "address");
|
|
1247
|
+
}
|
|
1248
|
+
value = value * 58n + BigInt(index);
|
|
1249
|
+
}
|
|
1250
|
+
const bytes = [];
|
|
1251
|
+
while (value > 0n) {
|
|
1252
|
+
bytes.unshift(Number(value % 256n));
|
|
1253
|
+
value = value / 256n;
|
|
1254
|
+
}
|
|
1255
|
+
const result = new Uint8Array(leadingOnes + bytes.length);
|
|
1256
|
+
for (let i = 0; i < leadingOnes; i++) {
|
|
1257
|
+
result[i] = 0;
|
|
1258
|
+
}
|
|
1259
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1260
|
+
result[leadingOnes + i] = bytes[i];
|
|
1261
|
+
}
|
|
1262
|
+
return result;
|
|
1263
|
+
}
|
|
1264
|
+
function ed25519PublicKeyToSolanaAddress(publicKey) {
|
|
1265
|
+
if (!isValidHex(publicKey)) {
|
|
1266
|
+
throw new ValidationError(
|
|
1267
|
+
"publicKey must be a valid hex string with 0x prefix",
|
|
1268
|
+
"publicKey"
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
if (!isValidEd25519PublicKey(publicKey)) {
|
|
1272
|
+
throw new ValidationError(
|
|
1273
|
+
"publicKey must be 32 bytes (64 hex characters)",
|
|
1274
|
+
"publicKey"
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
const publicKeyBytes = (0, import_utils2.hexToBytes)(publicKey.slice(2));
|
|
1278
|
+
return bytesToBase58(publicKeyBytes);
|
|
1279
|
+
}
|
|
1280
|
+
function isValidSolanaAddress(address) {
|
|
1281
|
+
if (typeof address !== "string" || address.length === 0) {
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
if (address.length < 32 || address.length > 44) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
try {
|
|
1288
|
+
const decoded = base58ToBytes(address);
|
|
1289
|
+
return decoded.length === 32;
|
|
1290
|
+
} catch {
|
|
1291
|
+
return false;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
function solanaAddressToEd25519PublicKey(address) {
|
|
1295
|
+
if (!isValidSolanaAddress(address)) {
|
|
1296
|
+
throw new ValidationError(
|
|
1297
|
+
"Invalid Solana address format",
|
|
1298
|
+
"address"
|
|
1299
|
+
);
|
|
1300
|
+
}
|
|
1301
|
+
const decoded = base58ToBytes(address);
|
|
1302
|
+
return `0x${(0, import_utils2.bytesToHex)(decoded)}`;
|
|
1303
|
+
}
|
|
1304
|
+
function ed25519PublicKeyToNearAddress(publicKey) {
|
|
1305
|
+
if (!isValidHex(publicKey)) {
|
|
1306
|
+
throw new ValidationError(
|
|
1307
|
+
"publicKey must be a valid hex string with 0x prefix",
|
|
1308
|
+
"publicKey"
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
if (!isValidEd25519PublicKey(publicKey)) {
|
|
1312
|
+
throw new ValidationError(
|
|
1313
|
+
"publicKey must be 32 bytes (64 hex characters)",
|
|
1314
|
+
"publicKey"
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1317
|
+
return publicKey.slice(2).toLowerCase();
|
|
1318
|
+
}
|
|
1319
|
+
function nearAddressToEd25519PublicKey(address) {
|
|
1320
|
+
if (!isValidNearImplicitAddress(address)) {
|
|
1321
|
+
throw new ValidationError(
|
|
1322
|
+
"Invalid NEAR implicit address format",
|
|
1323
|
+
"address"
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
return `0x${address.toLowerCase()}`;
|
|
1327
|
+
}
|
|
1328
|
+
function isValidNearImplicitAddress(address) {
|
|
1329
|
+
if (typeof address !== "string" || address.length === 0) {
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
if (address.length !== 64) {
|
|
1333
|
+
return false;
|
|
1334
|
+
}
|
|
1335
|
+
return /^[0-9a-f]{64}$/.test(address);
|
|
1336
|
+
}
|
|
1337
|
+
function isValidNearAccountId(accountId) {
|
|
1338
|
+
if (typeof accountId !== "string" || accountId.length === 0) {
|
|
1339
|
+
return false;
|
|
1340
|
+
}
|
|
1341
|
+
if (isValidNearImplicitAddress(accountId)) {
|
|
1342
|
+
return true;
|
|
1343
|
+
}
|
|
1344
|
+
if (accountId.length < 2 || accountId.length > 64) {
|
|
1345
|
+
return false;
|
|
1346
|
+
}
|
|
1347
|
+
const nearAccountPattern = /^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$/;
|
|
1348
|
+
if (!nearAccountPattern.test(accountId)) {
|
|
1349
|
+
return false;
|
|
1350
|
+
}
|
|
1351
|
+
if (accountId.includes("..")) {
|
|
1352
|
+
return false;
|
|
1353
|
+
}
|
|
1354
|
+
return true;
|
|
1355
|
+
}
|
|
906
1356
|
|
|
907
1357
|
// src/crypto.ts
|
|
908
1358
|
var import_sha2563 = require("@noble/hashes/sha256");
|
|
@@ -957,9 +1407,9 @@ function commit(value, blinding) {
|
|
|
957
1407
|
if (r.length !== 32) {
|
|
958
1408
|
throw new ValidationError("must be 32 bytes", "blinding", { received: r.length });
|
|
959
1409
|
}
|
|
960
|
-
|
|
1410
|
+
const rScalar = bytesToBigInt2(r) % CURVE_ORDER;
|
|
961
1411
|
if (rScalar === 0n) {
|
|
962
|
-
|
|
1412
|
+
throw new Error("CRITICAL: Zero blinding scalar after reduction - investigate RNG");
|
|
963
1413
|
}
|
|
964
1414
|
let C;
|
|
965
1415
|
if (value === 0n && rScalar === 0n) {
|
|
@@ -985,9 +1435,9 @@ function verifyOpening(commitment, value, blinding) {
|
|
|
985
1435
|
}
|
|
986
1436
|
const C = import_secp256k12.secp256k1.ProjectivePoint.fromHex(commitment.slice(2));
|
|
987
1437
|
const blindingBytes = (0, import_utils3.hexToBytes)(blinding.slice(2));
|
|
988
|
-
|
|
1438
|
+
const rScalar = bytesToBigInt2(blindingBytes) % CURVE_ORDER;
|
|
989
1439
|
if (rScalar === 0n) {
|
|
990
|
-
|
|
1440
|
+
throw new Error("CRITICAL: Zero blinding scalar after reduction - investigate RNG");
|
|
991
1441
|
}
|
|
992
1442
|
let expected;
|
|
993
1443
|
if (value === 0n) {
|
|
@@ -1151,7 +1601,7 @@ var import_sha2565 = require("@noble/hashes/sha256");
|
|
|
1151
1601
|
|
|
1152
1602
|
// src/privacy.ts
|
|
1153
1603
|
var import_sha2564 = require("@noble/hashes/sha256");
|
|
1154
|
-
var
|
|
1604
|
+
var import_sha5122 = require("@noble/hashes/sha512");
|
|
1155
1605
|
var import_hmac = require("@noble/hashes/hmac");
|
|
1156
1606
|
var import_hkdf = require("@noble/hashes/hkdf");
|
|
1157
1607
|
var import_utils5 = require("@noble/hashes/utils");
|
|
@@ -1213,7 +1663,7 @@ function deriveViewingKey(masterKey, childPath) {
|
|
|
1213
1663
|
const masterKeyHex = masterKey.key.startsWith("0x") ? masterKey.key.slice(2) : masterKey.key;
|
|
1214
1664
|
const masterKeyBytes = (0, import_utils5.hexToBytes)(masterKeyHex);
|
|
1215
1665
|
const childPathBytes = (0, import_utils5.utf8ToBytes)(childPath);
|
|
1216
|
-
const derivedFull = (0, import_hmac.hmac)(
|
|
1666
|
+
const derivedFull = (0, import_hmac.hmac)(import_sha5122.sha512, masterKeyBytes, childPathBytes);
|
|
1217
1667
|
try {
|
|
1218
1668
|
const derivedBytes = derivedFull.slice(0, 32);
|
|
1219
1669
|
const derived = `0x${(0, import_utils5.bytesToHex)(derivedBytes)}`;
|
|
@@ -1973,6 +2423,8 @@ var NEARIntentsAdapter = class {
|
|
|
1973
2423
|
let refundAddress = senderAddress;
|
|
1974
2424
|
let stealthData;
|
|
1975
2425
|
let sharedSecret;
|
|
2426
|
+
let curve;
|
|
2427
|
+
let nativeRecipientAddress;
|
|
1976
2428
|
if (request.privacyLevel !== import_types3.PrivacyLevel.TRANSPARENT) {
|
|
1977
2429
|
if (!recipientMetaAddress) {
|
|
1978
2430
|
throw new ValidationError(
|
|
@@ -1981,28 +2433,91 @@ var NEARIntentsAdapter = class {
|
|
|
1981
2433
|
);
|
|
1982
2434
|
}
|
|
1983
2435
|
const metaAddr = typeof recipientMetaAddress === "string" ? decodeStealthMetaAddress(recipientMetaAddress) : recipientMetaAddress;
|
|
1984
|
-
const
|
|
1985
|
-
const outputChainType = CHAIN_BLOCKCHAIN_MAP[
|
|
1986
|
-
if (
|
|
2436
|
+
const outputChain = request.outputAsset.chain;
|
|
2437
|
+
const outputChainType = CHAIN_BLOCKCHAIN_MAP[outputChain];
|
|
2438
|
+
if (isEd25519Chain(outputChain)) {
|
|
2439
|
+
curve = "ed25519";
|
|
2440
|
+
const spendingKeyBytes = (metaAddr.spendingKey.length - 2) / 2;
|
|
2441
|
+
if (spendingKeyBytes !== 32) {
|
|
2442
|
+
throw new ValidationError(
|
|
2443
|
+
`Meta-address has ${spendingKeyBytes}-byte keys but ${outputChain} requires ed25519 (32-byte) keys. Please generate an ed25519 meta-address using generateEd25519StealthMetaAddress('${outputChain}').`,
|
|
2444
|
+
"recipientMetaAddress",
|
|
2445
|
+
{ outputChain, keySize: spendingKeyBytes, expectedSize: 32 }
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
const { stealthAddress, sharedSecret: secret } = generateEd25519StealthAddress(metaAddr);
|
|
2449
|
+
stealthData = stealthAddress;
|
|
2450
|
+
sharedSecret = secret;
|
|
2451
|
+
if (outputChain === "solana") {
|
|
2452
|
+
recipientAddress = ed25519PublicKeyToSolanaAddress(stealthAddress.address);
|
|
2453
|
+
} else if (outputChain === "near") {
|
|
2454
|
+
recipientAddress = ed25519PublicKeyToNearAddress(stealthAddress.address);
|
|
2455
|
+
} else {
|
|
2456
|
+
throw new ValidationError(
|
|
2457
|
+
`ed25519 address derivation not implemented for ${outputChain}`,
|
|
2458
|
+
"outputAsset",
|
|
2459
|
+
{ outputChain }
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2462
|
+
nativeRecipientAddress = recipientAddress;
|
|
2463
|
+
} else if (outputChainType === "evm") {
|
|
2464
|
+
curve = "secp256k1";
|
|
2465
|
+
const spendingKeyBytes = (metaAddr.spendingKey.length - 2) / 2;
|
|
2466
|
+
if (spendingKeyBytes !== 33) {
|
|
2467
|
+
throw new ValidationError(
|
|
2468
|
+
`Meta-address has ${spendingKeyBytes}-byte keys but ${outputChain} requires secp256k1 (33-byte compressed) keys. Please generate a secp256k1 meta-address using generateStealthMetaAddress('${outputChain}').`,
|
|
2469
|
+
"recipientMetaAddress",
|
|
2470
|
+
{ outputChain, keySize: spendingKeyBytes, expectedSize: 33 }
|
|
2471
|
+
);
|
|
2472
|
+
}
|
|
2473
|
+
const { stealthAddress, sharedSecret: secret } = generateStealthAddress(metaAddr);
|
|
2474
|
+
stealthData = stealthAddress;
|
|
2475
|
+
sharedSecret = secret;
|
|
2476
|
+
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
2477
|
+
nativeRecipientAddress = recipientAddress;
|
|
2478
|
+
} else {
|
|
1987
2479
|
throw new ValidationError(
|
|
1988
|
-
`Stealth addresses are not supported for ${
|
|
2480
|
+
`Stealth addresses are not yet supported for ${outputChain} output. Supported chains: EVM (Ethereum, Polygon, etc.), Solana, NEAR. For ${outputChain}, please provide a direct wallet address.`,
|
|
1989
2481
|
"outputAsset",
|
|
1990
|
-
{ outputChain
|
|
2482
|
+
{ outputChain, outputChainType }
|
|
1991
2483
|
);
|
|
1992
2484
|
}
|
|
1993
|
-
recipientAddress = publicKeyToEthAddress(stealthAddress.address);
|
|
1994
|
-
stealthData = stealthAddress;
|
|
1995
|
-
sharedSecret = secret;
|
|
1996
2485
|
if (!senderAddress) {
|
|
1997
|
-
const
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2486
|
+
const inputChain = request.inputAsset.chain;
|
|
2487
|
+
const inputChainType = CHAIN_BLOCKCHAIN_MAP[inputChain];
|
|
2488
|
+
if (isEd25519Chain(inputChain)) {
|
|
2489
|
+
const inputKeyBytes = (metaAddr.spendingKey.length - 2) / 2;
|
|
2490
|
+
if (inputKeyBytes === 32) {
|
|
2491
|
+
const refundStealth = generateEd25519StealthAddress(metaAddr);
|
|
2492
|
+
if (inputChain === "solana") {
|
|
2493
|
+
refundAddress = ed25519PublicKeyToSolanaAddress(refundStealth.stealthAddress.address);
|
|
2494
|
+
} else if (inputChain === "near") {
|
|
2495
|
+
refundAddress = ed25519PublicKeyToNearAddress(refundStealth.stealthAddress.address);
|
|
2496
|
+
}
|
|
2497
|
+
} else {
|
|
2498
|
+
throw new ValidationError(
|
|
2499
|
+
`Cross-curve refunds not supported: input chain ${inputChain} requires ed25519 but meta-address uses secp256k1. Please provide a senderAddress for refunds, or use matching curves for input/output chains.`,
|
|
2500
|
+
"senderAddress",
|
|
2501
|
+
{ inputChain, inputChainType, metaAddressCurve: "secp256k1" }
|
|
2502
|
+
);
|
|
2503
|
+
}
|
|
2504
|
+
} else if (inputChainType === "evm") {
|
|
2505
|
+
const inputKeyBytes = (metaAddr.spendingKey.length - 2) / 2;
|
|
2506
|
+
if (inputKeyBytes === 33) {
|
|
2507
|
+
const refundStealth = generateStealthAddress(metaAddr);
|
|
2508
|
+
refundAddress = publicKeyToEthAddress(refundStealth.stealthAddress.address);
|
|
2509
|
+
} else {
|
|
2510
|
+
throw new ValidationError(
|
|
2511
|
+
`Cross-curve refunds not supported: input chain ${inputChain} requires secp256k1 but meta-address uses ed25519. Please provide a senderAddress for refunds, or use matching curves for input/output chains.`,
|
|
2512
|
+
"senderAddress",
|
|
2513
|
+
{ inputChain, inputChainType, metaAddressCurve: "ed25519" }
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2001
2516
|
} else {
|
|
2002
2517
|
throw new ValidationError(
|
|
2003
|
-
`senderAddress is required for refunds on ${
|
|
2518
|
+
`senderAddress is required for refunds on ${inputChain}. Automatic refund address generation is only supported for EVM, Solana, and NEAR chains.`,
|
|
2004
2519
|
"senderAddress",
|
|
2005
|
-
{ inputChain
|
|
2520
|
+
{ inputChain, inputChainType }
|
|
2006
2521
|
);
|
|
2007
2522
|
}
|
|
2008
2523
|
}
|
|
@@ -2020,7 +2535,9 @@ var NEARIntentsAdapter = class {
|
|
|
2020
2535
|
request,
|
|
2021
2536
|
quoteRequest,
|
|
2022
2537
|
stealthAddress: stealthData,
|
|
2023
|
-
sharedSecret
|
|
2538
|
+
sharedSecret,
|
|
2539
|
+
curve,
|
|
2540
|
+
nativeRecipientAddress
|
|
2024
2541
|
};
|
|
2025
2542
|
}
|
|
2026
2543
|
/**
|
|
@@ -4348,15 +4865,15 @@ var NoirProofProvider = class {
|
|
|
4348
4865
|
*/
|
|
4349
4866
|
async computeCommitmentHash(balance, blindingFactor, assetId) {
|
|
4350
4867
|
const blindingField = this.bytesToField(blindingFactor);
|
|
4351
|
-
const { sha256:
|
|
4352
|
-
const { bytesToHex:
|
|
4868
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
4869
|
+
const { bytesToHex: bytesToHex15 } = await import("@noble/hashes/utils");
|
|
4353
4870
|
const preimage = new Uint8Array([
|
|
4354
4871
|
...this.bigintToBytes(balance, 8),
|
|
4355
4872
|
...blindingFactor.slice(0, 32),
|
|
4356
4873
|
...this.hexToBytes(this.assetIdToField(assetId))
|
|
4357
4874
|
]);
|
|
4358
|
-
const hash2 =
|
|
4359
|
-
const commitmentHash =
|
|
4875
|
+
const hash2 = sha25611(preimage);
|
|
4876
|
+
const commitmentHash = bytesToHex15(hash2);
|
|
4360
4877
|
return { commitmentHash, blindingField };
|
|
4361
4878
|
}
|
|
4362
4879
|
/**
|
|
@@ -4435,14 +4952,14 @@ var NoirProofProvider = class {
|
|
|
4435
4952
|
* @see computeCommitmentHash for hash function compatibility notes
|
|
4436
4953
|
*/
|
|
4437
4954
|
async computeSenderCommitment(senderAddressField, senderBlindingField) {
|
|
4438
|
-
const { sha256:
|
|
4439
|
-
const { bytesToHex:
|
|
4955
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
4956
|
+
const { bytesToHex: bytesToHex15 } = await import("@noble/hashes/utils");
|
|
4440
4957
|
const addressBytes = this.hexToBytes(senderAddressField);
|
|
4441
4958
|
const blindingBytes = this.hexToBytes(senderBlindingField.padStart(64, "0"));
|
|
4442
4959
|
const preimage = new Uint8Array([...addressBytes, ...blindingBytes]);
|
|
4443
|
-
const hash2 =
|
|
4444
|
-
const commitmentX =
|
|
4445
|
-
const commitmentY =
|
|
4960
|
+
const hash2 = sha25611(preimage);
|
|
4961
|
+
const commitmentX = bytesToHex15(hash2.slice(0, 16)).padStart(64, "0");
|
|
4962
|
+
const commitmentY = bytesToHex15(hash2.slice(16, 32)).padStart(64, "0");
|
|
4446
4963
|
return { commitmentX, commitmentY };
|
|
4447
4964
|
}
|
|
4448
4965
|
/**
|
|
@@ -4454,14 +4971,14 @@ var NoirProofProvider = class {
|
|
|
4454
4971
|
* @see computeCommitmentHash for hash function compatibility notes
|
|
4455
4972
|
*/
|
|
4456
4973
|
async computeNullifier(senderSecretField, intentHashField, nonceField) {
|
|
4457
|
-
const { sha256:
|
|
4458
|
-
const { bytesToHex:
|
|
4974
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
4975
|
+
const { bytesToHex: bytesToHex15 } = await import("@noble/hashes/utils");
|
|
4459
4976
|
const secretBytes = this.hexToBytes(senderSecretField.padStart(64, "0"));
|
|
4460
4977
|
const intentBytes = this.hexToBytes(intentHashField);
|
|
4461
4978
|
const nonceBytes = this.hexToBytes(nonceField.padStart(64, "0"));
|
|
4462
4979
|
const preimage = new Uint8Array([...secretBytes, ...intentBytes, ...nonceBytes]);
|
|
4463
|
-
const hash2 =
|
|
4464
|
-
return
|
|
4980
|
+
const hash2 = sha25611(preimage);
|
|
4981
|
+
return bytesToHex15(hash2);
|
|
4465
4982
|
}
|
|
4466
4983
|
/**
|
|
4467
4984
|
* Compute output commitment for fulfillment proof
|
|
@@ -4472,14 +4989,14 @@ var NoirProofProvider = class {
|
|
|
4472
4989
|
* @see computeCommitmentHash for hash function compatibility notes
|
|
4473
4990
|
*/
|
|
4474
4991
|
async computeOutputCommitment(outputAmount, outputBlinding) {
|
|
4475
|
-
const { sha256:
|
|
4476
|
-
const { bytesToHex:
|
|
4992
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
4993
|
+
const { bytesToHex: bytesToHex15 } = await import("@noble/hashes/utils");
|
|
4477
4994
|
const amountBytes = this.bigintToBytes(outputAmount, 8);
|
|
4478
4995
|
const blindingBytes = outputBlinding.slice(0, 32);
|
|
4479
4996
|
const preimage = new Uint8Array([...amountBytes, ...blindingBytes]);
|
|
4480
|
-
const hash2 =
|
|
4481
|
-
const commitmentX =
|
|
4482
|
-
const commitmentY =
|
|
4997
|
+
const hash2 = sha25611(preimage);
|
|
4998
|
+
const commitmentX = bytesToHex15(hash2.slice(0, 16)).padStart(64, "0");
|
|
4999
|
+
const commitmentY = bytesToHex15(hash2.slice(16, 32)).padStart(64, "0");
|
|
4483
5000
|
return { commitmentX, commitmentY };
|
|
4484
5001
|
}
|
|
4485
5002
|
/**
|
|
@@ -4491,11 +5008,11 @@ var NoirProofProvider = class {
|
|
|
4491
5008
|
* @see computeCommitmentHash for hash function compatibility notes
|
|
4492
5009
|
*/
|
|
4493
5010
|
async computeSolverId(solverSecretField) {
|
|
4494
|
-
const { sha256:
|
|
4495
|
-
const { bytesToHex:
|
|
5011
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
5012
|
+
const { bytesToHex: bytesToHex15 } = await import("@noble/hashes/utils");
|
|
4496
5013
|
const secretBytes = this.hexToBytes(solverSecretField.padStart(64, "0"));
|
|
4497
|
-
const hash2 =
|
|
4498
|
-
return
|
|
5014
|
+
const hash2 = sha25611(secretBytes);
|
|
5015
|
+
return bytesToHex15(hash2);
|
|
4499
5016
|
}
|
|
4500
5017
|
/**
|
|
4501
5018
|
* Compute oracle message hash for fulfillment proof
|
|
@@ -4503,7 +5020,7 @@ var NoirProofProvider = class {
|
|
|
4503
5020
|
* Hash of attestation data that oracle signs
|
|
4504
5021
|
*/
|
|
4505
5022
|
async computeOracleMessageHash(recipient, amount, txHash, blockNumber) {
|
|
4506
|
-
const { sha256:
|
|
5023
|
+
const { sha256: sha25611 } = await import("@noble/hashes/sha256");
|
|
4507
5024
|
const recipientBytes = this.hexToBytes(this.hexToField(recipient));
|
|
4508
5025
|
const amountBytes = this.bigintToBytes(amount, 8);
|
|
4509
5026
|
const txHashBytes = this.hexToBytes(this.hexToField(txHash));
|
|
@@ -4514,7 +5031,7 @@ var NoirProofProvider = class {
|
|
|
4514
5031
|
...txHashBytes,
|
|
4515
5032
|
...blockBytes
|
|
4516
5033
|
]);
|
|
4517
|
-
const hash2 =
|
|
5034
|
+
const hash2 = sha25611(preimage);
|
|
4518
5035
|
return Array.from(hash2);
|
|
4519
5036
|
}
|
|
4520
5037
|
/**
|
|
@@ -4541,15 +5058,330 @@ var NoirProofProvider = class {
|
|
|
4541
5058
|
}
|
|
4542
5059
|
};
|
|
4543
5060
|
|
|
5061
|
+
// src/proofs/browser-utils.ts
|
|
5062
|
+
function hexToBytes5(hex) {
|
|
5063
|
+
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
5064
|
+
if (h.length === 0) return new Uint8Array(0);
|
|
5065
|
+
if (h.length % 2 !== 0) {
|
|
5066
|
+
throw new Error("Hex string must have even length");
|
|
5067
|
+
}
|
|
5068
|
+
const bytes = new Uint8Array(h.length / 2);
|
|
5069
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
5070
|
+
bytes[i] = parseInt(h.slice(i * 2, i * 2 + 2), 16);
|
|
5071
|
+
}
|
|
5072
|
+
return bytes;
|
|
5073
|
+
}
|
|
5074
|
+
function bytesToHex7(bytes) {
|
|
5075
|
+
return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5076
|
+
}
|
|
5077
|
+
function isBrowser() {
|
|
5078
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
5079
|
+
}
|
|
5080
|
+
function supportsWebWorkers() {
|
|
5081
|
+
return typeof Worker !== "undefined";
|
|
5082
|
+
}
|
|
5083
|
+
function supportsSharedArrayBuffer() {
|
|
5084
|
+
try {
|
|
5085
|
+
return typeof SharedArrayBuffer !== "undefined";
|
|
5086
|
+
} catch {
|
|
5087
|
+
return false;
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
function getBrowserInfo() {
|
|
5091
|
+
return {
|
|
5092
|
+
isBrowser: isBrowser(),
|
|
5093
|
+
supportsWorkers: supportsWebWorkers(),
|
|
5094
|
+
supportsSharedArrayBuffer: supportsSharedArrayBuffer(),
|
|
5095
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : null
|
|
5096
|
+
};
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
// src/oracle/types.ts
|
|
5100
|
+
var ORACLE_DOMAIN = "SIP-ORACLE-ATTESTATION-V1";
|
|
5101
|
+
var ATTESTATION_VERSION = 1;
|
|
5102
|
+
var DEFAULT_THRESHOLD = 3;
|
|
5103
|
+
var DEFAULT_TOTAL_ORACLES = 5;
|
|
5104
|
+
var CHAIN_NUMERIC_IDS = {
|
|
5105
|
+
ethereum: 1,
|
|
5106
|
+
polygon: 137,
|
|
5107
|
+
arbitrum: 42161,
|
|
5108
|
+
optimism: 10,
|
|
5109
|
+
base: 8453,
|
|
5110
|
+
bitcoin: 0,
|
|
5111
|
+
// Non-standard, SIP-specific (Bitcoin mainnet)
|
|
5112
|
+
solana: 501,
|
|
5113
|
+
// Non-standard, SIP-specific
|
|
5114
|
+
near: 502,
|
|
5115
|
+
// Non-standard, SIP-specific
|
|
5116
|
+
zcash: 503
|
|
5117
|
+
// Non-standard, SIP-specific
|
|
5118
|
+
};
|
|
5119
|
+
|
|
5120
|
+
// src/oracle/verification.ts
|
|
5121
|
+
var import_ed255192 = require("@noble/curves/ed25519");
|
|
5122
|
+
var import_sha2568 = require("@noble/hashes/sha256");
|
|
5123
|
+
var import_utils9 = require("@noble/hashes/utils");
|
|
5124
|
+
|
|
5125
|
+
// src/oracle/serialization.ts
|
|
5126
|
+
var import_sha2567 = require("@noble/hashes/sha256");
|
|
5127
|
+
var import_utils8 = require("@noble/hashes/utils");
|
|
5128
|
+
function serializeAttestationMessage(message) {
|
|
5129
|
+
const buffer = new Uint8Array(197);
|
|
5130
|
+
const view = new DataView(buffer.buffer);
|
|
5131
|
+
let offset = 0;
|
|
5132
|
+
buffer[offset++] = message.version;
|
|
5133
|
+
view.setUint32(offset, message.chainId, false);
|
|
5134
|
+
offset += 4;
|
|
5135
|
+
const intentHashBytes = normalizeToBytes(message.intentHash, 32, "intentHash");
|
|
5136
|
+
buffer.set(intentHashBytes, offset);
|
|
5137
|
+
offset += 32;
|
|
5138
|
+
const recipientBytes = normalizeToBytes(message.recipient, 32, "recipient");
|
|
5139
|
+
buffer.set(recipientBytes, offset);
|
|
5140
|
+
offset += 32;
|
|
5141
|
+
const amountBytes = bigintToBytes(message.amount, 16);
|
|
5142
|
+
buffer.set(amountBytes, offset);
|
|
5143
|
+
offset += 16;
|
|
5144
|
+
const assetIdBytes = normalizeToBytes(message.assetId, 32, "assetId");
|
|
5145
|
+
buffer.set(assetIdBytes, offset);
|
|
5146
|
+
offset += 32;
|
|
5147
|
+
const txHashBytes = normalizeToBytes(message.txHash, 32, "txHash");
|
|
5148
|
+
buffer.set(txHashBytes, offset);
|
|
5149
|
+
offset += 32;
|
|
5150
|
+
view.setBigUint64(offset, message.blockNumber, false);
|
|
5151
|
+
offset += 8;
|
|
5152
|
+
const blockHashBytes = normalizeToBytes(message.blockHash, 32, "blockHash");
|
|
5153
|
+
buffer.set(blockHashBytes, offset);
|
|
5154
|
+
offset += 32;
|
|
5155
|
+
view.setBigUint64(offset, BigInt(message.timestamp), false);
|
|
5156
|
+
return buffer;
|
|
5157
|
+
}
|
|
5158
|
+
function deserializeAttestationMessage(bytes) {
|
|
5159
|
+
if (bytes.length !== 197) {
|
|
5160
|
+
throw new ValidationError(
|
|
5161
|
+
`Invalid attestation message length: ${bytes.length}, expected 197`,
|
|
5162
|
+
"bytes"
|
|
5163
|
+
);
|
|
5164
|
+
}
|
|
5165
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset);
|
|
5166
|
+
let offset = 0;
|
|
5167
|
+
const version = bytes[offset++];
|
|
5168
|
+
const chainId = view.getUint32(offset, false);
|
|
5169
|
+
offset += 4;
|
|
5170
|
+
const intentHash = `0x${(0, import_utils8.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
5171
|
+
offset += 32;
|
|
5172
|
+
const recipient = `0x${(0, import_utils8.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
5173
|
+
offset += 32;
|
|
5174
|
+
const amount = bytesToBigint(bytes.slice(offset, offset + 16));
|
|
5175
|
+
offset += 16;
|
|
5176
|
+
const assetId = `0x${(0, import_utils8.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
5177
|
+
offset += 32;
|
|
5178
|
+
const txHash = `0x${(0, import_utils8.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
5179
|
+
offset += 32;
|
|
5180
|
+
const blockNumber = view.getBigUint64(offset, false);
|
|
5181
|
+
offset += 8;
|
|
5182
|
+
const blockHash = `0x${(0, import_utils8.bytesToHex)(bytes.slice(offset, offset + 32))}`;
|
|
5183
|
+
offset += 32;
|
|
5184
|
+
const timestamp = Number(view.getBigUint64(offset, false));
|
|
5185
|
+
return {
|
|
5186
|
+
version,
|
|
5187
|
+
chainId,
|
|
5188
|
+
intentHash,
|
|
5189
|
+
recipient,
|
|
5190
|
+
amount,
|
|
5191
|
+
assetId,
|
|
5192
|
+
txHash,
|
|
5193
|
+
blockNumber,
|
|
5194
|
+
blockHash,
|
|
5195
|
+
timestamp
|
|
5196
|
+
};
|
|
5197
|
+
}
|
|
5198
|
+
function computeAttestationHash(message) {
|
|
5199
|
+
const domain = (0, import_utils8.utf8ToBytes)(ORACLE_DOMAIN);
|
|
5200
|
+
const messageBytes = serializeAttestationMessage(message);
|
|
5201
|
+
const toHash = new Uint8Array(domain.length + messageBytes.length);
|
|
5202
|
+
toHash.set(domain, 0);
|
|
5203
|
+
toHash.set(messageBytes, domain.length);
|
|
5204
|
+
return (0, import_sha2567.sha256)(toHash);
|
|
5205
|
+
}
|
|
5206
|
+
function getChainNumericId(chain) {
|
|
5207
|
+
const id = CHAIN_NUMERIC_IDS[chain];
|
|
5208
|
+
if (id === void 0) {
|
|
5209
|
+
throw new ValidationError(`Unknown chain: ${chain}`, "chain");
|
|
5210
|
+
}
|
|
5211
|
+
return id;
|
|
5212
|
+
}
|
|
5213
|
+
function normalizeToBytes(hex, length, field) {
|
|
5214
|
+
const stripped = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
5215
|
+
const bytes = (0, import_utils8.hexToBytes)(stripped);
|
|
5216
|
+
if (bytes.length === length) {
|
|
5217
|
+
return bytes;
|
|
5218
|
+
}
|
|
5219
|
+
if (bytes.length > length) {
|
|
5220
|
+
throw new ValidationError(
|
|
5221
|
+
`${field} is too long: ${bytes.length} bytes, max ${length}`,
|
|
5222
|
+
field
|
|
5223
|
+
);
|
|
5224
|
+
}
|
|
5225
|
+
const padded = new Uint8Array(length);
|
|
5226
|
+
padded.set(bytes, length - bytes.length);
|
|
5227
|
+
return padded;
|
|
5228
|
+
}
|
|
5229
|
+
function bigintToBytes(value, length) {
|
|
5230
|
+
const bytes = new Uint8Array(length);
|
|
5231
|
+
let v = value;
|
|
5232
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
5233
|
+
bytes[i] = Number(v & 0xffn);
|
|
5234
|
+
v >>= 8n;
|
|
5235
|
+
}
|
|
5236
|
+
return bytes;
|
|
5237
|
+
}
|
|
5238
|
+
function bytesToBigint(bytes) {
|
|
5239
|
+
let result = 0n;
|
|
5240
|
+
for (const byte of bytes) {
|
|
5241
|
+
result = (result << 8n) + BigInt(byte);
|
|
5242
|
+
}
|
|
5243
|
+
return result;
|
|
5244
|
+
}
|
|
5245
|
+
|
|
5246
|
+
// src/oracle/verification.ts
|
|
5247
|
+
function deriveOracleId(publicKey) {
|
|
5248
|
+
const keyBytes = typeof publicKey === "string" ? (0, import_utils9.hexToBytes)(publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey) : publicKey;
|
|
5249
|
+
const hash2 = (0, import_sha2568.sha256)(keyBytes);
|
|
5250
|
+
return `0x${(0, import_utils9.bytesToHex)(hash2)}`;
|
|
5251
|
+
}
|
|
5252
|
+
function verifyAttestation(attestation, registry) {
|
|
5253
|
+
const { message, signatures } = attestation;
|
|
5254
|
+
const errors = [];
|
|
5255
|
+
const validOracles = [];
|
|
5256
|
+
if (signatures.length < registry.threshold) {
|
|
5257
|
+
errors.push(
|
|
5258
|
+
`Insufficient signatures: ${signatures.length} < ${registry.threshold} required`
|
|
5259
|
+
);
|
|
5260
|
+
}
|
|
5261
|
+
const messageHash = computeAttestationHash(message);
|
|
5262
|
+
const seenOracles = /* @__PURE__ */ new Set();
|
|
5263
|
+
let validCount = 0;
|
|
5264
|
+
for (const sig of signatures) {
|
|
5265
|
+
if (seenOracles.has(sig.oracleId)) {
|
|
5266
|
+
errors.push(`Duplicate signature from oracle: ${sig.oracleId}`);
|
|
5267
|
+
continue;
|
|
5268
|
+
}
|
|
5269
|
+
seenOracles.add(sig.oracleId);
|
|
5270
|
+
const oracle = registry.oracles.get(sig.oracleId);
|
|
5271
|
+
if (!oracle) {
|
|
5272
|
+
errors.push(`Unknown oracle: ${sig.oracleId}`);
|
|
5273
|
+
continue;
|
|
5274
|
+
}
|
|
5275
|
+
if (oracle.status !== "active") {
|
|
5276
|
+
errors.push(`Oracle not active: ${sig.oracleId} (status: ${oracle.status})`);
|
|
5277
|
+
continue;
|
|
5278
|
+
}
|
|
5279
|
+
try {
|
|
5280
|
+
const publicKeyBytes = (0, import_utils9.hexToBytes)(
|
|
5281
|
+
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
5282
|
+
);
|
|
5283
|
+
const signatureBytes = (0, import_utils9.hexToBytes)(
|
|
5284
|
+
sig.signature.startsWith("0x") ? sig.signature.slice(2) : sig.signature
|
|
5285
|
+
);
|
|
5286
|
+
const isValid = import_ed255192.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
5287
|
+
if (isValid) {
|
|
5288
|
+
validCount++;
|
|
5289
|
+
validOracles.push(sig.oracleId);
|
|
5290
|
+
} else {
|
|
5291
|
+
errors.push(`Invalid signature from oracle: ${sig.oracleId}`);
|
|
5292
|
+
}
|
|
5293
|
+
} catch (e) {
|
|
5294
|
+
errors.push(`Signature verification error for ${sig.oracleId}: ${e}`);
|
|
5295
|
+
}
|
|
5296
|
+
}
|
|
5297
|
+
const valid = validCount >= registry.threshold && errors.length === 0;
|
|
5298
|
+
return {
|
|
5299
|
+
valid,
|
|
5300
|
+
validSignatures: validCount,
|
|
5301
|
+
threshold: registry.threshold,
|
|
5302
|
+
validOracles,
|
|
5303
|
+
errors: errors.length > 0 ? errors : void 0
|
|
5304
|
+
};
|
|
5305
|
+
}
|
|
5306
|
+
function verifyOracleSignature(signature, messageHash, oracle) {
|
|
5307
|
+
try {
|
|
5308
|
+
const publicKeyBytes = (0, import_utils9.hexToBytes)(
|
|
5309
|
+
oracle.publicKey.startsWith("0x") ? oracle.publicKey.slice(2) : oracle.publicKey
|
|
5310
|
+
);
|
|
5311
|
+
const signatureBytes = (0, import_utils9.hexToBytes)(
|
|
5312
|
+
signature.signature.startsWith("0x") ? signature.signature.slice(2) : signature.signature
|
|
5313
|
+
);
|
|
5314
|
+
return import_ed255192.ed25519.verify(signatureBytes, messageHash, publicKeyBytes);
|
|
5315
|
+
} catch {
|
|
5316
|
+
return false;
|
|
5317
|
+
}
|
|
5318
|
+
}
|
|
5319
|
+
function signAttestationMessage(messageHash, privateKey) {
|
|
5320
|
+
const signature = import_ed255192.ed25519.sign(messageHash, privateKey);
|
|
5321
|
+
const publicKey = import_ed255192.ed25519.getPublicKey(privateKey);
|
|
5322
|
+
const oracleId = deriveOracleId(publicKey);
|
|
5323
|
+
return {
|
|
5324
|
+
oracleId,
|
|
5325
|
+
signature: `0x${(0, import_utils9.bytesToHex)(signature)}`
|
|
5326
|
+
};
|
|
5327
|
+
}
|
|
5328
|
+
function createOracleRegistry(config = {}) {
|
|
5329
|
+
const registry = {
|
|
5330
|
+
oracles: /* @__PURE__ */ new Map(),
|
|
5331
|
+
threshold: config.threshold ?? DEFAULT_THRESHOLD,
|
|
5332
|
+
totalOracles: 0,
|
|
5333
|
+
version: 1,
|
|
5334
|
+
lastUpdated: Date.now()
|
|
5335
|
+
};
|
|
5336
|
+
if (config.customOracles) {
|
|
5337
|
+
for (const oracle of config.customOracles) {
|
|
5338
|
+
registry.oracles.set(oracle.id, oracle);
|
|
5339
|
+
}
|
|
5340
|
+
registry.totalOracles = config.customOracles.length;
|
|
5341
|
+
}
|
|
5342
|
+
return registry;
|
|
5343
|
+
}
|
|
5344
|
+
function addOracle(registry, oracle) {
|
|
5345
|
+
registry.oracles.set(oracle.id, oracle);
|
|
5346
|
+
registry.totalOracles = registry.oracles.size;
|
|
5347
|
+
registry.lastUpdated = Date.now();
|
|
5348
|
+
}
|
|
5349
|
+
function removeOracle(registry, oracleId) {
|
|
5350
|
+
const removed = registry.oracles.delete(oracleId);
|
|
5351
|
+
if (removed) {
|
|
5352
|
+
registry.totalOracles = registry.oracles.size;
|
|
5353
|
+
registry.lastUpdated = Date.now();
|
|
5354
|
+
}
|
|
5355
|
+
return removed;
|
|
5356
|
+
}
|
|
5357
|
+
function updateOracleStatus(registry, oracleId, status) {
|
|
5358
|
+
const oracle = registry.oracles.get(oracleId);
|
|
5359
|
+
if (!oracle) {
|
|
5360
|
+
return false;
|
|
5361
|
+
}
|
|
5362
|
+
oracle.status = status;
|
|
5363
|
+
registry.lastUpdated = Date.now();
|
|
5364
|
+
return true;
|
|
5365
|
+
}
|
|
5366
|
+
function getActiveOracles(registry) {
|
|
5367
|
+
return Array.from(registry.oracles.values()).filter(
|
|
5368
|
+
(oracle) => oracle.status === "active"
|
|
5369
|
+
);
|
|
5370
|
+
}
|
|
5371
|
+
function hasEnoughOracles(registry) {
|
|
5372
|
+
const activeCount = getActiveOracles(registry).length;
|
|
5373
|
+
return activeCount >= registry.threshold;
|
|
5374
|
+
}
|
|
5375
|
+
|
|
4544
5376
|
// src/index.ts
|
|
4545
|
-
var import_types31 = require("@sip-protocol/types");
|
|
4546
|
-
var import_types32 = require("@sip-protocol/types");
|
|
4547
5377
|
var import_types33 = require("@sip-protocol/types");
|
|
4548
5378
|
var import_types34 = require("@sip-protocol/types");
|
|
5379
|
+
var import_types35 = require("@sip-protocol/types");
|
|
5380
|
+
var import_types36 = require("@sip-protocol/types");
|
|
4549
5381
|
|
|
4550
5382
|
// src/solver/mock-solver.ts
|
|
4551
|
-
var
|
|
4552
|
-
var
|
|
5383
|
+
var import_types7 = require("@sip-protocol/types");
|
|
5384
|
+
var import_utils10 = require("@noble/hashes/utils");
|
|
4553
5385
|
var MockSolver = class {
|
|
4554
5386
|
info;
|
|
4555
5387
|
capabilities;
|
|
@@ -4631,7 +5463,7 @@ var MockSolver = class {
|
|
|
4631
5463
|
const spreadAmount = baseOutput * BigInt(Math.floor(this.spreadPercent * 1e4)) / 10000n;
|
|
4632
5464
|
const outputAmount = baseOutput + spreadAmount;
|
|
4633
5465
|
const feeAmount = outputAmount * BigInt(Math.floor(this.feePercent * 1e4)) / 10000n;
|
|
4634
|
-
const quoteId = `quote-${(0,
|
|
5466
|
+
const quoteId = `quote-${(0, import_utils10.bytesToHex)((0, import_utils10.randomBytes)(8))}`;
|
|
4635
5467
|
const now = Math.floor(Date.now() / 1e3);
|
|
4636
5468
|
const quote = {
|
|
4637
5469
|
quoteId,
|
|
@@ -4642,7 +5474,7 @@ var MockSolver = class {
|
|
|
4642
5474
|
expiry: now + 60,
|
|
4643
5475
|
// Quote valid for 1 minute
|
|
4644
5476
|
fee: feeAmount,
|
|
4645
|
-
signature: `0x${(0,
|
|
5477
|
+
signature: `0x${(0, import_utils10.bytesToHex)((0, import_utils10.randomBytes)(64))}`,
|
|
4646
5478
|
// Mock signature
|
|
4647
5479
|
validUntil: now + 60,
|
|
4648
5480
|
estimatedGas: 200000n
|
|
@@ -4674,25 +5506,25 @@ var MockSolver = class {
|
|
|
4674
5506
|
status.error = "Simulated failure for testing";
|
|
4675
5507
|
return {
|
|
4676
5508
|
intentId: intent.intentId,
|
|
4677
|
-
status:
|
|
5509
|
+
status: import_types7.IntentStatus.FAILED,
|
|
4678
5510
|
fulfilledAt: Math.floor(Date.now() / 1e3),
|
|
4679
5511
|
error: status.error
|
|
4680
5512
|
};
|
|
4681
5513
|
}
|
|
4682
|
-
const txHash = `0x${(0,
|
|
5514
|
+
const txHash = `0x${(0, import_utils10.bytesToHex)((0, import_utils10.randomBytes)(32))}`;
|
|
4683
5515
|
status.status = "completed";
|
|
4684
5516
|
status.txHash = txHash;
|
|
4685
5517
|
return {
|
|
4686
5518
|
intentId: intent.intentId,
|
|
4687
|
-
status:
|
|
5519
|
+
status: import_types7.IntentStatus.FULFILLED,
|
|
4688
5520
|
outputAmount: quote.outputAmount,
|
|
4689
5521
|
txHash: intent.privacyLevel === "transparent" ? txHash : void 0,
|
|
4690
5522
|
fulfillmentProof: {
|
|
4691
5523
|
type: "fulfillment",
|
|
4692
|
-
proof: `0x${(0,
|
|
5524
|
+
proof: `0x${(0, import_utils10.bytesToHex)((0, import_utils10.randomBytes)(128))}`,
|
|
4693
5525
|
publicInputs: [
|
|
4694
|
-
`0x${(0,
|
|
4695
|
-
`0x${(0,
|
|
5526
|
+
`0x${(0, import_utils10.bytesToHex)(new TextEncoder().encode(intent.intentId))}`,
|
|
5527
|
+
`0x${(0, import_utils10.bytesToHex)(new TextEncoder().encode(quote.quoteId))}`
|
|
4696
5528
|
]
|
|
4697
5529
|
},
|
|
4698
5530
|
fulfilledAt: Math.floor(Date.now() / 1e3)
|
|
@@ -4730,10 +5562,10 @@ function createMockSolver(config) {
|
|
|
4730
5562
|
}
|
|
4731
5563
|
|
|
4732
5564
|
// src/index.ts
|
|
4733
|
-
var
|
|
5565
|
+
var import_types37 = require("@sip-protocol/types");
|
|
4734
5566
|
|
|
4735
5567
|
// src/zcash/rpc-client.ts
|
|
4736
|
-
var
|
|
5568
|
+
var import_types8 = require("@sip-protocol/types");
|
|
4737
5569
|
var DEFAULT_CONFIG = {
|
|
4738
5570
|
host: "127.0.0.1",
|
|
4739
5571
|
port: 8232,
|
|
@@ -4753,19 +5585,19 @@ var ZcashRPCError = class extends Error {
|
|
|
4753
5585
|
* Check if error is due to insufficient funds
|
|
4754
5586
|
*/
|
|
4755
5587
|
isInsufficientFunds() {
|
|
4756
|
-
return this.code ===
|
|
5588
|
+
return this.code === import_types8.ZcashErrorCode.WALLET_INSUFFICIENT_FUNDS;
|
|
4757
5589
|
}
|
|
4758
5590
|
/**
|
|
4759
5591
|
* Check if error is due to invalid address
|
|
4760
5592
|
*/
|
|
4761
5593
|
isInvalidAddress() {
|
|
4762
|
-
return this.code ===
|
|
5594
|
+
return this.code === import_types8.ZcashErrorCode.INVALID_ADDRESS_OR_KEY;
|
|
4763
5595
|
}
|
|
4764
5596
|
/**
|
|
4765
5597
|
* Check if error is due to wallet being locked
|
|
4766
5598
|
*/
|
|
4767
5599
|
isWalletLocked() {
|
|
4768
|
-
return this.code ===
|
|
5600
|
+
return this.code === import_types8.ZcashErrorCode.WALLET_UNLOCK_NEEDED;
|
|
4769
5601
|
}
|
|
4770
5602
|
};
|
|
4771
5603
|
var ZcashRPCClient = class {
|
|
@@ -5152,7 +5984,7 @@ function createZcashClient(config) {
|
|
|
5152
5984
|
}
|
|
5153
5985
|
|
|
5154
5986
|
// src/zcash/shielded-service.ts
|
|
5155
|
-
var
|
|
5987
|
+
var import_types9 = require("@sip-protocol/types");
|
|
5156
5988
|
var ZcashShieldedService = class _ZcashShieldedService {
|
|
5157
5989
|
client;
|
|
5158
5990
|
config;
|
|
@@ -5338,7 +6170,7 @@ var ZcashShieldedService = class _ZcashShieldedService {
|
|
|
5338
6170
|
* Higher-level method that handles privacy level mapping.
|
|
5339
6171
|
*/
|
|
5340
6172
|
async sendWithPrivacy(to, amount, privacyLevel, memo) {
|
|
5341
|
-
if (privacyLevel ===
|
|
6173
|
+
if (privacyLevel === import_types9.PrivacyLevel.TRANSPARENT) {
|
|
5342
6174
|
throw new ValidationError(
|
|
5343
6175
|
"Transparent mode not supported for Zcash shielded service. Use standard RPC client.",
|
|
5344
6176
|
"privacyLevel",
|
|
@@ -5432,7 +6264,7 @@ var ZcashShieldedService = class _ZcashShieldedService {
|
|
|
5432
6264
|
const viewingKey = await this.exportViewingKey();
|
|
5433
6265
|
return {
|
|
5434
6266
|
viewingKey,
|
|
5435
|
-
privacyLevel:
|
|
6267
|
+
privacyLevel: import_types9.PrivacyLevel.COMPLIANT,
|
|
5436
6268
|
disclaimer: "This viewing key provides read-only access to transaction history. It cannot be used to spend funds. Share only with authorized auditors."
|
|
5437
6269
|
};
|
|
5438
6270
|
}
|
|
@@ -5518,11 +6350,11 @@ var ZcashShieldedService = class _ZcashShieldedService {
|
|
|
5518
6350
|
*/
|
|
5519
6351
|
mapPrivacyLevelToPolicy(level) {
|
|
5520
6352
|
switch (level) {
|
|
5521
|
-
case
|
|
6353
|
+
case import_types9.PrivacyLevel.TRANSPARENT:
|
|
5522
6354
|
return "NoPrivacy";
|
|
5523
|
-
case
|
|
6355
|
+
case import_types9.PrivacyLevel.SHIELDED:
|
|
5524
6356
|
return "FullPrivacy";
|
|
5525
|
-
case
|
|
6357
|
+
case import_types9.PrivacyLevel.COMPLIANT:
|
|
5526
6358
|
return "FullPrivacy";
|
|
5527
6359
|
default:
|
|
5528
6360
|
return "FullPrivacy";
|
|
@@ -5575,15 +6407,15 @@ function createZcashShieldedService(config) {
|
|
|
5575
6407
|
}
|
|
5576
6408
|
|
|
5577
6409
|
// src/zcash/index.ts
|
|
5578
|
-
var
|
|
6410
|
+
var import_types10 = require("@sip-protocol/types");
|
|
5579
6411
|
|
|
5580
6412
|
// src/index.ts
|
|
5581
|
-
var
|
|
6413
|
+
var import_types38 = require("@sip-protocol/types");
|
|
5582
6414
|
|
|
5583
6415
|
// src/payment/payment.ts
|
|
5584
|
-
var
|
|
5585
|
-
var
|
|
5586
|
-
var
|
|
6416
|
+
var import_types11 = require("@sip-protocol/types");
|
|
6417
|
+
var import_sha2569 = require("@noble/hashes/sha256");
|
|
6418
|
+
var import_utils11 = require("@noble/hashes/utils");
|
|
5587
6419
|
var import_chacha2 = require("@noble/ciphers/chacha.js");
|
|
5588
6420
|
var import_hkdf2 = require("@noble/hashes/hkdf");
|
|
5589
6421
|
|
|
@@ -5768,7 +6600,7 @@ var PaymentBuilder = class {
|
|
|
5768
6600
|
_amount;
|
|
5769
6601
|
_recipientMetaAddress;
|
|
5770
6602
|
_recipientAddress;
|
|
5771
|
-
_privacy =
|
|
6603
|
+
_privacy = import_types11.PrivacyLevel.SHIELDED;
|
|
5772
6604
|
_viewingKey;
|
|
5773
6605
|
_sourceChain;
|
|
5774
6606
|
_destinationChain;
|
|
@@ -6051,7 +6883,7 @@ async function createShieldedPayment(params, options) {
|
|
|
6051
6883
|
} else {
|
|
6052
6884
|
resolvedToken = token;
|
|
6053
6885
|
}
|
|
6054
|
-
if (privacy !==
|
|
6886
|
+
if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && !recipientMetaAddress) {
|
|
6055
6887
|
throw new ValidationError(
|
|
6056
6888
|
"recipientMetaAddress is required for shielded/compliant privacy modes",
|
|
6057
6889
|
"recipientMetaAddress",
|
|
@@ -6059,7 +6891,7 @@ async function createShieldedPayment(params, options) {
|
|
|
6059
6891
|
"SIP_2008" /* MISSING_REQUIRED */
|
|
6060
6892
|
);
|
|
6061
6893
|
}
|
|
6062
|
-
if (privacy ===
|
|
6894
|
+
if (privacy === import_types11.PrivacyLevel.TRANSPARENT && !recipientAddress) {
|
|
6063
6895
|
throw new ValidationError(
|
|
6064
6896
|
"recipientAddress is required for transparent mode",
|
|
6065
6897
|
"recipientAddress",
|
|
@@ -6067,7 +6899,7 @@ async function createShieldedPayment(params, options) {
|
|
|
6067
6899
|
"SIP_2008" /* MISSING_REQUIRED */
|
|
6068
6900
|
);
|
|
6069
6901
|
}
|
|
6070
|
-
if (privacy ===
|
|
6902
|
+
if (privacy === import_types11.PrivacyLevel.COMPLIANT && !viewingKey) {
|
|
6071
6903
|
throw new ValidationError(
|
|
6072
6904
|
"viewingKey is required for compliant mode",
|
|
6073
6905
|
"viewingKey",
|
|
@@ -6079,8 +6911,8 @@ async function createShieldedPayment(params, options) {
|
|
|
6079
6911
|
let viewingKeyHash;
|
|
6080
6912
|
if (viewingKey) {
|
|
6081
6913
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
6082
|
-
const keyBytes = (0,
|
|
6083
|
-
viewingKeyHash = `0x${(0,
|
|
6914
|
+
const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
|
|
6915
|
+
viewingKeyHash = `0x${(0, import_utils11.bytesToHex)((0, import_sha2569.sha256)(keyBytes))}`;
|
|
6084
6916
|
}
|
|
6085
6917
|
const privacyConfig = getPrivacyConfig(
|
|
6086
6918
|
privacy,
|
|
@@ -6089,7 +6921,7 @@ async function createShieldedPayment(params, options) {
|
|
|
6089
6921
|
const now = Math.floor(Date.now() / 1e3);
|
|
6090
6922
|
const payment = {
|
|
6091
6923
|
paymentId,
|
|
6092
|
-
version:
|
|
6924
|
+
version: import_types11.SIP_VERSION,
|
|
6093
6925
|
privacyLevel: privacy,
|
|
6094
6926
|
createdAt: now,
|
|
6095
6927
|
expiry: now + ttl,
|
|
@@ -6100,7 +6932,7 @@ async function createShieldedPayment(params, options) {
|
|
|
6100
6932
|
purpose,
|
|
6101
6933
|
viewingKeyHash
|
|
6102
6934
|
};
|
|
6103
|
-
if (privacy !==
|
|
6935
|
+
if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && recipientMetaAddress) {
|
|
6104
6936
|
const metaAddress = decodeStealthMetaAddress(recipientMetaAddress);
|
|
6105
6937
|
const { stealthAddress } = generateStealthAddress(metaAddress);
|
|
6106
6938
|
payment.recipientStealth = stealthAddress;
|
|
@@ -6117,10 +6949,10 @@ async function createShieldedPayment(params, options) {
|
|
|
6117
6949
|
payment.recipientAddress = recipientAddress;
|
|
6118
6950
|
payment.memo = memo;
|
|
6119
6951
|
}
|
|
6120
|
-
if (privacy !==
|
|
6952
|
+
if (privacy !== import_types11.PrivacyLevel.TRANSPARENT && proofProvider?.isReady) {
|
|
6121
6953
|
const hexToUint8 = (hex) => {
|
|
6122
6954
|
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
6123
|
-
return (0,
|
|
6955
|
+
return (0, import_utils11.hexToBytes)(cleanHex);
|
|
6124
6956
|
};
|
|
6125
6957
|
const fundingResult = await proofProvider.generateFundingProof({
|
|
6126
6958
|
balance: amount,
|
|
@@ -6147,17 +6979,17 @@ async function createShieldedPayment(params, options) {
|
|
|
6147
6979
|
}
|
|
6148
6980
|
function encryptMemo(memo, viewingKey) {
|
|
6149
6981
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
6150
|
-
const keyBytes = (0,
|
|
6151
|
-
const encKey = (0, import_hkdf2.hkdf)(
|
|
6982
|
+
const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
|
|
6983
|
+
const encKey = (0, import_hkdf2.hkdf)(import_sha2569.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
6152
6984
|
try {
|
|
6153
|
-
const nonce = (0,
|
|
6985
|
+
const nonce = (0, import_utils11.randomBytes)(24);
|
|
6154
6986
|
const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
|
|
6155
6987
|
const plaintext = new TextEncoder().encode(memo);
|
|
6156
6988
|
const ciphertext = cipher.encrypt(plaintext);
|
|
6157
6989
|
const result = new Uint8Array(nonce.length + ciphertext.length);
|
|
6158
6990
|
result.set(nonce);
|
|
6159
6991
|
result.set(ciphertext, nonce.length);
|
|
6160
|
-
return `0x${(0,
|
|
6992
|
+
return `0x${(0, import_utils11.bytesToHex)(result)}`;
|
|
6161
6993
|
} finally {
|
|
6162
6994
|
secureWipe(keyBytes);
|
|
6163
6995
|
secureWipe(encKey);
|
|
@@ -6165,11 +6997,11 @@ function encryptMemo(memo, viewingKey) {
|
|
|
6165
6997
|
}
|
|
6166
6998
|
function decryptMemo(encryptedMemo, viewingKey) {
|
|
6167
6999
|
const keyHex = viewingKey.startsWith("0x") ? viewingKey.slice(2) : viewingKey;
|
|
6168
|
-
const keyBytes = (0,
|
|
6169
|
-
const encKey = (0, import_hkdf2.hkdf)(
|
|
7000
|
+
const keyBytes = (0, import_utils11.hexToBytes)(keyHex);
|
|
7001
|
+
const encKey = (0, import_hkdf2.hkdf)(import_sha2569.sha256, keyBytes, new Uint8Array(0), new Uint8Array(0), 32);
|
|
6170
7002
|
try {
|
|
6171
7003
|
const dataHex = encryptedMemo.startsWith("0x") ? encryptedMemo.slice(2) : encryptedMemo;
|
|
6172
|
-
const data = (0,
|
|
7004
|
+
const data = (0, import_utils11.hexToBytes)(dataHex);
|
|
6173
7005
|
const nonce = data.slice(0, 24);
|
|
6174
7006
|
const ciphertext = data.slice(24);
|
|
6175
7007
|
const cipher = (0, import_chacha2.xchacha20poly1305)(encKey, nonce);
|
|
@@ -6183,7 +7015,7 @@ function decryptMemo(encryptedMemo, viewingKey) {
|
|
|
6183
7015
|
function trackPayment(payment) {
|
|
6184
7016
|
return {
|
|
6185
7017
|
...payment,
|
|
6186
|
-
status:
|
|
7018
|
+
status: import_types11.PaymentStatus.DRAFT
|
|
6187
7019
|
};
|
|
6188
7020
|
}
|
|
6189
7021
|
function isPaymentExpired(payment) {
|
|
@@ -6216,10 +7048,10 @@ function getPaymentSummary(payment) {
|
|
|
6216
7048
|
}
|
|
6217
7049
|
|
|
6218
7050
|
// src/treasury/treasury.ts
|
|
6219
|
-
var
|
|
7051
|
+
var import_types12 = require("@sip-protocol/types");
|
|
6220
7052
|
var import_secp256k14 = require("@noble/curves/secp256k1");
|
|
6221
|
-
var
|
|
6222
|
-
var
|
|
7053
|
+
var import_sha25610 = require("@noble/hashes/sha256");
|
|
7054
|
+
var import_utils12 = require("@noble/hashes/utils");
|
|
6223
7055
|
var DEFAULT_PROPOSAL_TTL = 7 * 24 * 60 * 60;
|
|
6224
7056
|
var Treasury = class _Treasury {
|
|
6225
7057
|
config;
|
|
@@ -6249,7 +7081,7 @@ var Treasury = class _Treasury {
|
|
|
6249
7081
|
...m,
|
|
6250
7082
|
addedAt: now
|
|
6251
7083
|
})),
|
|
6252
|
-
defaultPrivacy: params.defaultPrivacy ??
|
|
7084
|
+
defaultPrivacy: params.defaultPrivacy ?? import_types12.PrivacyLevel.SHIELDED,
|
|
6253
7085
|
masterViewingKey,
|
|
6254
7086
|
dailyLimit: params.dailyLimit,
|
|
6255
7087
|
transactionLimit: params.transactionLimit,
|
|
@@ -6328,7 +7160,7 @@ var Treasury = class _Treasury {
|
|
|
6328
7160
|
proposalId,
|
|
6329
7161
|
treasuryId: this.config.treasuryId,
|
|
6330
7162
|
type: "payment",
|
|
6331
|
-
status:
|
|
7163
|
+
status: import_types12.ProposalStatus.PENDING,
|
|
6332
7164
|
proposer: "",
|
|
6333
7165
|
// Should be set by caller
|
|
6334
7166
|
title: params.title,
|
|
@@ -6361,7 +7193,7 @@ var Treasury = class _Treasury {
|
|
|
6361
7193
|
proposalId,
|
|
6362
7194
|
treasuryId: this.config.treasuryId,
|
|
6363
7195
|
type: "batch_payment",
|
|
6364
|
-
status:
|
|
7196
|
+
status: import_types12.ProposalStatus.PENDING,
|
|
6365
7197
|
proposer: "",
|
|
6366
7198
|
title: params.title,
|
|
6367
7199
|
description: params.description,
|
|
@@ -6395,7 +7227,7 @@ var Treasury = class _Treasury {
|
|
|
6395
7227
|
* Get pending proposals
|
|
6396
7228
|
*/
|
|
6397
7229
|
getPendingProposals() {
|
|
6398
|
-
return this.getAllProposals().filter((p) => p.status ===
|
|
7230
|
+
return this.getAllProposals().filter((p) => p.status === import_types12.ProposalStatus.PENDING);
|
|
6399
7231
|
}
|
|
6400
7232
|
/**
|
|
6401
7233
|
* Sign a proposal
|
|
@@ -6426,7 +7258,7 @@ var Treasury = class _Treasury {
|
|
|
6426
7258
|
"SIP_2001" /* INVALID_INPUT */
|
|
6427
7259
|
);
|
|
6428
7260
|
}
|
|
6429
|
-
if (proposal.status !==
|
|
7261
|
+
if (proposal.status !== import_types12.ProposalStatus.PENDING) {
|
|
6430
7262
|
throw new ValidationError(
|
|
6431
7263
|
`proposal is not pending: ${proposal.status}`,
|
|
6432
7264
|
"proposalId",
|
|
@@ -6436,7 +7268,7 @@ var Treasury = class _Treasury {
|
|
|
6436
7268
|
}
|
|
6437
7269
|
const now = Math.floor(Date.now() / 1e3);
|
|
6438
7270
|
if (now > proposal.expiresAt) {
|
|
6439
|
-
proposal.status =
|
|
7271
|
+
proposal.status = import_types12.ProposalStatus.EXPIRED;
|
|
6440
7272
|
throw new ValidationError(
|
|
6441
7273
|
"proposal has expired",
|
|
6442
7274
|
"proposalId",
|
|
@@ -6468,9 +7300,9 @@ var Treasury = class _Treasury {
|
|
|
6468
7300
|
const approvals = proposal.signatures.filter((s) => s.approved).length;
|
|
6469
7301
|
const rejections = proposal.signatures.filter((s) => !s.approved).length;
|
|
6470
7302
|
if (approvals >= proposal.requiredSignatures) {
|
|
6471
|
-
proposal.status =
|
|
7303
|
+
proposal.status = import_types12.ProposalStatus.APPROVED;
|
|
6472
7304
|
} else if (rejections > this.config.totalSigners - proposal.requiredSignatures) {
|
|
6473
|
-
proposal.status =
|
|
7305
|
+
proposal.status = import_types12.ProposalStatus.REJECTED;
|
|
6474
7306
|
}
|
|
6475
7307
|
return proposal;
|
|
6476
7308
|
}
|
|
@@ -6487,7 +7319,7 @@ var Treasury = class _Treasury {
|
|
|
6487
7319
|
"SIP_2001" /* INVALID_INPUT */
|
|
6488
7320
|
);
|
|
6489
7321
|
}
|
|
6490
|
-
if (proposal.status !==
|
|
7322
|
+
if (proposal.status !== import_types12.ProposalStatus.APPROVED) {
|
|
6491
7323
|
throw new ValidationError(
|
|
6492
7324
|
`proposal is not approved: ${proposal.status}`,
|
|
6493
7325
|
"proposalId",
|
|
@@ -6500,8 +7332,8 @@ var Treasury = class _Treasury {
|
|
|
6500
7332
|
const payment = await createShieldedPayment({
|
|
6501
7333
|
token: proposal.payment.token,
|
|
6502
7334
|
amount: proposal.payment.amount,
|
|
6503
|
-
recipientMetaAddress: proposal.payment.privacy !==
|
|
6504
|
-
recipientAddress: proposal.payment.privacy ===
|
|
7335
|
+
recipientMetaAddress: proposal.payment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
|
|
7336
|
+
recipientAddress: proposal.payment.privacy === import_types12.PrivacyLevel.TRANSPARENT ? proposal.payment.recipient : void 0,
|
|
6505
7337
|
privacy: proposal.payment.privacy,
|
|
6506
7338
|
viewingKey: this.config.masterViewingKey?.key,
|
|
6507
7339
|
sourceChain: this.config.chain,
|
|
@@ -6514,8 +7346,8 @@ var Treasury = class _Treasury {
|
|
|
6514
7346
|
const payment = await createShieldedPayment({
|
|
6515
7347
|
token: proposal.batchPayment.token,
|
|
6516
7348
|
amount: recipient.amount,
|
|
6517
|
-
recipientMetaAddress: proposal.batchPayment.privacy !==
|
|
6518
|
-
recipientAddress: proposal.batchPayment.privacy ===
|
|
7349
|
+
recipientMetaAddress: proposal.batchPayment.privacy !== import_types12.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
|
|
7350
|
+
recipientAddress: proposal.batchPayment.privacy === import_types12.PrivacyLevel.TRANSPARENT ? recipient.address : void 0,
|
|
6519
7351
|
privacy: proposal.batchPayment.privacy,
|
|
6520
7352
|
viewingKey: this.config.masterViewingKey?.key,
|
|
6521
7353
|
sourceChain: this.config.chain,
|
|
@@ -6525,7 +7357,7 @@ var Treasury = class _Treasury {
|
|
|
6525
7357
|
payments.push(payment);
|
|
6526
7358
|
}
|
|
6527
7359
|
}
|
|
6528
|
-
proposal.status =
|
|
7360
|
+
proposal.status = import_types12.ProposalStatus.EXECUTED;
|
|
6529
7361
|
proposal.executedAt = Math.floor(Date.now() / 1e3);
|
|
6530
7362
|
proposal.resultPayments = payments;
|
|
6531
7363
|
return payments;
|
|
@@ -6554,7 +7386,7 @@ var Treasury = class _Treasury {
|
|
|
6554
7386
|
"SIP_2001" /* INVALID_INPUT */
|
|
6555
7387
|
);
|
|
6556
7388
|
}
|
|
6557
|
-
if (proposal.status !==
|
|
7389
|
+
if (proposal.status !== import_types12.ProposalStatus.PENDING) {
|
|
6558
7390
|
throw new ValidationError(
|
|
6559
7391
|
`proposal is not pending: ${proposal.status}`,
|
|
6560
7392
|
"proposalId",
|
|
@@ -6562,7 +7394,7 @@ var Treasury = class _Treasury {
|
|
|
6562
7394
|
"SIP_2001" /* INVALID_INPUT */
|
|
6563
7395
|
);
|
|
6564
7396
|
}
|
|
6565
|
-
proposal.status =
|
|
7397
|
+
proposal.status = import_types12.ProposalStatus.CANCELLED;
|
|
6566
7398
|
return proposal;
|
|
6567
7399
|
}
|
|
6568
7400
|
// ─── Auditor Access ──────────────────────────────────────────────────────────
|
|
@@ -6659,7 +7491,7 @@ var Treasury = class _Treasury {
|
|
|
6659
7491
|
getCommittedAmount(token) {
|
|
6660
7492
|
let committed = 0n;
|
|
6661
7493
|
for (const proposal of this.proposals.values()) {
|
|
6662
|
-
if (proposal.status !==
|
|
7494
|
+
if (proposal.status !== import_types12.ProposalStatus.PENDING) continue;
|
|
6663
7495
|
if (proposal.type === "payment" && proposal.payment) {
|
|
6664
7496
|
if (proposal.payment.token.symbol === token.symbol && proposal.payment.token.chain === token.chain) {
|
|
6665
7497
|
committed += proposal.payment.amount;
|
|
@@ -6710,12 +7542,12 @@ var Treasury = class _Treasury {
|
|
|
6710
7542
|
}
|
|
6711
7543
|
};
|
|
6712
7544
|
function generateTreasuryId() {
|
|
6713
|
-
const bytes = (0,
|
|
6714
|
-
return `treasury_${(0,
|
|
7545
|
+
const bytes = (0, import_utils12.randomBytes)(16);
|
|
7546
|
+
return `treasury_${(0, import_utils12.bytesToHex)(bytes)}`;
|
|
6715
7547
|
}
|
|
6716
7548
|
function generateProposalId() {
|
|
6717
|
-
const bytes = (0,
|
|
6718
|
-
return `prop_${(0,
|
|
7549
|
+
const bytes = (0, import_utils12.randomBytes)(16);
|
|
7550
|
+
return `prop_${(0, import_utils12.bytesToHex)(bytes)}`;
|
|
6719
7551
|
}
|
|
6720
7552
|
function computeProposalHash(proposal) {
|
|
6721
7553
|
const data = JSON.stringify({
|
|
@@ -6727,11 +7559,11 @@ function computeProposalHash(proposal) {
|
|
|
6727
7559
|
createdAt: proposal.createdAt,
|
|
6728
7560
|
expiresAt: proposal.expiresAt
|
|
6729
7561
|
}, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
6730
|
-
return (0,
|
|
7562
|
+
return (0, import_sha25610.sha256)(new TextEncoder().encode(data));
|
|
6731
7563
|
}
|
|
6732
7564
|
function signMessage(messageHash, privateKey) {
|
|
6733
7565
|
const keyHex = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
6734
|
-
const keyBytes = (0,
|
|
7566
|
+
const keyBytes = (0, import_utils12.hexToBytes)(keyHex);
|
|
6735
7567
|
try {
|
|
6736
7568
|
const signature = import_secp256k14.secp256k1.sign(messageHash, keyBytes);
|
|
6737
7569
|
return `0x${signature.toCompactHex()}`;
|
|
@@ -6743,8 +7575,8 @@ function verifySignature(messageHash, signature, publicKey) {
|
|
|
6743
7575
|
const sigHex = signature.startsWith("0x") ? signature.slice(2) : signature;
|
|
6744
7576
|
const pubKeyHex = publicKey.startsWith("0x") ? publicKey.slice(2) : publicKey;
|
|
6745
7577
|
try {
|
|
6746
|
-
const sigBytes = (0,
|
|
6747
|
-
const pubKeyBytes = (0,
|
|
7578
|
+
const sigBytes = (0, import_utils12.hexToBytes)(sigHex);
|
|
7579
|
+
const pubKeyBytes = (0, import_utils12.hexToBytes)(pubKeyHex);
|
|
6748
7580
|
return import_secp256k14.secp256k1.verify(sigBytes, messageHash, pubKeyBytes);
|
|
6749
7581
|
} catch {
|
|
6750
7582
|
return false;
|
|
@@ -6902,8 +7734,8 @@ function validateBatchProposalParams(params, config) {
|
|
|
6902
7734
|
}
|
|
6903
7735
|
|
|
6904
7736
|
// src/compliance/compliance-manager.ts
|
|
6905
|
-
var
|
|
6906
|
-
var
|
|
7737
|
+
var import_types13 = require("@sip-protocol/types");
|
|
7738
|
+
var import_utils13 = require("@noble/hashes/utils");
|
|
6907
7739
|
var DEFAULTS2 = {
|
|
6908
7740
|
riskThreshold: 70,
|
|
6909
7741
|
highValueThreshold: 10000000000n,
|
|
@@ -7270,7 +8102,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
7270
8102
|
title: params.title,
|
|
7271
8103
|
description: params.description,
|
|
7272
8104
|
format: params.format,
|
|
7273
|
-
status:
|
|
8105
|
+
status: import_types13.ReportStatus.GENERATING,
|
|
7274
8106
|
requestedBy,
|
|
7275
8107
|
requestedAt: now,
|
|
7276
8108
|
startDate: params.startDate,
|
|
@@ -7299,10 +8131,10 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
7299
8131
|
} else if (params.format === "csv") {
|
|
7300
8132
|
report.content = this.generateCSV(transactions);
|
|
7301
8133
|
}
|
|
7302
|
-
report.status =
|
|
8134
|
+
report.status = import_types13.ReportStatus.COMPLETED;
|
|
7303
8135
|
report.generatedAt = Math.floor(Date.now() / 1e3);
|
|
7304
8136
|
} catch (error) {
|
|
7305
|
-
report.status =
|
|
8137
|
+
report.status = import_types13.ReportStatus.FAILED;
|
|
7306
8138
|
report.error = error instanceof Error ? error.message : "Unknown error";
|
|
7307
8139
|
}
|
|
7308
8140
|
this.addAuditLog(requestedBy, "report_generated", {
|
|
@@ -7577,7 +8409,7 @@ var ComplianceManager = class _ComplianceManager {
|
|
|
7577
8409
|
}
|
|
7578
8410
|
};
|
|
7579
8411
|
function generateId(prefix) {
|
|
7580
|
-
return `${prefix}_${(0,
|
|
8412
|
+
return `${prefix}_${(0, import_utils13.bytesToHex)((0, import_utils13.randomBytes)(12))}`;
|
|
7581
8413
|
}
|
|
7582
8414
|
function validateRegisterAuditorParams(params) {
|
|
7583
8415
|
if (!params.organization?.trim()) {
|
|
@@ -7665,10 +8497,10 @@ function validateReportParams(params) {
|
|
|
7665
8497
|
}
|
|
7666
8498
|
|
|
7667
8499
|
// src/wallet/errors.ts
|
|
7668
|
-
var
|
|
8500
|
+
var import_types14 = require("@sip-protocol/types");
|
|
7669
8501
|
var WalletError = class extends SIPError {
|
|
7670
8502
|
walletCode;
|
|
7671
|
-
constructor(message, walletCode =
|
|
8503
|
+
constructor(message, walletCode = import_types14.WalletErrorCode.UNKNOWN, options) {
|
|
7672
8504
|
super(message, "SIP_7000" /* WALLET_ERROR */, options);
|
|
7673
8505
|
this.walletCode = walletCode;
|
|
7674
8506
|
this.name = "WalletError";
|
|
@@ -7678,10 +8510,10 @@ var WalletError = class extends SIPError {
|
|
|
7678
8510
|
*/
|
|
7679
8511
|
isConnectionError() {
|
|
7680
8512
|
const codes = [
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
8513
|
+
import_types14.WalletErrorCode.NOT_INSTALLED,
|
|
8514
|
+
import_types14.WalletErrorCode.CONNECTION_REJECTED,
|
|
8515
|
+
import_types14.WalletErrorCode.CONNECTION_FAILED,
|
|
8516
|
+
import_types14.WalletErrorCode.NOT_CONNECTED
|
|
7685
8517
|
];
|
|
7686
8518
|
return codes.includes(this.walletCode);
|
|
7687
8519
|
}
|
|
@@ -7690,9 +8522,9 @@ var WalletError = class extends SIPError {
|
|
|
7690
8522
|
*/
|
|
7691
8523
|
isSigningError() {
|
|
7692
8524
|
const codes = [
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
8525
|
+
import_types14.WalletErrorCode.SIGNING_REJECTED,
|
|
8526
|
+
import_types14.WalletErrorCode.SIGNING_FAILED,
|
|
8527
|
+
import_types14.WalletErrorCode.INVALID_MESSAGE
|
|
7696
8528
|
];
|
|
7697
8529
|
return codes.includes(this.walletCode);
|
|
7698
8530
|
}
|
|
@@ -7701,10 +8533,10 @@ var WalletError = class extends SIPError {
|
|
|
7701
8533
|
*/
|
|
7702
8534
|
isTransactionError() {
|
|
7703
8535
|
const codes = [
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
8536
|
+
import_types14.WalletErrorCode.INSUFFICIENT_FUNDS,
|
|
8537
|
+
import_types14.WalletErrorCode.TRANSACTION_REJECTED,
|
|
8538
|
+
import_types14.WalletErrorCode.TRANSACTION_FAILED,
|
|
8539
|
+
import_types14.WalletErrorCode.INVALID_TRANSACTION
|
|
7708
8540
|
];
|
|
7709
8541
|
return codes.includes(this.walletCode);
|
|
7710
8542
|
}
|
|
@@ -7713,9 +8545,9 @@ var WalletError = class extends SIPError {
|
|
|
7713
8545
|
*/
|
|
7714
8546
|
isPrivacyError() {
|
|
7715
8547
|
const codes = [
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
8548
|
+
import_types14.WalletErrorCode.STEALTH_NOT_SUPPORTED,
|
|
8549
|
+
import_types14.WalletErrorCode.VIEWING_KEY_NOT_SUPPORTED,
|
|
8550
|
+
import_types14.WalletErrorCode.SHIELDED_NOT_SUPPORTED
|
|
7719
8551
|
];
|
|
7720
8552
|
return codes.includes(this.walletCode);
|
|
7721
8553
|
}
|
|
@@ -7724,10 +8556,10 @@ var WalletError = class extends SIPError {
|
|
|
7724
8556
|
*/
|
|
7725
8557
|
isUserRejection() {
|
|
7726
8558
|
const codes = [
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
8559
|
+
import_types14.WalletErrorCode.CONNECTION_REJECTED,
|
|
8560
|
+
import_types14.WalletErrorCode.SIGNING_REJECTED,
|
|
8561
|
+
import_types14.WalletErrorCode.TRANSACTION_REJECTED,
|
|
8562
|
+
import_types14.WalletErrorCode.CHAIN_SWITCH_REJECTED
|
|
7731
8563
|
];
|
|
7732
8564
|
return codes.includes(this.walletCode);
|
|
7733
8565
|
}
|
|
@@ -7735,15 +8567,15 @@ var WalletError = class extends SIPError {
|
|
|
7735
8567
|
function notConnectedError() {
|
|
7736
8568
|
return new WalletError(
|
|
7737
8569
|
"Wallet not connected. Call connect() first.",
|
|
7738
|
-
|
|
8570
|
+
import_types14.WalletErrorCode.NOT_CONNECTED
|
|
7739
8571
|
);
|
|
7740
8572
|
}
|
|
7741
|
-
function featureNotSupportedError(feature, code =
|
|
8573
|
+
function featureNotSupportedError(feature, code = import_types14.WalletErrorCode.UNKNOWN) {
|
|
7742
8574
|
return new WalletError(`${feature} is not supported by this wallet`, code);
|
|
7743
8575
|
}
|
|
7744
8576
|
|
|
7745
8577
|
// src/wallet/base-adapter.ts
|
|
7746
|
-
var
|
|
8578
|
+
var import_types15 = require("@sip-protocol/types");
|
|
7747
8579
|
var BaseWalletAdapter = class {
|
|
7748
8580
|
_address = "";
|
|
7749
8581
|
_publicKey = "";
|
|
@@ -7906,12 +8738,12 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
|
|
|
7906
8738
|
this._connectionState = "connecting";
|
|
7907
8739
|
if (this.shouldFailConnect) {
|
|
7908
8740
|
this.setError(
|
|
7909
|
-
|
|
8741
|
+
import_types15.WalletErrorCode.CONNECTION_FAILED,
|
|
7910
8742
|
"Mock connection failure"
|
|
7911
8743
|
);
|
|
7912
8744
|
throw new WalletError(
|
|
7913
8745
|
"Mock connection failure",
|
|
7914
|
-
|
|
8746
|
+
import_types15.WalletErrorCode.CONNECTION_FAILED
|
|
7915
8747
|
);
|
|
7916
8748
|
}
|
|
7917
8749
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
@@ -7923,7 +8755,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
|
|
|
7923
8755
|
async signMessage(message) {
|
|
7924
8756
|
this.requireConnected();
|
|
7925
8757
|
if (this.shouldFailSign) {
|
|
7926
|
-
throw new WalletError("Mock signing failure",
|
|
8758
|
+
throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
|
|
7927
8759
|
}
|
|
7928
8760
|
const mockSig = new Uint8Array(64);
|
|
7929
8761
|
for (let i = 0; i < 64; i++) {
|
|
@@ -7938,7 +8770,7 @@ var MockWalletAdapter = class extends BaseWalletAdapter {
|
|
|
7938
8770
|
async signTransaction(tx) {
|
|
7939
8771
|
this.requireConnected();
|
|
7940
8772
|
if (this.shouldFailSign) {
|
|
7941
|
-
throw new WalletError("Mock signing failure",
|
|
8773
|
+
throw new WalletError("Mock signing failure", import_types15.WalletErrorCode.SIGNING_FAILED);
|
|
7942
8774
|
}
|
|
7943
8775
|
const signature = await this.signMessage(
|
|
7944
8776
|
new TextEncoder().encode(JSON.stringify(tx.data))
|
|
@@ -8120,7 +8952,7 @@ function isPrivateWalletAdapter(adapter) {
|
|
|
8120
8952
|
}
|
|
8121
8953
|
|
|
8122
8954
|
// src/wallet/solana/adapter.ts
|
|
8123
|
-
var
|
|
8955
|
+
var import_types16 = require("@sip-protocol/types");
|
|
8124
8956
|
|
|
8125
8957
|
// src/wallet/solana/types.ts
|
|
8126
8958
|
function getSolanaProvider(wallet = "phantom") {
|
|
@@ -8241,19 +9073,19 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8241
9073
|
}
|
|
8242
9074
|
if (!this.provider) {
|
|
8243
9075
|
this.setError(
|
|
8244
|
-
|
|
9076
|
+
import_types16.WalletErrorCode.NOT_INSTALLED,
|
|
8245
9077
|
`${this.walletName} wallet is not installed`
|
|
8246
9078
|
);
|
|
8247
9079
|
throw new WalletError(
|
|
8248
9080
|
`${this.walletName} wallet is not installed`,
|
|
8249
|
-
|
|
9081
|
+
import_types16.WalletErrorCode.NOT_INSTALLED
|
|
8250
9082
|
);
|
|
8251
9083
|
}
|
|
8252
9084
|
const { publicKey } = await this.provider.connect();
|
|
8253
9085
|
if (!publicKey) {
|
|
8254
9086
|
throw new WalletError(
|
|
8255
9087
|
"No public key returned from wallet",
|
|
8256
|
-
|
|
9088
|
+
import_types16.WalletErrorCode.CONNECTION_FAILED
|
|
8257
9089
|
);
|
|
8258
9090
|
}
|
|
8259
9091
|
this.setupEventHandlers();
|
|
@@ -8263,11 +9095,11 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8263
9095
|
} catch (error) {
|
|
8264
9096
|
const message = error instanceof Error ? error.message : "Connection failed";
|
|
8265
9097
|
if (message.includes("User rejected") || message.includes("rejected")) {
|
|
8266
|
-
this.setError(
|
|
8267
|
-
throw new WalletError(message,
|
|
9098
|
+
this.setError(import_types16.WalletErrorCode.CONNECTION_REJECTED, message);
|
|
9099
|
+
throw new WalletError(message, import_types16.WalletErrorCode.CONNECTION_REJECTED);
|
|
8268
9100
|
}
|
|
8269
|
-
this.setError(
|
|
8270
|
-
throw error instanceof WalletError ? error : new WalletError(message,
|
|
9101
|
+
this.setError(import_types16.WalletErrorCode.CONNECTION_FAILED, message);
|
|
9102
|
+
throw error instanceof WalletError ? error : new WalletError(message, import_types16.WalletErrorCode.CONNECTION_FAILED, { cause: error });
|
|
8271
9103
|
}
|
|
8272
9104
|
}
|
|
8273
9105
|
/**
|
|
@@ -8290,7 +9122,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8290
9122
|
async signMessage(message) {
|
|
8291
9123
|
this.requireConnected();
|
|
8292
9124
|
if (!this.provider) {
|
|
8293
|
-
throw new WalletError("Provider not available",
|
|
9125
|
+
throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
|
|
8294
9126
|
}
|
|
8295
9127
|
try {
|
|
8296
9128
|
const { signature } = await this.provider.signMessage(message);
|
|
@@ -8301,9 +9133,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8301
9133
|
} catch (error) {
|
|
8302
9134
|
const message2 = error instanceof Error ? error.message : "Signing failed";
|
|
8303
9135
|
if (message2.includes("User rejected") || message2.includes("rejected")) {
|
|
8304
|
-
throw new WalletError(message2,
|
|
9136
|
+
throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_REJECTED);
|
|
8305
9137
|
}
|
|
8306
|
-
throw new WalletError(message2,
|
|
9138
|
+
throw new WalletError(message2, import_types16.WalletErrorCode.SIGNING_FAILED, {
|
|
8307
9139
|
cause: error
|
|
8308
9140
|
});
|
|
8309
9141
|
}
|
|
@@ -8316,7 +9148,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8316
9148
|
async signTransaction(tx) {
|
|
8317
9149
|
this.requireConnected();
|
|
8318
9150
|
if (!this.provider) {
|
|
8319
|
-
throw new WalletError("Provider not available",
|
|
9151
|
+
throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
|
|
8320
9152
|
}
|
|
8321
9153
|
try {
|
|
8322
9154
|
const solTx = tx.data;
|
|
@@ -8335,9 +9167,9 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8335
9167
|
} catch (error) {
|
|
8336
9168
|
const message = error instanceof Error ? error.message : "Signing failed";
|
|
8337
9169
|
if (message.includes("User rejected") || message.includes("rejected")) {
|
|
8338
|
-
throw new WalletError(message,
|
|
9170
|
+
throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
|
|
8339
9171
|
}
|
|
8340
|
-
throw new WalletError(message,
|
|
9172
|
+
throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
|
|
8341
9173
|
cause: error
|
|
8342
9174
|
});
|
|
8343
9175
|
}
|
|
@@ -8348,7 +9180,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8348
9180
|
async signAndSendTransaction(tx) {
|
|
8349
9181
|
this.requireConnected();
|
|
8350
9182
|
if (!this.provider) {
|
|
8351
|
-
throw new WalletError("Provider not available",
|
|
9183
|
+
throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
|
|
8352
9184
|
}
|
|
8353
9185
|
try {
|
|
8354
9186
|
const solTx = tx.data;
|
|
@@ -8363,12 +9195,12 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8363
9195
|
} catch (error) {
|
|
8364
9196
|
const message = error instanceof Error ? error.message : "Transaction failed";
|
|
8365
9197
|
if (message.includes("User rejected") || message.includes("rejected")) {
|
|
8366
|
-
throw new WalletError(message,
|
|
9198
|
+
throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_REJECTED);
|
|
8367
9199
|
}
|
|
8368
9200
|
if (message.includes("insufficient") || message.includes("Insufficient")) {
|
|
8369
|
-
throw new WalletError(message,
|
|
9201
|
+
throw new WalletError(message, import_types16.WalletErrorCode.INSUFFICIENT_FUNDS);
|
|
8370
9202
|
}
|
|
8371
|
-
throw new WalletError(message,
|
|
9203
|
+
throw new WalletError(message, import_types16.WalletErrorCode.TRANSACTION_FAILED, {
|
|
8372
9204
|
cause: error
|
|
8373
9205
|
});
|
|
8374
9206
|
}
|
|
@@ -8381,16 +9213,16 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8381
9213
|
async signAllTransactions(transactions) {
|
|
8382
9214
|
this.requireConnected();
|
|
8383
9215
|
if (!this.provider) {
|
|
8384
|
-
throw new WalletError("Provider not available",
|
|
9216
|
+
throw new WalletError("Provider not available", import_types16.WalletErrorCode.NOT_CONNECTED);
|
|
8385
9217
|
}
|
|
8386
9218
|
try {
|
|
8387
9219
|
return await this.provider.signAllTransactions(transactions);
|
|
8388
9220
|
} catch (error) {
|
|
8389
9221
|
const message = error instanceof Error ? error.message : "Signing failed";
|
|
8390
9222
|
if (message.includes("User rejected") || message.includes("rejected")) {
|
|
8391
|
-
throw new WalletError(message,
|
|
9223
|
+
throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_REJECTED);
|
|
8392
9224
|
}
|
|
8393
|
-
throw new WalletError(message,
|
|
9225
|
+
throw new WalletError(message, import_types16.WalletErrorCode.SIGNING_FAILED, {
|
|
8394
9226
|
cause: error
|
|
8395
9227
|
});
|
|
8396
9228
|
}
|
|
@@ -8411,7 +9243,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8411
9243
|
} catch (error) {
|
|
8412
9244
|
throw new WalletError(
|
|
8413
9245
|
"Failed to get balance",
|
|
8414
|
-
|
|
9246
|
+
import_types16.WalletErrorCode.UNKNOWN,
|
|
8415
9247
|
{ cause: error }
|
|
8416
9248
|
);
|
|
8417
9249
|
}
|
|
@@ -8424,7 +9256,7 @@ var SolanaWalletAdapter = class extends BaseWalletAdapter {
|
|
|
8424
9256
|
if (asset.chain !== "solana") {
|
|
8425
9257
|
throw new WalletError(
|
|
8426
9258
|
`Asset chain ${asset.chain} not supported by Solana adapter`,
|
|
8427
|
-
|
|
9259
|
+
import_types16.WalletErrorCode.UNSUPPORTED_CHAIN
|
|
8428
9260
|
);
|
|
8429
9261
|
}
|
|
8430
9262
|
if (!asset.address) {
|
|
@@ -8542,7 +9374,7 @@ function createSolanaAdapter(config = {}) {
|
|
|
8542
9374
|
}
|
|
8543
9375
|
|
|
8544
9376
|
// src/wallet/solana/mock.ts
|
|
8545
|
-
var
|
|
9377
|
+
var import_types18 = require("@sip-protocol/types");
|
|
8546
9378
|
var MockPublicKey = class {
|
|
8547
9379
|
base58;
|
|
8548
9380
|
bytes;
|
|
@@ -8608,8 +9440,8 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8608
9440
|
this._connectionState = "connecting";
|
|
8609
9441
|
await this.simulateLatency();
|
|
8610
9442
|
if (this.shouldFailConnect) {
|
|
8611
|
-
this.setError(
|
|
8612
|
-
throw new WalletError("Mock connection failure",
|
|
9443
|
+
this.setError(import_types18.WalletErrorCode.CONNECTION_FAILED, "Mock connection failure");
|
|
9444
|
+
throw new WalletError("Mock connection failure", import_types18.WalletErrorCode.CONNECTION_FAILED);
|
|
8613
9445
|
}
|
|
8614
9446
|
const hexPubKey = "0x" + Buffer.from(this.mockPublicKey.toBytes()).toString("hex");
|
|
8615
9447
|
this.setConnected(this.mockAddress, hexPubKey);
|
|
@@ -8628,7 +9460,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8628
9460
|
this.requireConnected();
|
|
8629
9461
|
await this.simulateLatency();
|
|
8630
9462
|
if (this.shouldFailSign) {
|
|
8631
|
-
throw new WalletError("Mock signing failure",
|
|
9463
|
+
throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
|
|
8632
9464
|
}
|
|
8633
9465
|
const mockSig = new Uint8Array(64);
|
|
8634
9466
|
for (let i = 0; i < 64; i++) {
|
|
@@ -8646,7 +9478,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8646
9478
|
this.requireConnected();
|
|
8647
9479
|
await this.simulateLatency();
|
|
8648
9480
|
if (this.shouldFailSign) {
|
|
8649
|
-
throw new WalletError("Mock signing failure",
|
|
9481
|
+
throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
|
|
8650
9482
|
}
|
|
8651
9483
|
const solTx = tx.data;
|
|
8652
9484
|
this.signedTransactions.push(solTx);
|
|
@@ -8666,10 +9498,10 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8666
9498
|
this.requireConnected();
|
|
8667
9499
|
await this.simulateLatency();
|
|
8668
9500
|
if (this.shouldFailSign) {
|
|
8669
|
-
throw new WalletError("Mock signing failure",
|
|
9501
|
+
throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
|
|
8670
9502
|
}
|
|
8671
9503
|
if (this.shouldFailTransaction) {
|
|
8672
|
-
throw new WalletError("Mock transaction failure",
|
|
9504
|
+
throw new WalletError("Mock transaction failure", import_types18.WalletErrorCode.TRANSACTION_FAILED);
|
|
8673
9505
|
}
|
|
8674
9506
|
const txSig = `mock_tx_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
8675
9507
|
this.sentTransactions.push(txSig);
|
|
@@ -8689,7 +9521,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8689
9521
|
this.requireConnected();
|
|
8690
9522
|
await this.simulateLatency();
|
|
8691
9523
|
if (this.shouldFailSign) {
|
|
8692
|
-
throw new WalletError("Mock signing failure",
|
|
9524
|
+
throw new WalletError("Mock signing failure", import_types18.WalletErrorCode.SIGNING_REJECTED);
|
|
8693
9525
|
}
|
|
8694
9526
|
this.signedTransactions.push(...transactions);
|
|
8695
9527
|
return transactions.map((tx) => {
|
|
@@ -8716,7 +9548,7 @@ var MockSolanaAdapter = class extends BaseWalletAdapter {
|
|
|
8716
9548
|
if (asset.chain !== "solana") {
|
|
8717
9549
|
throw new WalletError(
|
|
8718
9550
|
`Asset chain ${asset.chain} not supported by Solana adapter`,
|
|
8719
|
-
|
|
9551
|
+
import_types18.WalletErrorCode.UNSUPPORTED_CHAIN
|
|
8720
9552
|
);
|
|
8721
9553
|
}
|
|
8722
9554
|
if (!asset.address) {
|
|
@@ -8885,7 +9717,7 @@ function createMockSolanaAdapter(config = {}) {
|
|
|
8885
9717
|
}
|
|
8886
9718
|
|
|
8887
9719
|
// src/wallet/ethereum/adapter.ts
|
|
8888
|
-
var
|
|
9720
|
+
var import_types20 = require("@sip-protocol/types");
|
|
8889
9721
|
|
|
8890
9722
|
// src/wallet/ethereum/types.ts
|
|
8891
9723
|
var EthereumChainId = {
|
|
@@ -9027,7 +9859,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9027
9859
|
this._connectionState = "error";
|
|
9028
9860
|
throw new WalletError(
|
|
9029
9861
|
`${this.walletType} wallet not found. Please install the extension.`,
|
|
9030
|
-
|
|
9862
|
+
import_types20.WalletErrorCode.NOT_INSTALLED
|
|
9031
9863
|
);
|
|
9032
9864
|
}
|
|
9033
9865
|
const accounts = await this.provider.request({
|
|
@@ -9037,7 +9869,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9037
9869
|
this._connectionState = "error";
|
|
9038
9870
|
throw new WalletError(
|
|
9039
9871
|
"No accounts returned from wallet",
|
|
9040
|
-
|
|
9872
|
+
import_types20.WalletErrorCode.CONNECTION_REJECTED
|
|
9041
9873
|
);
|
|
9042
9874
|
}
|
|
9043
9875
|
const address = normalizeAddress(accounts[0]);
|
|
@@ -9057,12 +9889,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9057
9889
|
if (rpcError.code === 4001) {
|
|
9058
9890
|
throw new WalletError(
|
|
9059
9891
|
"User rejected connection request",
|
|
9060
|
-
|
|
9892
|
+
import_types20.WalletErrorCode.CONNECTION_REJECTED
|
|
9061
9893
|
);
|
|
9062
9894
|
}
|
|
9063
9895
|
throw new WalletError(
|
|
9064
9896
|
`Failed to connect: ${rpcError.message || String(error)}`,
|
|
9065
|
-
|
|
9897
|
+
import_types20.WalletErrorCode.CONNECTION_FAILED
|
|
9066
9898
|
);
|
|
9067
9899
|
}
|
|
9068
9900
|
}
|
|
@@ -9082,7 +9914,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9082
9914
|
if (!this.provider) {
|
|
9083
9915
|
throw new WalletError(
|
|
9084
9916
|
"Provider not available",
|
|
9085
|
-
|
|
9917
|
+
import_types20.WalletErrorCode.NOT_CONNECTED
|
|
9086
9918
|
);
|
|
9087
9919
|
}
|
|
9088
9920
|
try {
|
|
@@ -9100,12 +9932,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9100
9932
|
if (rpcError.code === 4001) {
|
|
9101
9933
|
throw new WalletError(
|
|
9102
9934
|
"User rejected signing request",
|
|
9103
|
-
|
|
9935
|
+
import_types20.WalletErrorCode.SIGNING_REJECTED
|
|
9104
9936
|
);
|
|
9105
9937
|
}
|
|
9106
9938
|
throw new WalletError(
|
|
9107
9939
|
`Failed to sign message: ${rpcError.message || String(error)}`,
|
|
9108
|
-
|
|
9940
|
+
import_types20.WalletErrorCode.SIGNING_FAILED
|
|
9109
9941
|
);
|
|
9110
9942
|
}
|
|
9111
9943
|
}
|
|
@@ -9117,7 +9949,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9117
9949
|
if (!this.provider) {
|
|
9118
9950
|
throw new WalletError(
|
|
9119
9951
|
"Provider not available",
|
|
9120
|
-
|
|
9952
|
+
import_types20.WalletErrorCode.NOT_CONNECTED
|
|
9121
9953
|
);
|
|
9122
9954
|
}
|
|
9123
9955
|
try {
|
|
@@ -9134,12 +9966,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9134
9966
|
if (rpcError.code === 4001) {
|
|
9135
9967
|
throw new WalletError(
|
|
9136
9968
|
"User rejected signing request",
|
|
9137
|
-
|
|
9969
|
+
import_types20.WalletErrorCode.SIGNING_REJECTED
|
|
9138
9970
|
);
|
|
9139
9971
|
}
|
|
9140
9972
|
throw new WalletError(
|
|
9141
9973
|
`Failed to sign typed data: ${rpcError.message || String(error)}`,
|
|
9142
|
-
|
|
9974
|
+
import_types20.WalletErrorCode.SIGNING_FAILED
|
|
9143
9975
|
);
|
|
9144
9976
|
}
|
|
9145
9977
|
}
|
|
@@ -9151,7 +9983,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9151
9983
|
if (!this.provider) {
|
|
9152
9984
|
throw new WalletError(
|
|
9153
9985
|
"Provider not available",
|
|
9154
|
-
|
|
9986
|
+
import_types20.WalletErrorCode.NOT_CONNECTED
|
|
9155
9987
|
);
|
|
9156
9988
|
}
|
|
9157
9989
|
try {
|
|
@@ -9179,7 +10011,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9179
10011
|
if (rpcError.code === 4001) {
|
|
9180
10012
|
throw new WalletError(
|
|
9181
10013
|
"User rejected transaction signing",
|
|
9182
|
-
|
|
10014
|
+
import_types20.WalletErrorCode.SIGNING_REJECTED
|
|
9183
10015
|
);
|
|
9184
10016
|
}
|
|
9185
10017
|
if (rpcError.code === -32601 || rpcError.message?.includes("not supported")) {
|
|
@@ -9197,7 +10029,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9197
10029
|
}
|
|
9198
10030
|
throw new WalletError(
|
|
9199
10031
|
`Failed to sign transaction: ${rpcError.message || String(error)}`,
|
|
9200
|
-
|
|
10032
|
+
import_types20.WalletErrorCode.TRANSACTION_FAILED
|
|
9201
10033
|
);
|
|
9202
10034
|
}
|
|
9203
10035
|
}
|
|
@@ -9209,7 +10041,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9209
10041
|
if (!this.provider) {
|
|
9210
10042
|
throw new WalletError(
|
|
9211
10043
|
"Provider not available",
|
|
9212
|
-
|
|
10044
|
+
import_types20.WalletErrorCode.NOT_CONNECTED
|
|
9213
10045
|
);
|
|
9214
10046
|
}
|
|
9215
10047
|
try {
|
|
@@ -9231,12 +10063,12 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9231
10063
|
if (rpcError.code === 4001) {
|
|
9232
10064
|
throw new WalletError(
|
|
9233
10065
|
"User rejected transaction",
|
|
9234
|
-
|
|
10066
|
+
import_types20.WalletErrorCode.TRANSACTION_REJECTED
|
|
9235
10067
|
);
|
|
9236
10068
|
}
|
|
9237
10069
|
throw new WalletError(
|
|
9238
10070
|
`Failed to send transaction: ${rpcError.message || String(error)}`,
|
|
9239
|
-
|
|
10071
|
+
import_types20.WalletErrorCode.TRANSACTION_FAILED
|
|
9240
10072
|
);
|
|
9241
10073
|
}
|
|
9242
10074
|
}
|
|
@@ -9271,7 +10103,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9271
10103
|
} catch (error) {
|
|
9272
10104
|
throw new WalletError(
|
|
9273
10105
|
`Failed to fetch balance: ${String(error)}`,
|
|
9274
|
-
|
|
10106
|
+
import_types20.WalletErrorCode.UNKNOWN
|
|
9275
10107
|
);
|
|
9276
10108
|
}
|
|
9277
10109
|
}
|
|
@@ -9283,7 +10115,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9283
10115
|
if (asset.chain !== "ethereum") {
|
|
9284
10116
|
throw new WalletError(
|
|
9285
10117
|
`Asset chain ${asset.chain} not supported by Ethereum adapter`,
|
|
9286
|
-
|
|
10118
|
+
import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
|
|
9287
10119
|
);
|
|
9288
10120
|
}
|
|
9289
10121
|
if (!asset.address) {
|
|
@@ -9308,7 +10140,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9308
10140
|
} catch (error) {
|
|
9309
10141
|
throw new WalletError(
|
|
9310
10142
|
`Failed to fetch token balance: ${String(error)}`,
|
|
9311
|
-
|
|
10143
|
+
import_types20.WalletErrorCode.UNKNOWN
|
|
9312
10144
|
);
|
|
9313
10145
|
}
|
|
9314
10146
|
}
|
|
@@ -9320,7 +10152,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9320
10152
|
if (!this.provider) {
|
|
9321
10153
|
throw new WalletError(
|
|
9322
10154
|
"Provider not available",
|
|
9323
|
-
|
|
10155
|
+
import_types20.WalletErrorCode.NOT_CONNECTED
|
|
9324
10156
|
);
|
|
9325
10157
|
}
|
|
9326
10158
|
try {
|
|
@@ -9335,18 +10167,18 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9335
10167
|
if (rpcError.code === 4001) {
|
|
9336
10168
|
throw new WalletError(
|
|
9337
10169
|
"User rejected chain switch",
|
|
9338
|
-
|
|
10170
|
+
import_types20.WalletErrorCode.CHAIN_SWITCH_REJECTED
|
|
9339
10171
|
);
|
|
9340
10172
|
}
|
|
9341
10173
|
if (rpcError.code === 4902) {
|
|
9342
10174
|
throw new WalletError(
|
|
9343
10175
|
`Chain ${chainId} not added to wallet`,
|
|
9344
|
-
|
|
10176
|
+
import_types20.WalletErrorCode.UNSUPPORTED_CHAIN
|
|
9345
10177
|
);
|
|
9346
10178
|
}
|
|
9347
10179
|
throw new WalletError(
|
|
9348
10180
|
`Failed to switch chain: ${rpcError.message || String(error)}`,
|
|
9349
|
-
|
|
10181
|
+
import_types20.WalletErrorCode.CHAIN_SWITCH_FAILED
|
|
9350
10182
|
);
|
|
9351
10183
|
}
|
|
9352
10184
|
}
|
|
@@ -9382,7 +10214,7 @@ var EthereumWalletAdapter = class extends BaseWalletAdapter {
|
|
|
9382
10214
|
}
|
|
9383
10215
|
throw new WalletError(
|
|
9384
10216
|
`Transaction ${txHash} not confirmed after ${maxAttempts * 5} seconds`,
|
|
9385
|
-
|
|
10217
|
+
import_types20.WalletErrorCode.TRANSACTION_FAILED
|
|
9386
10218
|
);
|
|
9387
10219
|
}
|
|
9388
10220
|
/**
|
|
@@ -9456,7 +10288,7 @@ function createEthereumAdapter(config) {
|
|
|
9456
10288
|
}
|
|
9457
10289
|
|
|
9458
10290
|
// src/wallet/ethereum/mock.ts
|
|
9459
|
-
var
|
|
10291
|
+
var import_types22 = require("@sip-protocol/types");
|
|
9460
10292
|
var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
9461
10293
|
chain = "ethereum";
|
|
9462
10294
|
name = "mock-ethereum";
|
|
@@ -9497,7 +10329,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9497
10329
|
this._connectionState = "error";
|
|
9498
10330
|
throw new WalletError(
|
|
9499
10331
|
"Mock connection rejected",
|
|
9500
|
-
|
|
10332
|
+
import_types22.WalletErrorCode.CONNECTION_REJECTED
|
|
9501
10333
|
);
|
|
9502
10334
|
}
|
|
9503
10335
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
@@ -9509,7 +10341,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9509
10341
|
this._connectionState = "error";
|
|
9510
10342
|
throw new WalletError(
|
|
9511
10343
|
`Mock connection failed: ${String(error)}`,
|
|
9512
|
-
|
|
10344
|
+
import_types22.WalletErrorCode.CONNECTION_FAILED
|
|
9513
10345
|
);
|
|
9514
10346
|
}
|
|
9515
10347
|
}
|
|
@@ -9527,7 +10359,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9527
10359
|
if (this._shouldFailSign) {
|
|
9528
10360
|
throw new WalletError(
|
|
9529
10361
|
"Mock signing rejected",
|
|
9530
|
-
|
|
10362
|
+
import_types22.WalletErrorCode.SIGNING_REJECTED
|
|
9531
10363
|
);
|
|
9532
10364
|
}
|
|
9533
10365
|
const msgHex = Buffer.from(message).toString("hex");
|
|
@@ -9545,7 +10377,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9545
10377
|
if (this._shouldFailSign) {
|
|
9546
10378
|
throw new WalletError(
|
|
9547
10379
|
"Mock signing rejected",
|
|
9548
|
-
|
|
10380
|
+
import_types22.WalletErrorCode.SIGNING_REJECTED
|
|
9549
10381
|
);
|
|
9550
10382
|
}
|
|
9551
10383
|
const mockSig = `0x${"1".repeat(130)}`;
|
|
@@ -9562,7 +10394,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9562
10394
|
if (this._shouldFailSign) {
|
|
9563
10395
|
throw new WalletError(
|
|
9564
10396
|
"Mock signing rejected",
|
|
9565
|
-
|
|
10397
|
+
import_types22.WalletErrorCode.SIGNING_REJECTED
|
|
9566
10398
|
);
|
|
9567
10399
|
}
|
|
9568
10400
|
this._signedTransactions.push(tx);
|
|
@@ -9587,7 +10419,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9587
10419
|
if (this._shouldFailTransaction) {
|
|
9588
10420
|
throw new WalletError(
|
|
9589
10421
|
"Mock transaction failed",
|
|
9590
|
-
|
|
10422
|
+
import_types22.WalletErrorCode.TRANSACTION_FAILED
|
|
9591
10423
|
);
|
|
9592
10424
|
}
|
|
9593
10425
|
this._signedTransactions.push(tx);
|
|
@@ -9617,7 +10449,7 @@ var MockEthereumAdapter = class extends BaseWalletAdapter {
|
|
|
9617
10449
|
if (asset.chain !== "ethereum") {
|
|
9618
10450
|
throw new WalletError(
|
|
9619
10451
|
`Asset chain ${asset.chain} not supported by Ethereum adapter`,
|
|
9620
|
-
|
|
10452
|
+
import_types22.WalletErrorCode.UNSUPPORTED_CHAIN
|
|
9621
10453
|
);
|
|
9622
10454
|
}
|
|
9623
10455
|
if (!asset.address) {
|
|
@@ -9896,7 +10728,7 @@ function getAvailableTransports() {
|
|
|
9896
10728
|
}
|
|
9897
10729
|
|
|
9898
10730
|
// src/wallet/hardware/ledger.ts
|
|
9899
|
-
var
|
|
10731
|
+
var import_types25 = require("@sip-protocol/types");
|
|
9900
10732
|
var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
9901
10733
|
chain;
|
|
9902
10734
|
name = "ledger";
|
|
@@ -10049,7 +10881,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
10049
10881
|
async getBalance() {
|
|
10050
10882
|
throw new WalletError(
|
|
10051
10883
|
"Hardware wallets do not track balances. Use an RPC provider.",
|
|
10052
|
-
|
|
10884
|
+
import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10053
10885
|
);
|
|
10054
10886
|
}
|
|
10055
10887
|
/**
|
|
@@ -10060,7 +10892,7 @@ var LedgerWalletAdapter = class extends BaseWalletAdapter {
|
|
|
10060
10892
|
async getTokenBalance(_asset) {
|
|
10061
10893
|
throw new WalletError(
|
|
10062
10894
|
"Hardware wallets do not track balances. Use an RPC provider.",
|
|
10063
|
-
|
|
10895
|
+
import_types25.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10064
10896
|
);
|
|
10065
10897
|
}
|
|
10066
10898
|
// ─── Account Management ─────────────────────────────────────────────────────
|
|
@@ -10348,7 +11180,7 @@ function createLedgerAdapter(config) {
|
|
|
10348
11180
|
}
|
|
10349
11181
|
|
|
10350
11182
|
// src/wallet/hardware/trezor.ts
|
|
10351
|
-
var
|
|
11183
|
+
var import_types27 = require("@sip-protocol/types");
|
|
10352
11184
|
var TrezorWalletAdapter = class extends BaseWalletAdapter {
|
|
10353
11185
|
chain;
|
|
10354
11186
|
name = "trezor";
|
|
@@ -10494,7 +11326,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
|
|
|
10494
11326
|
async getBalance() {
|
|
10495
11327
|
throw new WalletError(
|
|
10496
11328
|
"Hardware wallets do not track balances. Use an RPC provider.",
|
|
10497
|
-
|
|
11329
|
+
import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10498
11330
|
);
|
|
10499
11331
|
}
|
|
10500
11332
|
/**
|
|
@@ -10505,7 +11337,7 @@ var TrezorWalletAdapter = class extends BaseWalletAdapter {
|
|
|
10505
11337
|
async getTokenBalance(_asset) {
|
|
10506
11338
|
throw new WalletError(
|
|
10507
11339
|
"Hardware wallets do not track balances. Use an RPC provider.",
|
|
10508
|
-
|
|
11340
|
+
import_types27.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10509
11341
|
);
|
|
10510
11342
|
}
|
|
10511
11343
|
// ─── Account Management ─────────────────────────────────────────────────────
|
|
@@ -10786,8 +11618,8 @@ function createTrezorAdapter(config) {
|
|
|
10786
11618
|
}
|
|
10787
11619
|
|
|
10788
11620
|
// src/wallet/hardware/mock.ts
|
|
10789
|
-
var
|
|
10790
|
-
var
|
|
11621
|
+
var import_types29 = require("@sip-protocol/types");
|
|
11622
|
+
var import_utils14 = require("@noble/hashes/utils");
|
|
10791
11623
|
var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
10792
11624
|
chain;
|
|
10793
11625
|
name = "mock-ledger";
|
|
@@ -10934,7 +11766,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
10934
11766
|
async getBalance() {
|
|
10935
11767
|
throw new WalletError(
|
|
10936
11768
|
"Hardware wallets do not track balances",
|
|
10937
|
-
|
|
11769
|
+
import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10938
11770
|
);
|
|
10939
11771
|
}
|
|
10940
11772
|
/**
|
|
@@ -10943,7 +11775,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
10943
11775
|
async getTokenBalance(_asset) {
|
|
10944
11776
|
throw new WalletError(
|
|
10945
11777
|
"Hardware wallets do not track balances",
|
|
10946
|
-
|
|
11778
|
+
import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
10947
11779
|
);
|
|
10948
11780
|
}
|
|
10949
11781
|
/**
|
|
@@ -11032,15 +11864,15 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
11032
11864
|
}
|
|
11033
11865
|
}
|
|
11034
11866
|
generateMockAddress(index) {
|
|
11035
|
-
const bytes = (0,
|
|
11867
|
+
const bytes = (0, import_utils14.randomBytes)(20);
|
|
11036
11868
|
bytes[0] = index;
|
|
11037
|
-
return `0x${(0,
|
|
11869
|
+
return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
|
|
11038
11870
|
}
|
|
11039
11871
|
generateMockPublicKey(index) {
|
|
11040
|
-
const bytes = (0,
|
|
11872
|
+
const bytes = (0, import_utils14.randomBytes)(33);
|
|
11041
11873
|
bytes[0] = 2;
|
|
11042
11874
|
bytes[1] = index;
|
|
11043
|
-
return `0x${(0,
|
|
11875
|
+
return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
|
|
11044
11876
|
}
|
|
11045
11877
|
generateMockSignature(data) {
|
|
11046
11878
|
const sig = new Uint8Array(65);
|
|
@@ -11049,7 +11881,7 @@ var MockLedgerAdapter = class extends BaseWalletAdapter {
|
|
|
11049
11881
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 11;
|
|
11050
11882
|
}
|
|
11051
11883
|
sig[64] = 27;
|
|
11052
|
-
return `0x${(0,
|
|
11884
|
+
return `0x${(0, import_utils14.bytesToHex)(sig)}`;
|
|
11053
11885
|
}
|
|
11054
11886
|
delay(ms) {
|
|
11055
11887
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -11173,13 +12005,13 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
11173
12005
|
async getBalance() {
|
|
11174
12006
|
throw new WalletError(
|
|
11175
12007
|
"Hardware wallets do not track balances",
|
|
11176
|
-
|
|
12008
|
+
import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
11177
12009
|
);
|
|
11178
12010
|
}
|
|
11179
12011
|
async getTokenBalance(_asset) {
|
|
11180
12012
|
throw new WalletError(
|
|
11181
12013
|
"Hardware wallets do not track balances",
|
|
11182
|
-
|
|
12014
|
+
import_types29.WalletErrorCode.UNSUPPORTED_OPERATION
|
|
11183
12015
|
);
|
|
11184
12016
|
}
|
|
11185
12017
|
async getAccounts(startIndex = 0, count = 5) {
|
|
@@ -11238,15 +12070,15 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
11238
12070
|
}
|
|
11239
12071
|
}
|
|
11240
12072
|
generateMockAddress(index) {
|
|
11241
|
-
const bytes = (0,
|
|
12073
|
+
const bytes = (0, import_utils14.randomBytes)(20);
|
|
11242
12074
|
bytes[0] = index + 100;
|
|
11243
|
-
return `0x${(0,
|
|
12075
|
+
return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
|
|
11244
12076
|
}
|
|
11245
12077
|
generateMockPublicKey(index) {
|
|
11246
|
-
const bytes = (0,
|
|
12078
|
+
const bytes = (0, import_utils14.randomBytes)(33);
|
|
11247
12079
|
bytes[0] = 3;
|
|
11248
12080
|
bytes[1] = index + 100;
|
|
11249
|
-
return `0x${(0,
|
|
12081
|
+
return `0x${(0, import_utils14.bytesToHex)(bytes)}`;
|
|
11250
12082
|
}
|
|
11251
12083
|
generateMockSignature(data) {
|
|
11252
12084
|
const sig = new Uint8Array(65);
|
|
@@ -11255,7 +12087,7 @@ var MockTrezorAdapter = class extends BaseWalletAdapter {
|
|
|
11255
12087
|
sig[32 + i] = (data[i % data.length] ?? 0) ^ i * 17;
|
|
11256
12088
|
}
|
|
11257
12089
|
sig[64] = 28;
|
|
11258
|
-
return `0x${(0,
|
|
12090
|
+
return `0x${(0, import_utils14.bytesToHex)(sig)}`;
|
|
11259
12091
|
}
|
|
11260
12092
|
delay(ms) {
|
|
11261
12093
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -11269,12 +12101,16 @@ function createMockTrezorAdapter(config) {
|
|
|
11269
12101
|
}
|
|
11270
12102
|
|
|
11271
12103
|
// src/wallet/index.ts
|
|
11272
|
-
var
|
|
12104
|
+
var import_types32 = require("@sip-protocol/types");
|
|
11273
12105
|
// Annotate the CommonJS export names for ESM import in node:
|
|
11274
12106
|
0 && (module.exports = {
|
|
12107
|
+
ATTESTATION_VERSION,
|
|
11275
12108
|
BaseWalletAdapter,
|
|
12109
|
+
CHAIN_NUMERIC_IDS,
|
|
11276
12110
|
ComplianceManager,
|
|
11277
12111
|
CryptoError,
|
|
12112
|
+
DEFAULT_THRESHOLD,
|
|
12113
|
+
DEFAULT_TOTAL_ORACLES,
|
|
11278
12114
|
DerivationPath,
|
|
11279
12115
|
EncryptionNotImplementedError,
|
|
11280
12116
|
ErrorCode,
|
|
@@ -11297,6 +12133,7 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11297
12133
|
NEARIntentsAdapter,
|
|
11298
12134
|
NetworkError,
|
|
11299
12135
|
NoirProofProvider,
|
|
12136
|
+
ORACLE_DOMAIN,
|
|
11300
12137
|
OneClickClient,
|
|
11301
12138
|
OneClickDepositMode,
|
|
11302
12139
|
OneClickErrorCode,
|
|
@@ -11328,11 +12165,16 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11328
12165
|
ZcashShieldedService,
|
|
11329
12166
|
addBlindings,
|
|
11330
12167
|
addCommitments,
|
|
12168
|
+
addOracle,
|
|
11331
12169
|
attachProofs,
|
|
11332
12170
|
base58ToHex,
|
|
12171
|
+
browserBytesToHex,
|
|
12172
|
+
browserHexToBytes,
|
|
12173
|
+
checkEd25519StealthAddress,
|
|
11333
12174
|
checkStealthAddress,
|
|
11334
12175
|
commit,
|
|
11335
12176
|
commitZero,
|
|
12177
|
+
computeAttestationHash,
|
|
11336
12178
|
createCommitment,
|
|
11337
12179
|
createEthereumAdapter,
|
|
11338
12180
|
createLedgerAdapter,
|
|
@@ -11345,6 +12187,7 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11345
12187
|
createMockSolver,
|
|
11346
12188
|
createMockTrezorAdapter,
|
|
11347
12189
|
createNEARIntentsAdapter,
|
|
12190
|
+
createOracleRegistry,
|
|
11348
12191
|
createProductionSIP,
|
|
11349
12192
|
createSIP,
|
|
11350
12193
|
createShieldedIntent,
|
|
@@ -11357,12 +12200,17 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11357
12200
|
decodeStealthMetaAddress,
|
|
11358
12201
|
decryptMemo,
|
|
11359
12202
|
decryptWithViewing,
|
|
12203
|
+
deriveEd25519StealthPrivateKey,
|
|
12204
|
+
deriveOracleId,
|
|
11360
12205
|
deriveStealthPrivateKey,
|
|
11361
12206
|
deriveViewingKey,
|
|
12207
|
+
deserializeAttestationMessage,
|
|
11362
12208
|
deserializeIntent,
|
|
11363
12209
|
deserializePayment,
|
|
11364
12210
|
detectEthereumWallets,
|
|
11365
12211
|
detectSolanaWallets,
|
|
12212
|
+
ed25519PublicKeyToNearAddress,
|
|
12213
|
+
ed25519PublicKeyToSolanaAddress,
|
|
11366
12214
|
encodeStealthMetaAddress,
|
|
11367
12215
|
encryptForViewing,
|
|
11368
12216
|
featureNotSupportedError,
|
|
@@ -11370,13 +12218,19 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11370
12218
|
fromHex,
|
|
11371
12219
|
fromStablecoinUnits,
|
|
11372
12220
|
generateBlinding,
|
|
12221
|
+
generateEd25519StealthAddress,
|
|
12222
|
+
generateEd25519StealthMetaAddress,
|
|
11373
12223
|
generateIntentId,
|
|
11374
12224
|
generateRandomBytes,
|
|
11375
12225
|
generateStealthAddress,
|
|
11376
12226
|
generateStealthMetaAddress,
|
|
11377
12227
|
generateViewingKey,
|
|
12228
|
+
getActiveOracles,
|
|
11378
12229
|
getAvailableTransports,
|
|
12230
|
+
getBrowserInfo,
|
|
12231
|
+
getChainNumericId,
|
|
11379
12232
|
getChainsForStablecoin,
|
|
12233
|
+
getCurveForChain,
|
|
11380
12234
|
getDefaultRpcEndpoint,
|
|
11381
12235
|
getDerivationPath,
|
|
11382
12236
|
getErrorMessage,
|
|
@@ -11393,10 +12247,13 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11393
12247
|
getStablecoinsForChain,
|
|
11394
12248
|
getSupportedStablecoins,
|
|
11395
12249
|
getTimeRemaining,
|
|
12250
|
+
hasEnoughOracles,
|
|
11396
12251
|
hasErrorCode,
|
|
11397
12252
|
hasRequiredProofs,
|
|
11398
12253
|
hash,
|
|
11399
12254
|
hexToNumber,
|
|
12255
|
+
isBrowser,
|
|
12256
|
+
isEd25519Chain,
|
|
11400
12257
|
isExpired,
|
|
11401
12258
|
isNonNegativeAmount,
|
|
11402
12259
|
isPaymentExpired,
|
|
@@ -11408,40 +12265,54 @@ var import_types30 = require("@sip-protocol/types");
|
|
|
11408
12265
|
isValidAmount,
|
|
11409
12266
|
isValidChainId,
|
|
11410
12267
|
isValidCompressedPublicKey,
|
|
12268
|
+
isValidEd25519PublicKey,
|
|
11411
12269
|
isValidHex,
|
|
11412
12270
|
isValidHexLength,
|
|
12271
|
+
isValidNearAccountId,
|
|
12272
|
+
isValidNearImplicitAddress,
|
|
11413
12273
|
isValidPrivacyLevel,
|
|
11414
12274
|
isValidPrivateKey,
|
|
11415
12275
|
isValidScalar,
|
|
11416
12276
|
isValidSlippage,
|
|
12277
|
+
isValidSolanaAddress,
|
|
11417
12278
|
isValidStealthMetaAddress,
|
|
12279
|
+
nearAddressToEd25519PublicKey,
|
|
11418
12280
|
normalizeAddress,
|
|
11419
12281
|
notConnectedError,
|
|
11420
12282
|
publicKeyToEthAddress,
|
|
11421
12283
|
registerWallet,
|
|
12284
|
+
removeOracle,
|
|
11422
12285
|
secureWipe,
|
|
11423
12286
|
secureWipeAll,
|
|
12287
|
+
serializeAttestationMessage,
|
|
11424
12288
|
serializeIntent,
|
|
11425
12289
|
serializePayment,
|
|
12290
|
+
signAttestationMessage,
|
|
12291
|
+
solanaAddressToEd25519PublicKey,
|
|
11426
12292
|
solanaPublicKeyToHex,
|
|
11427
12293
|
subtractBlindings,
|
|
11428
12294
|
subtractCommitments,
|
|
12295
|
+
supportsSharedArrayBuffer,
|
|
11429
12296
|
supportsViewingKey,
|
|
11430
12297
|
supportsWebBluetooth,
|
|
11431
12298
|
supportsWebHID,
|
|
11432
12299
|
supportsWebUSB,
|
|
12300
|
+
supportsWebWorkers,
|
|
11433
12301
|
toHex,
|
|
11434
12302
|
toStablecoinUnits,
|
|
11435
12303
|
trackIntent,
|
|
11436
12304
|
trackPayment,
|
|
12305
|
+
updateOracleStatus,
|
|
11437
12306
|
validateAsset,
|
|
11438
12307
|
validateCreateIntentParams,
|
|
11439
12308
|
validateIntentInput,
|
|
11440
12309
|
validateIntentOutput,
|
|
11441
12310
|
validateScalar,
|
|
11442
12311
|
validateViewingKey,
|
|
12312
|
+
verifyAttestation,
|
|
11443
12313
|
verifyCommitment,
|
|
11444
12314
|
verifyOpening,
|
|
12315
|
+
verifyOracleSignature,
|
|
11445
12316
|
walletRegistry,
|
|
11446
12317
|
withSecureBuffer,
|
|
11447
12318
|
withSecureBufferSync,
|