@dynamic-labs/global-wallet-client 4.19.4 → 4.19.6

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +7 -7
  5. package/src/features.cjs +4 -0
  6. package/src/features.d.ts +2 -0
  7. package/src/features.js +2 -0
  8. package/src/lib/client/createClientStore/createClientStore.d.ts +1 -0
  9. package/src/lib/functions/connect/connect.cjs +1 -0
  10. package/src/lib/functions/connect/connect.js +1 -0
  11. package/src/lib/functions/getEoaWalletForSmartWallet/getEoaWalletForSmartWallet.cjs +30 -0
  12. package/src/lib/functions/getEoaWalletForSmartWallet/getEoaWalletForSmartWallet.d.ts +11 -0
  13. package/src/lib/functions/getEoaWalletForSmartWallet/getEoaWalletForSmartWallet.js +26 -0
  14. package/src/lib/functions/getEoaWalletForSmartWallet/index.d.ts +1 -0
  15. package/src/lib/functions/sendTransaction/index.d.ts +1 -0
  16. package/src/lib/functions/sendTransaction/sendTransaction.cjs +48 -0
  17. package/src/lib/functions/sendTransaction/sendTransaction.d.ts +12 -0
  18. package/src/lib/functions/sendTransaction/sendTransaction.js +44 -0
  19. package/src/lib/protocol/functions/decodeFromBase64.d.ts +7 -0
  20. package/src/lib/protocol/functions/encodeToBase64.d.ts +7 -0
  21. package/src/lib/protocol/functions/generateNonce.d.ts +6 -0
  22. package/src/lib/protocol/functions/generateRandomHex.d.ts +7 -0
  23. package/src/lib/protocol/functions/walletRequest/addActionToWalletRequest.d.ts +15 -0
  24. package/src/lib/protocol/functions/walletRequest/createWalletRequest.d.ts +7 -0
  25. package/src/lib/protocol/functions/walletRequest/decodeWalletRequest.d.ts +8 -0
  26. package/src/lib/protocol/functions/walletRequest/decryptWalletRequest.d.ts +10 -0
  27. package/src/lib/protocol/functions/walletRequest/encodeWalletRequest.d.ts +8 -0
  28. package/src/lib/protocol/functions/walletRequest/encryptWalletRequest.d.ts +10 -0
  29. package/src/lib/protocol/functions/walletRequest/getActionFromWalletRequest.d.ts +9 -0
  30. package/src/lib/protocol/functions/walletRequest/isEncryptedWalletRequest.d.ts +8 -0
  31. package/src/lib/protocol/functions/walletResponse/addActionErrorToWalletResponse.d.ts +9 -0
  32. package/src/lib/protocol/functions/walletResponse/addActionResultToWalletResponse.d.ts +9 -0
  33. package/src/lib/protocol/functions/walletResponse/addErrorToWalletResponse.d.ts +8 -0
  34. package/src/lib/protocol/functions/walletResponse/addNextNonceToWalletResponse.d.ts +8 -0
  35. package/src/lib/protocol/functions/walletResponse/createWalletResponse.d.ts +8 -0
  36. package/src/lib/protocol/functions/walletResponse/decodeWalletResponse.d.ts +8 -0
  37. package/src/lib/protocol/functions/walletResponse/decryptWalletResponse.d.ts +10 -0
  38. package/src/lib/protocol/functions/walletResponse/encodeWalletResponse.d.ts +8 -0
  39. package/src/lib/protocol/functions/walletResponse/encryptWalletResponse.d.ts +10 -0
  40. package/src/lib/protocol/functions/walletResponse/getActionErrorFromWalletResponse.d.ts +9 -0
  41. package/src/lib/protocol/functions/walletResponse/getActionResultFromWalletResponse.d.ts +10 -0
  42. package/src/lib/protocol/functions/walletResponse/getErrorFromWalletResponse.d.ts +8 -0
  43. package/src/lib/protocol/functions/walletResponse/getNextNonceFromWalletResponse.d.ts +8 -0
  44. package/src/lib/protocol/functions/walletResponse/isEncryptedWalletResponse.d.ts +8 -0
  45. package/src/lib/protocol/index.d.ts +24 -0
  46. package/src/lib/protocol/types.d.ts +48 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,24 @@
1
1
 
