@ultraos/wallet-sdk 0.0.3 → 0.0.5

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 (112) hide show
  1. package/package.json +4 -3
  2. package/src/index.d.ts +3 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/{index.ts → index.js} +1 -0
  5. package/src/index.js.map +1 -0
  6. package/src/lib/common/client-error.d.ts +8 -0
  7. package/src/lib/common/client-error.d.ts.map +1 -0
  8. package/src/lib/common/client-error.js +11 -0
  9. package/src/lib/common/client-error.js.map +1 -0
  10. package/src/lib/common/client-messenger.d.ts +10 -0
  11. package/src/lib/common/client-messenger.d.ts.map +1 -0
  12. package/src/lib/common/client-messenger.js +93 -0
  13. package/src/lib/common/client-messenger.js.map +1 -0
  14. package/src/lib/common/window-manager.d.ts +9 -0
  15. package/src/lib/common/window-manager.d.ts.map +1 -0
  16. package/src/lib/common/window-manager.js +25 -0
  17. package/src/lib/common/window-manager.js.map +1 -0
  18. package/src/lib/config/ultra-wallet-sdk.config.d.ts +16 -0
  19. package/src/lib/config/ultra-wallet-sdk.config.d.ts.map +1 -0
  20. package/src/lib/config/ultra-wallet-sdk.config.js +20 -0
  21. package/src/lib/config/ultra-wallet-sdk.config.js.map +1 -0
  22. package/src/lib/interfaces/blockchain-transaction.interface.d.ts +22 -0
  23. package/src/lib/interfaces/blockchain-transaction.interface.d.ts.map +1 -0
  24. package/src/lib/interfaces/blockchain-transaction.interface.js +2 -0
  25. package/src/lib/interfaces/blockchain-transaction.interface.js.map +1 -0
  26. package/src/lib/interfaces/connect-params.interface.d.ts +14 -0
  27. package/src/lib/interfaces/connect-params.interface.d.ts.map +1 -0
  28. package/src/lib/interfaces/connect-params.interface.js +2 -0
  29. package/src/lib/interfaces/connect-params.interface.js.map +1 -0
  30. package/src/lib/interfaces/error-enum.d.ts +11 -0
  31. package/src/lib/interfaces/error-enum.d.ts.map +1 -0
  32. package/src/lib/interfaces/error-enum.js +16 -0
  33. package/src/lib/interfaces/error-enum.js.map +1 -0
  34. package/src/lib/interfaces/index.d.ts +9 -0
  35. package/src/lib/interfaces/index.d.ts.map +1 -0
  36. package/src/lib/interfaces/{index.ts → index.js} +1 -0
  37. package/src/lib/interfaces/index.js.map +1 -0
  38. package/src/lib/interfaces/json-rpc-message.interface.d.ts +8 -0
  39. package/src/lib/interfaces/json-rpc-message.interface.d.ts.map +1 -0
  40. package/src/lib/interfaces/json-rpc-message.interface.js +2 -0
  41. package/src/lib/interfaces/json-rpc-message.interface.js.map +1 -0
  42. package/src/lib/interfaces/purchase-item.interface.d.ts +8 -0
  43. package/src/lib/interfaces/purchase-item.interface.d.ts.map +1 -0
  44. package/src/lib/interfaces/purchase-item.interface.js +9 -0
  45. package/src/lib/interfaces/purchase-item.interface.js.map +1 -0
  46. package/src/lib/interfaces/wallet-provider-response.interface.d.ts +150 -0
  47. package/src/lib/interfaces/wallet-provider-response.interface.d.ts.map +1 -0
  48. package/src/lib/interfaces/wallet-provider-response.interface.js +10 -0
  49. package/src/lib/interfaces/wallet-provider-response.interface.js.map +1 -0
  50. package/src/lib/interfaces/wallet-provider.interface.d.ts +41 -0
  51. package/src/lib/interfaces/wallet-provider.interface.d.ts.map +1 -0
  52. package/src/lib/interfaces/wallet-provider.interface.js +2 -0
  53. package/src/lib/interfaces/wallet-provider.interface.js.map +1 -0
  54. package/src/lib/interfaces/{wallet-sdk-options.interface.ts → wallet-sdk-options.interface.d.ts} +2 -1
  55. package/src/lib/interfaces/wallet-sdk-options.interface.d.ts.map +1 -0
  56. package/src/lib/interfaces/wallet-sdk-options.interface.js +2 -0
  57. package/src/lib/interfaces/wallet-sdk-options.interface.js.map +1 -0
  58. package/src/lib/providers/extension-provider/extension.provider.d.ts +17 -0
  59. package/src/lib/providers/extension-provider/extension.provider.d.ts.map +1 -0
  60. package/src/lib/providers/extension-provider/extension.provider.js +29 -0
  61. package/src/lib/providers/extension-provider/extension.provider.js.map +1 -0
  62. package/src/lib/providers/index.d.ts +3 -0
  63. package/src/lib/providers/index.d.ts.map +1 -0
  64. package/src/lib/providers/{index.ts → index.js} +1 -0
  65. package/src/lib/providers/index.js.map +1 -0
  66. package/src/lib/providers/web-provider/web.provider.d.ts +15 -0
  67. package/src/lib/providers/web-provider/web.provider.d.ts.map +1 -0
  68. package/src/lib/providers/web-provider/web.provider.js +36 -0
  69. package/src/lib/providers/web-provider/web.provider.js.map +1 -0
  70. package/src/lib/ultra-wallet-sdk.d.ts +25 -0
  71. package/src/lib/ultra-wallet-sdk.d.ts.map +1 -0
  72. package/src/lib/ultra-wallet-sdk.js +46 -0
  73. package/src/lib/ultra-wallet-sdk.js.map +1 -0
  74. package/src/lib/utils/chain-validator.d.ts +2 -0
  75. package/src/lib/utils/chain-validator.d.ts.map +1 -0
  76. package/src/lib/utils/chain-validator.js +6 -0
  77. package/src/lib/utils/chain-validator.js.map +1 -0
  78. package/src/lib/utils/detection.d.ts +2 -0
  79. package/src/lib/utils/detection.d.ts.map +1 -0
  80. package/src/lib/utils/detection.js +4 -0
  81. package/src/lib/utils/detection.js.map +1 -0
  82. package/LICENSE +0 -165
  83. package/README.md +0 -74
  84. package/eslint.config.js +0 -5
  85. package/jest.config.ts +0 -11
  86. package/karma.conf.js +0 -16
  87. package/project.json +0 -33
  88. package/src/lib/common/client-error.ts +0 -14
  89. package/src/lib/common/client-messenger.spec.ts +0 -118
  90. package/src/lib/common/client-messenger.ts +0 -109
  91. package/src/lib/common/window-manager.spec.ts +0 -65
  92. package/src/lib/common/window-manager.ts +0 -34
  93. package/src/lib/config/ultra-wallet-sdk.config.ts +0 -37
  94. package/src/lib/interfaces/blockchain-transaction.interface.ts +0 -21
  95. package/src/lib/interfaces/connect-params.interface.ts +0 -13
  96. package/src/lib/interfaces/error-enum.ts +0 -15
  97. package/src/lib/interfaces/json-rpc-message.interface.ts +0 -7
  98. package/src/lib/interfaces/purchase-item.interface.ts +0 -7
  99. package/src/lib/interfaces/wallet-provider-response.interface.ts +0 -157
  100. package/src/lib/interfaces/wallet-provider.interface.ts +0 -55
  101. package/src/lib/providers/extension-provider/extension.provider.spec.ts +0 -121
  102. package/src/lib/providers/extension-provider/extension.provider.ts +0 -55
  103. package/src/lib/providers/web-provider/web.provider.spec.ts +0 -76
  104. package/src/lib/providers/web-provider/web.provider.ts +0 -59
  105. package/src/lib/ultra-wallet-sdk.spec.ts +0 -90
  106. package/src/lib/ultra-wallet-sdk.ts +0 -67
  107. package/src/lib/utils/chain-validator.ts +0 -6
  108. package/src/lib/utils/detection.ts +0 -3
  109. package/tsconfig.json +0 -28
  110. package/tsconfig.lib.json +0 -12
  111. package/tsconfig.lib.prod.json +0 -9
  112. package/tsconfig.spec.json +0 -8
