wallaby-cash 1.7.8 → 1.7.9

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.
@@ -1,5 +1,5 @@
1
1
  import { Base } from 'src/base';
2
- import { WallabyConfig, Blockchain, AssetConfig, User } from 'src/types';
2
+ import { WallabyConfig, Blockchain, AssetConfig, User, BlockchainName } from 'src/types';
3
3
  export declare class System extends Base {
4
4
  constructor(config: WallabyConfig);
5
5
  /**
@@ -21,6 +21,51 @@ export declare class System extends Base {
21
21
  * @param {string} userId
22
22
  * @returns {User} Returns user public data
23
23
  */
24
+ /**
25
+ * Validates the contract address or SUI object ID for a given blockchain.
26
+ *
27
+ * @public
28
+ * @param {BlockchainName} blockchain - The name of the blockchain.
29
+ * @param {string} contractAddress - The contract address (optional for SUI blockchain).
30
+ * @param {string} suiObjectId - The SUI object ID (optional for SUI blockchain).
31
+ *
32
+ * @returns {string} The validated contract address or SUI object ID.
33
+ *
34
+ * @throws Will throw an error if both `contractAddress` and `suiObjectId` are provided for SUI blockchain.
35
+ * @throws Will throw an error if neither `contractAddress` nor `suiObjectId` are provided for SUI blockchain.
36
+ * @throws Will throw an error if `contractAddress` is not provided for non-SUI blockchains.
37
+ * @throws Will throw an error if the blockchain is not supported.
38
+ */
39
+ validateContractAddress(params: {
40
+ blockchain: BlockchainName;
41
+ contractAddress?: string;
42
+ suiObjectId?: string;
43
+ }): Promise<string>;
44
+ /**
45
+ * Fetches token information for a given blockchain and contract address or SUI object ID.
46
+ *
47
+ * @public
48
+ * @param {BlockchainName} blockchain - The name of the blockchain.
49
+ * @param {string} contractAddress - The contract address of the token (optional for non-SUI blockchains).
50
+ * @param {string} suiObjectId - The SUI object ID of the token (optional for SUI blockchain).
51
+ *
52
+ * @returns {Promise<{ decimals: number; symbol: string; name: string; tokenContractAddress: string }>} A promise that resolves to an object containing token information.
53
+ *
54
+ * @throws Will throw an error if both `contractAddress` and `suiObjectId` are provided for SUI blockchain.
55
+ * @throws Will throw an error if neither `contractAddress` nor `suiObjectId` are provided for SUI blockchain.
56
+ * @throws Will throw an error if `contractAddress` is not provided for non-SUI blockchains.
57
+ * @throws Will throw an error if the response is invalid or contains an error.
58
+ */
59
+ fetchTokenInfo(params: {
60
+ blockchain: BlockchainName;
61
+ contractAddress?: string;
62
+ suiObjectId?: string;
63
+ }): Promise<{
64
+ decimals: number;
65
+ symbol: string;
66
+ name: string;
67
+ tokenContractAddress: string;
68
+ }>;
24
69
  getUserData(userId: string): Promise<User | undefined>;
25
70
  /**
26
71
  * @public
@@ -1,5 +1,5 @@
1
1
  import { Base } from 'src/base';
2
- import { QueryUserRequest, CreateWalletRequest, CreateWalletResponse, RecoverWalletRequest, RecoverWalletResponse, TokenBalanceRequest, TokenBalanceResponse, WallabyError, QueryWalletRequest, UserAssetsResponse, UserWalletsResponse, WalletAssetsResponse, WallabyConfig, ConvertMnemonicSeedPhraseRequest, ConvertMnemonicSeedPhraseResponse, CreateMultisigAssetRequest, CreateMultisigAssetResponse, ImportWalletRequest, ImportWalletResponse } from 'src/types';
2
+ import { QueryUserRequest, CreateWalletRequest, CreateWalletResponse, RecoverWalletRequest, RecoverWalletResponse, TokenBalanceRequest, TokenBalanceResponse, WallabyError, QueryWalletRequest, UserAssetsResponse, UserWalletsResponse, WalletAssetsResponse, WallabyConfig, ConvertMnemonicSeedPhraseRequest, ConvertMnemonicSeedPhraseResponse, CreateMultisigAssetRequest, CreateMultisigAssetResponse, ImportWalletRequest, ImportWalletResponse, AddTokenToWalletRequest, AddTokenToWalletResponse } from 'src/types';
3
3
  export declare class Wallet extends Base {
4
4
  private auth;
5
5
  constructor(config: WallabyConfig);
@@ -140,9 +140,25 @@ export declare class Wallet extends Base {
140
140
  * @returns { WalletAssetsResponse } Returns all assets belonging in a certain wallet ID
141
141
  */
142
142
  getWalletAssets({ walletId, queryOptions }: QueryWalletRequest): Promise<WalletAssetsResponse | undefined>;
143
+ /**
144
+ * Adds a token to the wallet.
145
+ *
146
+ * @param {string} params.walletId - The wallet ID.
147
+ * @param {string} params.userId - The user ID.
148
+ * @param {Object} params.config - The configuration object.
149
+ * @param {string} [params.assetConfigId] - The asset configuration ID.
150
+ * @param {string} [params.config.contractAddress] - The contract address.
151
+ * @param {string} [params.config.suiObjectId] - The Sui object ID.
152
+ *
153
+ * @returns {Promise<AddTokenToWalletResponse>} The response from adding the token to the wallet.
154
+ *
155
+ * @throws {Error} If required parameters are missing or invalid.
156
+ */
157
+ addTokenToWallet(params: AddTokenToWalletRequest): Promise<AddTokenToWalletResponse>;
143
158
  /**
144
159
  *
145
160
  * @public
161
+ * @deprecated
146
162
  * Initiate creation for a new multisig asset, by specifying participants and the threshold
147
163
  * @param {string} assetSymbol Asset symbol
148
164
  * @param {string} tokenType Optional value only used when dealing with non native assets (aka tokens), If native asset, keep the field empty
package/dist/index.cjs.js CHANGED
@@ -6399,6 +6399,7 @@ var Wallet = /** @class */ (function (_super) {
6399
6399
  /**
6400
6400
  *
6401
6401
  * @public
6402
+ * @deprecated
6402
6403
  * Initiate creation for a new multisig asset, by specifying participants and the threshold
6403
6404
  * @param {string} assetSymbol Asset symbol
6404
6405
  * @param {string} tokenType Optional value only used when dealing with non native assets (aka tokens), If native asset, keep the field empty
@@ -6442,6 +6443,21 @@ var Wallet = /** @class */ (function (_super) {
6442
6443
  });
6443
6444
  });
6444
6445
  };
