@rango-dev/wallets-react 0.26.1-next.2 → 0.26.1-next.4

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 CHANGED
@@ -1,3 +1,7 @@
1
+ # [0.27.0](https://github.com/rango-exchange/rango-client/compare/wallets-react@0.26.0...wallets-react@0.27.0) (2024-12-30)
2
+
3
+
4
+
1
5
  # [0.26.0](https://github.com/rango-exchange/rango-client/compare/wallets-react@0.25.0...wallets-react@0.26.0) (2024-11-27)
2
6
 
3
7
 
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Detecting wether our code is running in a test environment or not.
3
+ *
4
+ * Note: This is only useful when HappyDOM or jsdom has been added to test runner.
5
+ */
6
+ export declare function isRunningInTestEnvironmentWithDom(): boolean;
7
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/test-utils/env.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iCAAiC,IAAI,OAAO,CAE3D"}
@@ -0,0 +1,14 @@
1
+ import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
2
+ import type { BlockchainMeta, GenericSigner } from 'rango-types';
3
+ import type { EvmTransaction } from 'rango-types/mainApi';
4
+ export declare const legacyAddress = "0x000000000000000000000000000000000000dead";
5
+ export declare class MockEvmSigner implements GenericSigner<EvmTransaction> {
6
+ signMessage(_msg: string, _address: string, _chainId: string | null): Promise<string>;
7
+ signAndSendTx(_tx: EvmTransaction, _address: string, _chainId: string | null): Promise<{
8
+ hash: string;
9
+ response?: any;
10
+ }>;
11
+ }
12
+ export declare const legacyProvider: LegacyProviderInterface;
13
+ export declare const blockchainsMeta: BlockchainMeta[];
14
+ //# sourceMappingURL=fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/test-utils/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D,eAAO,MAAM,aAAa,+CAA+C,CAAC;AAE1E,qBAAa,aAAc,YAAW,aAAa,CAAC,cAAc,CAAC;IAC3D,WAAW,CACf,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC,MAAM,CAAC;IAGZ,aAAa,CACjB,GAAG,EAAE,cAAc,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;CAK7C;AAED,eAAO,MAAM,cAAc,EAAE,uBA0C5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,cAAc,EAsK3C,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@rango-dev/wallets-react",
3
- "version": "0.26.1-next.2",
3
+ "version": "0.26.1-next.4",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./dist/index.js",
8
8
  "exports": {
9
- ".": "./dist/index.js"
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
10
13
  },
11
- "typings": "dist/index.d.ts",
12
14
  "files": [
13
15
  "dist",
14
16
  "src"
@@ -18,7 +20,9 @@
18
20
  "ts-check": "tsc --declaration --emitDeclarationOnly -p ./tsconfig.json",
19
21
  "clean": "rimraf dist",
20
22
  "format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
21
- "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
23
+ "lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore",
24
+ "test": "vitest",
25
+ "coverage": "vitest run --coverage"
22
26
  },
23
27
  "peerDependencies": {
24
28
  "@types/react": "^17.0.0 || ^18.0.0",
@@ -26,10 +30,14 @@
26
30
  "react-dom": "^17.0.0 || ^18.0.0"
27
31
  },
28
32
  "dependencies": {
29
- "@rango-dev/wallets-core": "^0.40.1-next.2",
30
- "@rango-dev/wallets-shared": "^0.40.1-next.2",
33
+ "@rango-dev/wallets-core": "^0.40.1-next.3",
34
+ "@rango-dev/wallets-shared": "^0.40.1-next.3",
31
35
  "rango-types": "^0.1.74"
32
36
  },
37
+ "devDependencies": {
38
+ "@types/react": "^18.0.25",
39
+ "@types/react-dom": "^18.0.25"
40
+ },
33
41
  "publishConfig": {
34
42
  "access": "public"
35
43
  }
