@xylabs/sdk-react 2.7.23 → 2.7.24

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.
Files changed (102) hide show
  1. package/dist/components/Experiments/Experiments.js +7 -2
  2. package/dist/components/Experiments/Experiments.js.map +1 -1
  3. package/dist/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
  4. package/dist/components/InvertableThemeProvider/InvertableThemeContext.js +2 -2
  5. package/dist/components/InvertableThemeProvider/InvertableThemeContext.js.map +1 -1
  6. package/dist/components/TokenAmount/TokenAmountProps.d.ts +1 -0
  7. package/dist/contexts/Ethers/Context.d.ts +2 -2
  8. package/dist/contexts/Ethers/Context.js +2 -2
  9. package/dist/contexts/Ethers/Context.js.map +1 -1
  10. package/dist/contexts/Ethers/Opera.d.ts +1 -1
  11. package/dist/contexts/Ethers/Opera.js +35 -40
  12. package/dist/contexts/Ethers/Opera.js.map +1 -1
  13. package/dist/contexts/Ethers/Trust.d.ts +1 -1
  14. package/dist/contexts/Ethers/Trust.js +28 -33
  15. package/dist/contexts/Ethers/Trust.js.map +1 -1
  16. package/dist/contexts/NetworkSettings/Context.d.ts +2 -2
  17. package/dist/contexts/NetworkSettings/Context.js +2 -2
  18. package/dist/contexts/NetworkSettings/Context.js.map +1 -1
  19. package/dist/contexts/UserEvents/Context.d.ts +2 -2
  20. package/dist/contexts/UserEvents/Context.js +2 -2
  21. package/dist/contexts/UserEvents/Context.js.map +1 -1
  22. package/dist/esm2017/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
  23. package/dist/esm2017/components/TokenAmount/TokenAmountProps.d.ts +1 -0
  24. package/dist/esm2017/contexts/Ethers/Context.d.ts +2 -2
  25. package/dist/esm2017/contexts/Ethers/Opera.d.ts +1 -1
  26. package/dist/esm2017/contexts/Ethers/Trust.d.ts +1 -1
  27. package/dist/esm2017/contexts/NetworkSettings/Context.d.ts +2 -2
  28. package/dist/esm2017/contexts/UserEvents/Context.d.ts +2 -2
  29. package/dist/esm2017/index.js +98 -173
  30. package/dist/esm2017/index.js.map +1 -1
  31. package/dist/esm2017/lib/Tracking/Facebook/Fbq.d.ts +2 -2
  32. package/dist/esm2017/lib/Tracking/Reddit/Rdt.d.ts +1 -1
  33. package/dist/esm2017/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
  34. package/dist/esm2017/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
  35. package/dist/esm5/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
  36. package/dist/esm5/components/TokenAmount/TokenAmountProps.d.ts +1 -0
  37. package/dist/esm5/contexts/Ethers/Context.d.ts +2 -2
  38. package/dist/esm5/contexts/Ethers/Opera.d.ts +1 -1
  39. package/dist/esm5/contexts/Ethers/Trust.d.ts +1 -1
  40. package/dist/esm5/contexts/NetworkSettings/Context.d.ts +2 -2
  41. package/dist/esm5/contexts/UserEvents/Context.d.ts +2 -2
  42. package/dist/esm5/index.js +98 -173
  43. package/dist/esm5/index.js.map +1 -1
  44. package/dist/esm5/lib/Tracking/Facebook/Fbq.d.ts +2 -2
  45. package/dist/esm5/lib/Tracking/Reddit/Rdt.d.ts +1 -1
  46. package/dist/esm5/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
  47. package/dist/esm5/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
  48. package/dist/lib/Tracking/Facebook/Fbq.d.ts +2 -2
  49. package/dist/lib/Tracking/Facebook/Fbq.js +3 -26
  50. package/dist/lib/Tracking/Facebook/Fbq.js.map +1 -1
  51. package/dist/lib/Tracking/Reddit/Rdt.d.ts +1 -1
  52. package/dist/lib/Tracking/Reddit/Rdt.js +7 -21
  53. package/dist/lib/Tracking/Reddit/Rdt.js.map +1 -1
  54. package/dist/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
  55. package/dist/lib/Tracking/Snapchat/Snaptr.js +2 -15
  56. package/dist/lib/Tracking/Snapchat/Snaptr.js.map +1 -1
  57. package/dist/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
  58. package/dist/lib/Tracking/Tiktok/Ttq.js +13 -40
  59. package/dist/lib/Tracking/Tiktok/Ttq.js.map +1 -1
  60. package/dist/lib/useAsyncEffect.js +5 -1
  61. package/dist/lib/useAsyncEffect.js.map +1 -1
  62. package/dist/node/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
  63. package/dist/node/components/TokenAmount/TokenAmountProps.d.ts +1 -0
  64. package/dist/node/contexts/Ethers/Context.d.ts +2 -2
  65. package/dist/node/contexts/Ethers/Opera.d.ts +1 -1
  66. package/dist/node/contexts/Ethers/Trust.d.ts +1 -1
  67. package/dist/node/contexts/NetworkSettings/Context.d.ts +2 -2
  68. package/dist/node/contexts/UserEvents/Context.d.ts +2 -2
  69. package/dist/node/index.js +142 -218
  70. package/dist/node/index.js.map +1 -1
  71. package/dist/node/lib/Tracking/Facebook/Fbq.d.ts +2 -2
  72. package/dist/node/lib/Tracking/Reddit/Rdt.d.ts +1 -1
  73. package/dist/node/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
  74. package/dist/node/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
  75. package/dist/node-esm/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
  76. package/dist/node-esm/components/TokenAmount/TokenAmountProps.d.ts +1 -0
  77. package/dist/node-esm/contexts/Ethers/Context.d.ts +2 -2
  78. package/dist/node-esm/contexts/Ethers/Opera.d.ts +1 -1
  79. package/dist/node-esm/contexts/Ethers/Trust.d.ts +1 -1
  80. package/dist/node-esm/contexts/NetworkSettings/Context.d.ts +2 -2
  81. package/dist/node-esm/contexts/UserEvents/Context.d.ts +2 -2
  82. package/dist/node-esm/index.js +98 -173
  83. package/dist/node-esm/index.js.map +1 -1
  84. package/dist/node-esm/lib/Tracking/Facebook/Fbq.d.ts +2 -2
  85. package/dist/node-esm/lib/Tracking/Reddit/Rdt.d.ts +1 -1
  86. package/dist/node-esm/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
  87. package/dist/node-esm/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
  88. package/package.json +6 -6
  89. package/src/components/Experiments/Experiments.tsx +7 -2
  90. package/src/components/InvertableThemeProvider/InvertableThemeContext.tsx +2 -2
  91. package/src/contexts/Ethers/Context.ts +2 -2
  92. package/src/contexts/Ethers/Opera.tsx +14 -20
  93. package/src/contexts/Ethers/Trust.tsx +10 -16
  94. package/src/contexts/NetworkSettings/Context.ts +2 -2
  95. package/src/contexts/UserEvents/Context.ts +2 -2
  96. package/src/lib/Tracking/Facebook/Fbq.ts +2 -6
  97. package/src/lib/Tracking/Reddit/Rdt.ts +1 -4
  98. package/src/lib/Tracking/Snapchat/Snaptr.ts +1 -4
  99. package/src/lib/Tracking/Tiktok/Ttq.ts +2 -6
  100. package/src/lib/useAsyncEffect.tsx +9 -5
  101. package/index.node.ts +0 -1
  102. package/index.ts +0 -1