6446
+ /**
6447
+ * Adds a token to the wallet.
6448
+ *
6449
+ * @param {string} params.assetConfigId - The asset configuration ID.
6450
+ * @param {string} params.walletId - The wallet ID.
6451
+ * @param {string} params.userId - The user ID.
6452
+ * @param {Object} params.config - The configuration object.
6453
+ * @param {string} [params.config.contractAddress] - The contract address.
6454
+ * @param {string} [params.config.suiObjectId] - The Sui object ID.
6455
+ * @param {string} params.config.chainName - The name of the blockchain.
6456
+ *
6457
+ * @returns {Promise<AddTokenToWalletResponse>} The response from adding the token to the wallet.
6458
+ *
6459
+ * @throws {Error} If required parameters are missing or invalid.
6460
+ */
6445
6461
  Wallet.prototype.addTokenToWallet = function (_a) {
6446
6462
  return __awaiter(this, arguments, void 0, function (_b) {
6447
6463
  var contractAddress, response, error_16;
@@ -6450,14 +6466,14 @@ var Wallet = /** @class */ (function (_super) {
6450
6466
  switch (_c.label) {
6451
6467
  case 0:
6452
6468
  _c.trys.push([0, 2, , 3]);
6453
- if (!assetConfigId || !walletId || !userId || !config) {
6469
+ if (!walletId || !userId) {
6454
6470
  throw new Error('Missing required parameters');
6455
6471
  }
6456
6472
  if (!assetConfigId && !config) {
6457
- throw new Error('Either assetConfigId or config is required');
6473
+ throw new Error('Either assetConfigId or config must be provided');
6458
6474
  }
6459
- contractAddress = config.contractAddress;
6460
- if (config.chainName === exports.BlockchainName.Sui) {
6475
+ contractAddress = config === null || config === void 0 ? void 0 : config.contractAddress;
6476
+ if ((config === null || config === void 0 ? void 0 : config.chainName) === exports.BlockchainName.Sui) {
6461
6477
  if (!config.suiObjectId || !!config.contractAddress) {
6462
6478
  throw new Error('`suiObjectId` instead of `contractAddress` is required for Sui chain');
6463
6479
  }