@rango-dev/provider-tokenpocket 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 +228 -0
- package/dist/constants.d.ts +4 -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/provider-tokenpocket.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 +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +32 -0
- package/readme.md +24 -0
- package/src/constants.ts +39 -0
- package/src/mod.ts +8 -0
- package/src/namespaces/evm.ts +55 -0
- package/src/provider.ts +21 -0
- package/src/signer.ts +24 -0
- package/src/types.ts +10 -0
- package/src/utils.ts +42 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# [0.55.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.54.1...provider-tokenpocket@0.55.0) (2025-12-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* migrate token-pocket to the hub ([d0c4d00](https://github.com/rango-exchange/rango-client/commit/d0c4d00df5c3a31bdf0aa27553771e462b2a75ad))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [0.54.1](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.54.0...provider-tokenpocket@0.54.1) (2025-11-22)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.52.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.51.0...provider-tokenpocket@0.52.0) (2025-10-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [0.51.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.50.0...provider-tokenpocket@0.51.0) (2025-09-29)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [0.50.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.49.0...provider-tokenpocket@0.50.0) (2025-09-06)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [0.49.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.48.0...provider-tokenpocket@0.49.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.48.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.47.0...provider-tokenpocket@0.48.0) (2025-08-05)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# [0.47.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.46.0...provider-tokenpocket@0.47.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.45.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.44.1...provider-tokenpocket@0.45.0) (2025-06-09)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [0.44.1](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.44.0...provider-tokenpocket@0.44.1) (2025-05-04)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# [0.44.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.43.0...provider-tokenpocket@0.44.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.43.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.42.0...provider-tokenpocket@0.43.0) (2025-03-11)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# [0.42.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.41.0...provider-tokenpocket@0.42.0) (2025-02-23)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
# [0.41.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.40.0...provider-tokenpocket@0.41.0) (2024-12-30)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# [0.40.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.39.0...provider-tokenpocket@0.40.0) (2024-11-27)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
# [0.39.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.38.0...provider-tokenpocket@0.39.0) (2024-11-12)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# [0.38.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.37.0...provider-tokenpocket@0.38.0) (2024-10-12)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
* bump sdk and fix type issues ([d442208](https://github.com/rango-exchange/rango-client/commit/d4422083bf5dd27d5f509ce1db7f9560d05428c8))
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Performance Improvements
|
|
105
|
+
|
|
106
|
+
* lazy load signer packages ([7b88f18](https://github.com/rango-exchange/rango-client/commit/7b88f1834f7b29b4b81ab6c81a07bb88e8ccf55c))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
# [0.37.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.36.0...provider-tokenpocket@0.37.0) (2024-09-10)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
# [0.36.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.35.1...provider-tokenpocket@0.36.0) (2024-08-11)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## [0.35.1](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.35.0...provider-tokenpocket@0.35.1) (2024-07-14)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# [0.35.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.33.2...provider-tokenpocket@0.35.0) (2024-07-09)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# [0.34.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.33.2...provider-tokenpocket@0.34.0) (2024-06-01)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## [0.33.2](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.33.1...provider-tokenpocket@0.33.2) (2024-05-26)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## [0.33.1](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.33.0...provider-tokenpocket@0.33.1) (2024-05-25)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# [0.33.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.32.0...provider-tokenpocket@0.33.0) (2024-05-14)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
# [0.32.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.31.0...provider-tokenpocket@0.32.0) (2024-04-24)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
# [0.31.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.30.0...provider-tokenpocket@0.31.0) (2024-04-23)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# [0.30.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.29.0...provider-tokenpocket@0.30.0) (2024-04-09)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# [0.29.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.28.0...provider-tokenpocket@0.29.0) (2024-03-12)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# [0.28.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.27.0...provider-tokenpocket@0.28.0) (2024-02-20)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
# [0.27.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.26.0...provider-tokenpocket@0.27.0) (2024-02-07)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# [0.26.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.25.0...provider-tokenpocket@0.26.0) (2024-01-22)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# [0.25.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.23.0...provider-tokenpocket@0.25.0) (2023-12-24)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
### Bug Fixes
|
|
174
|
+
|
|
175
|
+
* fix HMR for widget and playground ([8524820](https://github.com/rango-exchange/rango-client/commit/8524820f10cf0b8921f3db0c4f620ff98daa4103))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# [0.14.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.13.0...provider-tokenpocket@0.14.0) (2023-08-03)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
# [0.13.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.12.0...provider-tokenpocket@0.13.0) (2023-08-01)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# [0.9.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.8.0...provider-tokenpocket@0.9.0) (2023-07-31)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
# [0.7.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.6.0...provider-tokenpocket@0.7.0) (2023-07-11)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
# [0.6.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.5.0...provider-tokenpocket@0.6.0) (2023-07-11)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### Reverts
|
|
199
|
+
|
|
200
|
+
* Revert "support for rango-types cjs format" ([ed4e050](https://github.com/rango-exchange/rango-client/commit/ed4e050bfc0dcde7aeffa6b0d73b02080a5721eb))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
# [0.5.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.4.0...provider-tokenpocket@0.5.0) (2023-05-31)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
# [0.4.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.3.0...provider-tokenpocket@0.4.0) (2023-05-31)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
# [0.3.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.2.0...provider-tokenpocket@0.3.0) (2023-05-30)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# [0.2.0](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.1.15...provider-tokenpocket@0.2.0) (2023-05-30)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## [0.1.14](https://github.com/rango-exchange/rango-client/compare/provider-tokenpocket@0.1.13...provider-tokenpocket@0.1.14) (2023-05-15)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
### Bug Fixes
|
|
224
|
+
|
|
225
|
+
* update rango-types and fix notification bugs ([993f185](https://github.com/rango-exchange/rango-client/commit/993f185e0b8c5e5e15a2c65ba2d85d1f9c8daa90))
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
@@ -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;AAMhE,eAAO,MAAM,SAAS,iBAAiB,CAAC;AACxC,eAAO,MAAM,QAAQ,EAAE,gBA+BtB,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 h=Object.defineProperty;var t=(e,o)=>h(e,"name",{value:o,configurable:!0});import{defineVersions as V}from"@rango-dev/wallets-core/utils";import{ProviderBuilder as B}from"@rango-dev/wallets-core";import"@rango-dev/wallets-core";import{evmBlockchains as y}from"rango-types";import{dynamicImportWithRefinedError as w,getNetworkInstance as v,Networks as E}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as P,TransactionType as b}from"rango-types";async function m(e){let o=v(e,E.ETHEREUM),n=new P,{DefaultEvmSigner:k}=await w(async()=>await import("@rango-dev/signer-evm"));return n.registerSigner(b.EVM,new k(o)),n}t(m,"getSigners");import{LegacyNetworks as p}from"@rango-dev/wallets-core/legacy";function i(){let{tokenpocket:e}=window,o=e?.ethereum;if(!o)return null;let n=new Map;return n.set(p.ETHEREUM,o),n}t(i,"tokenPocket");function d(){let e=i();if(!e)throw new Error("TokenPocket Wallet is not injected. Please check your wallet.");return e}t(d,"getInstanceOrThrow");function r(){let o=i()?.get(p.ETHEREUM);if(!o)throw new Error("TokenPocket Wallet not injected or EVM not enabled. Please check your wallet.");return o}t(r,"evmTokenPocket");var c="token-pocket",l={name:"Token Pocket",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/tokenpocket/icon.svg",extensions:{chrome:"https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii",brave:"https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii",homepage:"https://www.tokenpocket.pro/en/download/app"},properties:[{name:"namespaces",value:{selection:"multiple",data:[{label:"EVM",value:"EVM",id:"ETH",getSupportedChains:e=>y(e)}]}},{name:"signers",value:{getSigners:async()=>m(d())}}]};import{NamespaceBuilder as T}from"@rango-dev/wallets-core";import{builders as S,standardizeAndThrowError as I}from"@rango-dev/wallets-core/namespaces/common";import{actions as a,builders as s,hooks as M}from"@rango-dev/wallets-core/namespaces/evm";var[A,u]=M.changeAccountSubscriber(r),x=s.connect().action(a.connect(r)).before(A).or(u).or(I).build(),C=S.disconnect().after(u).build(),L=s.canSwitchNetwork().action(a.canSwitchNetwork()).build(),N=s.canEagerConnect().action(a.canEagerConnect(r)).build(),j=s.getChainId().action(a.getChainId(r)).build(),f=new T("EVM",c).action(x).action(C).action(N).action(L).action(j).build();var g=t(()=>new B(c).init(function(e){let[,o]=e.state();i()&&(o("installed",!0),console.debug("[token-pocket] instance detected.",e))}).config("metadata",l).add("evm",f).build(),"buildProvider");var me=t(()=>V().version("1.0.0",g()).build(),"versions");export{me 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"],
|
|
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 { metadata, WALLET_ID } from './constants.js';\nimport { evm } from './namespaces/evm.js';\nimport { tokenPocket } from './utils.js';\n\nconst buildProvider = () =>\n new ProviderBuilder(WALLET_ID)\n .init(function (context) {\n const [, setState] = context.state();\n\n if (tokenPocket()) {\n setState('installed', true);\n console.debug('[token-pocket] instance detected.', context);\n }\n })\n .config('metadata', metadata)\n .add('evm', evm)\n .build();\n\nexport { buildProvider };\n", "import { type ProviderMetadata } from '@rango-dev/wallets-core';\nimport { type BlockchainMeta, evmBlockchains } from 'rango-types';\n\nimport getSigners from './signer.js';\nimport { getInstanceOrThrow } from './utils.js';\n\nexport const WALLET_ID = 'token-pocket';\nexport const metadata: ProviderMetadata = {\n name: 'Token Pocket',\n icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/tokenpocket/icon.svg',\n extensions: {\n chrome:\n 'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',\n brave:\n 'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',\n homepage: 'https://www.tokenpocket.pro/en/download/app',\n },\n properties: [\n {\n name: 'namespaces',\n value: {\n selection: 'multiple',\n data: [\n {\n label: 'EVM',\n value: 'EVM',\n id: 'ETH',\n getSupportedChains: (allBlockchains: BlockchainMeta[]) =>\n evmBlockchains(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 } from 'rango-types';\n\nexport default async function getSigners(\n provider: Provider\n): Promise<SignerFactory> {\n const ethProvider = getNetworkInstance(provider, Networks.ETHEREUM);\n const signers = new DefaultSignerFactory();\n const { DefaultEvmSigner } = await dynamicImportWithRefinedError(\n async () => await import('@rango-dev/signer-evm')\n );\n signers.registerSigner(\n TransactionType.EVM,\n new DefaultEvmSigner(ethProvider)\n );\n return signers;\n}\n", "import type { Provider } from './types.js';\nimport type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { LegacyNetworks } from '@rango-dev/wallets-core/legacy';\n\nexport function tokenPocket(): Provider | null {\n const { tokenpocket } = window;\n const ethereum = tokenpocket?.ethereum;\n if (!ethereum) {\n return null;\n }\n const instances: Provider = new Map();\n instances.set(LegacyNetworks.ETHEREUM, ethereum);\n\n return instances;\n}\n\nexport function getInstanceOrThrow(): Provider {\n const instances = tokenPocket();\n\n if (!instances) {\n throw new Error(\n 'TokenPocket Wallet is not injected. Please check your wallet.'\n );\n }\n\n return instances;\n}\n\nexport function evmTokenPocket(): ProviderAPI {\n const instances = tokenPocket();\n\n const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);\n\n if (!evmInstance) {\n throw new Error(\n 'TokenPocket Wallet not injected or EVM not enabled. Please check your wallet.'\n );\n }\n\n return evmInstance;\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 {\n actions,\n builders,\n hooks,\n} from '@rango-dev/wallets-core/namespaces/evm';\n\nimport { WALLET_ID } from '../constants.js';\nimport { evmTokenPocket } from '../utils.js';\n\nconst [changeAccountSubscriber, changeAccountCleanup] =\n hooks.changeAccountSubscriber(evmTokenPocket);\nconst connect = builders\n .connect()\n .action(actions.connect(evmTokenPocket))\n .before(changeAccountSubscriber)\n .or(changeAccountCleanup)\n .or(standardizeAndThrowError)\n .build();\n\nconst disconnect = commonBuilders\n .disconnect<EvmActions>()\n .after(changeAccountCleanup)\n .build();\n\nconst canSwitchNetwork = builders\n .canSwitchNetwork()\n .action(actions.canSwitchNetwork())\n .build();\n\nconst canEagerConnect = builders\n .canEagerConnect()\n .action(actions.canEagerConnect(evmTokenPocket))\n .build();\n\nconst getChainId = builders\n .getChainId()\n .action(actions.getChainId(evmTokenPocket))\n .build();\n\nconst evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)\n .action(connect)\n .action(disconnect)\n .action(canEagerConnect)\n .action(canSwitchNetwork)\n .action(getChainId)\n .build();\n\nexport { evm };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["defineVersions", "ProviderBuilder", "evmBlockchains", "dynamicImportWithRefinedError", "getNetworkInstance", "Networks", "DefaultSignerFactory", "TransactionType", "getSigners", "provider", "ethProvider", "getNetworkInstance", "Networks", "signers", "DefaultSignerFactory", "DefaultEvmSigner", "dynamicImportWithRefinedError", "TransactionType", "__name", "LegacyNetworks", "tokenPocket", "tokenpocket", "ethereum", "instances", "LegacyNetworks", "__name", "getInstanceOrThrow", "evmTokenPocket", "evmInstance", "WALLET_ID", "metadata", "allBlockchains", "evmBlockchains", "getSigners", "getInstanceOrThrow", "NamespaceBuilder", "commonBuilders", "standardizeAndThrowError", "actions", "builders", "hooks", "changeAccountSubscriber", "changeAccountCleanup", "hooks", "evmTokenPocket", "connect", "builders", "actions", "standardizeAndThrowError", "disconnect", "commonBuilders", "canSwitchNetwork", "canEagerConnect", "getChainId", "evm", "NamespaceBuilder", "WALLET_ID", "buildProvider", "__name", "ProviderBuilder", "WALLET_ID", "context", "setState", "tokenPocket", "metadata", "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;AA8CzE,QAAA,MAAM,GAAG,gEAMC,CAAC;AAEX,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/signer.ts":{"bytes":726,"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":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/utils.ts":{"bytes":1012,"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":1200,"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":1375,"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/provider.ts":{"bytes":581,"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/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":8871},"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/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}],"exports":["versions"],"entryPoint":"src/mod.ts","inputs":{"src/mod.ts":{"bytesInOutput":121},"src/provider.ts":{"bytesInOutput":253},"src/constants.ts":{"bytesInOutput":661},"src/signer.ts":{"bytesInOutput":371},"src/utils.ts":{"bytesInOutput":516},"src/namespaces/evm.ts":{"bytesInOutput":628}},"bytes":2685}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,aAAa,kDAYP,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,CAWxB"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
export type ProviderObject = {
|
|
4
|
+
[LegacyNetworks.ETHEREUM]: ProviderAPI;
|
|
5
|
+
};
|
|
6
|
+
export type Provider = Map<keyof ProviderObject, ProviderObject[keyof ProviderObject]>;
|
|
7
|
+
//# 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,EAAE,MAAM,wCAAwC,CAAC;AAE1E,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxC,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,6 @@
|
|
|
1
|
+
import type { Provider } from './types.js';
|
|
2
|
+
import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
export declare function tokenPocket(): Provider | null;
|
|
4
|
+
export declare function getInstanceOrThrow(): Provider;
|
|
5
|
+
export declare function evmTokenPocket(): ProviderAPI;
|
|
6
|
+
//# 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,EAAE,MAAM,wCAAwC,CAAC;AAI1E,wBAAgB,WAAW,IAAI,QAAQ,GAAG,IAAI,CAU7C;AAED,wBAAgB,kBAAkB,IAAI,QAAQ,CAU7C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAY5C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rango-dev/provider-tokenpocket",
|
|
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-tokenpocket --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/wallets-core": "^0.0.0-experimental-936229e8-20251208",
|
|
26
|
+
"@rango-dev/wallets-shared": "^0.0.0-experimental-936229e8-20251208",
|
|
27
|
+
"rango-types": "^0.1.89"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# TokenPocket
|
|
2
|
+
TokenPocket integration for hub.
|
|
3
|
+
[Homepage](https://www.tokenpocket.pro/) | [Docs](https://help.tokenpocket.pro/en/)
|
|
4
|
+
|
|
5
|
+
More about implementation status can be found [here](../readme.md).
|
|
6
|
+
|
|
7
|
+
## Implementation notes/limitations
|
|
8
|
+
|
|
9
|
+
### Group
|
|
10
|
+
|
|
11
|
+
TokenPocket does not introduce any group-related limitations in the current integration.
|
|
12
|
+
|
|
13
|
+
### Feature
|
|
14
|
+
|
|
15
|
+
#### ⚠️ Cross Browser
|
|
16
|
+
TokenPocket is **only available on Chromium-based browsers**
|
|
17
|
+
(e.g., Chrome, Brave, Edge).
|
|
18
|
+
It is **not supported** on Firefox or Safari.
|
|
19
|
+
|
|
20
|
+
All other supported features—connect, auto connect, account retrieval, network handling, and signing—work without known issues.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
More wallet information can be found in [readme.md](../readme.md).
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ProviderMetadata } from '@rango-dev/wallets-core';
|
|
2
|
+
import { type BlockchainMeta, evmBlockchains } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import getSigners from './signer.js';
|
|
5
|
+
import { getInstanceOrThrow } from './utils.js';
|
|
6
|
+
|
|
7
|
+
export const WALLET_ID = 'token-pocket';
|
|
8
|
+
export const metadata: ProviderMetadata = {
|
|
9
|
+
name: 'Token Pocket',
|
|
10
|
+
icon: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/tokenpocket/icon.svg',
|
|
11
|
+
extensions: {
|
|
12
|
+
chrome:
|
|
13
|
+
'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',
|
|
14
|
+
brave:
|
|
15
|
+
'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',
|
|
16
|
+
homepage: 'https://www.tokenpocket.pro/en/download/app',
|
|
17
|
+
},
|
|
18
|
+
properties: [
|
|
19
|
+
{
|
|
20
|
+
name: 'namespaces',
|
|
21
|
+
value: {
|
|
22
|
+
selection: 'multiple',
|
|
23
|
+
data: [
|
|
24
|
+
{
|
|
25
|
+
label: 'EVM',
|
|
26
|
+
value: 'EVM',
|
|
27
|
+
id: 'ETH',
|
|
28
|
+
getSupportedChains: (allBlockchains: BlockchainMeta[]) =>
|
|
29
|
+
evmBlockchains(allBlockchains),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'signers',
|
|
36
|
+
value: { getSigners: async () => getSigners(getInstanceOrThrow()) },
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
package/src/mod.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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 {
|
|
9
|
+
actions,
|
|
10
|
+
builders,
|
|
11
|
+
hooks,
|
|
12
|
+
} from '@rango-dev/wallets-core/namespaces/evm';
|
|
13
|
+
|
|
14
|
+
import { WALLET_ID } from '../constants.js';
|
|
15
|
+
import { evmTokenPocket } from '../utils.js';
|
|
16
|
+
|
|
17
|
+
const [changeAccountSubscriber, changeAccountCleanup] =
|
|
18
|
+
hooks.changeAccountSubscriber(evmTokenPocket);
|
|
19
|
+
const connect = builders
|
|
20
|
+
.connect()
|
|
21
|
+
.action(actions.connect(evmTokenPocket))
|
|
22
|
+
.before(changeAccountSubscriber)
|
|
23
|
+
.or(changeAccountCleanup)
|
|
24
|
+
.or(standardizeAndThrowError)
|
|
25
|
+
.build();
|
|
26
|
+
|
|
27
|
+
const disconnect = commonBuilders
|
|
28
|
+
.disconnect<EvmActions>()
|
|
29
|
+
.after(changeAccountCleanup)
|
|
30
|
+
.build();
|
|
31
|
+
|
|
32
|
+
const canSwitchNetwork = builders
|
|
33
|
+
.canSwitchNetwork()
|
|
34
|
+
.action(actions.canSwitchNetwork())
|
|
35
|
+
.build();
|
|
36
|
+
|
|
37
|
+
const canEagerConnect = builders
|
|
38
|
+
.canEagerConnect()
|
|
39
|
+
.action(actions.canEagerConnect(evmTokenPocket))
|
|
40
|
+
.build();
|
|
41
|
+
|
|
42
|
+
const getChainId = builders
|
|
43
|
+
.getChainId()
|
|
44
|
+
.action(actions.getChainId(evmTokenPocket))
|
|
45
|
+
.build();
|
|
46
|
+
|
|
47
|
+
const evm = new NamespaceBuilder<EvmActions>('EVM', WALLET_ID)
|
|
48
|
+
.action(connect)
|
|
49
|
+
.action(disconnect)
|
|
50
|
+
.action(canEagerConnect)
|
|
51
|
+
.action(canSwitchNetwork)
|
|
52
|
+
.action(getChainId)
|
|
53
|
+
.build();
|
|
54
|
+
|
|
55
|
+
export { evm };
|
package/src/provider.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ProviderBuilder } from '@rango-dev/wallets-core';
|
|
2
|
+
|
|
3
|
+
import { metadata, WALLET_ID } from './constants.js';
|
|
4
|
+
import { evm } from './namespaces/evm.js';
|
|
5
|
+
import { tokenPocket } from './utils.js';
|
|
6
|
+
|
|
7
|
+
const buildProvider = () =>
|
|
8
|
+
new ProviderBuilder(WALLET_ID)
|
|
9
|
+
.init(function (context) {
|
|
10
|
+
const [, setState] = context.state();
|
|
11
|
+
|
|
12
|
+
if (tokenPocket()) {
|
|
13
|
+
setState('installed', true);
|
|
14
|
+
console.debug('[token-pocket] instance detected.', context);
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
.config('metadata', metadata)
|
|
18
|
+
.add('evm', evm)
|
|
19
|
+
.build();
|
|
20
|
+
|
|
21
|
+
export { buildProvider };
|
package/src/signer.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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 } 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 signers = new DefaultSignerFactory();
|
|
16
|
+
const { DefaultEvmSigner } = await dynamicImportWithRefinedError(
|
|
17
|
+
async () => await import('@rango-dev/signer-evm')
|
|
18
|
+
);
|
|
19
|
+
signers.registerSigner(
|
|
20
|
+
TransactionType.EVM,
|
|
21
|
+
new DefaultEvmSigner(ethProvider)
|
|
22
|
+
);
|
|
23
|
+
return signers;
|
|
24
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
2
|
+
import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
|
|
4
|
+
export type ProviderObject = {
|
|
5
|
+
[LegacyNetworks.ETHEREUM]: ProviderAPI;
|
|
6
|
+
};
|
|
7
|
+
export type Provider = Map<
|
|
8
|
+
keyof ProviderObject,
|
|
9
|
+
ProviderObject[keyof ProviderObject]
|
|
10
|
+
>;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Provider } from './types.js';
|
|
2
|
+
import type { ProviderAPI } from '@rango-dev/wallets-core/namespaces/evm';
|
|
3
|
+
|
|
4
|
+
import { LegacyNetworks } from '@rango-dev/wallets-core/legacy';
|
|
5
|
+
|
|
6
|
+
export function tokenPocket(): Provider | null {
|
|
7
|
+
const { tokenpocket } = window;
|
|
8
|
+
const ethereum = tokenpocket?.ethereum;
|
|
9
|
+
if (!ethereum) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const instances: Provider = new Map();
|
|
13
|
+
instances.set(LegacyNetworks.ETHEREUM, ethereum);
|
|
14
|
+
|
|
15
|
+
return instances;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getInstanceOrThrow(): Provider {
|
|
19
|
+
const instances = tokenPocket();
|
|
20
|
+
|
|
21
|
+
if (!instances) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'TokenPocket Wallet is not injected. Please check your wallet.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return instances;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function evmTokenPocket(): ProviderAPI {
|
|
31
|
+
const instances = tokenPocket();
|
|
32
|
+
|
|
33
|
+
const evmInstance = instances?.get(LegacyNetworks.ETHEREUM);
|
|
34
|
+
|
|
35
|
+
if (!evmInstance) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
'TokenPocket Wallet not injected or EVM not enabled. Please check your wallet.'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return evmInstance;
|
|
42
|
+
}
|