@@ -1,7 +1,8 @@
1
1
  import { JsonRpcProvider, JsonRpcSigner, Web3Provider } from '@ethersproject/providers'
2
2
  import { EthAddress } from '@xylabs/sdk-js'
3
- import React, { PropsWithChildren, useState } from 'react'
3
+ import { PropsWithChildren, useState } from 'react'
4
4
 
5
+ import { useAsyncEffect } from '../../lib'
5
6
  import { EthersContext } from './Context'
6
7
 
7
8
  interface Props {
@@ -23,37 +24,30 @@ export const OperaEthersLoader: React.FC<PropsWithChildren<Props>> = (props) =>
23
24
  const chainId = ethereum?.chainId ? parseInt(ethereum?.chainId) : 1
24
25
  const isConnected = ethereum?.isConnected() ?? false
25
26
 
26
- React.useEffect(() => {
27
- let cancelled = false
28
-
29
- if (ethereum) {
30
- ethereum.enable()
31
- const operaProvider = new Web3Provider(ethereum)
32
- const provider = operaProvider
33
- const signer = operaProvider.getSigner()
34
- const load = async () => {
27
+ useAsyncEffect(
28
+ async (mounted) => {
29
+ if (ethereum) {
30
+ ethereum.enable()
31
+ const operaProvider = new Web3Provider(ethereum)
32
+ const provider = operaProvider
33
+ const signer = operaProvider.getSigner()
35
34
  try {
36
35
  const localAddress = EthAddress.fromString(await signer.getAddress())
37
36
  ethereum.autoRefreshOnNetworkChange = false
38
- if (!cancelled) {
37
+ if (mounted()) {
39
38
  setSigner(signer)
40
39
  setProvider(provider)
41
40
  setLocalAddress(localAddress)
42
41
  }
43
42
  } catch (ex) {
44
- if (!cancelled) {
43
+ if (mounted()) {
45
44
  setError(Error(`localAddress: ${ex}`))
46
45
  }
47
46
  }
48
47
  }
49
-
50
- load()
51
- }
52
-
53
- return () => {
54
- cancelled = true
55
- }
56
- }, [ethereum])
48
+ },
49
+ [ethereum]
50
+ )
57
51
 
58
52
  return (
59
53
  <EthersContext.Provider
@@ -1,7 +1,8 @@
1
1
  import { Web3Provider } from '@ethersproject/providers'
2
2
  import { EthAddress } from '@xylabs/sdk-js'
3
- import React, { PropsWithChildren, useEffect, useState } from 'react'
3
+ import { PropsWithChildren, useState } from 'react'
4
4
 
5
+ import { useAsyncEffect } from '../../lib'
5
6
  import { EthersContext } from './Context'
6
7
 
7
8
  interface Props {
@@ -22,30 +23,23 @@ export const TrustEthersLoader: React.FC<PropsWithChildren<Props>> = (props) =>
22
23
 
23
24
  const provider = trustProvider
24
25
 
25
- useEffect(() => {
26
- let cancelled = false
27
-
28
- if (signer) {
29
- const load = async () => {
26
+ useAsyncEffect(
27
+ async (mounted) => {
28
+ if (signer) {
30
29
  try {
31
30
  const localAddress = EthAddress.fromString(await signer.getAddress())
32
- if (!cancelled) {
31
+ if (mounted()) {
33
32
  setLocalAddress(localAddress)
34
33
  }
35
34
  } catch (ex) {
36
- if (!cancelled) {
35
+ if (mounted()) {
37
36
  setError(Error(`localAddress: ${ex}`))
38
37
  }
39
38
  }
40
39
  }
41
-
42
- load()
43
- }
44
-
45
- return () => {
46
- cancelled = true
47
- }
48
- }, [signer])
40
+ },
41
+ [signer]
42
+ )
49
43
 
50
44
  return (
51
45
  <EthersContext.Provider
@@ -1,7 +1,7 @@
1
1
  import { EthAddress } from '@xylabs/sdk-js'
2
- import React from 'react'
2
+ import { createContext } from 'react'
3
3
 
4
- const NetworkSettingsContext = React.createContext<{
4
+ const NetworkSettingsContext = createContext<{
5
5
  xyStakingConsensusAddress?: EthAddress
6
6
  xyBondAddress?: EthAddress
7
7
  xyGovernanceAddress?: EthAddress
@@ -1,9 +1,9 @@
1
1
  import { UserEventHandler } from '@xylabs/pixel'
2
- import React from 'react'
2
+ import { createContext } from 'react'
3
3
 
4
4
  interface Props {
5
5
  userEvents?: UserEventHandler<unknown>
6
6
  }
7
7
 
8
- const UserEventsContext = React.createContext<Props>({})
8
+ const UserEventsContext = createContext<Props>({})
9
9
  export { UserEventsContext }
@@ -1,5 +1,3 @@
1
- import { delay } from '@xylabs/sdk-js'
2
-
3
1
  import { global } from '../../global'
4
2
 
5
3
  class Fbq {
@@ -36,18 +34,16 @@ class Fbq {
36
34
  return this.instance
37
35
  }
38
36
 
39
- public async track(event: string, data: Record<string, unknown>) {
37
+ public track(event: string, data: Record<string, unknown>) {
40
38
  this.fbq('track', event, {
41
39
  ...data,
42
40
  })
43
- await delay(0)
44
41
  }
45
42
 
46
- public async trackCustom(event: string, data: Record<string, unknown>) {
43
+ public trackCustom(event: string, data: Record<string, unknown>) {
47
44
  this.fbq('trackCustom', event, {
48
45
  ...data,
49
46
  })
50
- await delay(0)
51
47
  }
52
48
  }
53
49
 
@@ -1,5 +1,3 @@
1
- import { delay } from '@xylabs/sdk-js'
2
-
3
1
  import { global } from '../../global'
4
2
 
5
3
  class Rdt {
@@ -26,12 +24,11 @@ class Rdt {
26
24
  }
27
25
  }
28
26
 
29
- public async track(event: string, data?: Record<string, unknown>) {
27
+ public track(event: string, data?: Record<string, unknown>) {
30
28
  try {
31
29
  Rdt.getRdt()('track', event, {
32
30
  ...data,
33
31
  })
34
- await delay(0)
35
32
  } catch (ex) {
36
33
  console.error(ex)
37
34
  }
@@ -1,5 +1,3 @@
1
- import { delay } from '@xylabs/sdk-js'
2
-
3
1
  import { global } from '../../global'
4
2
 
5
3
  class SnapTr {
@@ -15,10 +13,9 @@ class SnapTr {
15
13
  this.track('PAGE_VIEW')
16
14
  }
17
15
 
18
- public static async track<T>(event: string, data?: T) {
16
+ public static track<T>(event: string, data?: T) {
19
17
  this.getSnapTr()('init', this.pixelId)
20
18
  this.getSnapTr()('track', event, data)
21
- await delay(0)
22
19
  }
23
20
  }
24
21
 
@@ -1,5 +1,3 @@
1
- import { delay } from '@xylabs/sdk-js'
2
-
3
1
  import { global } from '../../global'
4
2
 
5
3
  class Ttq {
@@ -18,21 +16,19 @@ class Ttq {
18
16
  return global.ttq
19
17
  }
20
18
 
21
- public static async page() {
19
+ public static page() {
22
20
  try {
23
21
  Ttq.getTtq().page()
24
- await delay(0)
25
22
  } catch (ex) {
26
23
  console.error(`Ttq.page: ${ex}`)
27
24
  }
28
25
  }
29
26
 
30
- public async track(event: string, data?: Record<string, unknown>) {
27
+ public track(event: string, data?: Record<string, unknown>) {
31
28
  try {
32
29
  Ttq.getTtq().track(event, {
33
30
  ...data,
34
31
  })
35
- await delay(0)
36
32
  } catch (ex) {
37
33
  console.error(`Ttq.track: ${ex}`)
38
34
  }
@@ -12,11 +12,15 @@ function useAsyncEffect(effect: EffectFunc, inputs?: unknown[]) {
12
12
  return mounted
13
13
  })
14
14
 
15
- Promise.resolve(promise).then((callback) => {
16
- if (callback) {
17
- callback?.()
18
- }
19
- })
15
+ Promise.resolve(promise)
16
+ .then((callback) => {
17
+ if (callback) {
18
+ callback?.()
19
+ }
20
+ })
21
+ .catch((reason) => {
22
+ console.log(`useAsyncEffect Excepted: ${reason}`)
23
+ })
20
24
 
21
25
  return function () {
22
26
  mounted = false
package/index.node.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src'
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './src'