2
+ ### [4.19.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.5...v4.19.6) (2025-06-04)
3
+
4
+
5
+ ### Features
6
+
7
+ * backup unsuccessful popup when create wallet fails ([#8872](https://github.com/dynamic-labs/dynamic-auth/issues/8872)) ([c8f88f2](https://github.com/dynamic-labs/dynamic-auth/commit/c8f88f2cafdb7856764305764a230e159f09dadf))
8
+ * **global-wallet:** new native api method to return the eoa wallet for a connected smart wallet ([#8864](https://github.com/dynamic-labs/dynamic-auth/issues/8864)) ([5d0e200](https://github.com/dynamic-labs/dynamic-auth/commit/5d0e2002caefb658f6120b102abe145d6caafaf4))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * dont call select endpoint when signing in with 7702 wallet ([#8854](https://github.com/dynamic-labs/dynamic-auth/issues/8854)) ([9828a8f](https://github.com/dynamic-labs/dynamic-auth/commit/9828a8fb758b07dd4dc51cb9eadee483b884defe))
14
+
15
+ ### [4.19.5](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.4...v4.19.5) (2025-06-02)
16
+
17
+
18
+ ### Features
19
+
20
+ * add cleanup for waas connectors ([#8849](https://github.com/dynamic-labs/dynamic-auth/issues/8849)) ([5899169](https://github.com/dynamic-labs/dynamic-auth/commit/5899169abaf7ce86add2b1393cfd9b967da5e388))
21
+
2
22
  ### [4.19.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.3...v4.19.4) (2025-05-31)
3
23
 
4
24
  ### [4.19.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.19.2...v4.19.3) (2025-05-28)
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.19.4";
6
+ var version = "4.19.6";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.19.4";
2
+ var version = "4.19.6";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/global-wallet-client",
3
- "version": "4.19.4",
3
+ "version": "4.19.6",
4
4
  "description": "Core package for building Dynamic's Global Wallet",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -55,12 +55,12 @@
55
55
  },
56
56
  "homepage": "https://www.dynamic.xyz/",
57
57
  "dependencies": {
58
- "@dynamic-labs/assert-package-version": "4.19.4",
59
- "@dynamic-labs/logger": "4.19.4",
60
- "@dynamic-labs/message-transport": "4.19.4",
61
- "@dynamic-labs/store": "4.19.4",
62
- "@dynamic-labs/types": "4.19.4",
63
- "@dynamic-labs/utils": "4.19.4",
58
+ "@dynamic-labs/assert-package-version": "4.19.6",
59
+ "@dynamic-labs/logger": "4.19.6",
60
+ "@dynamic-labs/message-transport": "4.19.6",
61
+ "@dynamic-labs/store": "4.19.6",
62
+ "@dynamic-labs/types": "4.19.6",
63
+ "@dynamic-labs/utils": "4.19.6",
64
64
  "eventemitter3": "5.0.1"
65
65
  },
66
66
  "peerDependencies": {
package/src/features.cjs CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var connect = require('./lib/functions/connect/connect.cjs');
7
7
  var disconnect = require('./lib/functions/disconnect/disconnect.cjs');
8
+ var getEoaWalletForSmartWallet = require('./lib/functions/getEoaWalletForSmartWallet/getEoaWalletForSmartWallet.cjs');
8
9
  var getEthereumWallets = require('./lib/functions/getEthereumWallets/getEthereumWallets.cjs');
9
10
  var getSolanaWallets = require('./lib/functions/getSolanaWallets/getSolanaWallets.cjs');
10
11
  var getSupportedEthereumNetworks = require('./lib/functions/getSupportedEthereumNetworks/getSupportedEthereumNetworks.cjs');
@@ -14,11 +15,13 @@ var isSolanaWallet = require('./lib/functions/isSolanaWallet/isSolanaWallet.cjs'
14
15
  var onEvent = require('./lib/functions/onEvent/onEvent.cjs');
15
16
  var signMessage = require('./lib/functions/signMessage/signMessage.cjs');
16
17
  var switchNetwork = require('./lib/functions/switchNetwork/switchNetwork.cjs');
18
+ var sendTransaction = require('./lib/functions/sendTransaction/sendTransaction.cjs');
17
19
 
18
20
 
19
21
 
20
22
  exports.connect = connect.connect;
21
23
  exports.disconnect = disconnect.disconnect;
24
+ exports.getEoaWalletForSmartWallet = getEoaWalletForSmartWallet.getEoaWalletForSmartWallet;
22
25
  exports.getEthereumWallets = getEthereumWallets.getEthereumWallets;
23
26
  exports.getSolanaWallets = getSolanaWallets.getSolanaWallets;
24
27
  exports.getSupportedEthereumNetworks = getSupportedEthereumNetworks.getSupportedEthereumNetworks;
@@ -28,3 +31,4 @@ exports.isSolanaWallet = isSolanaWallet.isSolanaWallet;
28
31
  exports.onEvent = onEvent.onEvent;
29
32
  exports.signMessage = signMessage.signMessage;
30
33
  exports.switchNetwork = switchNetwork.switchNetwork;
34
+ exports.sendTransaction = sendTransaction.sendTransaction;
package/src/features.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { connect } from './lib/functions/connect';
2
2
  export { disconnect } from './lib/functions/disconnect';
3
+ export { getEoaWalletForSmartWallet } from './lib/functions/getEoaWalletForSmartWallet';
3
4
  export { getEthereumWallets } from './lib/functions/getEthereumWallets';
4
5
  export { getSolanaWallets } from './lib/functions/getSolanaWallets';
5
6
  export { getSupportedEthereumNetworks } from './lib/functions/getSupportedEthereumNetworks';
@@ -9,3 +10,4 @@ export { isSolanaWallet } from './lib/functions/isSolanaWallet';
9
10
  export { onEvent } from './lib/functions/onEvent';
10
11
  export { signMessage } from './lib/functions/signMessage';
11
12
  export { switchNetwork } from './lib/functions/switchNetwork';
13
+ export { sendTransaction } from './lib/functions/sendTransaction';
package/src/features.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use client'
2
2
  export { connect } from './lib/functions/connect/connect.js';
3
3
  export { disconnect } from './lib/functions/disconnect/disconnect.js';
4
+ export { getEoaWalletForSmartWallet } from './lib/functions/getEoaWalletForSmartWallet/getEoaWalletForSmartWallet.js';
4
5
  export { getEthereumWallets } from './lib/functions/getEthereumWallets/getEthereumWallets.js';
5
6
  export { getSolanaWallets } from './lib/functions/getSolanaWallets/getSolanaWallets.js';
6
7
  export { getSupportedEthereumNetworks } from './lib/functions/getSupportedEthereumNetworks/getSupportedEthereumNetworks.js';
@@ -10,3 +11,4 @@ export { isSolanaWallet } from './lib/functions/isSolanaWallet/isSolanaWallet.js
10
11
  export { onEvent } from './lib/functions/onEvent/onEvent.js';
11
12
  export { signMessage } from './lib/functions/signMessage/signMessage.js';
12
13
  export { switchNetwork } from './lib/functions/switchNetwork/switchNetwork.js';
14
+ export { sendTransaction } from './lib/functions/sendTransaction/sendTransaction.js';
@@ -18,6 +18,7 @@ export type ClientStoreState = {
18
18
  * Ethereum specific state
19
19
  */
20
20
  ethereum: {
21
+ eoaWallets: Record<string, BaseWallet>;
21
22
  supportedNetworks: {
22
23
  chainId: number;
23
24
  rpcUrl?: string;
@@ -54,6 +54,7 @@ const connect = (client) => _tslib.__awaiter(void 0, void 0, void 0, function* (
54
54
  ethereum: ethereum
55
55
  ? {
56
56
  currentNetworkId: ethereum.currentNetworkId,
57
+ eoaWallets: ethereum.eoaWallets,
57
58
  supportedNetworks: ethereum.supportedNetworks,
58
59
  }
59
60
  : null,
@@ -50,6 +50,7 @@ const connect = (client) => __awaiter(void 0, void 0, void 0, function* () {
50
50
  ethereum: ethereum
51
51
  ? {
52
52
  currentNetworkId: ethereum.currentNetworkId,
53
+ eoaWallets: ethereum.eoaWallets,
53
54
  supportedNetworks: ethereum.supportedNetworks,
54
55
  }
55
56
  : null,
@@ -0,0 +1,30 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ require('eventemitter3');
7
+ require('@dynamic-labs/logger');
8
+ require('@dynamic-labs/store');
9
+ require('../../errors/DisconnectError.cjs');
10
+ require('../../../../_virtual/_tslib.cjs');
11
+ require('@dynamic-labs/utils');
12
+ require('../../constants/logger.cjs');
13
+ var getCore = require('../../client/getCore/getCore.cjs');
14
+ var getClient = require('../../client/getClient/getClient.cjs');
15
+
16
+ /**
17
+ * Gets the EOA wallet for a smart wallet.
18
+ *
19
+ * @param smartWallet - The smart wallet.
20
+ *
21
+ * @returns The EOA wallet for the smart wallet.
22
+ */
23
+ const getEoaWalletForSmartWallet = ({ smartWallet, }) => {
24
+ const client = getClient.getClient(smartWallet);
25
+ const core = getCore.getCore(client);
26
+ const { ethereum } = core.store.getState();
27
+ return ethereum === null || ethereum === void 0 ? void 0 : ethereum.eoaWallets[smartWallet.address];
28
+ };
29
+
30
+ exports.getEoaWalletForSmartWallet = getEoaWalletForSmartWallet;
@@ -0,0 +1,11 @@
1
+ import { BaseWallet } from '@dynamic-labs/types';
2
+ /**
3
+ * Gets the EOA wallet for a smart wallet.
4
+ *
5
+ * @param smartWallet - The smart wallet.
6
+ *
7
+ * @returns The EOA wallet for the smart wallet.
8
+ */
9
+ export declare const getEoaWalletForSmartWallet: ({ smartWallet, }: {
10
+ smartWallet: BaseWallet;
11
+ }) => BaseWallet | undefined;
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+ import 'eventemitter3';
3
+ import '@dynamic-labs/logger';
4
+ import '@dynamic-labs/store';
5
+ import '../../errors/DisconnectError.js';
6
+ import '../../../../_virtual/_tslib.js';
7
+ import '@dynamic-labs/utils';
8
+ import '../../constants/logger.js';
9
+ import { getCore } from '../../client/getCore/getCore.js';
10
+ import { getClient } from '../../client/getClient/getClient.js';
11
+
12
+ /**
13
+ * Gets the EOA wallet for a smart wallet.
14
+ *
15
+ * @param smartWallet - The smart wallet.
16
+ *
17
+ * @returns The EOA wallet for the smart wallet.
18
+ */
19
+ const getEoaWalletForSmartWallet = ({ smartWallet, }) => {
20
+ const client = getClient(smartWallet);
21
+ const core = getCore(client);
22
+ const { ethereum } = core.store.getState();
23
+ return ethereum === null || ethereum === void 0 ? void 0 : ethereum.eoaWallets[smartWallet.address];
24
+ };
25
+
26
+ export { getEoaWalletForSmartWallet };
@@ -0,0 +1 @@
1
+ export { getEoaWalletForSmartWallet } from './getEoaWalletForSmartWallet';
@@ -0,0 +1 @@
1
+ export { sendTransaction } from './sendTransaction';
@@ -0,0 +1,48 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../_virtual/_tslib.cjs');
7
+ require('eventemitter3');
8
+ require('@dynamic-labs/logger');
9
+ require('@dynamic-labs/store');
10
+ var getActiveConnection = require('../getActiveConnection/getActiveConnection.cjs');
11
+ require('../../errors/DisconnectError.cjs');
12
+ require('@dynamic-labs/utils');
13
+ require('../../constants/logger.cjs');
14
+ var getCore = require('../../client/getCore/getCore.cjs');
15
+ var getClient = require('../../client/getClient/getClient.cjs');
16
+ var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
17
+ var getCurrentEthereumNetworkId = require('../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs');
18
+
19
+ /**
20
+ * Sends a transaction to the Ethereum network
21
+ * @param {BaseWallet} wallet - The wallet to send the transaction from
22
+ * @param {SendTransactionParams} params - The parameters for the transaction
23
+ * @returns {Promise<string>} The transaction hash
24
+ */
25
+ const sendTransaction = (wallet, params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
26
+ if (!isEthereumWallet.isEthereumWallet(wallet)) {
27
+ throw new Error('Wallet is not an Ethereum wallet');
28
+ }
29
+ const client = getClient.getClient(wallet);
30
+ const chainId = getCurrentEthereumNetworkId.getCurrentEthereumNetworkId(client);
31
+ if (!chainId) {
32
+ throw new Error('No chain id found');
33
+ }
34
+ const requestParams = Object.assign(Object.assign({}, params), { from: wallet.address });
35
+ const { data } = yield getCore.getCore(client).request({
36
+ args: {
37
+ chainId,
38
+ method: 'eth_sendTransaction',
39
+ params: [requestParams],
40
+ sessionId: params.sessionId,
41
+ },
42
+ connection: getActiveConnection.getActiveConnection(client),
43
+ name: 'eth-request',
44
+ });
45
+ return data;
46
+ });
47
+
48
+ exports.sendTransaction = sendTransaction;
@@ -0,0 +1,12 @@
1
+ import { SendTransactionParameters } from 'viem';
2
+ import { BaseWallet, ConvertBigIntToString } from '@dynamic-labs/types';
3
+ export type SendTransactionParams = ConvertBigIntToString<Omit<SendTransactionParameters, 'account' | 'chain'>> & {
4
+ sessionId?: string;
5
+ };
6
+ /**
7
+ * Sends a transaction to the Ethereum network
8
+ * @param {BaseWallet} wallet - The wallet to send the transaction from
9
+ * @param {SendTransactionParams} params - The parameters for the transaction
10
+ * @returns {Promise<string>} The transaction hash
11
+ */
12
+ export declare const sendTransaction: (wallet: BaseWallet, params: SendTransactionParams) => Promise<string>;
@@ -0,0 +1,44 @@
1
+ 'use client'
2
+ import { __awaiter } from '../../../../_virtual/_tslib.js';
3
+ import 'eventemitter3';
4
+ import '@dynamic-labs/logger';
5
+ import '@dynamic-labs/store';
6
+ import { getActiveConnection } from '../getActiveConnection/getActiveConnection.js';
7
+ import '../../errors/DisconnectError.js';
8
+ import '@dynamic-labs/utils';
9
+ import '../../constants/logger.js';
10
+ import { getCore } from '../../client/getCore/getCore.js';
11
+ import { getClient } from '../../client/getClient/getClient.js';
12
+ import { isEthereumWallet } from '../isEthereumWallet/isEthereumWallet.js';
13
+ import { getCurrentEthereumNetworkId } from '../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.js';
14
+
15
+ /**
16
+ * Sends a transaction to the Ethereum network
17
+ * @param {BaseWallet} wallet - The wallet to send the transaction from
18
+ * @param {SendTransactionParams} params - The parameters for the transaction
19
+ * @returns {Promise<string>} The transaction hash
20
+ */
21
+ const sendTransaction = (wallet, params) => __awaiter(void 0, void 0, void 0, function* () {
22
+ if (!isEthereumWallet(wallet)) {
23
+ throw new Error('Wallet is not an Ethereum wallet');
24
+ }
25
+ const client = getClient(wallet);
26
+ const chainId = getCurrentEthereumNetworkId(client);
27
+ if (!chainId) {
28
+ throw new Error('No chain id found');
29
+ }
30
+ const requestParams = Object.assign(Object.assign({}, params), { from: wallet.address });
31
+ const { data } = yield getCore(client).request({
32
+ args: {
33
+ chainId,
34
+ method: 'eth_sendTransaction',
35
+ params: [requestParams],
36
+ sessionId: params.sessionId,
37
+ },
38
+ connection: getActiveConnection(client),
39
+ name: 'eth-request',
40
+ });
41
+ return data;
42
+ });
43
+
44
+ export { sendTransaction };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Decodes a base64-encoded string to a UTF-8 string.
3
+ *
4
+ * @param encodedPayload - The base64-encoded string to decode
5
+ * @returns A promise that resolves to the decoded UTF-8 string
6
+ */
7
+ export declare const decodeFromBase64: (encodedPayload: string) => Promise<string>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Encodes a string to base64.
3
+ *
4
+ * @param payload - The string to encode
5
+ * @returns A promise that resolves to the base64-encoded string
6
+ */
7
+ export declare const encodeToBase64: (payload: string) => Promise<string>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates a 6-character hexadecimal nonce for encrypted communications.
3
+ *
4
+ * @returns A 6-character hexadecimal string to use as a nonce
5
+ */
6
+ export declare const generateNonce: () => string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Generates a random hexadecimal string of a specified length.
3
+ *
4
+ * @param length - The length of the hexadecimal string to generate (default: 6)
5
+ * @returns A random hexadecimal string
6
+ */
7
+ export declare const generateRandomHex: (length?: number) => string;
@@ -0,0 +1,15 @@
1
+ import { WalletRequest, WalletRequestAction } from '../../types';
2
+ /**
3
+ * Adds a new action to an existing wallet request.
4
+ *
5
+ * @param request - The wallet request to add the action to
6
+ * @param action - The action to add, containing name and arguments
7
+ * @returns The created WalletRequestAction with auto-generated ID
8
+ */
9
+ export declare const addActionToWalletRequest: <T extends {
10
+ name: string;
11
+ args: Record<string, unknown>;
12
+ } = {
13
+ name: never;
14
+ args: never;
15
+ }>(request: WalletRequest, action: T) => WalletRequestAction;
@@ -0,0 +1,7 @@
1
+ import { WalletRequest } from '../../types';
2
+ /**
3
+ * Creates a new wallet request with an empty body and a generated request ID.
4
+ *
5
+ * @returns A new WalletRequest object with empty body and auto-generated request ID
6
+ */
7
+ export declare const createWalletRequest: () => WalletRequest;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletRequest, WalletRequest } from '../../types';
2
+ /**
3
+ * Decodes a base64-encoded wallet request string back to a request object.
4
+ *
5
+ * @param encodedRequest - The base64-encoded request string to decode
6
+ * @returns A promise that resolves to the decoded wallet request (encrypted or unencrypted)
7
+ */
8
+ export declare const decodeWalletRequest: (encodedRequest: string) => Promise<WalletRequest | EncryptedWalletRequest>;
@@ -0,0 +1,10 @@
1
+ import { EncryptedWalletRequest, WalletRequest } from '../../types';
2
+ /**
3
+ * Decrypts an encrypted wallet request using AES-GCM decryption with a shared secret and nonce.
4
+ *
5
+ * @param encryptedRequest - The encrypted wallet request to decrypt
6
+ * @param sharedSecret - The shared secret key for decryption
7
+ * @param nonce - The nonce value used during encryption
8
+ * @returns A promise that resolves to the decrypted wallet request
9
+ */
10
+ export declare const decryptWalletRequest: (encryptedRequest: EncryptedWalletRequest, sharedSecret: string, nonce: string) => Promise<WalletRequest>;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletRequest, WalletRequest } from '../../types';
2
+ /**
3
+ * Encodes a wallet request (encrypted or unencrypted) to a base64 string for transmission.
4
+ *
5
+ * @param request - The wallet request to encode
6
+ * @returns A promise that resolves to the base64-encoded request string
7
+ */
8
+ export declare const encodeWalletRequest: (request: WalletRequest | EncryptedWalletRequest) => Promise<string>;
@@ -0,0 +1,10 @@
1
+ import { EncryptedWalletRequest, WalletRequest } from '../../types';
2
+ /**
3
+ * Encrypts a wallet request using AES-GCM encryption with a shared secret and nonce.
4
+ *
5
+ * @param request - The wallet request to encrypt
6
+ * @param sharedSecret - The shared secret key for encryption
7
+ * @param nonce - The nonce value to use for encryption
8
+ * @returns A promise that resolves to the encrypted wallet request
9
+ */
10
+ export declare const encryptWalletRequest: (request: WalletRequest, sharedSecret: string, nonce: string) => Promise<EncryptedWalletRequest>;
@@ -0,0 +1,9 @@
1
+ import { WalletRequest, WalletRequestAction } from '../../types';
2
+ /**
3
+ * Retrieves the first action from a wallet request.
4
+ *
5
+ * @param request - The wallet request to extract the action from
6
+ * @returns The first action found in the request
7
+ * @throws {Error} When no action is found in the request
8
+ */
9
+ export declare const getActionFromWalletRequest: (request: WalletRequest) => WalletRequestAction;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletRequest, WalletRequest } from '../../types';
2
+ /**
3
+ * Type guard to determine if a wallet request is encrypted.
4
+ *
5
+ * @param request - The wallet request to check
6
+ * @returns True if the request is encrypted, false otherwise
7
+ */
8
+ export declare const isEncryptedWalletRequest: (request: WalletRequest | EncryptedWalletRequest) => request is EncryptedWalletRequest;
@@ -0,0 +1,9 @@
1
+ import { WalletResponse, WalletRequestAction } from '../../types';
2
+ /**
3
+ * Adds an action-specific error to a wallet response.
4
+ *
5
+ * @param response - The wallet response to add the error to
6
+ * @param action - The action that failed
7
+ * @param error - The error that occurred during action execution
8
+ */
9
+ export declare const addActionErrorToWalletResponse: (response: WalletResponse, action: WalletRequestAction, error: Error) => void;
@@ -0,0 +1,9 @@
1
+ import { WalletRequestAction, WalletResponse } from '../../types';
2
+ /**
3
+ * Adds a successful action result to a wallet response.
4
+ *
5
+ * @param response - The wallet response to add the result to
6
+ * @param requestAction - The action that was executed successfully
7
+ * @param result - The result data from executing the action
8
+ */
9
+ export declare const addActionResultToWalletResponse: (response: WalletResponse, requestAction: WalletRequestAction, result: Record<string, unknown>) => void;
@@ -0,0 +1,8 @@
1
+ import { WalletResponse } from '../../types';
2
+ /**
3
+ * Adds a general error to a wallet response.
4
+ *
5
+ * @param response - The wallet response to add the error to
6
+ * @param error - The general error that occurred
7
+ */
8
+ export declare const addErrorToWalletResponse: (response: WalletResponse, error: Error) => void;
@@ -0,0 +1,8 @@
1
+ import { WalletResponse } from '../../types';
2
+ /**
3
+ * Adds a next nonce to a wallet response for encrypted communication flows.
4
+ *
5
+ * @param response - The wallet response to add the next nonce to
6
+ * @param nonce - The nonce value to include for the next encrypted exchange
7
+ */
8
+ export declare const addNextNonceToWalletResponse: (response: WalletResponse, nonce: string) => void;
@@ -0,0 +1,8 @@
1
+ import { WalletRequest, WalletResponse } from '../../types';
2
+ /**
3
+ * Creates a new wallet response, optionally linked to a request.
4
+ *
5
+ * @param request - Optional wallet request to link this response to
6
+ * @returns A new WalletResponse object with empty body and optional request ID
7
+ */
8
+ export declare const createWalletResponse: (request?: WalletRequest) => WalletResponse;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletResponse, WalletResponse } from '../../types';
2
+ /**
3
+ * Decodes a base64-encoded wallet response string back to a response object.
4
+ *
5
+ * @param response - The base64-encoded response string to decode
6
+ * @returns A promise that resolves to the decoded wallet response (encrypted or unencrypted)
7
+ */
8
+ export declare const decodeWalletResponse: (response: string) => Promise<WalletResponse | EncryptedWalletResponse>;
@@ -0,0 +1,10 @@
1
+ import { EncryptedWalletResponse, WalletResponse } from '../../types';
2
+ /**
3
+ * Decrypts an encrypted wallet response using AES-GCM decryption with a shared secret and nonce.
4
+ *
5
+ * @param encryptedResponse - The encrypted wallet response to decrypt
6
+ * @param sharedSecret - The shared secret key for decryption
7
+ * @param nonce - The nonce value used during encryption
8
+ * @returns A promise that resolves to the decrypted wallet response
9
+ */
10
+ export declare const decryptWalletResponse: (encryptedResponse: EncryptedWalletResponse, sharedSecret: string, nonce: string) => Promise<WalletResponse>;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletResponse, WalletResponse } from '../../types';
2
+ /**
3
+ * Encodes a wallet response (encrypted or unencrypted) to a base64 string for transmission.
4
+ *
5
+ * @param response - The wallet response to encode
6
+ * @returns A promise that resolves to the base64-encoded response string
7
+ */
8
+ export declare const encodeWalletResponse: (response: WalletResponse | EncryptedWalletResponse) => Promise<string>;
@@ -0,0 +1,10 @@
1
+ import { EncryptedWalletResponse, WalletResponse } from '../../types';
2
+ /**
3
+ * Encrypts a wallet response using AES-GCM encryption with a shared secret and nonce.
4
+ *
5
+ * @param response - The wallet response to encrypt
6
+ * @param sharedSecret - The shared secret key for encryption
7
+ * @param nonce - The nonce value to use for encryption
8
+ * @returns A promise that resolves to the encrypted wallet response
9
+ */
10
+ export declare const encryptWalletResponse: (response: WalletResponse, sharedSecret: string, nonce: string) => Promise<EncryptedWalletResponse>;
@@ -0,0 +1,9 @@
1
+ import { WalletResponse, WalletRequestAction } from '../../types';
2
+ /**
3
+ * Retrieves an action-specific error from a wallet response.
4
+ *
5
+ * @param response - The wallet response to search for the action error
6
+ * @param action - The action to find the error for
7
+ * @returns The action error if found, null otherwise
8
+ */
9
+ export declare const getActionErrorFromWalletResponse: (response: WalletResponse, action: WalletRequestAction) => Error | null;
@@ -0,0 +1,10 @@
1
+ import { WalletRequestAction, WalletResponse } from '../../types';
2
+ /**
3
+ * Retrieves the result data for a specific action from a wallet response.
4
+ *
5
+ * @param response - The wallet response to search for the action result
6
+ * @param action - The action to find the result for
7
+ * @returns The action result data
8
+ * @throws {Error} When no action result is found for the given action
9
+ */
10
+ export declare const getActionResultFromWalletResponse: <T extends Record<string, unknown> = never>(response: WalletResponse, action: WalletRequestAction) => T;
@@ -0,0 +1,8 @@
1
+ import { WalletResponse } from '../../types';
2
+ /**
3
+ * Retrieves a general error from a wallet response.
4
+ *
5
+ * @param response - The wallet response to search for the general error
6
+ * @returns The general error if found, null otherwise
7
+ */
8
+ export declare const getErrorFromWalletResponse: (response: WalletResponse) => Error | null;
@@ -0,0 +1,8 @@
1
+ import { WalletResponse } from '../../types';
2
+ /**
3
+ * Extracts the next nonce from a wallet response for encrypted communication flows.
4
+ *
5
+ * @param response - The wallet response to extract the next nonce from
6
+ * @returns The next nonce string if found, null otherwise
7
+ */
8
+ export declare const getNextNonceFromWalletResponse: (response: WalletResponse) => string | null;
@@ -0,0 +1,8 @@
1
+ import { EncryptedWalletResponse, WalletResponse } from '../../types';
2
+ /**
3
+ * Type guard to determine if a wallet response is encrypted.
4
+ *
5
+ * @param response - The wallet response to check
6
+ * @returns True if the response is encrypted, false otherwise
7
+ */
8
+ export declare const isEncryptedWalletResponse: (response: WalletResponse | EncryptedWalletResponse) => response is EncryptedWalletResponse;
@@ -0,0 +1,24 @@
1
+ export type { WalletRequest, WalletResponse, EncryptedWalletRequest, EncryptedWalletResponse, } from './types';
2
+ export { createWalletRequest } from './functions/walletRequest/createWalletRequest';
3
+ export { getActionResultFromWalletResponse } from './functions/walletResponse/getActionResultFromWalletResponse';
4
+ export { addActionResultToWalletResponse } from './functions/walletResponse/addActionResultToWalletResponse';
5
+ export { addActionToWalletRequest } from './functions/walletRequest/addActionToWalletRequest';
6
+ export { createWalletResponse } from './functions/walletResponse/createWalletResponse';
7
+ export { encodeWalletRequest } from './functions/walletRequest/encodeWalletRequest';
8
+ export { decodeWalletRequest } from './functions/walletRequest/decodeWalletRequest';
9
+ export { encodeWalletResponse } from './functions/walletResponse/encodeWalletResponse';
10
+ export { decodeWalletResponse } from './functions/walletResponse/decodeWalletResponse';
11
+ export { decryptWalletRequest } from './functions/walletRequest/decryptWalletRequest';
12
+ export { decryptWalletResponse } from './functions/walletResponse/decryptWalletResponse';
13
+ export { encryptWalletRequest } from './functions/walletRequest/encryptWalletRequest';
14
+ export { encryptWalletResponse } from './functions/walletResponse/encryptWalletResponse';
15
+ export { isEncryptedWalletRequest } from './functions/walletRequest/isEncryptedWalletRequest';
16
+ export { isEncryptedWalletResponse } from './functions/walletResponse/isEncryptedWalletResponse';
17
+ export { getActionFromWalletRequest } from './functions/walletRequest/getActionFromWalletRequest';
18
+ export { generateNonce } from './functions/generateNonce';
19
+ export { addNextNonceToWalletResponse } from './functions/walletResponse/addNextNonceToWalletResponse';
20
+ export { getNextNonceFromWalletResponse } from './functions/walletResponse/getNextNonceFromWalletResponse';
21
+ export { addActionErrorToWalletResponse } from './functions/walletResponse/addActionErrorToWalletResponse';
22
+ export { addErrorToWalletResponse } from './functions/walletResponse/addErrorToWalletResponse';
23
+ export { getActionErrorFromWalletResponse } from './functions/walletResponse/getActionErrorFromWalletResponse';
24
+ export { getErrorFromWalletResponse } from './functions/walletResponse/getErrorFromWalletResponse';
@@ -0,0 +1,48 @@
1
+ import { SerializedError } from '@dynamic-labs/message-transport';
2
+ export type WalletRequestAction = {
3
+ id: string;
4
+ type: 'action';
5
+ name: string;
6
+ args: Record<string, unknown>;
7
+ };
8
+ export type WalletRequestBody = WalletRequestAction[];
9
+ export type WalletRequest = {
10
+ version: string;
11
+ requestId: string;
12
+ body: WalletRequestBody;
13
+ };
14
+ export type EncryptedWalletRequest = {
15
+ iv: string;
16
+ encryptedMessage: string;
17
+ };
18
+ export type WalletResponseBodyActionResult = {
19
+ type: 'action-result';
20
+ actionId: string;
21
+ data: Record<string, unknown>;
22
+ };
23
+ export type WalletResponseBodyNextNonce = {
24
+ type: 'next-nonce';
25
+ nonce: string;
26
+ };
27
+ export type WalletResponseBodyEvent = {
28
+ type: 'event';
29
+ data: Record<string, unknown>;
30
+ };
31
+ export type WalletResponseBodyActionError = {
32
+ type: 'action-error';
33
+ actionId: string;
34
+ error: SerializedError;
35
+ };
36
+ export type WalletResponseBodyError = {
37
+ type: 'error';
38
+ error: SerializedError;
39
+ };
40
+ export type WalletResponseBody = (WalletResponseBodyActionResult | WalletResponseBodyNextNonce | WalletResponseBodyEvent | WalletResponseBodyActionError | WalletResponseBodyError)[];
41
+ export type WalletResponse = {
42
+ requestId?: string;
43
+ body: WalletResponseBody;
44
+ };
45
+ export type EncryptedWalletResponse = {
46
+ iv: string;
47
+ encryptedMessage: string;
48
+ };