@rango-dev/provider-math-wallet 0.0.0-experimental-936229e8-20251208
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 +253 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/mod.d.ts +3 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +2 -0
- package/dist/mod.js.map +7 -0
- package/dist/namespaces/evm.d.ts +4 -0
- package/dist/namespaces/evm.d.ts.map +1 -0
- package/dist/namespaces/solana.d.ts +4 -0
- package/dist/namespaces/solana.d.ts.map +1 -0
- package/dist/provider-math-wallet.build.json +1 -0
- package/dist/provider.d.ts +3 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/signer.d.ts +4 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +33 -0
- package/readme.md +34 -0
- package/src/constants.ts +51 -0
- package/src/mod.ts +8 -0
- package/src/namespaces/evm.ts +45 -0
- package/src/namespaces/solana.ts +28 -0
- package/src/provider.ts +29 -0
- package/src/signer.ts +33 -0
- package/src/types.ts +17 -0
- package/src/utils.ts +57 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# [0.56.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.55.1...provider-math-wallet@0.56.0) (2025-12-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* migrate math wallet to the hub ([5bc83c6](https://github.com/rango-exchange/rango-client/commit/5bc83c61100534715c1d8469c15486552e6baeea))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [0.55.1](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.55.0...provider-math-wallet@0.55.1) (2025-11-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.53.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.52.0...provider-math-wallet@0.53.0) (2025-10-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [0.52.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.51.0...provider-math-wallet@0.52.0) (2025-09-29)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [0.51.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.50.0...provider-math-wallet@0.51.0) (2025-09-06)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [0.50.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.49.0...provider-math-wallet@0.50.0) (2025-08-19)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* add rango-dev/wallets-core to dependencies of providers ([84b4b2b](https://github.com/rango-exchange/rango-client/commit/84b4b2b7c3a7f5631228fb6ebf04617c3c4428e9))
|
|
32
|
+
* remove retry dynamic import and throw refined error on dynamic import failure ([a2944ac](https://github.com/rango-exchange/rango-client/commit/a2944ac3c05a0e945f6e5621fa5693ab89625485))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* implement retry mechanism for lazy imports ([9a8e191](https://github.com/rango-exchange/rango-client/commit/9a8e191711d2319990ca4d0613e8188a5f86842f))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [0.49.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.48.0...provider-math-wallet@0.49.0) (2025-08-05)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# [0.48.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.47.0...provider-math-wallet@0.48.0) (2025-07-22)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Reverts
|
|
49
|
+
|
|
50
|
+
* Revert "chore(release): publish" ([064ce15](https://github.com/rango-exchange/rango-client/commit/064ce157a2f819856f647f83aeb1c0410542e8d7))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [0.46.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.45.1...provider-math-wallet@0.46.0) (2025-06-09)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [0.45.1](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.45.0...provider-math-wallet@0.45.1) (2025-05-04)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# [0.45.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.44.0...provider-math-wallet@0.45.0) (2025-04-30)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
* rename pbt to ptb for sui ([3d6d89f](https://github.com/rango-exchange/rango-client/commit/3d6d89f2265766607a15d61e0df92643fb33072b))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
* update sui to consider recent api changes ([d764b25](https://github.com/rango-exchange/rango-client/commit/d764b2501df9bb295f63cdbc0b05acd4a3abb4b9))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# [0.44.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.43.0...provider-math-wallet@0.44.0) (2025-03-11)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# [0.43.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.42.0...provider-math-wallet@0.43.0) (2025-02-23)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# [0.42.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.41.0...provider-math-wallet@0.42.0) (2025-01-20)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# [0.41.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.40.0...provider-math-wallet@0.41.0) (2024-12-30)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# [0.40.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.39.0...provider-math-wallet@0.40.0) (2024-11-27)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
### Features
|
|
96
|
+
|
|
97
|
+
* add ton connect provider ([2a2dbb7](https://github.com/rango-exchange/rango-client/commit/2a2dbb79022263f19446ced49d298e04d63f927f))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
# [0.39.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.38.0...provider-math-wallet@0.39.0) (2024-11-12)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# [0.38.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.37.0...provider-math-wallet@0.38.0) (2024-10-12)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
### Bug Fixes
|
|
109
|
+
|
|
110
|
+
* bump sdk and fix type issues ([d442208](https://github.com/rango-exchange/rango-client/commit/d4422083bf5dd27d5f509ce1db7f9560d05428c8))
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Performance Improvements
|
|
114
|
+
|
|
115
|
+
* enable code splitting in build process ([fe5a41e](https://github.com/rango-exchange/rango-client/commit/fe5a41e0e297298de11cd74ca5825544742aa03a))
|
|
116
|
+
* lazy load signer packages ([7b88f18](https://github.com/rango-exchange/rango-client/commit/7b88f1834f7b29b4b81ab6c81a07bb88e8ccf55c))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# [0.37.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.36.0...provider-math-wallet@0.37.0) (2024-09-10)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# [0.36.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.35.1...provider-math-wallet@0.36.0) (2024-08-11)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## [0.35.1](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.35.0...provider-math-wallet@0.35.1) (2024-07-14)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# [0.35.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.33.2...provider-math-wallet@0.35.0) (2024-07-09)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# [0.34.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.33.2...provider-math-wallet@0.34.0) (2024-06-01)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
## [0.33.2](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.33.1...provider-math-wallet@0.33.2) (2024-05-26)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
## [0.33.1](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.33.0...provider-math-wallet@0.33.1) (2024-05-25)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
# [0.33.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.32.0...provider-math-wallet@0.33.0) (2024-05-14)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# [0.32.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.31.0...provider-math-wallet@0.32.0) (2024-04-24)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
# [0.31.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.30.0...provider-math-wallet@0.31.0) (2024-04-23)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
# [0.30.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.29.0...provider-math-wallet@0.30.0) (2024-04-09)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# [0.29.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.28.0...provider-math-wallet@0.29.0) (2024-03-12)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
# [0.28.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.27.0...provider-math-wallet@0.28.0) (2024-02-20)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### Bug Fixes
|
|
172
|
+
|
|
173
|
+
* fix cosmjs incompatible dependency version problem ([bf76c4c](https://github.com/rango-exchange/rango-client/commit/bf76c4ca19db0f28ceaa83d89982f0972ec730ac))
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
### Features
|
|
177
|
+
|
|
178
|
+
* add cosmos account and signer for math wallet ([e43a489](https://github.com/rango-exchange/rango-client/commit/e43a48936a63804d688f3ad1408244d7f2ff32f2))
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# [0.27.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.26.0...provider-math-wallet@0.27.0) (2024-02-07)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# [0.26.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.25.0...provider-math-wallet@0.26.0) (2024-01-22)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
### Bug Fixes
|
|
190
|
+
|
|
191
|
+
* cleanup wallets' subscriber when setProvider get null ([88d6a42](https://github.com/rango-exchange/rango-client/commit/88d6a423c49b34b3d9ff567e22df36c3b009bb76))
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
# [0.25.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.23.0...provider-math-wallet@0.25.0) (2023-12-24)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### Bug Fixes
|
|
199
|
+
|
|
200
|
+
* fix HMR for widget and playground ([8524820](https://github.com/rango-exchange/rango-client/commit/8524820f10cf0b8921f3db0c4f620ff98daa4103))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# [0.14.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.13.0...provider-math-wallet@0.14.0) (2023-08-03)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
# [0.13.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.12.0...provider-math-wallet@0.13.0) (2023-08-01)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
# [0.9.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.8.0...provider-math-wallet@0.9.0) (2023-07-31)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# [0.7.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.6.0...provider-math-wallet@0.7.0) (2023-07-11)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# [0.6.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.5.0...provider-math-wallet@0.6.0) (2023-07-11)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
### Reverts
|
|
224
|
+
|
|
225
|
+
* Revert "support for rango-types cjs format" ([ed4e050](https://github.com/rango-exchange/rango-client/commit/ed4e050bfc0dcde7aeffa6b0d73b02080a5721eb))
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# [0.5.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.4.0...provider-math-wallet@0.5.0) (2023-05-31)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
# [0.4.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.3.0...provider-math-wallet@0.4.0) (2023-05-31)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
# [0.3.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.2.0...provider-math-wallet@0.3.0) (2023-05-30)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
# [0.2.0](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.1.15...provider-math-wallet@0.2.0) (2023-05-30)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
## [0.1.14](https://github.com/rango-exchange/rango-client/compare/provider-math-wallet@0.1.13...provider-math-wallet@0.1.14) (2023-05-15)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
### Bug Fixes
|
|
249
|
+
|
|
250
|
+
* update rango-types and fix notification bugs ([993f185](https://github.com/rango-exchange/rango-client/commit/993f185e0b8c5e5e15a2c65ba2d85d1f9c8daa90))
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAChD,eAAO,MAAM,QAAQ,EAAE,gBAsCtB,CAAC"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,QAAQ,kEAC8C,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var M=Object.defineProperty;var o=(e,t)=>M(e,"name",{value:t,configurable:!0});import{defineVersions as J}from"@rango-dev/wallets-core/utils";import{ProviderBuilder as U}from"@rango-dev/wallets-core";import"@rango-dev/wallets-core";import{evmBlockchains as L,solanaBlockchain as I}from"rango-types";import{dynamicImportWithRefinedError as p,getNetworkInstance as f,Networks as h}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as T,TransactionType as u}from"rango-types";async function m(e){let t=f(e,h.ETHEREUM),a=f(e,h.SOLANA),l=new T,{DefaultEvmSigner:P}=await p(async()=>await import("@rango-dev/signer-evm")),{DefaultSolanaSigner:y}=await p(async()=>await import("@rango-dev/signer-solana"));return t&&l.registerSigner(u.EVM,new P(t)),a&&l.registerSigner(u.SOLANA,new y(a)),l}o(m,"getSigners");import{LegacyNetworks as i}from"@rango-dev/wallets-core/legacy";function r(){let{solana:e,ethereum:t}=window,a=new Map;return t&&t.isMathWallet&&a.set(i.ETHEREUM,t),e&&e.isMathWallet&&a.set(i.SOLANA,e),a.size===0?null:a}o(r,"mathWallet");function g(){let e=r();if(!e)throw new Error("Math Wallet is not injected. Please check your wallet.");return e}o(g,"getInstanceOrThrow");function c(){let t=r()?.get(i.ETHEREUM);if(!t)throw new Error("Math Wallet not injected or EVM not enabled. Please check your wallet.");return t}o(c,"evmMathWallet");function v(){let t=r()?.get(i.SOLANA);if(!t)throw new Error("Math Wallet not injected or Solana not enabled. Please check your wallet.");return t}o(v,"solanaMathWallet");var n="math",w=1e3,E={name:"Math Wallet",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/math/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc",brave:"https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc",homepage:"https://mathwallet.org/en-us/"},properties:[{name:"namespaces",value:{selection:"single",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:e=>L(e)},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:e=>I(e)}]}},{name:"signers",value:{getSigners:async()=>m(g())}}]};import{NamespaceBuilder as W}from"@rango-dev/wallets-core";import{builders as k,standardizeAndThrowError as N}from"@rango-dev/wallets-core/namespaces/common";import{actions as d,builders as s}from"@rango-dev/wallets-core/namespaces/evm";var x=s.connect().action(d.connect(c)).or(N).build(),B=s.canEagerConnect().action(d.canEagerConnect(c)).build(),C=k.disconnect().build(),_=s.canSwitchNetwork().action(()=>!1).build(),D=s.getChainId().action(d.getChainId(c)).build(),A=new W("EVM",n).action(x).action(C).action(_).action(B).action(D).build();import{NamespaceBuilder as O}from"@rango-dev/wallets-core";import{builders as j,standardizeAndThrowError as H}from"@rango-dev/wallets-core/namespaces/common";import{actions as V,builders as R}from"@rango-dev/wallets-core/namespaces/solana";var z=R.connect().action(V.connect(v)).or(H).build(),F=j.disconnect().build(),b=new O("Solana",n).action(z).action(F).build();var S=o(()=>new U(n).init(function(e){let[,t]=e.state();setTimeout(()=>{r()&&(t("installed",!0),console.debug("[math-wallet] instance detected.",e))},w)}).config("metadata",E).add("solana",b).add("evm",A).build(),"buildProvider");var Te=o(()=>J().version("1.0.0",S()).build(),"versions");export{Te as versions};
|
|
2
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/mod.ts", "../src/provider.ts", "../src/constants.ts", "../src/signer.ts", "../src/utils.ts", "../src/namespaces/evm.ts", "../src/namespaces/solana.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineVersions } from '@rango-dev/wallets-core/utils';\n\nimport { buildProvider } from './provider.js';\n\nconst versions = () =>\n defineVersions().version('1.0.0', buildProvider()).build();\n\nexport { versions };\n", "import { ProviderBuilder } from '@rango-dev/wallets-core';\n\nimport {\n MATH_WALLET_INJECTION_DELAY,\n metadata,\n WALLET_ID,\n} from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { solana } from './namespaces/solana.js';\nimport { mathWallet } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n setTimeout(() => {\n if (mathWallet()) {\n setState('installed', true);\n console.debug('[math-wallet] instance detected.', context);\n }\n }, MATH_WALLET_INJECTION_DELAY);\n })\n .config('metadata', metadata)\n .add('solana', solana)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import { type ProviderMetadata } from '@rango-dev/wallets-core';\nimport {\n type BlockchainMeta,\n evmBlockchains,\n solanaBlockchain,\n} from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'math';\nexport const MATH_WALLET_INJECTION_DELAY = 1000;\nexport const metadata: ProviderMetadata = {\n name: 'Math Wallet',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/math/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc',\n brave:\n 'https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc',\n homepage: 'https://mathwallet.org/en-us/',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'single',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n evmBlockchains(allBlockchains),\n },\n {\n label: 'Solana',\n value: 'Solana',\n id: 'SOLANA',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n solanaBlockchain(allBlockchains),\n },\n ],\n },\n },\n {\n name: 'signers',\n value: { getSigners: async () => getSigners(getInstanceOrThrow()) },\n },\n ],\n};\n", "import type { Provider } from './types.js';\nimport type { SignerFactory } from 'rango-types';\n\nimport {\n dynamicImportWithRefinedError,\n getNetworkInstance,\n Networks,\n} from '@rango-dev/wallets-shared';\nimport { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, Networks.ETHEREUM);\n const solProvider = getNetworkInstance(provider, Networks.SOLANA);\n\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n const { DefaultSolanaSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-solana')\n );\n\n if (!!ethProvider) {\n signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));\n }\n if (!!solProvider) {\n signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(solProvider));\n }\n\n return signers;\n}\n", "import type { Provider } from './types.js';\nimport type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';\nimport type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\n\nexport function mathWallet(): Provider | null {\n const { solana, ethereum } = window;\n const instances: Provider = new Map();\n if (ethereum && ethereum.isMathWallet) {\n instances.set(LegacyNetworks.ETHEREUM, ethereum);\n }\n if (solana && solana.isMathWallet) {\n instances.set(LegacyNetworks.SOLANA, solana);\n }\n if (instances.size === 0) {\n return null;\n }\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = mathWallet();\n\n if (!instances) {\n throw new Error('Math Wallet is not injected. Please check your wallet.');\n }\n\n return instances;\n}\n\nexport function evmMathWallet(): EvmProviderApi {\n const instances = mathWallet();\n\n const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);\n\n if (!evmInstance) {\n throw new Error(\n 'Math Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance as EvmProviderApi;\n}\n\nexport function solanaMathWallet(): SolanaProviderApi {\n const instance = mathWallet();\n const solanaInstance = instance?.get(LegacyNetworks.SOLANA);\n\n if (!solanaInstance) {\n throw new Error(\n 'Math Wallet not injected or Solana not enabled. Please check your wallet.'\n );\n }\n\n return solanaInstance as SolanaProviderApi;\n}\n", "import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { NamespaceBuilder } from '@rango-dev/wallets-core';\nimport {\n builders as commonBuilders,\n standardizeAndThrowError,\n} from '@rango-dev/wallets-core/namespaces/common';\nimport { actions, builders } from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmMathWallet } from '../utils.js';\n\nconst connect = builders\n .connect()\n .action(actions.connect(evmMathWallet))\n .or(standardizeAndThrowError)\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmMathWallet))\n .build();\n\nconst disconnect = commonBuilders.disconnect<EvmActions>().build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n // Math wallet doesn't support switch network.\n .action(() => false)\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmMathWallet))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canSwitchNetwork)\n .action(canEagerConnect)\n .action(getChainId)\n .build();\n\nexport { evm };\n", "import { NamespaceBuilder } from '@rango-dev/wallets-core';\nimport {\n builders as commonBuilders,\n standardizeAndThrowError,\n} from '@rango-dev/wallets-core/namespaces/common';\nimport {\n actions,\n builders,\n type SolanaActions,\n} from '@rango-dev/wallets-core/namespaces/solana';\n\nimport { WALLET_ID } from '../constants.js';\nimport { solanaMathWallet } from '../utils.js';\n\nconst connect = builders\n .connect()\n .action(actions.connect(solanaMathWallet))\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders.disconnect<SolanaActions>().build();\n\nconst solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .build();\n\nexport { solana };\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,kBAAAA,MAAsB,gCCA/B,OAAS,mBAAAC,MAAuB,0BCAhC,MAAsC,0BACtC,OAEE,kBAAAC,EACA,oBAAAC,MACK,cCFP,OACE,iCAAAC,EACA,sBAAAC,EACA,YAAAC,MACK,4BACP,OAAS,wBAAAC,EAAsB,mBAAmBC,MAAc,cAEhE,eAAOC,EACLC,EACwB,CACxB,IAAMC,EAAcC,EAAmBF,EAAUG,EAAS,QAAQ,EAC5DC,EAAcF,EAAmBF,EAAUG,EAAS,MAAM,EAE1DE,EAAU,IAAIC,EACd,CAAE,iBAAAC,CAAiB,EAAI,MAAMC,EACjC,SAAY,KAAM,QAAO,uBAAuB,CAClD,EACM,CAAE,oBAAAC,CAAoB,EAAI,MAAMD,EACpC,SAAY,KAAM,QAAO,0BAA0B,CACrD,EAEA,OAAMP,GACJI,EAAQ,eAAeK,EAAO,IAAK,IAAIH,EAAiBN,CAAW,CAAC,EAEhEG,GACJC,EAAQ,eAAeK,EAAO,OAAQ,IAAID,EAAoBL,CAAW,CAAC,EAGrEC,CACT,CAtB8BM,EAAAZ,EAAA,cCN9B,OAAS,kBAAAa,MAAsB,iCAExB,SAASC,GAA8B,CAC5C,GAAM,CAAE,OAAAC,EAAQ,SAAAC,CAAS,EAAI,OACvBC,EAAsB,IAAI,IAOhC,OANID,GAAYA,EAAS,cACvBC,EAAU,IAAIC,EAAe,SAAUF,CAAQ,EAE7CD,GAAUA,EAAO,cACnBE,EAAU,IAAIC,EAAe,OAAQH,CAAM,EAEzCE,EAAU,OAAS,EACd,KAEFA,CACT,CAbgBE,EAAAL,EAAA,cAeT,SAASM,GAA+B,CAC7C,IAAMH,EAAYH,EAAW,EAE7B,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,wDAAwD,EAG1E,OAAOA,CACT,CARgBE,EAAAC,EAAA,sBAUT,SAASC,GAAgC,CAG9C,IAAMC,EAFYR,EAAW,GAEE,IAAII,EAAe,QAAQ,EAE1D,GAAI,CAACI,EACH,MAAM,IAAI,MACR,wEACF,EAGF,OAAOA,CACT,CAZgBH,EAAAE,EAAA,iBAcT,SAASE,GAAsC,CAEpD,IAAMC,EADWV,EAAW,GACK,IAAII,EAAe,MAAM,EAE1D,GAAI,CAACM,EACH,MAAM,IAAI,MACR,2EACF,EAGF,OAAOA,CACT,CAXgBL,EAAAI,EAAA,oBFnCT,IAAME,EAAY,OACZC,EAA8B,IAC9BC,EAA6B,CACxC,KAAM,cACN,KAAM,qFACN,WAAY,CACV,OACE,yFACF,MACE,yFACF,SAAU,+BACZ,EACA,WAAY,CACV,CACE,KAAM,aACN,MAAO,CACL,UAAW,SACX,KAAM,CACJ,CACE,MAAO,MACP,MAAO,MACP,GAAI,MACJ,mBAAqBC,GACnBC,EAAeD,CAAc,CACjC,EACA,CACE,MAAO,SACP,MAAO,SACP,GAAI,SACJ,mBAAqBA,GACnBE,EAAiBF,CAAc,CACnC,CACF,CACF,CACF,EACA,CACE,KAAM,UACN,MAAO,CAAE,WAAY,SAAYG,EAAWC,EAAmB,CAAC,CAAE,CACpE,CACF,CACF,EGhDA,OAAS,oBAAAC,MAAwB,0BACjC,OACE,YAAYC,EACZ,4BAAAC,MACK,4CACP,OAAS,WAAAC,EAAS,YAAAC,MAAgB,yCAKlC,IAAMC,EAAUC,EACb,QAAQ,EACR,OAAOC,EAAQ,QAAQC,CAAa,CAAC,EACrC,GAAGC,CAAwB,EAC3B,MAAM,EAEHC,EAAkBJ,EACrB,gBAAgB,EAChB,OAAOC,EAAQ,gBAAgBC,CAAa,CAAC,EAC7C,MAAM,EAEHG,EAAaC,EAAe,WAAuB,EAAE,MAAM,EAE3DC,EAAmBP,EACtB,iBAAiB,EAEjB,OAAO,IAAM,EAAK,EAClB,MAAM,EAEHQ,EAAaR,EAChB,WAAW,EACX,OAAOC,EAAQ,WAAWC,CAAa,CAAC,EACxC,MAAM,EAEHO,EAAM,IAAIC,EAA6B,MAAOC,CAAS,EAC1D,OAAOZ,CAAO,EACd,OAAOM,CAAU,EACjB,OAAOE,CAAgB,EACvB,OAAOH,CAAe,EACtB,OAAOI,CAAU,EACjB,MAAM,EC1CT,OAAS,oBAAAI,MAAwB,0BACjC,OACE,YAAYC,EACZ,4BAAAC,MACK,4CACP,OACE,WAAAC,EACA,YAAAC,MAEK,4CAKP,IAAMC,EAAUC,EACb,QAAQ,EACR,OAAOC,EAAQ,QAAQC,CAAgB,CAAC,EACxC,GAAGC,CAAwB,EAC3B,MAAM,EAEHC,EAAaC,EAAe,WAA0B,EAAE,MAAM,EAE9DC,EAAS,IAAIC,EAAgC,SAAUC,CAAS,EACnE,OAAOT,CAAO,EACd,OAAOK,CAAU,EACjB,MAAM,ELdT,IAAMK,EAAgBC,EAAA,IACpB,IAAIC,EAAgBC,CAAS,EAC1B,KAAK,SAAUC,EAAS,CACvB,GAAM,CAAC,CAAEC,CAAQ,EAAID,EAAQ,MAAM,EAEnC,WAAW,IAAM,CACXE,EAAW,IACbD,EAAS,YAAa,EAAI,EAC1B,QAAQ,MAAM,mCAAoCD,CAAO,EAE7D,EAAGG,CAA2B,CAChC,CAAC,EACA,OAAO,WAAYC,CAAQ,EAC3B,IAAI,SAAUC,CAAM,EACpB,IAAI,MAAOC,CAAG,EACd,MAAM,EAfW,iBDPtB,IAAMC,GAAWC,EAAA,IACfC,EAAe,EAAE,QAAQ,QAASC,EAAc,CAAC,EAAE,MAAM,EAD1C",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "evmBlockchains", "solanaBlockchain", "dynamicImportWithRefinedError", "getNetworkInstance", "Networks", "DefaultSignerFactory", "TxType", "getSigners", "provider", "ethProvider", "getNetworkInstance", "Networks", "solProvider", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "dynamicImportWithRefinedError", "DefaultSolanaSigner", "TxType", "__name", "LegacyNetworks", "mathWallet", "solana", "ethereum", "instances", "LegacyNetworks", "__name", "getInstanceOrThrow", "evmMathWallet", "evmInstance", "solanaMathWallet", "solanaInstance", "WALLET_ID", "MATH_WALLET_INJECTION_DELAY", "metadata", "allBlockchains", "evmBlockchains", "solanaBlockchain", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "actions", "builders", "connect", "builders", "actions", "evmMathWallet", "standardizeAndThrowError", "canEagerConnect", "disconnect", "commonBuilders", "canSwitchNetwork", "getChainId", "evm", "NamespaceBuilder", "WALLET_ID", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "actions", "builders", "connect", "builders", "actions", "solanaMathWallet", "standardizeAndThrowError", "disconnect", "commonBuilders", "solana", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "mathWallet", "MATH_WALLET_INJECTION_DELAY", "metadata", "solana", "evm", "versions", "__name", "defineVersions", "buildProvider"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/namespaces/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAoCzE,QAAA,MAAM,GAAG,gEAMC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/namespaces/solana.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,2CAA2C,CAAC;AAanD,QAAA,MAAM,MAAM,mEAGF,CAAC;AAEX,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/signer.ts":{"bytes":1057,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-evm","kind":"dynamic-import","external":true},{"path":"@rango-dev/signer-solana","kind":"dynamic-import","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1577,"imports":[{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/constants.ts":{"bytes":1469,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signer.ts","kind":"import-statement","original":"./signer.js"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils.js"}],"format":"esm"},"src/namespaces/evm.ts":{"bytes":1186,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils.js"}],"format":"esm"},"src/namespaces/solana.ts":{"bytes":725,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/solana","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants.js"},{"path":"src/utils.ts","kind":"import-statement","original":"../utils.js"}],"format":"esm"},"src/provider.ts":{"bytes":762,"imports":[{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants.js"},{"path":"src/namespaces/evm.ts","kind":"import-statement","original":"./namespaces/evm.js"},{"path":"src/namespaces/solana.ts","kind":"import-statement","original":"./namespaces/solana.js"},{"path":"src/utils.ts","kind":"import-statement","original":"./utils.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/mod.ts":{"bytes":220,"imports":[{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"src/provider.ts","kind":"import-statement","original":"./provider.js"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/mod.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":11869},"dist/mod.js":{"imports":[{"path":"@rango-dev/wallets-core/utils","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-evm","kind":"dynamic-import","external":true},{"path":"@rango-dev/signer-solana","kind":"dynamic-import","external":true},{"path":"@rango-dev/wallets-core/legacy","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/evm","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/common","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-core/namespaces/solana","kind":"import-statement","external":true}],"exports":["versions"],"entryPoint":"src/mod.ts","inputs":{"src/mod.ts":{"bytesInOutput":121},"src/provider.ts":{"bytesInOutput":288},"src/constants.ts":{"bytesInOutput":728},"src/signer.ts":{"bytesInOutput":512},"src/utils.ts":{"bytesInOutput":712},"src/namespaces/evm.ts":{"bytesInOutput":544},"src/namespaces/solana.ts":{"bytesInOutput":366}},"bytes":3406}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,aAAa,kDAeP,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AASjD,wBAA8B,UAAU,CACtC,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,aAAa,CAAC,CAoBxB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
|
|
4
|
+
export type OkxBtcAddress = {
|
|
5
|
+
address: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
compressedPublicKey: string;
|
|
8
|
+
};
|
|
9
|
+
export type ProviderObject = {
|
|
10
|
+
[LegacyNetworks.ETHEREUM]: EvmProviderApi;
|
|
11
|
+
[LegacyNetworks.SOLANA]: SolanaProviderApi;
|
|
12
|
+
};
|
|
13
|
+
export type Provider = Map<keyof ProviderObject, ProviderObject[keyof ProviderObject]>;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAElG,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1C,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5C,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,GAAG,CACxB,MAAM,cAAc,EACpB,cAAc,CAAC,MAAM,cAAc,CAAC,CACrC,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Provider } from './types.js';
|
|
2
|
+
import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
|
|
4
|
+
export declare function mathWallet(): Provider | null;
|
|
5
|
+
export declare function getInstanceOrThrow(): Provider;
|
|
6
|
+
export declare function evmMathWallet(): EvmProviderApi;
|
|
7
|
+
export declare function solanaMathWallet(): SolanaProviderApi;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC5F,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAIlG,wBAAgB,UAAU,IAAI,QAAQ,GAAG,IAAI,CAa5C;AAED,wBAAgB,kBAAkB,IAAI,QAAQ,CAQ7C;AAED,wBAAgB,aAAa,IAAI,cAAc,CAY9C;AAED,wBAAgB,gBAAgB,IAAI,iBAAiB,CAWpD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rango-dev/provider-math-wallet",
|
|
3
|
+
"version": "0.0.0-experimental-936229e8-20251208",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"source": "./src/mod.ts",
|
|
7
|
+
"main": "./dist/mod.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/mod.js"
|
|
10
|
+
},
|
|
11
|
+
"typings": "dist/mod.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/provider-math-wallet --splitting --inputs src/mod.ts",
|
|
18
|
+
"ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
|
|
19
|
+
"clean": "rimraf dist",
|
|
20
|
+
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
21
|
+
"lint": "eslint \"**/*.{ts,tsx}\""
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@rango-dev/signer-evm": "^0.40.0",
|
|
25
|
+
"@rango-dev/signer-solana": "^0.46.1",
|
|
26
|
+
"@rango-dev/wallets-core": "^0.0.0-experimental-936229e8-20251208",
|
|
27
|
+
"@rango-dev/wallets-shared": "^0.0.0-experimental-936229e8-20251208",
|
|
28
|
+
"rango-types": "^0.1.89"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# MathWallet
|
|
2
|
+
MathWallet integration for hub.
|
|
3
|
+
[Homepage](https://mathwallet.org/)
|
|
4
|
+
|
|
5
|
+
More about implementation status can be found [here](../readme.md).
|
|
6
|
+
|
|
7
|
+
## Implementation notes/limitations
|
|
8
|
+
|
|
9
|
+
#### ⚠️ Cross Browser
|
|
10
|
+
MathWallet is **only available on Chromium-based browsers**
|
|
11
|
+
(e.g., Chrome, Brave, Edge).
|
|
12
|
+
It is **not supported** on Firefox or Safari.
|
|
13
|
+
|
|
14
|
+
### Feature
|
|
15
|
+
|
|
16
|
+
#### ❌ Auto Connect (Solana)
|
|
17
|
+
MathWallet does **not** provide a silent or eager-connect mechanism for **Solana**.
|
|
18
|
+
A manual approval popup is required each time.
|
|
19
|
+
|
|
20
|
+
#### ❌ Switch Account
|
|
21
|
+
MathWallet does **not offer a functional switch-account mechanism**.
|
|
22
|
+
Account changes inside the wallet **do not notify the dApp**, and the session remains tied to the originally connected account.
|
|
23
|
+
|
|
24
|
+
#### ❌ Switch Network
|
|
25
|
+
MathWallet does **not support programmatic network switching**.
|
|
26
|
+
All network changes must be performed manually within the wallet.
|
|
27
|
+
|
|
28
|
+
#### ⚠️ Single Namespace Limitation
|
|
29
|
+
MathWallet can only maintain **one active namespace connection at a time**.
|
|
30
|
+
Users cannot be simultaneously connected to multiple namespaces (e.g., Solana + EVM).
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
More wallet information can be found in [readme.md](../readme.md).
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ProviderMetadata } from '@rango-dev/wallets-core';
|
|
2
|
+
import {
|
|
3
|
+
type BlockchainMeta,
|
|
4
|
+
evmBlockchains,
|
|
5
|
+
solanaBlockchain,
|
|
6
|
+
} from 'rango-types';
|
|
7
|
+
|
|
8
|
+
import getSigners from './signer.js';
|
|
9
|
+
import { getInstanceOrThrow } from './utils.js';
|
|
10
|
+
|
|
11
|
+
export const WALLET_ID = 'math';
|
|
12
|
+
export const MATH_WALLET_INJECTION_DELAY = 1000;
|
|
13
|
+
export const metadata: ProviderMetadata = {
|
|
14
|
+
name: 'Math Wallet',
|
|
15
|
+
icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/math/icon.svg',
|
|
16
|
+
extensions: {
|
|
17
|
+
chrome:
|
|
18
|
+
'https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc',
|
|
19
|
+
brave:
|
|
20
|
+
'https://chrome.google.com/webstore/detail/math-wallet/afbcbjpbpfadlkmhmclhkeeodmamcflc',
|
|
21
|
+
homepage: 'https://mathwallet.org/en-us/',
|
|
22
|
+
},
|
|
23
|
+
properties: [
|
|
24
|
+
{
|
|
25
|
+
name: 'namespaces',
|
|
26
|
+
value: {
|
|
27
|
+
selection: 'single',
|
|
28
|
+
data: [
|
|
29
|
+
{
|
|
30
|
+
label: 'EVM',
|
|
31
|
+
value: 'EVM',
|
|
32
|
+
id: 'ETH',
|
|
33
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
34
|
+
evmBlockchains(allBlockchains),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: 'Solana',
|
|
38
|
+
value: 'Solana',
|
|
39
|
+
id: 'SOLANA',
|
|
40
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
41
|
+
solanaBlockchain(allBlockchains),
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'signers',
|
|
48
|
+
value: { getSigners: async () => getSigners(getInstanceOrThrow()) },
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
package/src/mod.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EvmActions } from '@rango-dev/wallets-core/namespaces/evm';
|
|
2
|
+
|
|
3
|
+
import { NamespaceBuilder } from '@rango-dev/wallets-core';
|
|
4
|
+
import {
|
|
5
|
+
builders as commonBuilders,
|
|
6
|
+
standardizeAndThrowError,
|
|
7
|
+
} from '@rango-dev/wallets-core/namespaces/common';
|
|
8
|
+
import { actions, builders } from '@rango-dev/wallets-core/namespaces/evm';
|
|
9
|
+
|
|
10
|
+
import { WALLET_ID } from '../constants.js';
|
|
11
|
+
import { evmMathWallet } from '../utils.js';
|
|
12
|
+
|
|
13
|
+
const connect = builders
|
|
14
|
+
.connect()
|
|
15
|
+
.action(actions.connect(evmMathWallet))
|
|
16
|
+
.or(standardizeAndThrowError)
|
|
17
|
+
.build();
|
|
18
|
+
|
|
19
|
+
const canEagerConnect = builders
|
|
20
|
+
.canEagerConnect()
|
|
21
|
+
.action(actions.canEagerConnect(evmMathWallet))
|
|
22
|
+
.build();
|
|
23
|
+
|
|
24
|
+
const disconnect = commonBuilders.disconnect<EvmActions>().build();
|
|
25
|
+
|
|
26
|
+
const canSwitchNetwork = builders
|
|
27
|
+
.canSwitchNetwork()
|
|
28
|
+
// Math wallet doesn't support switch network.
|
|
29
|
+
.action(() => false)
|
|
30
|
+
.build();
|
|
31
|
+
|
|
32
|
+
const getChainId = builders
|
|
33
|
+
.getChainId()
|
|
34
|
+
.action(actions.getChainId(evmMathWallet))
|
|
35
|
+
.build();
|
|
36
|
+
|
|
37
|
+
const evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)
|
|
38
|
+
.action(connect)
|
|
39
|
+
.action(disconnect)
|
|
40
|
+
.action(canSwitchNetwork)
|
|
41
|
+
.action(canEagerConnect)
|
|
42
|
+
.action(getChainId)
|
|
43
|
+
.build();
|
|
44
|
+
|
|
45
|
+
export { evm };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NamespaceBuilder } from '@rango-dev/wallets-core';
|
|
2
|
+
import {
|
|
3
|
+
builders as commonBuilders,
|
|
4
|
+
standardizeAndThrowError,
|
|
5
|
+
} from '@rango-dev/wallets-core/namespaces/common';
|
|
6
|
+
import {
|
|
7
|
+
actions,
|
|
8
|
+
builders,
|
|
9
|
+
type SolanaActions,
|
|
10
|
+
} from '@rango-dev/wallets-core/namespaces/solana';
|
|
11
|
+
|
|
12
|
+
import { WALLET_ID } from '../constants.js';
|
|
13
|
+
import { solanaMathWallet } from '../utils.js';
|
|
14
|
+
|
|
15
|
+
const connect = builders
|
|
16
|
+
.connect()
|
|
17
|
+
.action(actions.connect(solanaMathWallet))
|
|
18
|
+
.or(standardizeAndThrowError)
|
|
19
|
+
.build();
|
|
20
|
+
|
|
21
|
+
const disconnect = commonBuilders.disconnect<SolanaActions>().build();
|
|
22
|
+
|
|
23
|
+
const solana = new NamespaceBuilder<SolanaActions>('Solana', WALLET_ID)
|
|
24
|
+
.action(connect)
|
|
25
|
+
.action(disconnect)
|
|
26
|
+
.build();
|
|
27
|
+
|
|
28
|
+
export { solana };
|
package/src/provider.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProviderBuilder } from '@rango-dev/wallets-core';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MATH_WALLET_INJECTION_DELAY,
|
|
5
|
+
metadata,
|
|
6
|
+
WALLET_ID,
|
|
7
|
+
} from './constants.js';
|
|
8
|
+
import { evm } from './namespaces/evm.js';
|
|
9
|
+
import { solana } from './namespaces/solana.js';
|
|
10
|
+
import { mathWallet } from './utils.js';
|
|
11
|
+
|
|
12
|
+
const buildProvider = () =>
|
|
13
|
+
new ProviderBuilder(WALLET_ID)
|
|
14
|
+
.init(function (context) {
|
|
15
|
+
const [, setState] = context.state();
|
|
16
|
+
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
if (mathWallet()) {
|
|
19
|
+
setState('installed', true);
|
|
20
|
+
console.debug('[math-wallet] instance detected.', context);
|
|
21
|
+
}
|
|
22
|
+
}, MATH_WALLET_INJECTION_DELAY);
|
|
23
|
+
})
|
|
24
|
+
.config('metadata', metadata)
|
|
25
|
+
.add('solana', solana)
|
|
26
|
+
.add('evm', evm)
|
|
27
|
+
.build();
|
|
28
|
+
|
|
29
|
+
export { buildProvider };
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Provider } from './types.js';
|
|
2
|
+
import type { SignerFactory } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
dynamicImportWithRefinedError,
|
|
6
|
+
getNetworkInstance,
|
|
7
|
+
Networks,
|
|
8
|
+
} from '@rango-dev/wallets-shared';
|
|
9
|
+
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
10
|
+
|
|
11
|
+
export default async function getSigners(
|
|
12
|
+
provider: Provider
|
|
13
|
+
): Promise<SignerFactory> {
|
|
14
|
+
const ethProvider = getNetworkInstance(provider, Networks.ETHEREUM);
|
|
15
|
+
const solProvider = getNetworkInstance(provider, Networks.SOLANA);
|
|
16
|
+
|
|
17
|
+
const signers = new DefaultSignerFactory();
|
|
18
|
+
const { DefaultEvmSigner } = await dynamicImportWithRefinedError(
|
|
19
|
+
async () => await import('@rango-dev/signer-evm')
|
|
20
|
+
);
|
|
21
|
+
const { DefaultSolanaSigner } = await dynamicImportWithRefinedError(
|
|
22
|
+
async () => await import('@rango-dev/signer-solana')
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (!!ethProvider) {
|
|
26
|
+
signers.registerSigner(TxType.EVM, new DefaultEvmSigner(ethProvider));
|
|
27
|
+
}
|
|
28
|
+
if (!!solProvider) {
|
|
29
|
+
signers.registerSigner(TxType.SOLANA, new DefaultSolanaSigner(solProvider));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return signers;
|
|
33
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
|
|
4
|
+
|
|
5
|
+
export type OkxBtcAddress = {
|
|
6
|
+
address: string;
|
|
7
|
+
publicKey: string;
|
|
8
|
+
compressedPublicKey: string;
|
|
9
|
+
};
|
|
10
|
+
export type ProviderObject = {
|
|
11
|
+
[LegacyNetworks.ETHEREUM]: EvmProviderApi;
|
|
12
|
+
[LegacyNetworks.SOLANA]: SolanaProviderApi;
|
|
13
|
+
};
|
|
14
|
+
export type Provider = Map<
|
|
15
|
+
keyof ProviderObject,
|
|
16
|
+
ProviderObject[keyof ProviderObject]
|
|
17
|
+
>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Provider } from './types.js';
|
|
2
|
+
import type { ProviderAPI as EvmProviderApi } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
import type { ProviderAPI as SolanaProviderApi } from '@rango-dev/wallets-core/namespaces/solana';
|
|
4
|
+
|
|
5
|
+
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
6
|
+
|
|
7
|
+
export function mathWallet(): Provider | null {
|
|
8
|
+
const { solana, ethereum } = window;
|
|
9
|
+
const instances: Provider = new Map();
|
|
10
|
+
if (ethereum && ethereum.isMathWallet) {
|
|
11
|
+
instances.set(LegacyNetworks.ETHEREUM, ethereum);
|
|
12
|
+
}
|
|
13
|
+
if (solana && solana.isMathWallet) {
|
|
14
|
+
instances.set(LegacyNetworks.SOLANA, solana);
|
|
15
|
+
}
|
|
16
|
+
if (instances.size === 0) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return instances;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getInstanceOrThrow(): Provider {
|
|
23
|
+
const instances = mathWallet();
|
|
24
|
+
|
|
25
|
+
if (!instances) {
|
|
26
|
+
throw new Error('Math Wallet is not injected. Please check your wallet.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return instances;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function evmMathWallet(): EvmProviderApi {
|
|
33
|
+
const instances = mathWallet();
|
|
34
|
+
|
|
35
|
+
const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);
|
|
36
|
+
|
|
37
|
+
if (!evmInstance) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
'Math Wallet not injected or EVM not enabled. Please check your wallet.'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return evmInstance as EvmProviderApi;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function solanaMathWallet(): SolanaProviderApi {
|
|
47
|
+
const instance = mathWallet();
|
|
48
|
+
const solanaInstance = instance?.get(LegacyNetworks.SOLANA);
|
|
49
|
+
|
|
50
|
+
if (!solanaInstance) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
'Math Wallet not injected or Solana not enabled. Please check your wallet.'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return solanaInstance as SolanaProviderApi;
|
|
57
|
+
}
|