@meshconnect/uwc-types 0.20.0 → 0.22.0-snapshot.56a9011
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/dist/UWC-state.d.ts +8 -0
- package/dist/UWC-state.d.ts.map +1 -1
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +8 -0
- package/dist/errors.js.map +1 -1
- package/package.json +1 -1
- package/src/UWC-state.ts +8 -0
- package/src/errors.test.ts +62 -0
- package/src/errors.ts +17 -0
package/dist/UWC-state.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export interface DetectedSolanaWalletInfo {
|
|
|
13
13
|
uuid: string;
|
|
14
14
|
name: string;
|
|
15
15
|
features: string[];
|
|
16
|
+
/**
|
|
17
|
+
* True when this wallet was discovered via the legacy injected-Solana fallback
|
|
18
|
+
* (a `window[injectedId]` global, e.g. Coinbase/Base Wallet's `coinbaseSolana`)
|
|
19
|
+
* rather than the Wallet Standard registry (MFS-805). Absent/false for registry
|
|
20
|
+
* wallets. Telemetry-only signal so a dashboard can confirm the legacy path was
|
|
21
|
+
* exercised — never a wallet id or address.
|
|
22
|
+
*/
|
|
23
|
+
legacyInjected?: boolean;
|
|
16
24
|
}
|
|
17
25
|
export interface DetectedTronWalletInfo {
|
|
18
26
|
uuid: string;
|
package/dist/UWC-state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UWC-state.d.ts","sourceRoot":"","sources":["../src/UWC-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,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WAAW,qBAAqB;IACpC,mBAAmB,EAAE,SAAS,EAAE,CAAA;IAChC,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAA;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,iBAAiB,CAAC,EAAE,YAAY,CAAA;QAChC,gDAAgD;QAChD,wBAAwB,CAAC,EAAE,YAAY,CAAA;QACvC,gDAAgD;QAChD,oBAAoB,CAAC,EAAE,YAAY,CAAA;KACpC,CAAA;CACF;AAED,yEAAyE;AACzE,MAAM,WAAW,wBAAwB;IACvC,mBAAmB,EAAE,SAAS,EAAE,CAAA;IAChC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,4EAA4E;AAC5E,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAA;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;CAC/B;AAGD,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACrD,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,CAAA;IACX,yBAAyB,CAAC,EAAE,yBAAyB,CAAA;IACrD,iCAAiC,CAAC,EAAE,iCAAiC,CAAA;IACrE,qBAAqB,CAAC,EAAE,qBAAqB,CAAA;IAC7C,kBAAkB,CAAC,EAAE,wBAAwB,CAAA;CAC9C"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ export type ErrorType = 'unknown' | 'rejected' | 'expired';
|
|
|
2
2
|
export interface WalletError {
|
|
3
3
|
type: ErrorType;
|
|
4
4
|
message: string;
|
|
5
|
+
/**
|
|
6
|
+
* EIP-1193 / JSON-RPC numeric error code from the underlying provider error,
|
|
7
|
+
* when present. Numeric-only by design so no free-form data reaches structured
|
|
8
|
+
* telemetry; lets `classifyError` place errors from their code (e.g. `-32002` →
|
|
9
|
+
* `provider_error`) without inferring anything from the message.
|
|
10
|
+
*/
|
|
11
|
+
code?: number;
|
|
5
12
|
}
|
|
6
13
|
/**
|
|
7
14
|
* Custom error class that includes wallet error metadata
|
|
@@ -9,6 +16,8 @@ export interface WalletError {
|
|
|
9
16
|
*/
|
|
10
17
|
export declare class WalletConnectorError extends Error {
|
|
11
18
|
type: ErrorType;
|
|
19
|
+
/** See {@link WalletError.code}. Set only when the source error had a numeric code. */
|
|
20
|
+
code?: number;
|
|
12
21
|
constructor(walletError: WalletError);
|
|
13
22
|
}
|
|
14
23
|
/**
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAE1D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;AAE1D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,IAAI,EAAE,SAAS,CAAA;IACf,uFAAuF;IACvF,IAAI,CAAC,EAAE,MAAM,CAAA;gBAED,WAAW,EAAE,WAAW;CAarC;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,oBAAoB;IAC5D,mDAAmD;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;IACnC,kDAAkD;IAClD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAA;gBAE3B,gBAAgB,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,MAAM,EAAE;CAUvE"}
|
package/dist/errors.js
CHANGED
|
@@ -4,10 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export class WalletConnectorError extends Error {
|
|
6
6
|
type;
|
|
7
|
+
/** See {@link WalletError.code}. Set only when the source error had a numeric code. */
|
|
8
|
+
code;
|
|
7
9
|
constructor(walletError) {
|
|
8
10
|
super(walletError.message);
|
|
9
11
|
this.name = 'WalletConnectorError';
|
|
10
12
|
this.type = walletError.type;
|
|
13
|
+
// Finite-integer guard: a stray string/undefined/NaN/Infinity/float never
|
|
14
|
+
// reaches the code slot telemetry treats as a structural signal.
|
|
15
|
+
if (typeof walletError.code === 'number' &&
|
|
16
|
+
Number.isInteger(walletError.code)) {
|
|
17
|
+
this.code = walletError.code;
|
|
18
|
+
}
|
|
11
19
|
}
|
|
12
20
|
}
|
|
13
21
|
/**
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,IAAI,CAAW;IACf,uFAAuF;IACvF,IAAI,CAAS;IAEb,YAAY,WAAwB;QAClC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;QAC5B,0EAA0E;QAC1E,iEAAiE;QACjE,IACE,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ;YACpC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,EAClC,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;QAC9B,CAAC;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAqB,SAAQ,oBAAoB;IAC5D,mDAAmD;IAC1C,gBAAgB,CAAU;IACnC,kDAAkD;IACzC,oBAAoB,CAAU;IAEvC,YAAY,gBAA0B,EAAE,oBAA8B;QACpE,KAAK,CAAC;YACJ,IAAI,EAAE,SAAS;YACf,OAAO,EACL,0EAA0E;SAC7E,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;QAClC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAA;IAClD,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/UWC-state.ts
CHANGED
|
@@ -16,6 +16,14 @@ export interface DetectedSolanaWalletInfo {
|
|
|
16
16
|
uuid: string
|
|
17
17
|
name: string
|
|
18
18
|
features: string[]
|
|
19
|
+
/**
|
|
20
|
+
* True when this wallet was discovered via the legacy injected-Solana fallback
|
|
21
|
+
* (a `window[injectedId]` global, e.g. Coinbase/Base Wallet's `coinbaseSolana`)
|
|
22
|
+
* rather than the Wallet Standard registry (MFS-805). Absent/false for registry
|
|
23
|
+
* wallets. Telemetry-only signal so a dashboard can confirm the legacy path was
|
|
24
|
+
* exercised — never a wallet id or address.
|
|
25
|
+
*/
|
|
26
|
+
legacyInjected?: boolean
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
export interface DetectedTronWalletInfo {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { WalletConnectorError, NoCommonNetworkError } from './errors'
|
|
3
|
+
|
|
4
|
+
describe('WalletConnectorError', () => {
|
|
5
|
+
it('preserves a numeric EIP-1193 code (MFS-667)', () => {
|
|
6
|
+
const err = new WalletConnectorError({
|
|
7
|
+
type: 'unknown',
|
|
8
|
+
message: 'already pending',
|
|
9
|
+
code: -32002
|
|
10
|
+
})
|
|
11
|
+
expect(err.code).toBe(-32002)
|
|
12
|
+
expect(err.type).toBe('unknown')
|
|
13
|
+
expect(err.message).toBe('already pending')
|
|
14
|
+
expect(err).toBeInstanceOf(Error)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('omits code when none is provided', () => {
|
|
18
|
+
const err = new WalletConnectorError({ type: 'rejected', message: 'no' })
|
|
19
|
+
expect(err.code).toBeUndefined()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('ignores a non-numeric code so the structural slot never carries free-form data', () => {
|
|
23
|
+
// The `code` field feeds telemetry as a structural signal; a wrapper that
|
|
24
|
+
// passes a string/NaN must not smuggle it onto the numeric slot.
|
|
25
|
+
const err = new WalletConnectorError({
|
|
26
|
+
type: 'unknown',
|
|
27
|
+
message: 'x',
|
|
28
|
+
// @ts-expect-error — a wallet-controlled value may be the wrong type at runtime
|
|
29
|
+
code: 'ACTION_REJECTED'
|
|
30
|
+
})
|
|
31
|
+
expect(err.code).toBeUndefined()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('rejects non-integer numeric codes (NaN / Infinity / float)', () => {
|
|
35
|
+
// A wallet controls `code`; only a finite integer is a valid JSON-RPC/EIP-1193
|
|
36
|
+
// code, so NaN/Infinity/floats must not flip the classifier's hasNumericCode.
|
|
37
|
+
for (const code of [NaN, Infinity, -Infinity, 1.5]) {
|
|
38
|
+
const err = new WalletConnectorError({
|
|
39
|
+
type: 'unknown',
|
|
40
|
+
message: 'x',
|
|
41
|
+
code
|
|
42
|
+
})
|
|
43
|
+
expect(err.code).toBeUndefined()
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('keeps a valid negative integer code (e.g. -32002)', () => {
|
|
48
|
+
const err = new WalletConnectorError({
|
|
49
|
+
type: 'unknown',
|
|
50
|
+
message: 'x',
|
|
51
|
+
code: -32002
|
|
52
|
+
})
|
|
53
|
+
expect(err.code).toBe(-32002)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('NoCommonNetworkError carries no code and keeps its id lists', () => {
|
|
57
|
+
const err = new NoCommonNetworkError(['eip155:1'], ['solana:101'])
|
|
58
|
+
expect(err.code).toBeUndefined()
|
|
59
|
+
expect(err.walletNetworkIds).toEqual(['eip155:1'])
|
|
60
|
+
expect(err.configuredNetworkIds).toEqual(['solana:101'])
|
|
61
|
+
})
|
|
62
|
+
})
|
package/src/errors.ts
CHANGED
|
@@ -3,6 +3,13 @@ export type ErrorType = 'unknown' | 'rejected' | 'expired'
|
|
|
3
3
|
export interface WalletError {
|
|
4
4
|
type: ErrorType
|
|
5
5
|
message: string
|
|
6
|
+
/**
|
|
7
|
+
* EIP-1193 / JSON-RPC numeric error code from the underlying provider error,
|
|
8
|
+
* when present. Numeric-only by design so no free-form data reaches structured
|
|
9
|
+
* telemetry; lets `classifyError` place errors from their code (e.g. `-32002` →
|
|
10
|
+
* `provider_error`) without inferring anything from the message.
|
|
11
|
+
*/
|
|
12
|
+
code?: number
|
|
6
13
|
}
|
|
7
14
|
|
|
8
15
|
/**
|
|
@@ -11,11 +18,21 @@ export interface WalletError {
|
|
|
11
18
|
*/
|
|
12
19
|
export class WalletConnectorError extends Error {
|
|
13
20
|
type: ErrorType
|
|
21
|
+
/** See {@link WalletError.code}. Set only when the source error had a numeric code. */
|
|
22
|
+
code?: number
|
|
14
23
|
|
|
15
24
|
constructor(walletError: WalletError) {
|
|
16
25
|
super(walletError.message)
|
|
17
26
|
this.name = 'WalletConnectorError'
|
|
18
27
|
this.type = walletError.type
|
|
28
|
+
// Finite-integer guard: a stray string/undefined/NaN/Infinity/float never
|
|
29
|
+
// reaches the code slot telemetry treats as a structural signal.
|
|
30
|
+
if (
|
|
31
|
+
typeof walletError.code === 'number' &&
|
|
32
|
+
Number.isInteger(walletError.code)
|
|
33
|
+
) {
|
|
34
|
+
this.code = walletError.code
|
|
35
|
+
}
|
|
19
36
|
}
|
|
20
37
|
}
|
|
21
38
|
|