wallaby-cash 2.2.9 → 2.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/normalize-storage-keys.d.ts +8 -0
- package/dist/index.cjs.js +322 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +322 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +322 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/swap/index.d.ts +36 -0
- package/dist/lib/system/index.d.ts +14 -4
- package/dist/lib/wallet/wallet-data.service.d.ts +2 -0
- package/dist/package.json +8 -9
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/swap.d.ts +24 -0
- package/dist/types/common.d.ts +3 -0
- package/dist/types/error-response-codes.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/swap.d.ts +95 -0
- package/dist/types/wallet.d.ts +2 -0
- package/package.json +8 -9
package/dist/index.js
CHANGED
|
@@ -362,6 +362,7 @@ var ErrorResponseCodes;
|
|
|
362
362
|
ErrorResponseCodes["sdk_missing_parameter"] = "sdk_missing_parameter";
|
|
363
363
|
ErrorResponseCodes["sdk_invalid_parameter"] = "sdk_invalid_parameter";
|
|
364
364
|
ErrorResponseCodes["sdk_wrong_password"] = "sdk_wrong_password";
|
|
365
|
+
ErrorResponseCodes["sdk_no_valid_seed_option"] = "sdk_no_valid_seed_option";
|
|
365
366
|
// passkey errors
|
|
366
367
|
ErrorResponseCodes["sdk_passkey_prf_not_available"] = "sdk_passkey_prf_not_available";
|
|
367
368
|
ErrorResponseCodes["sdk_passkey_challenge_unavailable"] = "sdk_passkey_challenge_unavailable";
|
|
@@ -775,7 +776,17 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
|
|
|
775
776
|
{ type: 'public-key', alg: PublicKeyCredentialAlgorithm.RS256 },
|
|
776
777
|
{ type: 'public-key', alg: PublicKeyCredentialAlgorithm.ES256 },
|
|
777
778
|
];
|
|
778
|
-
const
|
|
779
|
+
const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
780
|
+
const currentPackageVersion = "2.2.11";
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Storage keys adapter for Storage interface across different platforms.
|
|
784
|
+
*
|
|
785
|
+
* This sdk uses keys like "wsdk:version:key-name" but `SecureStore` doesn't allow colons in key names,
|
|
786
|
+
* Valid SecureStore key characters: alphanumeric, ".", "-", "_"
|
|
787
|
+
*
|
|
788
|
+
*/
|
|
789
|
+
const normalizeKey = (key) => key.replace(/:/g, '_');
|
|
779
790
|
|
|
780
791
|
const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
|
|
781
792
|
|
|
@@ -5037,6 +5048,9 @@ class StorageService {
|
|
|
5037
5048
|
else {
|
|
5038
5049
|
storageKey = `wsdk:v2:${this.shortenedEnv}:${key}:${this.userId}`;
|
|
5039
5050
|
}
|
|
5051
|
+
if (!isWeb) {
|
|
5052
|
+
storageKey = normalizeKey(storageKey);
|
|
5053
|
+
}
|
|
5040
5054
|
const item = await this.getItem(storageKey);
|
|
5041
5055
|
if (!item) {
|
|
5042
5056
|
logger.debug(`(404): Item with key ${storageKey} was not found in storage.`);
|
|
@@ -5070,6 +5084,9 @@ class StorageService {
|
|
|
5070
5084
|
else {
|
|
5071
5085
|
storageKey = `wsdk:v2:${this.shortenedEnv}:${key}:${this.userId}`;
|
|
5072
5086
|
}
|
|
5087
|
+
if (!isWeb) {
|
|
5088
|
+
storageKey = normalizeKey(storageKey);
|
|
5089
|
+
}
|
|
5073
5090
|
let valueToStore;
|
|
5074
5091
|
if (this._keysProtectedByMasterKey.includes(key)) {
|
|
5075
5092
|
const wrappedByMasterKey = this.cipher.encryptWithMasterKey({ data: value });
|
|
@@ -5094,6 +5111,9 @@ class StorageService {
|
|
|
5094
5111
|
else {
|
|
5095
5112
|
storageKey = `wsdk:v2:${this.shortenedEnv}:${key}:${this.userId}`;
|
|
5096
5113
|
}
|
|
5114
|
+
if (!isWeb) {
|
|
5115
|
+
storageKey = normalizeKey(storageKey);
|
|
5116
|
+
}
|
|
5097
5117
|
return await this.removeItem(storageKey);
|
|
5098
5118
|
}
|
|
5099
5119
|
setItem(key, value) {
|
|
@@ -6984,6 +7004,7 @@ function objectToQueryParams(obj) {
|
|
|
6984
7004
|
|
|
6985
7005
|
class Base {
|
|
6986
7006
|
constructor(config) {
|
|
7007
|
+
var _a;
|
|
6987
7008
|
const sanitizedConfig = sanitizeConfig(config);
|
|
6988
7009
|
this.apiKey = sanitizedConfig.apiKey;
|
|
6989
7010
|
this.baseUrl = sanitizedConfig.baseUrl;
|
|
@@ -7033,10 +7054,7 @@ class Base {
|
|
|
7033
7054
|
}
|
|
7034
7055
|
};
|
|
7035
7056
|
this.api = new Api(httpClient);
|
|
7036
|
-
this.api.http.setSecurityData({
|
|
7037
|
-
'x-api-key': config.apiKey,
|
|
7038
|
-
'x-client-jwt': config.clientAuthToken,
|
|
7039
|
-
});
|
|
7057
|
+
this.api.http.setSecurityData(Object.assign({ 'x-api-key': config.apiKey, 'x-client-jwt': config.clientAuthToken }, (_a = this.options) === null || _a === void 0 ? void 0 : _a.headers));
|
|
7040
7058
|
}
|
|
7041
7059
|
set setClientAuthToken(token) {
|
|
7042
7060
|
this._initializeClientAuthToken(token);
|
|
@@ -7483,6 +7501,24 @@ const TransactionsRoutes = {
|
|
|
7483
7501
|
},
|
|
7484
7502
|
};
|
|
7485
7503
|
|
|
7504
|
+
const SwapRoutes = {
|
|
7505
|
+
getQuote: {
|
|
7506
|
+
fullPath: ({ walletId }) => `/api/v1/wallets/${walletId}/swap/quote`,
|
|
7507
|
+
method: RequestMethod.Post,
|
|
7508
|
+
requiresAccessToken: true,
|
|
7509
|
+
},
|
|
7510
|
+
executeSwap: {
|
|
7511
|
+
fullPath: ({ walletId }) => `/api/v1/wallets/${walletId}/swap`,
|
|
7512
|
+
method: RequestMethod.Post,
|
|
7513
|
+
requiresAccessToken: true,
|
|
7514
|
+
},
|
|
7515
|
+
getSwaps: {
|
|
7516
|
+
fullPath: ({ walletId }) => `/api/v1/wallets/${walletId}/swaps`,
|
|
7517
|
+
method: RequestMethod.Get,
|
|
7518
|
+
requiresAccessToken: true,
|
|
7519
|
+
},
|
|
7520
|
+
};
|
|
7521
|
+
|
|
7486
7522
|
/* eslint-disable no-useless-catch */
|
|
7487
7523
|
/**
|
|
7488
7524
|
* Web Authenticator Implementation
|
|
@@ -10426,7 +10462,7 @@ class WalletDataService extends Base {
|
|
|
10426
10462
|
});
|
|
10427
10463
|
}
|
|
10428
10464
|
const response = await this.request(WalletRoutes.getMultiTokenBalances, {
|
|
10429
|
-
payload: {
|
|
10465
|
+
payload: { tokensAndAddressesList },
|
|
10430
10466
|
});
|
|
10431
10467
|
return response;
|
|
10432
10468
|
}
|
|
@@ -10514,10 +10550,20 @@ class WalletDataService extends Base {
|
|
|
10514
10550
|
* Get all assets that exist in a certain wallet, by specifying a wallet ID
|
|
10515
10551
|
* @param walletId Wallaby's wallet ID
|
|
10516
10552
|
* @param { BasicQueryOptions } queryOptions Optional query options
|
|
10553
|
+
* @param { string } [queryOptions.search] - Search assets by name or symbol (minimum 3 characters)
|
|
10554
|
+
* @param { BlockchainName } [queryOptions.chainName] - Filter assets by blockchain name
|
|
10517
10555
|
* @returns { GetUserAssetsByWalletIdData } Returns all assets belonging in a certain wallet ID
|
|
10518
10556
|
*/
|
|
10519
10557
|
async getWalletAssets({ walletId, queryOptions }) {
|
|
10520
10558
|
try {
|
|
10559
|
+
// Validate search parameter if provided
|
|
10560
|
+
if ((queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.search) !== undefined && queryOptions.search.length < 3) {
|
|
10561
|
+
throw new WallabyError({
|
|
10562
|
+
message: 'Search parameter must be at least 3 characters long',
|
|
10563
|
+
statusCode: 400,
|
|
10564
|
+
errorCode: ErrorResponseCodes.sdk_invalid_parameter,
|
|
10565
|
+
});
|
|
10566
|
+
}
|
|
10521
10567
|
const response = await this.request(WalletRoutes.getWalletAssets, {
|
|
10522
10568
|
payload: {
|
|
10523
10569
|
walletId,
|
|
@@ -10987,6 +11033,246 @@ class HttpApi extends Base {
|
|
|
10987
11033
|
}
|
|
10988
11034
|
}
|
|
10989
11035
|
|
|
11036
|
+
class Swap extends Base {
|
|
11037
|
+
constructor(config) {
|
|
11038
|
+
super(config);
|
|
11039
|
+
this.authService = new AuthService(config);
|
|
11040
|
+
this.walletService = new WalletService(config);
|
|
11041
|
+
}
|
|
11042
|
+
/**
|
|
11043
|
+
* Gets a swap quote between two assets (from/to), including fees, min output, and slippage limits.
|
|
11044
|
+
*
|
|
11045
|
+
* @public
|
|
11046
|
+
* @param {SwapQuoteRequest} request - The swap quote request parameters
|
|
11047
|
+
* @returns {Promise<SwapQuoteResponse>} A promise that resolves with the swap quote
|
|
11048
|
+
*/
|
|
11049
|
+
async getQuote({ walletId, fromAsset, toAsset, fromAmount, toAmount }) {
|
|
11050
|
+
try {
|
|
11051
|
+
if (!walletId || !fromAsset || !toAsset) {
|
|
11052
|
+
throw new WallabyError({
|
|
11053
|
+
message: 'Missing required parameters: walletId, fromAsset, and toAsset are required',
|
|
11054
|
+
statusCode: 400,
|
|
11055
|
+
errorCode: ErrorResponseCodes.sdk_missing_parameter,
|
|
11056
|
+
});
|
|
11057
|
+
}
|
|
11058
|
+
if (!fromAmount && !toAmount) {
|
|
11059
|
+
throw new WallabyError({
|
|
11060
|
+
message: 'Either fromAmount or toAmount must be provided',
|
|
11061
|
+
statusCode: 400,
|
|
11062
|
+
errorCode: ErrorResponseCodes.sdk_missing_parameter,
|
|
11063
|
+
});
|
|
11064
|
+
}
|
|
11065
|
+
// Build path with walletId, but exclude it from request body
|
|
11066
|
+
const routePayload = { walletId };
|
|
11067
|
+
const requestBody = Object.assign(Object.assign({ fromAsset,
|
|
11068
|
+
toAsset }, (fromAmount && { fromAmount })), (toAmount && { toAmount }));
|
|
11069
|
+
const response = await this.request(Object.assign(Object.assign({}, SwapRoutes.getQuote), { fullPath: SwapRoutes.getQuote.fullPath(routePayload) }), {
|
|
11070
|
+
payload: requestBody,
|
|
11071
|
+
});
|
|
11072
|
+
return response;
|
|
11073
|
+
}
|
|
11074
|
+
catch (error) {
|
|
11075
|
+
logger.error('SDK::Swap::getQuote::error', error);
|
|
11076
|
+
throw error;
|
|
11077
|
+
}
|
|
11078
|
+
}
|
|
11079
|
+
/**
|
|
11080
|
+
* Executes a swap using a previously generated quote.
|
|
11081
|
+
*
|
|
11082
|
+
* @public
|
|
11083
|
+
* @param {ExecuteSwapRequest} request - The execute swap request parameters
|
|
11084
|
+
* @returns {Promise<ExecuteSwapResponse>} A promise that resolves with the swap execution response
|
|
11085
|
+
*/
|
|
11086
|
+
async executeSwap({ walletId, quoteId, authenticationOptions }) {
|
|
11087
|
+
try {
|
|
11088
|
+
// Only attempt migration if we have password auth and V2 storage might be incomplete
|
|
11089
|
+
if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
|
|
11090
|
+
try {
|
|
11091
|
+
await this.walletService.handleUpdateToV2({
|
|
11092
|
+
password: authenticationOptions.password,
|
|
11093
|
+
walletId: walletId,
|
|
11094
|
+
});
|
|
11095
|
+
}
|
|
11096
|
+
catch (error) {
|
|
11097
|
+
logger.error('SDK::Swap::executeSwap::handleUpdateToV2::error', error);
|
|
11098
|
+
throw new WallabyError({
|
|
11099
|
+
message: 'Error accessing user wallet on this device. Please ensure the password is correct and try again.',
|
|
11100
|
+
statusCode: 500,
|
|
11101
|
+
errorCode: ErrorResponseCodes.sdk_unknown_error,
|
|
11102
|
+
});
|
|
11103
|
+
}
|
|
11104
|
+
}
|
|
11105
|
+
const { deviceAuthPublicKey, signatureMessage, readyForTransportSeedPhrase, sharesEncryptedWithWallabyPubKey, hasShares } = await this.prepareSwapAuth(authenticationOptions, walletId);
|
|
11106
|
+
let swapResponse;
|
|
11107
|
+
// Build path with walletId, but exclude it from request body
|
|
11108
|
+
const routePayload = { walletId };
|
|
11109
|
+
if (readyForTransportSeedPhrase) {
|
|
11110
|
+
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath(routePayload) }), {
|
|
11111
|
+
payload: {
|
|
11112
|
+
quoteId,
|
|
11113
|
+
message: signatureMessage.message,
|
|
11114
|
+
signature: signatureMessage.signature,
|
|
11115
|
+
clientAuthPubKey: deviceAuthPublicKey,
|
|
11116
|
+
encryptedSeed: readyForTransportSeedPhrase,
|
|
11117
|
+
},
|
|
11118
|
+
});
|
|
11119
|
+
}
|
|
11120
|
+
else if (hasShares) {
|
|
11121
|
+
swapResponse = await this.request(Object.assign(Object.assign({}, SwapRoutes.executeSwap), { fullPath: SwapRoutes.executeSwap.fullPath(routePayload) }), {
|
|
11122
|
+
payload: {
|
|
11123
|
+
quoteId,
|
|
11124
|
+
message: signatureMessage.message,
|
|
11125
|
+
signature: signatureMessage.signature,
|
|
11126
|
+
clientAuthPubKey: deviceAuthPublicKey,
|
|
11127
|
+
encryptedShares: sharesEncryptedWithWallabyPubKey,
|
|
11128
|
+
},
|
|
11129
|
+
});
|
|
11130
|
+
}
|
|
11131
|
+
else {
|
|
11132
|
+
throw new WallabyError({
|
|
11133
|
+
message: 'No valid seed option found on this device.',
|
|
11134
|
+
statusCode: 400,
|
|
11135
|
+
errorCode: ErrorResponseCodes.sdk_no_valid_seed_option,
|
|
11136
|
+
});
|
|
11137
|
+
}
|
|
11138
|
+
return swapResponse;
|
|
11139
|
+
}
|
|
11140
|
+
catch (error) {
|
|
11141
|
+
logger.error('SDK::Swap::executeSwap::error', error);
|
|
11142
|
+
throw error;
|
|
11143
|
+
}
|
|
11144
|
+
}
|
|
11145
|
+
/**
|
|
11146
|
+
* Lists executed swap transactions for a given wallet, with optional date and pagination filters.
|
|
11147
|
+
*
|
|
11148
|
+
* @public
|
|
11149
|
+
* @param {GetSwapsRequest} request - The get swaps request parameters
|
|
11150
|
+
* @returns {Promise<GetSwapsResponse>} A promise that resolves with the list of swaps
|
|
11151
|
+
*/
|
|
11152
|
+
async getSwaps({ walletId, queryParams }) {
|
|
11153
|
+
try {
|
|
11154
|
+
if (!walletId) {
|
|
11155
|
+
throw new WallabyError({
|
|
11156
|
+
message: 'Missing required parameter: walletId',
|
|
11157
|
+
statusCode: 400,
|
|
11158
|
+
errorCode: ErrorResponseCodes.sdk_missing_parameter,
|
|
11159
|
+
});
|
|
11160
|
+
}
|
|
11161
|
+
// Build path with walletId
|
|
11162
|
+
const routePayload = { walletId };
|
|
11163
|
+
const response = await this.request(Object.assign(Object.assign({}, SwapRoutes.getSwaps), { fullPath: SwapRoutes.getSwaps.fullPath(routePayload) }), {
|
|
11164
|
+
queryParams: queryParams,
|
|
11165
|
+
});
|
|
11166
|
+
return response;
|
|
11167
|
+
}
|
|
11168
|
+
catch (error) {
|
|
11169
|
+
logger.error('SDK::Swap::getSwaps::error', error);
|
|
11170
|
+
throw error;
|
|
11171
|
+
}
|
|
11172
|
+
}
|
|
11173
|
+
/**
|
|
11174
|
+
* Prepares authentication data and encrypted payload for swap requests
|
|
11175
|
+
* @private
|
|
11176
|
+
*/
|
|
11177
|
+
async prepareSwapAuth(authenticationOptions, walletId) {
|
|
11178
|
+
const { password, prfValue, user, clientSalt: authClientSalt } = authenticationOptions;
|
|
11179
|
+
const encryptedDevicePrivateKey = await this.localStorageService.fetch(LocalStorageItems.EncryptedDevicePrivateKey, {
|
|
11180
|
+
walletId,
|
|
11181
|
+
});
|
|
11182
|
+
if (!encryptedDevicePrivateKey) {
|
|
11183
|
+
throw new WallabyError({
|
|
11184
|
+
message: 'No private key was found on this device.',
|
|
11185
|
+
statusCode: 400,
|
|
11186
|
+
errorCode: ErrorResponseCodes.sdk_private_key_not_found,
|
|
11187
|
+
});
|
|
11188
|
+
}
|
|
11189
|
+
// Get credentials key pair for device private key decryption
|
|
11190
|
+
const clientSalt = authClientSalt || user.clientSalt;
|
|
11191
|
+
const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
|
|
11192
|
+
authType: this.deviceAuthType,
|
|
11193
|
+
password,
|
|
11194
|
+
prfValue,
|
|
11195
|
+
salt: clientSalt,
|
|
11196
|
+
});
|
|
11197
|
+
// Decrypt device private key
|
|
11198
|
+
const decryptedDevicePrivateKey = await this.cipher.decrypt({
|
|
11199
|
+
cipherText: JSON.parse(encryptedDevicePrivateKey),
|
|
11200
|
+
decryptionKey: credentialsKeyPair.privateKey,
|
|
11201
|
+
});
|
|
11202
|
+
if (!decryptedDevicePrivateKey) {
|
|
11203
|
+
throw new WallabyError({
|
|
11204
|
+
message: 'Credentials are wrong, please pass the correct credentials.',
|
|
11205
|
+
statusCode: 400,
|
|
11206
|
+
errorCode: ErrorResponseCodes.sdk_private_key_decryption_failed,
|
|
11207
|
+
});
|
|
11208
|
+
}
|
|
11209
|
+
const deviceAuthPublicKey = publicKeyByPrivateKey(decryptedDevicePrivateKey);
|
|
11210
|
+
// Get signature message
|
|
11211
|
+
const signatureMessage = await this.authService.getSignature({
|
|
11212
|
+
publicKey: deviceAuthPublicKey,
|
|
11213
|
+
privateKey: decryptedDevicePrivateKey,
|
|
11214
|
+
}, this.deviceAuthType === AuthType.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
|
|
11215
|
+
// Prepare encrypted data (seed phrase or key shares)
|
|
11216
|
+
const sharesEncryptedWithWallabyPubKey = [];
|
|
11217
|
+
let readyForTransportSeedPhrase = undefined;
|
|
11218
|
+
const primaryKeyShare = await this.localStorageService.fetch(LocalStorageItems.PrimaryDeviceKeyShare, { walletId });
|
|
11219
|
+
if (!primaryKeyShare) {
|
|
11220
|
+
// No primary share, try seed phrase
|
|
11221
|
+
const encryptedSeedPhrase = await this.localStorageService.fetch(LocalStorageItems.EncryptedStandardSeedPhrase, {
|
|
11222
|
+
walletId,
|
|
11223
|
+
});
|
|
11224
|
+
if (!encryptedSeedPhrase) {
|
|
11225
|
+
throw new WallabyError({
|
|
11226
|
+
message: 'Your device does not have a seed phrase or an operating share to sign the transaction.',
|
|
11227
|
+
statusCode: 400,
|
|
11228
|
+
errorCode: ErrorResponseCodes.sdk_seed_phrase_not_found,
|
|
11229
|
+
});
|
|
11230
|
+
}
|
|
11231
|
+
const parsedSeedPhrase = safeJsonParse(encryptedSeedPhrase);
|
|
11232
|
+
readyForTransportSeedPhrase = await this.cipher.prepareStoredDataForTransport({
|
|
11233
|
+
storedEncryptedData: parsedSeedPhrase,
|
|
11234
|
+
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11235
|
+
wallabyPublicKey: user.wallabyAuthPubKey,
|
|
11236
|
+
options: {
|
|
11237
|
+
authType: this.deviceAuthType,
|
|
11238
|
+
password,
|
|
11239
|
+
prfValue,
|
|
11240
|
+
salt: clientSalt,
|
|
11241
|
+
},
|
|
11242
|
+
});
|
|
11243
|
+
}
|
|
11244
|
+
else {
|
|
11245
|
+
// Use primary key share
|
|
11246
|
+
const parsedPrimaryShare = safeJsonParse(primaryKeyShare);
|
|
11247
|
+
const readyForTransportShare = await this.cipher.prepareStoredDataForTransport({
|
|
11248
|
+
storedEncryptedData: parsedPrimaryShare,
|
|
11249
|
+
encryptedDevicePrivateKey: JSON.parse(encryptedDevicePrivateKey),
|
|
11250
|
+
wallabyPublicKey: user.wallabyAuthPubKey,
|
|
11251
|
+
options: {
|
|
11252
|
+
authType: this.deviceAuthType,
|
|
11253
|
+
password,
|
|
11254
|
+
prfValue,
|
|
11255
|
+
salt: clientSalt,
|
|
11256
|
+
},
|
|
11257
|
+
});
|
|
11258
|
+
sharesEncryptedWithWallabyPubKey.push(readyForTransportShare);
|
|
11259
|
+
}
|
|
11260
|
+
return Object.freeze({
|
|
11261
|
+
deviceAuthPublicKey,
|
|
11262
|
+
signatureMessage,
|
|
11263
|
+
readyForTransportSeedPhrase,
|
|
11264
|
+
sharesEncryptedWithWallabyPubKey,
|
|
11265
|
+
hasShares: sharesEncryptedWithWallabyPubKey.length > 0,
|
|
11266
|
+
});
|
|
11267
|
+
}
|
|
11268
|
+
}
|
|
11269
|
+
__decorate([
|
|
11270
|
+
WithLock('executeSwap'),
|
|
11271
|
+
__metadata("design:type", Function),
|
|
11272
|
+
__metadata("design:paramtypes", [Object]),
|
|
11273
|
+
__metadata("design:returntype", Promise)
|
|
11274
|
+
], Swap.prototype, "executeSwap", null);
|
|
11275
|
+
|
|
10990
11276
|
/**
|
|
10991
11277
|
* Sanitizes a Sui object ID by removing any part of the string after '::'.
|
|
10992
11278
|
*
|
|
@@ -11013,13 +11299,14 @@ class System extends Base {
|
|
|
11013
11299
|
/**
|
|
11014
11300
|
* @public
|
|
11015
11301
|
* Get all supported chains
|
|
11016
|
-
* @param {
|
|
11302
|
+
* @param {Object} [options] - Optional query parameters
|
|
11303
|
+
* @param {boolean} [options.supportSwaps] - When true, include only chains that support swaps
|
|
11017
11304
|
* @returns {Array<Blockchain>} Array of supported chains
|
|
11018
11305
|
*/
|
|
11019
|
-
async getSupportedBlockchains() {
|
|
11306
|
+
async getSupportedBlockchains(options) {
|
|
11020
11307
|
try {
|
|
11021
11308
|
const response = await this.request(SystemRoutes.getSupportedBlockchains, {
|
|
11022
|
-
|
|
11309
|
+
queryParams: (options === null || options === void 0 ? void 0 : options.supportSwaps) !== undefined ? { supportSwaps: options.supportSwaps } : undefined,
|
|
11023
11310
|
});
|
|
11024
11311
|
return response.chains;
|
|
11025
11312
|
}
|
|
@@ -11124,13 +11411,33 @@ class System extends Base {
|
|
|
11124
11411
|
/**
|
|
11125
11412
|
* @public
|
|
11126
11413
|
* Get all supported assets configuration
|
|
11127
|
-
* @param {
|
|
11414
|
+
* @param {Object} [options] - Optional query parameters
|
|
11415
|
+
* @param {boolean} [options.supportsSwaps] - When true, filter to assets that support swaps
|
|
11416
|
+
* @param {string} [options.search] - Search assets by name or symbol (minimum 3 characters)
|
|
11417
|
+
* @param {BlockchainName} [options.chainName] - Filter assets by blockchain name
|
|
11128
11418
|
* @returns {Array<AssetConfig>} Array of supported tokens
|
|
11129
11419
|
*/
|
|
11130
|
-
async getSupportedTokens() {
|
|
11420
|
+
async getSupportedTokens(options) {
|
|
11131
11421
|
try {
|
|
11422
|
+
const queryParams = {};
|
|
11423
|
+
if ((options === null || options === void 0 ? void 0 : options.supportsSwaps) !== undefined) {
|
|
11424
|
+
queryParams.supportsSwaps = options.supportsSwaps;
|
|
11425
|
+
}
|
|
11426
|
+
if ((options === null || options === void 0 ? void 0 : options.search) !== undefined) {
|
|
11427
|
+
if (options.search.length < 3) {
|
|
11428
|
+
throw new WallabyError({
|
|
11429
|
+
message: 'Search parameter must be at least 3 characters long',
|
|
11430
|
+
statusCode: 400,
|
|
11431
|
+
errorCode: ErrorResponseCodes.sdk_invalid_parameter,
|
|
11432
|
+
});
|
|
11433
|
+
}
|
|
11434
|
+
queryParams.search = options.search;
|
|
11435
|
+
}
|
|
11436
|
+
if ((options === null || options === void 0 ? void 0 : options.chainName) !== undefined) {
|
|
11437
|
+
queryParams.chainName = options.chainName;
|
|
11438
|
+
}
|
|
11132
11439
|
const response = await this.request(SystemRoutes.getSupportedTokens, {
|
|
11133
|
-
|
|
11440
|
+
queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
|
|
11134
11441
|
});
|
|
11135
11442
|
return response.assets;
|
|
11136
11443
|
}
|
|
@@ -11319,7 +11626,7 @@ class Transactions extends Base {
|
|
|
11319
11626
|
throw new WallabyError({
|
|
11320
11627
|
message: 'No valid seed option found on this device.',
|
|
11321
11628
|
statusCode: 400,
|
|
11322
|
-
errorCode:
|
|
11629
|
+
errorCode: ErrorResponseCodes.sdk_no_valid_seed_option,
|
|
11323
11630
|
});
|
|
11324
11631
|
}
|
|
11325
11632
|
return transferResponse;
|
|
@@ -11386,6 +11693,7 @@ class Transactions extends Base {
|
|
|
11386
11693
|
}
|
|
11387
11694
|
const payload = Object.assign({ message,
|
|
11388
11695
|
walletId,
|
|
11696
|
+
authenticationOptions,
|
|
11389
11697
|
signature, clientAuthPubKey: deviceAuthPublicKey, ownerAddress,
|
|
11390
11698
|
spenderAddress,
|
|
11391
11699
|
chainName,
|
|
@@ -11611,6 +11919,7 @@ class Wallaby {
|
|
|
11611
11919
|
this.auth = new AuthService(config);
|
|
11612
11920
|
this.system = new System(config);
|
|
11613
11921
|
this.transactions = new Transactions(config);
|
|
11922
|
+
this.swap = new Swap(config);
|
|
11614
11923
|
this.merchants = new Merchants(config);
|
|
11615
11924
|
this.httpApi = new HttpApi(config);
|
|
11616
11925
|
}
|