@ultraos/wallet-sdk 0.3.2 → 0.6.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/CHANGELOG.md +67 -0
- package/LICENSE +165 -0
- package/README.md +21 -10
- package/dist/index.mjs +45 -56
- package/dist/index.mjs.map +4 -4
- package/package.json +5 -2
- package/src/index.d.ts +2 -2
- package/src/lib/common/client-error.d.ts +1 -1
- package/src/lib/common/client-messenger.d.ts +3 -2
- package/src/lib/common/client-messenger.d.ts.map +1 -1
- package/src/lib/common/client-messenger.js +24 -12
- package/src/lib/common/client-messenger.js.map +1 -1
- package/src/lib/common/window-manager.d.ts +3 -2
- package/src/lib/common/window-manager.d.ts.map +1 -1
- package/src/lib/common/window-manager.js.map +1 -1
- package/src/lib/config/ultra-wallet-sdk.config.d.ts +2 -1
- package/src/lib/config/ultra-wallet-sdk.config.d.ts.map +1 -1
- package/src/lib/config/ultra-wallet-sdk.config.js +2 -1
- package/src/lib/config/ultra-wallet-sdk.config.js.map +1 -1
- package/src/lib/interfaces/connect-params.interface.d.ts +12 -0
- package/src/lib/interfaces/connect-params.interface.d.ts.map +1 -1
- package/src/lib/interfaces/connect-params.interface.js.map +1 -1
- package/src/lib/interfaces/error-enum.d.ts +1 -0
- package/src/lib/interfaces/error-enum.d.ts.map +1 -1
- package/src/lib/interfaces/error-enum.js +2 -0
- package/src/lib/interfaces/error-enum.js.map +1 -1
- package/src/lib/interfaces/index.d.ts +7 -8
- package/src/lib/interfaces/index.d.ts.map +1 -1
- package/src/lib/interfaces/index.js +0 -1
- package/src/lib/interfaces/index.js.map +1 -1
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts +88 -27
- package/src/lib/interfaces/wallet-provider-response.interface.d.ts.map +1 -1
- package/src/lib/interfaces/wallet-provider-response.interface.js.map +1 -1
- package/src/lib/interfaces/wallet-provider.interface.d.ts +4 -20
- package/src/lib/interfaces/wallet-provider.interface.d.ts.map +1 -1
- package/src/lib/interfaces/wallet-provider.interface.js.map +1 -1
- package/src/lib/providers/extension-provider/extension.provider.d.ts +1 -7
- package/src/lib/providers/extension-provider/extension.provider.d.ts.map +1 -1
- package/src/lib/providers/extension-provider/extension.provider.js +0 -6
- package/src/lib/providers/extension-provider/extension.provider.js.map +1 -1
- package/src/lib/providers/index.d.ts +2 -2
- package/src/lib/providers/web-provider/web.provider.d.ts +5 -7
- package/src/lib/providers/web-provider/web.provider.d.ts.map +1 -1
- package/src/lib/providers/web-provider/web.provider.js +9 -12
- package/src/lib/providers/web-provider/web.provider.js.map +1 -1
- package/src/lib/ultra-wallet-sdk.d.ts +1 -7
- package/src/lib/ultra-wallet-sdk.d.ts.map +1 -1
- package/src/lib/ultra-wallet-sdk.js +0 -6
- package/src/lib/ultra-wallet-sdk.js.map +1 -1
- package/src/lib/interfaces/purchase-item.interface.d.ts +0 -8
- package/src/lib/interfaces/purchase-item.interface.d.ts.map +0 -1
- package/src/lib/interfaces/purchase-item.interface.js +0 -9
- package/src/lib/interfaces/purchase-item.interface.js.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@ultraos/wallet-sdk` are documented in this file.
|
|
4
|
+
|
|
5
|
+
## 0.6.1
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- `environment: 'testnet'` with the Web Wallet provider now rejects immediately with the new
|
|
10
|
+
`SdkErrorCode.WEB_WALLET_UNAVAILABLE` (4302) instead of opening a popup to the decommissioned
|
|
11
|
+
`web-wallet.staging.ultra.io`. Testnet is supported through the browser extension; `getChainId()` still answers
|
|
12
|
+
locally.
|
|
13
|
+
- Web Wallet JSON-RPC errors (for example calling an extension-only method such as `getAccounts()` with the Web Wallet
|
|
14
|
+
provider) rejected with `undefined`. They now reject with the wallet's `{ status: 'error', code, message }`
|
|
15
|
+
(`UNKNOWN_ERROR` -32604 when the error has no code), and the SDK closes the popup so the next request is not left
|
|
16
|
+
waiting for a `ready` handshake that never comes.
|
|
17
|
+
- Type declarations use explicit `.js` specifiers, so they resolve under TypeScript `moduleResolution: node16/nodenext`
|
|
18
|
+
(previously every export was reported missing).
|
|
19
|
+
- The package now declares `"license": "LGPL-3.0-only"` and ships the `LICENSE` file.
|
|
20
|
+
- CI publishing (`release:wallet-sdk` → `nx-release-publish`) now publishes the packaged `dist/libs/wallet-sdk` (via the
|
|
21
|
+
new `wallet-sdk:package` target) instead of the raw library folder.
|
|
22
|
+
|
|
23
|
+
## 0.6.0
|
|
24
|
+
|
|
25
|
+
0.4.0 and 0.5.0 were never published to npm; their changes (below) first shipped in 0.6.0.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
|
|
29
|
+
- `purchaseItem()` and the `PurchaseItemType` / `PurchaseItemResult` types. Neither wallet serves it any more: the
|
|
30
|
+
extension redesign deliberately removed Ultra-platform checkout dependencies and the Web Wallet never shipped the
|
|
31
|
+
route, so calls could only hang until the user closed the popup.
|
|
32
|
+
- `addNetwork()`. The extension removed its dApp-callable route in the v4 security audit (N-N1): adding a network
|
|
33
|
+
without an explicit approval screen is a silent RPC-takeover vector. Users add custom networks in the wallet's
|
|
34
|
+
Settings → Networks; dApps can then call `switchNetwork()`.
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Corrected the `ConnectResult.blockchainid` documentation: it is the connected account **name** (equal to
|
|
39
|
+
`selectedAccount.accountName`), not a network identifier.
|
|
40
|
+
- Declared the `nonce` / `signedNonce` fields every wallet already returns from `connect({ nonce })`.
|
|
41
|
+
- Marked the connect-time attestation surface (`ConnectAttestation`, `AttestationPayload`, `SignableAccount`,
|
|
42
|
+
`ConnectResult.attestation`, `ConnectParams.requireAttestation`) `@experimental`: only the browser extension issues it
|
|
43
|
+
and no Ultra service consumes it yet.
|
|
44
|
+
- Published as a bundled ES module (`dist/index.mjs` + `exports` map), as in 0.3.2, now produced reproducibly by
|
|
45
|
+
`npm run build:wallet-sdk`.
|
|
46
|
+
|
|
47
|
+
## 0.5.0
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
|
|
51
|
+
- `requireAttestation?: boolean` on `ConnectParams`. When set, a dApp signals that it needs a connect-time identity
|
|
52
|
+
attestation; if the wallet supports attestation but the origin hasn't yet consented, the wallet prompts for consent
|
|
53
|
+
via the existing connect prompt (no separate signature dialog) and resolves `connect()` with a populated
|
|
54
|
+
`ConnectResult.attestation`. Strictly additive and pass-through — the SDK forwards the flag to the wallet verbatim and
|
|
55
|
+
performs no logic on it; wallets without attestation support ignore it. Omitting it preserves existing behavior. See
|
|
56
|
+
the RFC:
|
|
57
|
+
<https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md>
|
|
58
|
+
|
|
59
|
+
## 0.4.0
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
|
|
63
|
+
- `ConnectAttestation` type and an optional `attestation` field on `ConnectResult`. When the connected wallet supports
|
|
64
|
+
silent connect-time identity attestation, `connect()` now surfaces it; otherwise `attestation` is `undefined`. This is
|
|
65
|
+
a strictly additive, type-only change — the SDK passes the value through verbatim and performs no verification. See
|
|
66
|
+
the RFC:
|
|
67
|
+
<https://github.com/ultraio/ultra-tool-kit/blob/feature/ai-enhancement/docs/proposals/wallet-native-attestation.md>
|
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -7,8 +7,8 @@ browser extension or via a web fallback.
|
|
|
7
7
|
|
|
8
8
|
- Automatically detects and uses the Ultra Wallet Extension if available.
|
|
9
9
|
- Falls back to a Web Wallet if the extension is not installed.
|
|
10
|
-
- Connect, sign messages
|
|
11
|
-
- Environment support: `mainnet`, `testnet
|
|
10
|
+
- Connect, sign messages and sign transactions with a simple API.
|
|
11
|
+
- Environment support: `mainnet`, `testnet` (browser extension only), or a custom Web Wallet URL.
|
|
12
12
|
|
|
13
13
|
## 📦 Installation
|
|
14
14
|
|
|
@@ -44,7 +44,7 @@ await ultra.signTransaction({
|
|
|
44
44
|
contract: 'eosio.token',
|
|
45
45
|
action: 'transfer',
|
|
46
46
|
data: { from: 'user', to: 'receiver', quantity: '1.00000000 UOS', memo: '' },
|
|
47
|
-
|
|
47
|
+
// authorization defaults to the connected account's `active` permission
|
|
48
48
|
});
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -55,7 +55,7 @@ You can pass options during initialization:
|
|
|
55
55
|
```ts
|
|
56
56
|
new UltraWalletSDK({
|
|
57
57
|
environment: 'testnet', // or 'mainnet', or provide custom URL
|
|
58
|
-
provider: 'web', // or 'extension', use a specific provider
|
|
58
|
+
provider: 'web', // or 'extension', use a specific provider independently of auto-detection
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -63,12 +63,23 @@ new UltraWalletSDK({
|
|
|
63
63
|
|
|
64
64
|
### Methods
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
All methods resolve to `UltraResponse<T>` (`{ status: 'success', data: T }`) and reject with
|
|
67
|
+
`{ status, code, message }`.
|
|
68
|
+
|
|
69
|
+
| Method | Extension | Web Wallet |
|
|
70
|
+
| ------------------------------------------------------------------------------------- | --------- | ---------- |
|
|
71
|
+
| `connect(params?: ConnectParams)` / `disconnect()` | ✅ | ✅ |
|
|
72
|
+
| `signMessage(message: string)` | ✅ | ✅ |
|
|
73
|
+
| `signTransaction(transaction, options?: { signOnly?: boolean })` | ✅ | ✅ |
|
|
74
|
+
| `getChainId()` | ✅ | ✅ |
|
|
75
|
+
| `getAccounts()` / `getSelectedAccount()` / `getAvailableAuthorizations()` | ✅ | — |
|
|
76
|
+
| `getNetwork()` / `getNetworks()` / `switchNetwork(chainId)` | ✅ | — |
|
|
77
|
+
| `on(event, cb)` / `off(event, cb)` — `accountChanged`, `networkChanged`, `disconnect` | ✅ | — |
|
|
78
|
+
| `dispose()` | ✅ | ✅ |
|
|
79
|
+
|
|
80
|
+
The Web Wallet is currently deployed for **mainnet** only.
|
|
81
|
+
|
|
82
|
+
Full documentation: <https://developers.ultra.io/products/ultra-wallet-sdk/>
|
|
72
83
|
|
|
73
84
|
---
|
|
74
85
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// src/lib/interfaces/error-enum.js
|
|
1
|
+
// dist/libs/wallet-sdk/src/lib/interfaces/error-enum.js
|
|
2
2
|
var SdkErrorCode;
|
|
3
3
|
(function(SdkErrorCode2) {
|
|
4
4
|
SdkErrorCode2[SdkErrorCode2["USER_REJECTED_REQUEST"] = 4001] = "USER_REJECTED_REQUEST";
|
|
5
5
|
SdkErrorCode2[SdkErrorCode2["WALLET_HANDSHAKE_TIMEOUT"] = 4300] = "WALLET_HANDSHAKE_TIMEOUT";
|
|
6
6
|
SdkErrorCode2[SdkErrorCode2["WALLET_WINDOW_UNAVAILABLE"] = 4301] = "WALLET_WINDOW_UNAVAILABLE";
|
|
7
|
+
SdkErrorCode2[SdkErrorCode2["WEB_WALLET_UNAVAILABLE"] = 4302] = "WEB_WALLET_UNAVAILABLE";
|
|
7
8
|
SdkErrorCode2[SdkErrorCode2["REQUESTED_RESOURCE_NOT_AVAILABLE"] = 32002] = "REQUESTED_RESOURCE_NOT_AVAILABLE";
|
|
8
9
|
SdkErrorCode2[SdkErrorCode2["UNKNOWN_ERROR"] = -32604] = "UNKNOWN_ERROR";
|
|
9
10
|
})(SdkErrorCode || (SdkErrorCode = {}));
|
|
@@ -11,18 +12,12 @@ var SDK_ERROR_MESSAGE = {
|
|
|
11
12
|
[SdkErrorCode.USER_REJECTED_REQUEST]: "The user rejected the request.",
|
|
12
13
|
[SdkErrorCode.WALLET_HANDSHAKE_TIMEOUT]: "Timeout to connect with the web wallet.",
|
|
13
14
|
[SdkErrorCode.WALLET_WINDOW_UNAVAILABLE]: "Wallet window blocked by browser or failed to open.",
|
|
15
|
+
[SdkErrorCode.WEB_WALLET_UNAVAILABLE]: "The Ultra Web Wallet is not available on this network. Use the Ultra Wallet browser extension.",
|
|
14
16
|
[SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE]: "Requested resource not available.",
|
|
15
17
|
[SdkErrorCode.UNKNOWN_ERROR]: "Unknown error occurred."
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
// src/lib/interfaces/
|
|
19
|
-
var PurchaseItemType;
|
|
20
|
-
(function(PurchaseItemType2) {
|
|
21
|
-
PurchaseItemType2["UNIQ_FACTORY"] = "UniqFactory";
|
|
22
|
-
PurchaseItemType2["GAME_FACTORY"] = "GameFactory";
|
|
23
|
-
})(PurchaseItemType || (PurchaseItemType = {}));
|
|
24
|
-
|
|
25
|
-
// src/lib/interfaces/wallet-provider-response.interface.js
|
|
20
|
+
// dist/libs/wallet-sdk/src/lib/interfaces/wallet-provider-response.interface.js
|
|
26
21
|
var ResponseStatus;
|
|
27
22
|
(function(ResponseStatus2) {
|
|
28
23
|
ResponseStatus2["SUCCESS"] = "success";
|
|
@@ -30,13 +25,14 @@ var ResponseStatus;
|
|
|
30
25
|
ResponseStatus2["ERROR"] = "error";
|
|
31
26
|
})(ResponseStatus || (ResponseStatus = {}));
|
|
32
27
|
|
|
33
|
-
// src/lib/config/ultra-wallet-sdk.config.js
|
|
28
|
+
// dist/libs/wallet-sdk/src/lib/config/ultra-wallet-sdk.config.js
|
|
34
29
|
var UltraWalletSdkConfig = Object.freeze({
|
|
35
30
|
width: 420,
|
|
36
31
|
height: 815,
|
|
37
32
|
walletUrls: {
|
|
38
33
|
mainnet: "https://web-wallet.ultra.io",
|
|
39
|
-
testnet
|
|
34
|
+
// The testnet Web Wallet (web-wallet.staging.ultra.io) was decommissioned; testnet is extension-only.
|
|
35
|
+
testnet: null
|
|
40
36
|
},
|
|
41
37
|
networkInfo: {
|
|
42
38
|
mainnet: {
|
|
@@ -51,13 +47,13 @@ var UltraWalletSdkConfig = Object.freeze({
|
|
|
51
47
|
});
|
|
52
48
|
var ultra_wallet_sdk_config_default = UltraWalletSdkConfig;
|
|
53
49
|
|
|
54
|
-
// src/lib/utils/chain-validator.js
|
|
50
|
+
// dist/libs/wallet-sdk/src/lib/utils/chain-validator.js
|
|
55
51
|
function isValidChain(targetNetwork, walletChainId) {
|
|
56
52
|
const { chainId } = ultra_wallet_sdk_config_default.networkInfo[targetNetwork] || {};
|
|
57
53
|
return !chainId || chainId === walletChainId;
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
// src/lib/providers/extension-provider/extension.provider.js
|
|
56
|
+
// dist/libs/wallet-sdk/src/lib/providers/extension-provider/extension.provider.js
|
|
61
57
|
var HEARTBEAT_INTERVAL_MS = 2e3;
|
|
62
58
|
var ExtensionProvider = class {
|
|
63
59
|
/**
|
|
@@ -130,9 +126,6 @@ var ExtensionProvider = class {
|
|
|
130
126
|
getChainId() {
|
|
131
127
|
return this.walletProvider.getChainId();
|
|
132
128
|
}
|
|
133
|
-
purchaseItem(itemType, itemId) {
|
|
134
|
-
return this.walletProvider.purchaseItem(itemType, itemId);
|
|
135
|
-
}
|
|
136
129
|
getAccounts() {
|
|
137
130
|
return this.walletProvider.getAccounts();
|
|
138
131
|
}
|
|
@@ -171,9 +164,6 @@ var ExtensionProvider = class {
|
|
|
171
164
|
getNetworks() {
|
|
172
165
|
return this.walletProvider.getNetworks();
|
|
173
166
|
}
|
|
174
|
-
addNetwork(params) {
|
|
175
|
-
return this.walletProvider.addNetwork(params);
|
|
176
|
-
}
|
|
177
167
|
/**
|
|
178
168
|
* Detach the window message listener and clear timers + maps. Safe to call
|
|
179
169
|
* multiple times. Does NOT deregister each listener on the BG — the BG
|
|
@@ -253,10 +243,10 @@ var ExtensionProvider = class {
|
|
|
253
243
|
}
|
|
254
244
|
};
|
|
255
245
|
|
|
256
|
-
// src/lib/common/client-messenger.js
|
|
246
|
+
// dist/libs/wallet-sdk/src/lib/common/client-messenger.js
|
|
257
247
|
import { JSONRPCClient } from "json-rpc-2.0";
|
|
258
248
|
|
|
259
|
-
// src/lib/common/client-error.js
|
|
249
|
+
// dist/libs/wallet-sdk/src/lib/common/client-error.js
|
|
260
250
|
var ClientError = class extends Error {
|
|
261
251
|
constructor(code, data) {
|
|
262
252
|
super();
|
|
@@ -267,7 +257,7 @@ var ClientError = class extends Error {
|
|
|
267
257
|
}
|
|
268
258
|
};
|
|
269
259
|
|
|
270
|
-
// src/lib/common/client-messenger.js
|
|
260
|
+
// dist/libs/wallet-sdk/src/lib/common/client-messenger.js
|
|
271
261
|
var ClientMessenger = class {
|
|
272
262
|
constructor(windowManager) {
|
|
273
263
|
this.pendingRequest = false;
|
|
@@ -293,6 +283,9 @@ var ClientMessenger = class {
|
|
|
293
283
|
});
|
|
294
284
|
}
|
|
295
285
|
async sendRequest(requestMethod, requestParams) {
|
|
286
|
+
if (!this.windowManager.walletUrl) {
|
|
287
|
+
throw this.createErrorResponse(SdkErrorCode.WEB_WALLET_UNAVAILABLE);
|
|
288
|
+
}
|
|
296
289
|
if (this.pendingRequest && !this.isWalletWindowClosed()) {
|
|
297
290
|
throw this.createErrorResponse(SdkErrorCode.REQUESTED_RESOURCE_NOT_AVAILABLE);
|
|
298
291
|
}
|
|
@@ -353,18 +346,13 @@ var ClientMessenger = class {
|
|
|
353
346
|
try {
|
|
354
347
|
result = await this.rpcClient.request(requestMethod, requestParams);
|
|
355
348
|
} catch (error) {
|
|
356
|
-
|
|
357
|
-
throw
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
} finally {
|
|
362
|
-
if (result?.status === ResponseStatus.SUCCESS) {
|
|
363
|
-
return result;
|
|
364
|
-
} else {
|
|
365
|
-
throw result;
|
|
366
|
-
}
|
|
349
|
+
walletWindow.close();
|
|
350
|
+
throw this.createRpcErrorResponse(error);
|
|
351
|
+
}
|
|
352
|
+
if (result?.status === ResponseStatus.SUCCESS) {
|
|
353
|
+
return result;
|
|
367
354
|
}
|
|
355
|
+
throw result;
|
|
368
356
|
});
|
|
369
357
|
}
|
|
370
358
|
async withWindowMonitoring(walletWindow, operation) {
|
|
@@ -390,13 +378,26 @@ var ClientMessenger = class {
|
|
|
390
378
|
const msg = event.data;
|
|
391
379
|
return msg?.jsonrpc === "2.0" && msg.method === "ready";
|
|
392
380
|
}
|
|
381
|
+
createRpcErrorResponse(error) {
|
|
382
|
+
const { code, message } = error ?? {};
|
|
383
|
+
if (typeof code === "number") {
|
|
384
|
+
return {
|
|
385
|
+
status: ResponseStatus.ERROR,
|
|
386
|
+
code,
|
|
387
|
+
message: typeof message === "string" ? message : "",
|
|
388
|
+
data: error.data
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const clientError = new ClientError(SdkErrorCode.UNKNOWN_ERROR);
|
|
392
|
+
return { status: ResponseStatus.ERROR, code: clientError.code, message: clientError.message, data: error };
|
|
393
|
+
}
|
|
393
394
|
createErrorResponse(errorCode) {
|
|
394
395
|
const { code, message } = new ClientError(errorCode);
|
|
395
396
|
return { status: ResponseStatus.ERROR, code, message, data: null };
|
|
396
397
|
}
|
|
397
398
|
};
|
|
398
399
|
|
|
399
|
-
// src/lib/common/window-manager.js
|
|
400
|
+
// dist/libs/wallet-sdk/src/lib/common/window-manager.js
|
|
400
401
|
var WindowManager = class {
|
|
401
402
|
constructor(walletUrl) {
|
|
402
403
|
this.walletWindow = null;
|
|
@@ -420,7 +421,7 @@ var WindowManager = class {
|
|
|
420
421
|
}
|
|
421
422
|
};
|
|
422
423
|
|
|
423
|
-
// src/lib/providers/web-provider/web.provider.js
|
|
424
|
+
// dist/libs/wallet-sdk/src/lib/providers/web-provider/web.provider.js
|
|
424
425
|
var WebProvider = class {
|
|
425
426
|
constructor(options) {
|
|
426
427
|
this.options = options;
|
|
@@ -458,12 +459,6 @@ var WebProvider = class {
|
|
|
458
459
|
return this.clientMessenger.sendRequest("getChainId", {});
|
|
459
460
|
}
|
|
460
461
|
}
|
|
461
|
-
purchaseItem(itemType, itemId) {
|
|
462
|
-
return this.clientMessenger.sendRequest("purchaseItem", {
|
|
463
|
-
itemType,
|
|
464
|
-
itemId
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
462
|
getAccounts() {
|
|
468
463
|
return this.clientMessenger.sendRequest("getAccounts", {});
|
|
469
464
|
}
|
|
@@ -489,24 +484,25 @@ var WebProvider = class {
|
|
|
489
484
|
getNetworks() {
|
|
490
485
|
throw new Error("Not supported in web provider");
|
|
491
486
|
}
|
|
492
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
493
|
-
addNetwork(_params) {
|
|
494
|
-
throw new Error("Not supported in web provider");
|
|
495
|
-
}
|
|
496
487
|
dispose() {
|
|
497
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Built-in networks map to their configured Web Wallet URL (`null` when none is deployed);
|
|
491
|
+
* any other `environment` value is a custom Web Wallet URL.
|
|
492
|
+
*/
|
|
498
493
|
resolveWalletUrl() {
|
|
499
|
-
const
|
|
500
|
-
|
|
494
|
+
const environment = this.options?.environment || "mainnet";
|
|
495
|
+
const { walletUrls } = ultra_wallet_sdk_config_default;
|
|
496
|
+
return Object.prototype.hasOwnProperty.call(walletUrls, environment) ? walletUrls[environment] : environment;
|
|
501
497
|
}
|
|
502
498
|
};
|
|
503
499
|
|
|
504
|
-
// src/lib/utils/detection.js
|
|
500
|
+
// dist/libs/wallet-sdk/src/lib/utils/detection.js
|
|
505
501
|
function isExtensionAvailable() {
|
|
506
502
|
return typeof window !== "undefined" && "ultra" in window;
|
|
507
503
|
}
|
|
508
504
|
|
|
509
|
-
// src/lib/ultra-wallet-sdk.js
|
|
505
|
+
// dist/libs/wallet-sdk/src/lib/ultra-wallet-sdk.js
|
|
510
506
|
var UltraWalletSDK = class {
|
|
511
507
|
/**
|
|
512
508
|
* Constructs an UltraWalletClient instance.
|
|
@@ -534,9 +530,6 @@ var UltraWalletSDK = class {
|
|
|
534
530
|
getChainId() {
|
|
535
531
|
return this.provider.getChainId();
|
|
536
532
|
}
|
|
537
|
-
purchaseItem(itemType, itemId) {
|
|
538
|
-
return this.provider.purchaseItem(itemType, itemId);
|
|
539
|
-
}
|
|
540
533
|
getAccounts() {
|
|
541
534
|
return this.provider.getAccounts();
|
|
542
535
|
}
|
|
@@ -561,9 +554,6 @@ var UltraWalletSDK = class {
|
|
|
561
554
|
getNetworks() {
|
|
562
555
|
return this.provider.getNetworks();
|
|
563
556
|
}
|
|
564
|
-
addNetwork(params) {
|
|
565
|
-
return this.provider.addNetwork(params);
|
|
566
|
-
}
|
|
567
557
|
dispose() {
|
|
568
558
|
this.provider.dispose();
|
|
569
559
|
}
|
|
@@ -580,7 +570,6 @@ var UltraWalletSDK = class {
|
|
|
580
570
|
}
|
|
581
571
|
};
|
|
582
572
|
export {
|
|
583
|
-
PurchaseItemType,
|
|
584
573
|
ResponseStatus,
|
|
585
574
|
SDK_ERROR_MESSAGE,
|
|
586
575
|
SdkErrorCode,
|