@xyo-network/react-chain-model 1.15.27 → 1.16.0

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.
@@ -1,3 +1,2 @@
1
- export * from './provider/index.ts';
2
1
  export * from './types/index.ts';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -1,30 +1,16 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
- // src/provider/xyoProvider.ts
5
- var hasXyoWalletInjectable = /* @__PURE__ */ __name(() => {
6
- return "xyo" in globalThis && "walletExtensionId" in globalThis.xyo;
7
- }, "hasXyoWalletInjectable");
8
- var hasXyoWalletProvider = /* @__PURE__ */ __name(() => {
9
- return hasXyoWalletInjectable() && "provider" in globalThis.xyo;
10
- }, "hasXyoWalletProvider");
11
- function getXyoProvider(options) {
12
- const { assert } = options ?? {};
13
- if (hasXyoWalletProvider()) {
14
- return globalThis.xyo.provider;
15
- } else {
16
- console.error("XYO Wallet not installed");
17
- if (assert) {
18
- throw new Error("XYO Wallet not installed");
19
- } else {
20
- return void 0;
21
- }
22
- }
23
- }
24
- __name(getXyoProvider, "getXyoProvider");
4
+ // src/types/XyoGlobal.ts
5
+ import { isDefinedNotNull, isObject } from "@xylabs/typeof";
6
+ var isXyoGlobal = /* @__PURE__ */ __name((obj) => {
7
+ return isDefinedNotNull(obj) && isObject(obj) && "client" in obj && "connections" in obj && "errors" in obj && "sessionId" in obj && "walletExtensionId" in obj;
8
+ }, "isXyoGlobal");
9
+ var isUninitializedXyoGlobal = /* @__PURE__ */ __name((obj) => {
10
+ return isDefinedNotNull(obj) && isObject(obj) && "connections" in obj && "sessionId" in obj && "walletExtensionId" in obj && !("client" in obj) && "errors" in obj && Array.isArray(obj.errors) && obj.errors.length === 0;
11
+ }, "isUninitializedXyoGlobal");
25
12
  export {
26
- getXyoProvider,
27
- hasXyoWalletInjectable,
28
- hasXyoWalletProvider
13
+ isUninitializedXyoGlobal,
14
+ isXyoGlobal
29
15
  };