@@ -0,0 +1,10 @@
1
+ const TEST_ENVIRONMENT_AGENT = 'HappyDOM/0.0.0';
2
+
3
+ /**
4
+ * Detecting wether our code is running in a test environment or not.
5
+ *
6
+ * Note: This is only useful when HappyDOM or jsdom has been added to test runner.
7
+ */
8
+ export function isRunningInTestEnvironmentWithDom(): boolean {
9
+ return navigator.userAgent.includes(TEST_ENVIRONMENT_AGENT);
10
+ }
@@ -0,0 +1,238 @@
1
+ import type { LegacyProviderInterface } from '@rango-dev/wallets-core/legacy';
2
+ import type { BlockchainMeta, GenericSigner } from 'rango-types';
3
+ import type { EvmTransaction } from 'rango-types/mainApi';
4
+
5
+ import { DefaultSignerFactory, TransactionType } from 'rango-types';
6
+
7
+ export const legacyAddress = '0x000000000000000000000000000000000000dead';
8
+
9
+ export class MockEvmSigner implements GenericSigner<EvmTransaction> {
10
+ async signMessage(
11
+ _msg: string,
12
+ _address: string,
13
+ _chainId: string | null
14
+ ): Promise<string> {
15
+ return '0x';
16
+ }
17
+ async signAndSendTx(
18
+ _tx: EvmTransaction,
19
+ _address: string,
20
+ _chainId: string | null
21
+ ): Promise<{ hash: string; response?: any }> {
22
+ return {
23
+ hash: '0x',
24
+ };
25
+ }
26
+ }
27
+
28
+ export const legacyProvider: LegacyProviderInterface = {
29
+ config: {
30
+ type: 'legacy-garbage',
31
+ },
32
+ async connect({ network }) {
33
+ // we added a timeout to simulate requesting to extension for connection.
34
+ return await new Promise((resolve, reject) => {
35
+ setTimeout(() => {
36
+ // This is useful for simulating error scenarios.
37
+ if (network === 'When Airdrop?') {
38
+ reject(
39
+ 'please stay tuned we shall announce the detailed information soon.'
40
+ );
41
+ } else {
42
+ resolve([
43
+ {
44
+ accounts: [legacyAddress],
45
+ chainId: network || '',
46
+ },
47
+ ]);
48
+ }
49
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
50
+ }, 10);
51
+ });
52
+ },
53
+ getInstance() {
54
+ return {};
55
+ },
56
+ async getSigners() {
57
+ const signers = new DefaultSignerFactory();
58
+ signers.registerSigner(TransactionType.EVM, new MockEvmSigner());
59
+ return signers;
60
+ },
61
+ getWalletInfo() {
62
+ return {
63
+ name: 'legacy garbage wallet',
64
+ color: '#000',
65
+ img: 'https://...',
66
+ installLink: 'https://...',
67
+ supportedChains: [],
68
+ };
69
+ },
70
+ };
71
+
72
+ export const blockchainsMeta: BlockchainMeta[] = [
73
+ {
74
+ name: 'BTC',
75
+ defaultDecimals: 8,
76
+ addressPatterns: [
77
+ '^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$',
78
+ ],
79
+ feeAssets: [
80
+ {
81
+ blockchain: 'BTC',
82
+ symbol: 'BTC',
83
+ address: null,
84
+ },
85
+ ],
86
+ logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/BTC/icon.svg',
87
+ displayName: 'Bitcoin',
88
+ shortName: 'BTC',
89
+ sort: 12,
90
+ color: '#F7931A',
91
+ enabled: true,
92
+ type: TransactionType.TRANSFER,
93
+ chainId: null,
94
+ info: {
95
+ infoType: 'TransferMetaInfo',
96
+ blockExplorerUrls: ['https://www.blockchain.com/btc/'],
97
+ addressUrl: 'https://www.blockchain.com/btc/address/{wallet}',
98
+ transactionUrl: 'https://www.blockchain.com/btc/tx/{txHash}',
99
+ },
100
+ },
101
+ {
102
+ name: 'ETH',
103
+ defaultDecimals: 18,
104
+ addressPatterns: ['^(0x)[0-9A-Fa-f]{40}$'],
105
+ feeAssets: [
106
+ {
107
+ blockchain: 'ETH',
108
+ symbol: 'ETH',
109
+ address: null,
110
+ },
111
+ ],
112
+ logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/ETH/icon.svg',
113
+ displayName: 'Ethereum',
114
+ shortName: 'ETH',
115
+ sort: 0,
116
+ color: '#ecf0f1',
117
+ enabled: true,
118
+ type: TransactionType.EVM,
119
+ chainId: '0x1',
120
+ info: {
121
+ infoType: 'EvmMetaInfo',
122
+ chainName: 'Ethereum Mainnet',
123
+ nativeCurrency: {
124
+ name: 'ETH',
125
+ symbol: 'ETH',
126
+ decimals: 18,
127
+ },
128
+ rpcUrls: ['https://rpc.ankr.com/eth'],
129
+ blockExplorerUrls: ['https://etherscan.io'],
130
+ addressUrl: 'https://etherscan.io/address/{wallet}',
131
+ transactionUrl: 'https://etherscan.io/tx/{txHash}',
132
+ enableGasV2: true,
133
+ },
134
+ },
135
+ {
136
+ name: 'SOLANA',
137
+ defaultDecimals: 9,
138
+ addressPatterns: ['^[1-9A-HJ-NP-Za-km-z]{32,44}$'],
139
+ feeAssets: [
140
+ {
141
+ blockchain: 'SOLANA',
142
+ symbol: 'SOL',
143
+ address: null,
144
+ },
145
+ ],
146
+ logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/SOLANA/icon.svg',
147
+ displayName: 'Solana',
148
+ shortName: 'Solana',
149
+ sort: 20,
150
+ color: '#708DD2',
151
+ enabled: true,
152
+ type: TransactionType.SOLANA,
153
+ chainId: 'mainnet-beta',
154
+ info: {
155
+ infoType: 'SolanaMetaInfo',
156
+ blockExplorerUrls: ['https://solscan.io/'],
157
+ addressUrl: 'https://solscan.io/account/{wallet}',
158
+ transactionUrl: 'https://solscan.io/tx/{txHash}',
159
+ },
160
+ },
161
+ {
162
+ name: 'COSMOS',
163
+ defaultDecimals: 6,
164
+ addressPatterns: ['^(cosmos1)[0-9a-z]{38}$'],
165
+ feeAssets: [
166
+ {
167
+ blockchain: 'COSMOS',
168
+ symbol: 'ATOM',
169
+ address: null,
170
+ },
171
+ ],
172
+ logo: 'https://raw.githubusercontent.com/rango-exchange/assets/main/blockchains/COSMOS/icon.svg',
173
+ displayName: 'Cosmos',
174
+ shortName: 'Cosmos',
175
+ sort: 15,
176
+ color: '#2E3148',
177
+ enabled: true,
178
+ type: TransactionType.COSMOS,
179
+ chainId: 'cosmoshub-4',
180
+ info: {
181
+ infoType: 'CosmosMetaInfo',
182
+ experimental: false,
183
+ rpc: 'https://cosmos-rpc.polkachu.com',
184
+ rest: 'https://lcd-cosmoshub.blockapsis.com',
185
+ cosmostationLcdUrl: 'https://lcd-cosmoshub.blockapsis.com',
186
+ cosmostationApiUrl: 'https://cosmos-rpc.polkachu.com',
187
+ cosmostationDenomTracePath: '/ibc/apps/transfer/v1/denom_traces/',
188
+ mintScanName: 'cosmos',
189
+ chainName: 'Cosmos',
190
+ stakeCurrency: {
191
+ coinDenom: 'ATOM',
192
+ coinMinimalDenom: 'uatom',
193
+ coinDecimals: 6,
194
+ coinGeckoId: 'cosmos',
195
+ coinImageUrl: '/tokens/blockchain/cosmos.svg',
196
+ },
197
+ bip44: {
198
+ coinType: 118,
199
+ },
200
+ bech32Config: {
201
+ bech32PrefixAccAddr: 'cosmos',
202
+ bech32PrefixAccPub: 'cosmospub',
203
+ bech32PrefixValAddr: 'cosmosvaloper',
204
+ bech32PrefixValPub: 'cosmosvaloperpub',
205
+ bech32PrefixConsAddr: 'cosmosvalcons',
206
+ bech32PrefixConsPub: 'cosmosvalconspub',
207
+ },
208
+ currencies: [
209
+ {
210
+ coinDenom: 'ATOM',
211
+ coinMinimalDenom: 'uatom',
212
+ coinDecimals: 6,
213
+ coinGeckoId: 'cosmos',
214
+ coinImageUrl: '/tokens/blockchain/cosmos.svg',
215
+ },
216
+ ],
217
+ feeCurrencies: [
218
+ {
219
+ coinDenom: 'ATOM',
220
+ coinMinimalDenom: 'uatom',
221
+ coinDecimals: 6,
222
+ coinGeckoId: 'cosmos',
223
+ coinImageUrl: '/tokens/blockchain/cosmos.svg',
224
+ },
225
+ ],
226
+ features: ['stargate', 'ibc-transfer'],
227
+ explorerUrlToTx: 'https://www.mintscan.io/cosmos/txs/{txHash}',
228
+ gasPriceStep: {
229
+ low: 0.01,
230
+ average: 0.025,
231
+ high: 0.04,
232
+ },
233
+ blockExplorerUrls: ['https://www.mintscan.io/cosmos/'],
234
+ addressUrl: 'https://www.mintscan.io/cosmos/account/{wallet}',
235
+ transactionUrl: 'https://www.mintscan.io/cosmos/txs/{txHash}',
236
+ },
237
+ },
238
+ ];