@meshconnect/web-link-sdk 2.1.0-rc.0 → 2.1.0-rc.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/utils/style.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { LinkStyle } from './types';
2
- export declare function getLinkStyle(url: string): LinkStyle | undefined;
3
- export declare function getNumber(def: number, value?: number): number;
package/utils/style.js DELETED
@@ -1,13 +0,0 @@
1
- export function getLinkStyle(url) {
2
- try {
3
- var params = new URLSearchParams(new URL(url).search);
4
- var style = params.get('link_style');
5
- return style && JSON.parse(window.atob(style));
6
- }
7
- catch (e) {
8
- return undefined;
9
- }
10
- }
11
- export function getNumber(def, value) {
12
- return value !== undefined ? value : def;
13
- }
package/utils/types.d.ts DELETED
@@ -1,134 +0,0 @@
1
- import type { BrokerType } from '@meshconnect/node-api';
2
- import { SessionSymmary, LinkEventType } from './event-types';
3
- import { Hash, Chain } from 'viem';
4
- export type EventType = 'brokerageAccountAccessToken' | 'delayedAuthentication' | 'loaded' | 'oauthLinkOpen' | 'transferFinished';
5
- export interface Link {
6
- /**
7
- * A function that takes linkToken parameter from `/api/v1/linktoken` endpoint as an input, and opens the Link UI popup
8
- */
9
- openLink: (linkToken: string) => Promise<void>;
10
- /**
11
- * A function to close Link UI popup
12
- */
13
- closeLink: () => void;
14
- }
15
- export interface AccountToken {
16
- account: Account;
17
- accessToken: string;
18
- refreshToken?: string;
19
- }
20
- export interface Account {
21
- accountId: string;
22
- accountName: string;
23
- fund?: number;
24
- cash?: number;
25
- isReconnected?: boolean;
26
- }
27
- export interface BrandInfo {
28
- brokerLogo: string;
29
- brokerPrimaryColor?: string;
30
- }
31
- export interface LinkPayload {
32
- accessToken?: AccessTokenPayload;
33
- delayedAuth?: DelayedAuthPayload;
34
- }
35
- export interface AccessTokenPayload {
36
- accountTokens: AccountToken[];
37
- brokerBrandInfo: BrandInfo;
38
- expiresInSeconds?: number;
39
- refreshTokenExpiresInSeconds?: number;
40
- brokerType: BrokerType;
41
- brokerName: string;
42
- }
43
- export interface DelayedAuthPayload {
44
- refreshTokenExpiresInSeconds?: number;
45
- brokerType: BrokerType;
46
- refreshToken: string;
47
- brokerName: string;
48
- brokerBrandInfo: BrandInfo;
49
- }
50
- export interface TransferFinishedPayload {
51
- status: 'success';
52
- txId: string;
53
- fromAddress: string;
54
- toAddress: string;
55
- symbol: string;
56
- amount: number;
57
- networkId: string;
58
- }
59
- export interface IntegrationAccessToken {
60
- accountId: string;
61
- accountName: string;
62
- accessToken: string;
63
- brokerType: BrokerType;
64
- brokerName: string;
65
- }
66
- export interface WagmiInjectedConnectorData {
67
- id: string;
68
- name: string;
69
- type: string;
70
- icon?: string;
71
- uid: string;
72
- }
73
- export interface ConnectReturnTypeAndTxHash {
74
- accounts: string[];
75
- chainId: number;
76
- txSigned: Hash;
77
- }
78
- export interface IncomingConfig {
79
- chains: Chain[];
80
- transports: Record<number, string | string[]>;
81
- }
82
- export interface AbiItem {
83
- name: string;
84
- type: string;
85
- inputs: {
86
- name: string;
87
- type: string;
88
- }[];
89
- outputs?: {
90
- name: string;
91
- type: string;
92
- }[];
93
- stateMutability?: string;
94
- }
95
- export type Abi = AbiItem[];
96
- export interface LinkOptions {
97
- /**
98
- * Client ID that can be obtained at https://dashboard.meshconnect.com/company/keys
99
- */
100
- clientId: string;
101
- /**
102
- * A callback function that is called when an integration is successfully connected.
103
- * It receives a payload of type `LinkPayload`.
104
- */
105
- onIntegrationConnected: (payload: LinkPayload) => void;
106
- /**
107
- * (Optional) A callback function that is called when the Front iframe is closed.
108
- */
109
- onExit?: (error?: string, summary?: SessionSymmary) => void;
110
- /**
111
- * (Optional) A callback function that is called when a transfer is finished.
112
- * It receives a payload of type `TransferFinishedPayload`.
113
- */
114
- onTransferFinished?: (payload: TransferFinishedPayload) => void;
115
- /**
116
- * (Optional) A callback function that is called when various events occur within the Front iframe.
117
- * It receives an object with type `LinkEventTypeKeys` indicating the event, and an optional 'payload' containing additional data.
118
- */
119
- onEvent?: (event: LinkEventType) => void;
120
- /**
121
- * (Optional) An array of integration access tokens.
122
- * These access tokens are used to initialize crypto transfers flow at 'Select asset step'
123
- */
124
- accessTokens?: IntegrationAccessToken[];
125
- /**
126
- * (Optional) An array of integration access tokens.
127
- * Can be used to initialize the crypto transfers flow as an alternative to the target addresses.
128
- */
129
- transferDestinationTokens?: IntegrationAccessToken[];
130
- }
131
- export interface LinkStyle {
132
- ir: number;
133
- io: number;
134
- }
package/utils/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const sdkVersion = "2.1.0-rc.0";
package/utils/version.js DELETED
@@ -1 +0,0 @@
1
- export var sdkVersion = '2.1.0-rc.0';
@@ -1,11 +0,0 @@
1
- import { type GetAccountReturnType, type Config, type GetBalanceReturnType } from '@wagmi/core';
2
- import { WagmiInjectedConnectorData, ConnectReturnTypeAndTxHash, Abi } from './types';
3
- import { Hash, Chain } from 'viem';
4
- export declare const getWagmiCoreInjectedData: () => Promise<WagmiInjectedConnectorData[] | Error>;
5
- export declare const connectToSpecificWallet: (walletName: string) => Promise<ConnectReturnTypeAndTxHash | Error>;
6
- export declare const signedMessage: (config: Config, accountInfo: GetAccountReturnType) => Promise<Hash | Error>;
7
- export declare const walletBalance: (account: string, chainId: number) => Promise<GetBalanceReturnType | Error>;
8
- export declare const switchChainFromSDK: (chainId: number) => Promise<Chain | Error>;
9
- export declare const sendTransactionFromSDK: (toAddress: string, amount: number, decimalPlaces: number, chainId: number, account: string) => Promise<Hash | Error>;
10
- export declare const sendNonNativeTransactionFromSDK: (address: string, abi: Abi, functionName: string, args: any[], value?: bigint) => Promise<Hash | Error>;
11
- export declare const disconnectAllAccounts: () => Promise<void | Error>;
@@ -1,414 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
38
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
39
- if (ar || !(i in from)) {
40
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
41
- ar[i] = from[i];
42
- }
43
- }
44
- return to.concat(ar || Array.prototype.slice.call(from));
45
- };
46
- import { getConnectors, connect, disconnect, getAccount, signMessage, getBalance, sendTransaction, switchChain, simulateContract, writeContract, createConfig, http, fallback, BaseError, ChainNotConfiguredError, ConnectorAccountNotFoundError, ConnectorAlreadyConnectedError, ConnectorNotConnectedError, ConnectorNotFoundError, ProviderNotFoundError, SwitchChainNotSupportedError } from '@wagmi/core';
47
- import { injected } from '@wagmi/connectors';
48
- import { parseUnits } from 'viem';
49
- var resolveConfigReady;
50
- var configReady = new Promise(function (resolve) {
51
- resolveConfigReady = resolve;
52
- });
53
- var setConfig = function (config) {
54
- try {
55
- var transports = {};
56
- for (var chainId in config.transports) {
57
- var urls = config.transports[chainId];
58
- if (Array.isArray(urls)) {
59
- // If the URL is an array, create a fallback transport with multiple transports
60
- transports[chainId] = fallback(urls.map(function (url) { return http(url); }));
61
- }
62
- else {
63
- // If the URL is a string, create a single HTTP transport
64
- transports[chainId] = http(urls);
65
- }
66
- }
67
- var chainsTuple = __spreadArray([], config.chains, true);
68
- var dynamicConfig = createConfig({
69
- chains: chainsTuple,
70
- multiInjectedProviderDiscovery: true,
71
- transports: transports,
72
- connectors: [injected()]
73
- });
74
- resolveConfigReady(dynamicConfig);
75
- }
76
- catch (error) {
77
- console.error('Error setting configuration:', error);
78
- }
79
- };
80
- window.addEventListener('message', function (event) {
81
- if (event.data.type === 'walletBrowserConfigInitialize') {
82
- try {
83
- var parsedConfig = JSON.parse(event.data.payload);
84
- setConfig(parsedConfig);
85
- }
86
- catch (error) {
87
- console.error('Error parsing configuration:', error);
88
- }
89
- }
90
- });
91
- var configPromise = configReady;
92
- export var getWagmiCoreInjectedData = function () { return __awaiter(void 0, void 0, void 0, function () {
93
- return __generator(this, function (_a) {
94
- return [2 /*return*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
95
- var config, connectors, mappedConnectors;
96
- return __generator(this, function (_a) {
97
- switch (_a.label) {
98
- case 0: return [4 /*yield*/, configPromise];
99
- case 1:
100
- config = _a.sent();
101
- return [4 /*yield*/, getConnectors(config)];
102
- case 2:
103
- connectors = _a.sent();
104
- mappedConnectors = connectors.map(function (_a) {
105
- var id = _a.id, name = _a.name, type = _a.type, uid = _a.uid, icon = _a.icon;
106
- return ({
107
- id: id,
108
- name: name,
109
- type: type,
110
- uid: uid,
111
- icon: icon || undefined
112
- });
113
- });
114
- return [2 /*return*/, mappedConnectors];
115
- }
116
- });
117
- }); })];
118
- });
119
- }); };
120
- export var connectToSpecificWallet = function (walletName) { return __awaiter(void 0, void 0, void 0, function () {
121
- return __generator(this, function (_a) {
122
- return [2 /*return*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
123
- var config, connectors, selectedConnector, result, accountInfo, txSigned;
124
- return __generator(this, function (_a) {
125
- switch (_a.label) {
126
- case 0: return [4 /*yield*/, configPromise];
127
- case 1:
128
- config = _a.sent();
129
- connectors = getConnectors(config);
130
- selectedConnector = connectors.find(function (connector) {
131
- return connector.name.toLowerCase() === walletName.toLowerCase();
132
- });
133
- if (!selectedConnector) {
134
- throw new Error("No connector found for wallet: ".concat(walletName));
135
- }
136
- return [4 /*yield*/, disconnectCurrentAccount(config, selectedConnector)];
137
- case 2:
138
- _a.sent();
139
- return [4 /*yield*/, connect(config, { connector: selectedConnector })];
140
- case 3:
141
- result = _a.sent();
142
- return [4 /*yield*/, getAccount(config)];
143
- case 4:
144
- accountInfo = _a.sent();
145
- return [4 /*yield*/, signedMessage(config, accountInfo)];
146
- case 5:
147
- txSigned = _a.sent();
148
- return [2 /*return*/, {
149
- accounts: __spreadArray([], result.accounts, true),
150
- chainId: result.chainId,
151
- txSigned: txSigned
152
- }];
153
- }
154
- });
155
- }); })];
156
- });
157
- }); };
158
- export var signedMessage = function (config, accountInfo) { return __awaiter(void 0, void 0, void 0, function () {
159
- return __generator(this, function (_a) {
160
- if (!accountInfo.address) {
161
- return [2 /*return*/, new Error('Address not found')];
162
- }
163
- return [2 /*return*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
164
- var signedMessage;
165
- return __generator(this, function (_a) {
166
- switch (_a.label) {
167
- case 0: return [4 /*yield*/, signMessage(config, {
168
- account: accountInfo.address,
169
- message: 'Sign to verify ownership of wallet'
170
- })];
171
- case 1:
172
- signedMessage = _a.sent();
173
- return [2 /*return*/, signedMessage];
174
- }
175
- });
176
- }); })];
177
- });
178
- }); };
179
- export var walletBalance = function (account, chainId) { return __awaiter(void 0, void 0, void 0, function () {
180
- return __generator(this, function (_a) {
181
- return [2 /*return*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
182
- var config, balance;
183
- return __generator(this, function (_a) {
184
- switch (_a.label) {
185
- case 0: return [4 /*yield*/, configPromise];
186
- case 1:
187
- config = _a.sent();
188
- return [4 /*yield*/, getBalance(config, {
189
- address: account,
190
- chainId: chainId
191
- })];
192
- case 2:
193
- balance = _a.sent();
194
- return [2 /*return*/, balance];
195
- }
196
- });
197
- }); })];
198
- });
199
- }); };
200
- export var switchChainFromSDK = function (chainId) { return __awaiter(void 0, void 0, void 0, function () {
201
- return __generator(this, function (_a) {
202
- switch (_a.label) {
203
- case 0: return [4 /*yield*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
204
- var config, result;
205
- return __generator(this, function (_a) {
206
- switch (_a.label) {
207
- case 0: return [4 /*yield*/, configPromise];
208
- case 1:
209
- config = _a.sent();
210
- return [4 /*yield*/, switchChain(config, { chainId: chainId })];
211
- case 2:
212
- result = _a.sent();
213
- return [2 /*return*/, result];
214
- }
215
- });
216
- }); })];
217
- case 1: return [2 /*return*/, _a.sent()];
218
- }
219
- });
220
- }); };
221
- export var sendTransactionFromSDK = function (toAddress, amount, decimalPlaces, chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
222
- return __generator(this, function (_a) {
223
- switch (_a.label) {
224
- case 0: return [4 /*yield*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
225
- var config, result;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0: return [4 /*yield*/, configPromise];
229
- case 1:
230
- config = _a.sent();
231
- return [4 /*yield*/, sendTransaction(config, {
232
- to: formatAddress(toAddress),
233
- value: parseUnits(amount.toFixed(decimalPlaces) || '0', decimalPlaces),
234
- chainId: chainId,
235
- account: formatAddress(account)
236
- })];
237
- case 2:
238
- result = _a.sent();
239
- return [2 /*return*/, result];
240
- }
241
- });
242
- }); })];
243
- case 1: return [2 /*return*/, _a.sent()];
244
- }
245
- });
246
- }); };
247
- var formatAddress = function (address) {
248
- return address.startsWith('0x') ? address : "0x".concat(address);
249
- };
250
- export var sendNonNativeTransactionFromSDK = function (address, abi, functionName, args, // eslint-disable-line @typescript-eslint/no-explicit-any
251
- value) { return __awaiter(void 0, void 0, void 0, function () {
252
- return __generator(this, function (_a) {
253
- switch (_a.label) {
254
- case 0: return [4 /*yield*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
255
- var config, connector, request, result;
256
- return __generator(this, function (_a) {
257
- switch (_a.label) {
258
- case 0: return [4 /*yield*/, configPromise];
259
- case 1:
260
- config = _a.sent();
261
- return [4 /*yield*/, getAccount(config)];
262
- case 2:
263
- connector = (_a.sent()).connector;
264
- return [4 /*yield*/, simulateContract(config, {
265
- address: formatAddress(address),
266
- abi: abi,
267
- functionName: functionName,
268
- args: args,
269
- value: value,
270
- connector: connector
271
- })];
272
- case 3:
273
- request = (_a.sent()).request;
274
- return [4 /*yield*/, writeContract(config, request)];
275
- case 4:
276
- result = _a.sent();
277
- return [2 /*return*/, result];
278
- }
279
- });
280
- }); })];
281
- case 1: return [2 /*return*/, _a.sent()];
282
- }
283
- });
284
- }); };
285
- var disconnectCurrentAccount = function (config, currentConnector) { return __awaiter(void 0, void 0, void 0, function () {
286
- return __generator(this, function (_a) {
287
- switch (_a.label) {
288
- case 0: return [4 /*yield*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
289
- return __generator(this, function (_a) {
290
- switch (_a.label) {
291
- case 0: return [4 /*yield*/, disconnect(config, { connector: currentConnector })];
292
- case 1:
293
- _a.sent();
294
- return [2 /*return*/];
295
- }
296
- });
297
- }); })];
298
- case 1: return [2 /*return*/, _a.sent()];
299
- }
300
- });
301
- }); };
302
- export var disconnectAllAccounts = function () { return __awaiter(void 0, void 0, void 0, function () {
303
- var config;
304
- return __generator(this, function (_a) {
305
- switch (_a.label) {
306
- case 0: return [4 /*yield*/, configPromise];
307
- case 1:
308
- config = _a.sent();
309
- return [2 /*return*/, withWagmiErrorHandling(function () { return __awaiter(void 0, void 0, void 0, function () {
310
- return __generator(this, function (_a) {
311
- switch (_a.label) {
312
- case 0: return [4 /*yield*/, disconnect(config)];
313
- case 1:
314
- _a.sent();
315
- return [2 /*return*/];
316
- }
317
- });
318
- }); })];
319
- }
320
- });
321
- }); };
322
- /**
323
- * Wrapper function for Wagmi Core functions that handles errors
324
- * @param fn - The function to wrap
325
- * @returns - The result of the function or an error
326
- */
327
- function withWagmiErrorHandling(fn) {
328
- return __awaiter(this, void 0, void 0, function () {
329
- var error_1;
330
- return __generator(this, function (_a) {
331
- switch (_a.label) {
332
- case 0:
333
- _a.trys.push([0, 2, , 3]);
334
- return [4 /*yield*/, fn()];
335
- case 1: return [2 /*return*/, _a.sent()];
336
- case 2:
337
- error_1 = _a.sent();
338
- if (error_1 instanceof BaseError) {
339
- return [2 /*return*/, handleWagmiError(error_1)];
340
- }
341
- else {
342
- if (error_1 instanceof Error) {
343
- throw new Error(error_1.message);
344
- }
345
- else {
346
- throw new Error('An unexpected error has occurred');
347
- }
348
- }
349
- return [3 /*break*/, 3];
350
- case 3: return [2 /*return*/];
351
- }
352
- });
353
- });
354
- }
355
- var handleWagmiError = function (error) {
356
- if (error instanceof ChainNotConfiguredError) {
357
- return handleChainNotConfiguredError(error);
358
- }
359
- else if (error instanceof ConnectorAccountNotFoundError) {
360
- return handleConnectorAccountNotFoundError(error);
361
- }
362
- else if (error instanceof ConnectorAlreadyConnectedError) {
363
- return handleConnectorAlreadyConnectedError(error);
364
- }
365
- else if (error instanceof ConnectorNotConnectedError) {
366
- return handleConnectorNotConnectedError(error);
367
- }
368
- else if (error instanceof ConnectorNotFoundError) {
369
- return handleConnectorNotFoundError(error);
370
- }
371
- else if (error instanceof ProviderNotFoundError) {
372
- return handleProviderNotFoundError(error);
373
- }
374
- else if (error instanceof SwitchChainNotSupportedError) {
375
- return handleSwitchChainNotSupportedError(error);
376
- }
377
- else if (error instanceof BaseError) {
378
- return handleBaseError(error);
379
- }
380
- else {
381
- // Handle unknown error types
382
- if (error instanceof Error) {
383
- throw new Error(error.message);
384
- }
385
- else {
386
- throw new Error('An unexpected error has occurred');
387
- }
388
- }
389
- };
390
- // All errors extend base error
391
- var handleBaseError = function (error) {
392
- throw new Error(error.message);
393
- };
394
- var handleChainNotConfiguredError = function (error) {
395
- throw new Error("Chain not configured: ".concat(error.message));
396
- };
397
- var handleConnectorAccountNotFoundError = function (error) {
398
- throw new Error("Connector account not found: ".concat(error.message));
399
- };
400
- var handleConnectorAlreadyConnectedError = function (error) {
401
- throw new Error("Connector already connected: ".concat(error.message));
402
- };
403
- var handleConnectorNotConnectedError = function (error) {
404
- throw new Error("Connector not connected: ".concat(error.message));
405
- };
406
- var handleConnectorNotFoundError = function (error) {
407
- throw new Error("Connector not found: ".concat(error.message));
408
- };
409
- var handleProviderNotFoundError = function (error) {
410
- throw new Error("Provider not found: ".concat(error.message));
411
- };
412
- var handleSwitchChainNotSupportedError = function (error) {
413
- throw new Error("Switch chain not supported: ".concat(error.message));
414
- };
@@ -1,59 +0,0 @@
1
- export type WalletBrowserEventType = WalletBrowserInjectedWalletSelected | WalletBrowserChainSwitchRequest | WalletBrowserTransferBalanceRequest | WalletBrowserNativeTransferRequest | WalletBrowserNonNativeTransferRequest | WalletBrowserNativeSmartDeposit | WalletBrowserNonNativeSmartDeposit | WalletBrowserDisconnect;
2
- declare const WALLET_BROWSER_EVENT_TYPE_KEYS: readonly ["walletBrowserInjectedWalletSelected", "walletBrowserChainSwitchRequest", "walletBrowserTransferBalanceRequest", "walletBrowserNativeTransferRequest", "walletBrowserNonNativeTransferRequest", "walletBrowserNativeSmartDeposit", "walletBrowserNonNativeSmartDeposit", "walletBrowserDisconnect"];
3
- export type WalletBrowserEventTypeKeys = (typeof WALLET_BROWSER_EVENT_TYPE_KEYS)[number];
4
- export declare function isWalletBrowserEventTypeKey(key: string): key is WalletBrowserEventTypeKeys;
5
- interface WalletBrowserEventBase {
6
- type: WalletBrowserEventTypeKeys;
7
- }
8
- export interface WalletBrowserInjectedWalletSelected extends WalletBrowserEventBase {
9
- type: 'walletBrowserInjectedWalletSelected';
10
- payload: {
11
- integrationName: string;
12
- };
13
- }
14
- export interface WalletBrowserChainSwitchRequest extends WalletBrowserEventBase {
15
- type: 'walletBrowserChainSwitchRequest';
16
- payload: {
17
- chainId: number;
18
- };
19
- }
20
- export interface WalletBrowserTransferBalanceRequest extends WalletBrowserEventBase {
21
- type: 'walletBrowserTransferBalanceRequest';
22
- payload: {
23
- account: string;
24
- chainId: number;
25
- };
26
- }
27
- export interface WalletBrowserNativeTransferRequest extends WalletBrowserEventBase {
28
- type: 'walletBrowserNativeTransferRequest';
29
- payload: {
30
- toAddress: string;
31
- amount: number;
32
- decimalPlaces: number;
33
- chainId: number;
34
- account: string;
35
- };
36
- }
37
- interface SmartContractPayload {
38
- address: string;
39
- abi: string;
40
- functionName: string;
41
- args: any[];
42
- value?: bigint;
43
- }
44
- export interface WalletBrowserNonNativeTransferRequest extends WalletBrowserEventBase {
45
- type: 'walletBrowserNonNativeTransferRequest';
46
- payload: SmartContractPayload;
47
- }
48
- export interface WalletBrowserNativeSmartDeposit extends WalletBrowserEventBase {
49
- type: 'walletBrowserNativeSmartDeposit';
50
- payload: SmartContractPayload;
51
- }
52
- export interface WalletBrowserNonNativeSmartDeposit extends WalletBrowserEventBase {
53
- type: 'walletBrowserNonNativeSmartDeposit';
54
- payload: SmartContractPayload;
55
- }
56
- export interface WalletBrowserDisconnect extends WalletBrowserEventBase {
57
- type: 'walletBrowserDisconnect';
58
- }
59
- export {};
@@ -1,13 +0,0 @@
1
- var WALLET_BROWSER_EVENT_TYPE_KEYS = [
2
- 'walletBrowserInjectedWalletSelected',
3
- 'walletBrowserChainSwitchRequest',
4
- 'walletBrowserTransferBalanceRequest',
5
- 'walletBrowserNativeTransferRequest',
6
- 'walletBrowserNonNativeTransferRequest',
7
- 'walletBrowserNativeSmartDeposit',
8
- 'walletBrowserNonNativeSmartDeposit',
9
- 'walletBrowserDisconnect'
10
- ];
11
- export function isWalletBrowserEventTypeKey(key) {
12
- return WALLET_BROWSER_EVENT_TYPE_KEYS.includes(key);
13
- }