30
16
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/provider/xyoProvider.ts"],"sourcesContent":["import type { XyoConnection } from '@xyo-network/xl1-protocol'\n\nimport type { XyoGlobal } from '../types/index.ts'\n\ndeclare global {\n interface Window {\n xyo: XyoGlobal\n }\n\n var xyo: XyoGlobal\n var xyoWalletExtensionId: string\n}\n\nexport const hasXyoWalletInjectable = () => {\n return 'xyo' in globalThis && 'walletExtensionId' in globalThis.xyo\n}\n\nexport const hasXyoWalletProvider = () => {\n return hasXyoWalletInjectable() && 'provider' in globalThis.xyo\n}\n\nexport function getXyoProvider(options: { assert: true }): XyoConnection\nexport function getXyoProvider(options?: { assert?: boolean }): XyoConnection | undefined {\n const { assert } = options ?? {}\n if (hasXyoWalletProvider()) {\n return globalThis.xyo.provider\n } else {\n console.error('XYO Wallet not installed')\n if (assert) {\n throw new Error('XYO Wallet not installed')\n } else {\n return undefined\n }\n }\n}\n"],"mappings":";;;;AAaO,IAAMA,yBAAyB,6BAAA;AACpC,SAAO,SAASC,cAAc,uBAAuBA,WAAWC;AAClE,GAFsC;AAI/B,IAAMC,uBAAuB,6BAAA;AAClC,SAAOH,uBAAAA,KAA4B,cAAcC,WAAWC;AAC9D,GAFoC;AAK7B,SAASE,eAAeC,SAA8B;AAC3D,QAAM,EAAEC,OAAM,IAAKD,WAAW,CAAC;AAC/B,MAAIF,qBAAAA,GAAwB;AAC1B,WAAOF,WAAWC,IAAIK;EACxB,OAAO;AACLC,YAAQC,MAAM,0BAAA;AACd,QAAIH,QAAQ;AACV,YAAM,IAAII,MAAM,0BAAA;IAClB,OAAO;AACL,aAAOC;IACT;EACF;AACF;AAZgBP;","names":["hasXyoWalletInjectable","globalThis","xyo","hasXyoWalletProvider","getXyoProvider","options","assert","provider","console","error","Error","undefined"]}
1
+ {"version":3,"sources":["../../src/types/XyoGlobal.ts"],"sourcesContent":["import { isDefinedNotNull, isObject } from '@xylabs/typeof'\nimport type { NetworkBootstrap } from '@xyo-network/xl1-network-model'\nimport type { NetworkId } from '@xyo-network/xl1-protocol'\nimport type { XyoClient } from '@xyo-network/xl1-protocol-sdk'\n\nexport interface XyoGlobal extends UninitializedXyoGlobal {\n client: XyoClient\n errors: Error[]\n}\n\n/**\n * Describes the initial state of the global XYO object before initialization\n * (i.e. before the client is initialized)\n */\nexport interface UninitializedXyoGlobal {\n connections: Record<NetworkId, NetworkBootstrap>\n sessionId: () => string\n walletExtensionId: () => string\n}\n\nexport const isXyoGlobal = (obj: unknown): obj is XyoGlobal => {\n return (\n isDefinedNotNull(obj)\n && isObject(obj)\n && 'client' in obj\n && 'connections' in obj\n && 'errors' in obj\n && 'sessionId' in obj\n && 'walletExtensionId' in obj\n )\n}\n\nexport const isUninitializedXyoGlobal = (obj: unknown): obj is UninitializedXyoGlobal => {\n return (\n isDefinedNotNull(obj)\n && isObject(obj)\n && 'connections' in obj\n && 'sessionId' in obj\n && 'walletExtensionId' in obj\n && !('client' in obj)\n && ('errors' in obj)\n && Array.isArray((obj).errors)\n && obj.errors.length === 0\n )\n}\n"],"mappings":";;;;AAAA,SAASA,kBAAkBC,gBAAgB;AAoBpC,IAAMC,cAAc,wBAACC,QAAAA;AAC1B,SACEC,iBAAiBD,GAAAA,KACdE,SAASF,GAAAA,KACT,YAAYA,OACZ,iBAAiBA,OACjB,YAAYA,OACZ,eAAeA,OACf,uBAAuBA;AAE9B,GAV2B;AAYpB,IAAMG,2BAA2B,wBAACH,QAAAA;AACvC,SACEC,iBAAiBD,GAAAA,KACdE,SAASF,GAAAA,KACT,iBAAiBA,OACjB,eAAeA,OACf,uBAAuBA,OACvB,EAAE,YAAYA,QACb,YAAYA,OACbI,MAAMC,QAASL,IAAKM,MAAM,KAC1BN,IAAIM,OAAOC,WAAW;AAE7B,GAZwC;","names":["isDefinedNotNull","isObject","isXyoGlobal","obj","isDefinedNotNull","isObject","isUninitializedXyoGlobal","Array","isArray","errors","length"]}
@@ -1,17 +1,19 @@
1
- import type { ChainConnection } from '@xyo-network/chain-network-model';
2
- import type { XyoClient, XyoConnection, XyoGatewayProvider } from '@xyo-network/xl1-protocol';
3
- export interface XyoGlobal {
4
- client?: XyoClient;
5
- /** @deprecated - use client gateways instead */
6
- connections: {
7
- [chainId: string]: ChainConnection;
8
- };
9
- errors?: Error[];
10
- gateway?: XyoGatewayProvider;
11
- /** @deprecated - use client gateways instead */
12
- provider?: XyoConnection;
1
+ import type { NetworkBootstrap } from '@xyo-network/xl1-network-model';
2
+ import type { NetworkId } from '@xyo-network/xl1-protocol';
3
+ import type { XyoClient } from '@xyo-network/xl1-protocol-sdk';
4
+ export interface XyoGlobal extends UninitializedXyoGlobal {
5
+ client: XyoClient;
6
+ errors: Error[];
7
+ }
8
+ /**
9
+ * Describes the initial state of the global XYO object before initialization
10
+ * (i.e. before the client is initialized)
11
+ */
12
+ export interface UninitializedXyoGlobal {
13
+ connections: Record<NetworkId, NetworkBootstrap>;
13
14
  sessionId: () => string;
14
- /** @deprecated - use session id instead */
15
15
  walletExtensionId: () => string;
16
16
  }
17
+ export declare const isXyoGlobal: (obj: unknown) => obj is XyoGlobal;
18
+ export declare const isUninitializedXyoGlobal: (obj: unknown) => obj is UninitializedXyoGlobal;
17
19
  //# sourceMappingURL=XyoGlobal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XyoGlobal.d.ts","sourceRoot":"","sources":["../../../src/types/XyoGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EACV,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAC7C,MAAM,2BAA2B,CAAA;AAGlC,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,gDAAgD;IAChD,WAAW,EAAE;QAEX,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAA;KACnC,CAAA;IACD,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,OAAO,CAAC,EAAE,kBAAkB,CAAA;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,2CAA2C;IAC3C,iBAAiB,EAAE,MAAM,MAAM,CAAA;CAChC"}
1
+ {"version":3,"file":"XyoGlobal.d.ts","sourceRoot":"","sources":["../../../src/types/XyoGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAE9D,MAAM,WAAW,SAAU,SAAQ,sBAAsB;IACvD,MAAM,EAAE,SAAS,CAAA;IACjB,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAChD,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,MAAM,CAAA;CAChC;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,SAUjD,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,sBAY9D,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/react-chain-model",
4
- "version": "1.15.27",
4
+ "version": "1.16.0",
5
5
  "description": "XYO Layer One React SDK Stake",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -41,15 +41,17 @@
41
41
  "src"
42
42
  ],
43
43
  "dependencies": {
44
- "@xyo-network/chain-network-model": "~1.15.27",
45
- "@xyo-network/xl1-protocol": "~1.12.95"
44
+ "@xylabs/typeof": "~5.0.19",
45
+ "@xyo-network/xl1-network-model": "~1.16.0",
46
+ "@xyo-network/xl1-protocol": "~1.13.0",
47
+ "@xyo-network/xl1-protocol-sdk": "~1.16.0"
46
48
  },
47
49
  "devDependencies": {
48
- "@xylabs/ts-scripts-yarn3": "~7.1.8",
49
- "@xylabs/tsconfig": "~7.1.8",
50
- "@xylabs/tsconfig-dom": "~7.1.8",
51
- "@xylabs/tsconfig-react": "~7.1.8",
52
- "eslint": "^9.39.0",
50
+ "@xylabs/ts-scripts-yarn3": "~7.2.4",
51
+ "@xylabs/tsconfig": "~7.2.4",
52
+ "@xylabs/tsconfig-dom": "~7.2.4",
53
+ "@xylabs/tsconfig-react": "~7.2.4",
54
+ "eslint": "^9.39.1",
53
55
  "typescript": "~5.9.3"
54
56
  },
55
57
  "publishConfig": {
package/src/index.ts CHANGED
@@ -1,2 +1 @@
1
- export * from './provider/index.ts'
2
1
  export * from './types/index.ts'
@@ -1,22 +1,45 @@
1
- // eslint-disable-next-line sonarjs/deprecation
2
- import type { ChainConnection } from '@xyo-network/chain-network-model'
3
- import type {
4
- XyoClient, XyoConnection, XyoGatewayProvider,
5
- } from '@xyo-network/xl1-protocol'
1
+ import { isDefinedNotNull, isObject } from '@xylabs/typeof'
2
+ import type { NetworkBootstrap } from '@xyo-network/xl1-network-model'
3
+ import type { NetworkId } from '@xyo-network/xl1-protocol'
4
+ import type { XyoClient } from '@xyo-network/xl1-protocol-sdk'
6
5
 
7
- // TODO - add optional send method of type Transport
8
- export interface XyoGlobal {
9
- client?: XyoClient
10
- /** @deprecated - use client gateways instead */
11
- connections: {
12
- // eslint-disable-next-line sonarjs/deprecation
13
- [chainId: string]: ChainConnection
14
- }
15
- errors?: Error[]
16
- gateway?: XyoGatewayProvider
17
- /** @deprecated - use client gateways instead */
18
- provider?: XyoConnection
6
+ export interface XyoGlobal extends UninitializedXyoGlobal {
7
+ client: XyoClient
8
+ errors: Error[]
9
+ }
10
+
11
+ /**
12
+ * Describes the initial state of the global XYO object before initialization
13
+ * (i.e. before the client is initialized)
14
+ */
15
+ export interface UninitializedXyoGlobal {
16
+ connections: Record<NetworkId, NetworkBootstrap>
19
17
  sessionId: () => string
20
- /** @deprecated - use session id instead */
21
18
  walletExtensionId: () => string
22
19
  }
20
+
21
+ export const isXyoGlobal = (obj: unknown): obj is XyoGlobal => {
22
+ return (
23
+ isDefinedNotNull(obj)
24
+ && isObject(obj)
25
+ && 'client' in obj
26
+ && 'connections' in obj
27
+ && 'errors' in obj
28
+ && 'sessionId' in obj
29
+ && 'walletExtensionId' in obj
30
+ )
31
+ }
32
+
33
+ export const isUninitializedXyoGlobal = (obj: unknown): obj is UninitializedXyoGlobal => {
34
+ return (
35
+ isDefinedNotNull(obj)
36
+ && isObject(obj)
37
+ && 'connections' in obj
38
+ && 'sessionId' in obj
39
+ && 'walletExtensionId' in obj
40
+ && !('client' in obj)
41
+ && ('errors' in obj)
42
+ && Array.isArray((obj).errors)
43
+ && obj.errors.length === 0
44
+ )
45
+ }
@@ -1,2 +0,0 @@
1
- export * from './xyoProvider.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/provider/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -1,15 +0,0 @@
1
- import type { XyoConnection } from '@xyo-network/xl1-protocol';
2
- import type { XyoGlobal } from '../types/index.ts';
3
- declare global {
4
- interface Window {
5
- xyo: XyoGlobal;
6
- }
7
- var xyo: XyoGlobal;
8
- var xyoWalletExtensionId: string;
9
- }
10
- export declare const hasXyoWalletInjectable: () => boolean;
11
- export declare const hasXyoWalletProvider: () => boolean;
12
- export declare function getXyoProvider(options: {
13
- assert: true;
14
- }): XyoConnection;
15
- //# sourceMappingURL=xyoProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"xyoProvider.d.ts","sourceRoot":"","sources":["../../../src/provider/xyoProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,GAAG,EAAE,SAAS,CAAA;KACf;IAED,IAAI,GAAG,EAAE,SAAS,CAAA;IAClB,IAAI,oBAAoB,EAAE,MAAM,CAAA;CACjC;AAED,eAAO,MAAM,sBAAsB,eAElC,CAAA;AAED,eAAO,MAAM,oBAAoB,eAEhC,CAAA;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,GAAG,aAAa,CAAA"}
@@ -1 +0,0 @@
1
- export * from './xyoProvider.ts'
@@ -1,35 +0,0 @@
1
- import type { XyoConnection } from '@xyo-network/xl1-protocol'
2
-
3
- import type { XyoGlobal } from '../types/index.ts'
4
-
5
- declare global {
6
- interface Window {
7
- xyo: XyoGlobal
8
- }
9
-
10
- var xyo: XyoGlobal
11
- var xyoWalletExtensionId: string
12
- }
13
-
14
- export const hasXyoWalletInjectable = () => {
15
- return 'xyo' in globalThis && 'walletExtensionId' in globalThis.xyo
16
- }
17
-
18
- export const hasXyoWalletProvider = () => {
19
- return hasXyoWalletInjectable() && 'provider' in globalThis.xyo
20
- }
21
-
22
- export function getXyoProvider(options: { assert: true }): XyoConnection
23
- export function getXyoProvider(options?: { assert?: boolean }): XyoConnection | undefined {
24
- const { assert } = options ?? {}
25
- if (hasXyoWalletProvider()) {
26
- return globalThis.xyo.provider
27
- } else {
28
- console.error('XYO Wallet not installed')
29
- if (assert) {
30
- throw new Error('XYO Wallet not installed')
31
- } else {
32
- return undefined
33
- }
34
- }
35
- }