package/jest.config.ts DELETED
@@ -1,11 +0,0 @@
1
- /* eslint-disable */
2
- export default {
3
- displayName: 'wallet-sdk',
4
- preset: '../../jest.preset.js',
5
- testEnvironment: 'jsdom',
6
- transform: {
7
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8
- },
9
- moduleFileExtensions: ['ts', 'js', 'html'],
10
- coverageDirectory: '../../coverage/libs/wallet-sdk',
11
- };
package/karma.conf.js DELETED
@@ -1,16 +0,0 @@
1
- // Karma configuration file, see link for more information
2
- // https://karma-runner.github.io/6.4/config/configuration-file.html
3
-
4
- const { join } = require('path');
5
- const getBaseKarmaConfig = require('../../karma.conf');
6
-
7
- module.exports = function (config) {
8
- const baseConfig = getBaseKarmaConfig();
9
- config.set({
10
- ...baseConfig,
11
- coverageReporter: {
12
- ...baseConfig.coverageReporter,
13
- dir: join(__dirname, '../../coverage/libs/wallet-sdk'),
14
- },
15
- });
16
- };
package/project.json DELETED
@@ -1,33 +0,0 @@
1
- {
2
- "name": "wallet-sdk",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "libs/wallet-sdk/src",
5
- "projectType": "library",
6
- "targets": {
7
- "build": {
8
- "executor": "@nx/js:tsc",
9
- "outputs": ["{options.outputPath}"],
10
- "options": {
11
- "outputPath": "dist/libs/wallet-sdk",
12
- "main": "libs/wallet-sdk/src/index.ts",
13
- "tsConfig": "libs/wallet-sdk/tsconfig.lib.json",
14
- "assets": ["libs/wallet-sdk/*.md"]
15
- }
16
- },
17
- "publish": {
18
- "command": "node tools/scripts/publish.mjs wallet-sdk {args.ver} {args.tag}",
19
- "dependsOn": ["build"]
20
- },
21
- "lint": {
22
- "executor": "@nx/eslint:lint"
23
- },
24
- "test": {
25
- "executor": "@nx/jest:jest",
26
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
27
- "options": {
28
- "jestConfig": "libs/wallet-sdk/jest.config.ts"
29
- }
30
- }
31
- },
32
- "tags": ["type:lib", "type:sdk"]
33
- }
@@ -1,14 +0,0 @@
1
- import { SDK_ERROR_MESSAGE, SdkErrorCode } from '../interfaces';
2
-
3
- export class ClientError extends Error {
4
- override message: string;
5
-
6
- constructor(
7
- public code: SdkErrorCode,
8
- public data?,
9
- ) {
10
- super();
11
- this.message = SDK_ERROR_MESSAGE[code];
12
- this.name = this.constructor.name;
13
- }
14
- }
@@ -1,118 +0,0 @@
1
- import { ClientMessenger } from './client-messenger';
2
- import { WindowManager } from './window-manager';
3
- import { ResponseStatus, SdkErrorCode } from '../interfaces';
4
-
5
- jest.mock('./window-manager');
6
-
7
- describe('ClientMessenger', () => {
8
- let messenger: ClientMessenger;
9
- let windowManager: jest.Mocked<WindowManager>;
10
- let walletWindow: jest.Mocked<Window>;
11
-
12
- beforeEach(() => {
13
- walletWindow = {
14
- closed: false,
15
- postMessage: jest.fn(),
16
- close: jest.fn(),
17
- } as unknown as jest.Mocked<Window>;
18
-
19
- windowManager = new WindowManager('https://wallet.ultra.io') as jest.Mocked<WindowManager>;
20
- windowManager.getWalletWindow.mockReturnValue(walletWindow);
21
- windowManager.openOrReuseWallet.mockImplementation(() => {});
22
-
23
- messenger = new ClientMessenger(windowManager);
24
- });
25
-
26
- afterEach(() => {
27
- jest.clearAllMocks();
28
- });
29
-
30
- function fireWalletReady() {
31
- window.dispatchEvent(
32
- new MessageEvent('message', {
33
- origin: 'https://wallet.ultra.io',
34
- data: { jsonrpc: '2.0', method: 'ready' },
35
- }),
36
- );
37
- }
38
-
39
- function fireWalletResponse(id: string, result: any) {
40
- window.dispatchEvent(
41
- new MessageEvent('message', {
42
- origin: 'https://wallet.ultra.io',
43
- data: { jsonrpc: '2.0', id, result },
44
- }),
45
- );
46
- }
47
-
48
- it('resolves request after wallet ready and response received', async () => {
49
- Object.defineProperty(windowManager, 'walletUrl', { get: () => 'https://wallet.ultra.io' });
50
- const requestPromise = messenger.sendRequest('connect', {});
51
- fireWalletReady();
52
-
53
- // Wait one event loop tick to allow postMessage to be called
54
- await new Promise((resolve) => setTimeout(resolve, 0));
55
-
56
- // Extract the actual ID sent
57
- const [[message]] = (walletWindow.postMessage as jest.Mock).mock.calls;
58
- const requestId = message.id;
59
- fireWalletResponse(requestId, { status: ResponseStatus.SUCCESS, data: { address: 'abc' } });
60
-
61
- await expect(requestPromise).resolves.toEqual({
62
- status: ResponseStatus.SUCCESS,
63
- data: { address: 'abc' },
64
- });
65
- });
66
-
67
- it('rejects if window is closed before ready', async () => {
68
- Object.defineProperty(walletWindow, 'closed', { get: () => true });
69
- const requestPromise = messenger.sendRequest('connect', {});
70
- await expect(requestPromise).rejects.toEqual({
71
- status: ResponseStatus.ERROR,
72
- code: SdkErrorCode.USER_REJECTED_REQUEST,
73
- message: expect.any(String),
74
- });
75
- });
76
-
77
- it('rejects if wallet window is not available', async () => {
78
- windowManager.getWalletWindow.mockReturnValue(null);
79
- await expect(messenger.sendRequest('connect', {})).rejects.toEqual({
80
- status: ResponseStatus.ERROR,
81
- code: SdkErrorCode.WALLET_WINDOW_UNAVAILABLE,
82
- message: expect.any(String),
83
- });
84
- });
85
-
86
- it('rejects if wallet does not become ready before timeout', async () => {
87
- jest.useFakeTimers();
88
- const promise = messenger.sendRequest('connect', {});
89
- jest.advanceTimersByTime(10000); // simulate timeout
90
- await expect(promise).rejects.toEqual({
91
- status: ResponseStatus.ERROR,
92
- code: SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT,
93
- message: expect.any(String),
94
- });
95
- jest.useRealTimers();
96
- });
97
-
98
- it('rejects on rpcClient.request failure', async () => {
99
- Object.defineProperty(windowManager, 'walletUrl', { get: () => 'https://wallet.ultra.io' });
100
- const promise = messenger.sendRequest('connect', {});
101
- fireWalletReady();
102
-
103
- // Extract the actual ID sent
104
- const [[message]] = (walletWindow.postMessage as jest.Mock).mock.calls;
105
- const requestId = message.id;
106
- fireWalletResponse(requestId, {
107
- status: ResponseStatus.ERROR,
108
- code: SdkErrorCode.UNKNOWN_ERROR,
109
- message: 'error',
110
- });
111
-
112
- await expect(promise).rejects.toEqual({
113
- status: ResponseStatus.ERROR,
114
- code: SdkErrorCode.UNKNOWN_ERROR,
115
- message: expect.any(String),
116
- });
117
- });
118
- });
@@ -1,109 +0,0 @@
1
- import { JSONRPCClient } from 'json-rpc-2.0';
2
-
3
- import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';
4
- import { JsonRpcMessage, ResponseStatus, SdkErrorCode, UltraResponse } from '../interfaces';
5
-
6
- import { ClientError } from './client-error';
7
- import { WindowManager } from './window-manager';
8
-
9
- export class ClientMessenger {
10
- private windowManager: WindowManager;
11
- private rpcClient: JSONRPCClient;
12
- private pendingRequest = false;
13
-
14
- constructor(windowManager: WindowManager) {
15
- this.windowManager = windowManager;
16
-
17
- this.rpcClient = new JSONRPCClient((request) => {
18
- const walletWindow = this.windowManager.getWalletWindow();
19
- if (!walletWindow) {
20
- return Promise.reject(new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE));
21
- }
22
- walletWindow.postMessage(request, this.windowManager.walletUrl);
23
- return Promise.resolve();
24
- });
25
-
26
- window.addEventListener('message', (event) => {
27
- if (event.origin === this.windowManager.walletUrl && event.data?.jsonrpc === '2.0') {
28
- this.rpcClient.receive(event.data);
29
- }
30
- });
31
- }
32
-
33
- async sendRequest<T>(requestMethod: string, requestParams: object): Promise<UltraResponse<T>> {
34
- if (this.pendingRequest && this.windowManager.getWalletWindow()?.closed === false) {
35
- const { code, message } = new ClientError(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);
36
- return Promise.reject({ status: ResponseStatus.ERROR, code, message });
37
- }
38
-
39
- this.pendingRequest = true;
40
-
41
- this.windowManager.openOrReuseWallet();
42
-
43
- const walletWindow = this.windowManager.getWalletWindow();
44
- if (!walletWindow) {
45
- const { code, message } = new ClientError(SdkErrorCode.WALLET_WINDOW_UNAVAILABLE);
46
- return Promise.reject({ status: ResponseStatus.ERROR, code, message });
47
- }
48
-
49
- let ready = false;
50
- let cleanupCalled = false;
51
-
52
- return new Promise<UltraResponse<T>>((resolve, reject) => {
53
- const cleanup = () => {
54
- if (cleanupCalled) return;
55
- cleanupCalled = true;
56
- this.pendingRequest = false;
57
- clearTimeout(timeout);
58
- clearInterval(checkWindowClose);
59
- window.removeEventListener('message', handleReady);
60
- walletWindow.close();
61
- };
62
-
63
- const handleReady = (event: MessageEvent) => {
64
- if (event.origin !== this.windowManager.walletUrl) return;
65
- const msg: JsonRpcMessage = event.data;
66
- if (msg?.jsonrpc === '2.0' && msg.method === 'ready') {
67
- ready = true;
68
- window.removeEventListener('message', handleReady);
69
-
70
- Promise.resolve(this.rpcClient.request(requestMethod, requestParams))
71
- .then((result) => {
72
- cleanup();
73
- if (result.status === ResponseStatus.SUCCESS) {
74
- resolve(result);
75
- } else {
76
- reject(result);
77
- }
78
- })
79
- .catch((error) => {
80
- cleanup();
81
- const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR, error);
82
- reject({
83
- status: ResponseStatus.ERROR,
84
- ...clientError,
85
- });
86
- });
87
- }
88
- };
89
-
90
- const timeout = setTimeout(() => {
91
- if (!ready) {
92
- cleanup();
93
- const { code, message } = new ClientError(SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT);
94
- reject({ status: ResponseStatus.ERROR, code, message });
95
- }
96
- }, UltraWalletSdkConfig.handshakeTimeout);
97
-
98
- const checkWindowClose = setInterval(() => {
99
- if (walletWindow.closed) {
100
- cleanup();
101
- const { code, message } = new ClientError(SdkErrorCode.USER_REJECTED_REQUEST);
102
- reject({ status: ResponseStatus.ERROR, code, message });
103
- }
104
- }, UltraWalletSdkConfig.checkWindowInterval);
105
-
106
- window.addEventListener('message', handleReady);
107
- });
108
- }
109
- }
@@ -1,65 +0,0 @@
1
- import { WindowManager } from './window-manager';
2
- import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';
3
-
4
- describe('WindowManager', () => {
5
- let windowManager: WindowManager;
6
- const walletUrl = 'https://wallet.example.com';
7
-
8
- let walletWindowMock: Window;
9
-
10
- beforeEach(() => {
11
- walletWindowMock = {
12
- closed: false,
13
- focus: jest.fn(),
14
- } as unknown as Window;
15
-
16
- (window as any).open = jest.fn(() => walletWindowMock);
17
- Object.defineProperty(window, 'top', { value: 100 });
18
- Object.defineProperty(window, 'screenLeft', { value: 200 });
19
- Object.defineProperty(window, 'innerWidth', { value: 1200 });
20
-
21
- windowManager = new WindowManager(walletUrl);
22
- });
23
-
24
- afterEach(() => {
25
- jest.clearAllMocks();
26
- });
27
-
28
- it('opens a new wallet window when none exists', () => {
29
- windowManager.openOrReuseWallet();
30
-
31
- expect(window.open).toHaveBeenCalledWith(
32
- walletUrl,
33
- '_blank',
34
- expect.stringContaining(`width=${UltraWalletSdkConfig.width}`),
35
- );
36
- expect(windowManager.getWalletWindow()).toBe(walletWindowMock);
37
- });
38
-
39
- it('focuses existing wallet window if already open and not closed', () => {
40
- windowManager['walletWindow'] = walletWindowMock;
41
- windowManager.openOrReuseWallet();
42
-
43
- expect(walletWindowMock.focus).toHaveBeenCalled();
44
- expect(window.open).not.toHaveBeenCalled();
45
- });
46
-
47
- it('returns the current wallet window reference', () => {
48
- windowManager['walletWindow'] = walletWindowMock;
49
- const result = windowManager.getWalletWindow();
50
- expect(result).toBe(walletWindowMock);
51
- });
52
-
53
- it('opens a new window if previous one was closed', () => {
54
- const closedWindowMock = { closed: true } as unknown as Window;
55
- windowManager['walletWindow'] = closedWindowMock;
56
-
57
- windowManager.openOrReuseWallet();
58
-
59
- expect(window.open).toHaveBeenCalledWith(
60
- walletUrl,
61
- '_blank',
62
- expect.stringContaining(`width=${UltraWalletSdkConfig.width}`),
63
- );
64
- });
65
- });
@@ -1,34 +0,0 @@
1
- import UltraWalletSdkConfig from '../config/ultra-wallet-sdk.config';
2
-
3
- export class WindowManager {
4
- private currentWindow: Window;
5
- private walletWindow: Window | null = null;
6
- public readonly walletUrl: string;
7
-
8
- constructor(walletUrl: string) {
9
- this.currentWindow = window;
10
- this.walletUrl = walletUrl;
11
- }
12
-
13
- openOrReuseWallet() {
14
- if (this.walletWindow == null || this.walletWindow.closed) {
15
- const height = UltraWalletSdkConfig.height;
16
- const width = UltraWalletSdkConfig.width;
17
- const top = this.currentWindow.top;
18
- const left = this.currentWindow.screenLeft + this.currentWindow.innerWidth - width;
19
-
20
- this.walletWindow = window.open(
21
- this.walletUrl,
22
- '_blank',
23
- `width=${width},height=${height},top=${top},left=${left}`,
24
- );
25
- } else {
26
- this.walletWindow.focus();
27
- }
28
- }
29
-
30
- // Provides a reference to the wallet window
31
- getWalletWindow(): Window | null {
32
- return this.walletWindow;
33
- }
34
- }
@@ -1,37 +0,0 @@
1
- interface UltraWalletSdkConfig {
2
- width: number;
3
- height: number;
4
- walletUrls: {
5
- mainnet: string;
6
- testnet: string;
7
- };
8
- checkWindowInterval: number;
9
- handshakeTimeout: number;
10
- networkInfo: Record<
11
- 'mainnet' | 'testnet',
12
- {
13
- chainId: string;
14
- }
15
- >;
16
- }
17
-
18
- const UltraWalletSdkConfig: UltraWalletSdkConfig = Object.freeze({
19
- width: 345,
20
- height: 610,
21
- walletUrls: {
22
- mainnet: 'https://web-wallet.ultra.io',
23
- testnet: 'https://web-wallet.staging.ultra.io',
24
- },
25
- networkInfo: {
26
- mainnet: {
27
- chainId: 'a9c481dfbc7d9506dc7e87e9a137c931b0a9303f64fd7a1d08b8230133920097',
28
- },
29
- testnet: {
30
- chainId: '7fc56be645bb76ab9d747b53089f132dcb7681db06f0852cfa03eaf6f7ac80e9',
31
- },
32
- },
33
- checkWindowInterval: 500,
34
- handshakeTimeout: 10_000,
35
- });
36
-
37
- export default UltraWalletSdkConfig;
@@ -1,21 +0,0 @@
1
- /**
2
- * Defines the structure of a blockchain transaction request to be signed by the Ultra Wallet.
3
- */
4
- export interface BlockchainTransaction {
5
- /**
6
- * The smart contract address or name to interact with.
7
- */
8
- contract: string;
9
- /**
10
- * The action or method to call on the contract.
11
- */
12
- action: string;
13
- /**
14
- * The data payload for the contract action.
15
- */
16
- data: any;
17
- /**
18
- * List of authorizations (account@permission) required for the transaction.
19
- */
20
- authorizations?: string[];
21
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Optional parameters for establishing a connection with the Ultra Wallet.
3
- */
4
- export interface ConnectParams {
5
- /**
6
- * If true, do not prompt the user for permissions; share account info only if Dapp is already trusted.
7
- */
8
- onlyIfTrusted?: boolean;
9
- /**
10
- * Optional referral code to associate with the connection request.
11
- */
12
- referralCode?: string;
13
- }
@@ -1,15 +0,0 @@
1
- export enum SdkErrorCode {
2
- USER_REJECTED_REQUEST = 4001,
3
- WALLET_HANDSHAKE_TIMEOUT = 4300,
4
- WALLET_WINDOW_UNAVAILABLE = 4301,
5
- REQUESTED_RESOURCE_NOT_AVAILABLE = 32002,
6
- UNKNOWN_ERROR = -32604,
7
- }
8
-
9
- export const SDK_ERROR_MESSAGE: { [key in SdkErrorCode]: string } = {
10
- [SdkErrorCode.USER_REJECTED_REQUEST]: 'The user rejected the request.',
11
- [SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: 'Timeout to connect with the web wallet.',
12
- [SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: 'The Web Wallet is not available.',
13
- [SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: 'Requested resource not available.',
14
- [SdkErrorCode.UNKNOWN_ERROR]: 'Unknown error occurred.',
15
- };
@@ -1,7 +0,0 @@
1
- export interface JsonRpcMessage {
2
- jsonrpc: '2.0';
3
- method: string;
4
- params?: any;
5
- id?: string;
6
- result?: any;
7
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Enumeration of supported item types that can be purchased via the Ultra Wallet.
3
- */
4
- export enum PurchaseItemType {
5
- UNIQ_FACTORY = 'UniqFactory',
6
- GAME_FACTORY = 'GameFactory',
7
- }
@@ -1,157 +0,0 @@
1
- /**
2
- * A generic wrapper for all Ultra Wallet SDK responses.
3
- * Encapsulates the status, data payload, and optional error messaging or codes.
4
- *
5
- * @template T The type of the data payload contained in the response.
6
- */
7
- export interface UltraResponse<T = any> {
8
- /**
9
- * The status of the response, e.g., success, fail, or error.
10
- */
11
- status: ResponseStatus;
12
- /**
13
- * The actual response data payload.
14
- */
15
- data: T;
16
- /**
17
- * Optional end-user-readable message, explaining what went wrong (if applicable).
18
- */
19
- message?: string;
20
- /**
21
- * Optional error or status code.
22
- */
23
- code?: number;
24
- }
25
-
26
- /**
27
- * Enumeration of possible response statuses returned by the Ultra Wallet SDK.
28
- */
29
- export enum ResponseStatus {
30
- SUCCESS = 'success',
31
- FAIL = 'fail',
32
- ERROR = 'error',
33
- }
34
-
35
- /**
36
- * Represents the result of a disconnect request.
37
- * A boolean indicating whether the disconnection was successful.
38
- */
39
- export type DisconnectResponse = boolean;
40
-
41
- /**
42
- * Represents the result of a successful connection request, containing the user's account details.
43
- */
44
- export type ConnectResult = Array<{
45
- /**
46
- * The blockchain network identifier.
47
- */
48
- blockchainid: string;
49
- /**
50
- * The public key associated with the user's account.
51
- */
52
- publicKey: string;
53
- }>;
54
-
55
- /**
56
- * The result structure returned after a successful item purchase using the Ultra Wallet.
57
- * Contains metadata about the purchased items and the associated blockchain transaction.
58
- */
59
- export interface PurchaseItemResult {
60
- /**
61
- * An ID associated with the purchase order, used for support requests if required.
62
- */
63
- orderHash: string;
64
-
65
- items: {
66
- /**
67
- * The ID of the minted Uniq.
68
- */
69
- artifactId: string;
70
- /**
71
- * The purchased item ID.
72
- */
73
- productId: string;
74
- /**
75
- * The ID of the transaction in the blockchain, useful for tracking the status and details of the transaction.
76
- */
77
- blockchainTransactionId: string;
78
- }[];
79
- }
80
-
81
- /**
82
- * Represents the result returned after signing a message with the Ultra Wallet.
83
- */
84
- export interface SignMessageResult {
85
- signature: string;
86
- }
87
-
88
- /**
89
- * Represents the result returned after signing a blockchain transaction with the Ultra Wallet.
90
- */
91
- export interface SignTransactionResult {
92
- /**
93
- * The hash of the signed blockchain transaction.
94
- */
95
- transactionHash?: string;
96
- processed?: {
97
- id: string;
98
- block_num: number;
99
- block_time: string; // ISO timestamp
100
- producer_block_id: string | null;
101
- receipt: {
102
- status: string;
103
- cpu_usage_us: number;
104
- net_usage_words: number;
105
- };
106
- elapsed: number;
107
- net_usage: number;
108
- scheduled: boolean;
109
- action_traces: ActionTrace[];
110
- account_ram_delta: any | null;
111
- except: any | null;
112
- error_code: number | null;
113
- };
114
- }
115
-
116
- export interface ActionTrace {
117
- action_ordinal: number;
118
- creator_action_ordinal: number;
119
- closest_unnotified_ancestor_action_ordinal: number;
120
- receipt: {
121
- receiver: string;
122
- act_digest: string;
123
- global_sequence: number;
124
- recv_sequence: number;
125
- auth_sequence: [string, number][];
126
- code_sequence: number;
127
- abi_sequence: number;
128
- };
129
- receiver: string;
130
- act: {
131
- account: string;
132
- name: string;
133
- authorization: {
134
- actor: string;
135
- permission: string;
136
- }[];
137
- data: {
138
- from: string;
139
- to: string;
140
- quantity: string;
141
- memo: string;
142
- };
143
- hex_data: string;
144
- };
145
- context_free: boolean;
146
- elapsed: number;
147
- console: string;
148
- trx_id: string;
149
- block_num: number;
150
- block_time: string;
151
- producer_block_id: string | null;
152
- account_ram_deltas: any[];
153
- except: any | null;
154
- error_code: number | null;
155
- return_value_hex_data: string;
156
- inline_traces: ActionTrace[];
157
- }