@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.
- package/dist/components/Experiments/Experiments.js +7 -2
- package/dist/components/Experiments/Experiments.js.map +1 -1
- package/dist/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
- package/dist/components/InvertableThemeProvider/InvertableThemeContext.js +2 -2
- package/dist/components/InvertableThemeProvider/InvertableThemeContext.js.map +1 -1
- package/dist/components/TokenAmount/TokenAmountProps.d.ts +1 -0
- package/dist/contexts/Ethers/Context.d.ts +2 -2
- package/dist/contexts/Ethers/Context.js +2 -2
- package/dist/contexts/Ethers/Context.js.map +1 -1
- package/dist/contexts/Ethers/Opera.d.ts +1 -1
- package/dist/contexts/Ethers/Opera.js +35 -40
- package/dist/contexts/Ethers/Opera.js.map +1 -1
- package/dist/contexts/Ethers/Trust.d.ts +1 -1
- package/dist/contexts/Ethers/Trust.js +28 -33
- package/dist/contexts/Ethers/Trust.js.map +1 -1
- package/dist/contexts/NetworkSettings/Context.d.ts +2 -2
- package/dist/contexts/NetworkSettings/Context.js +2 -2
- package/dist/contexts/NetworkSettings/Context.js.map +1 -1
- package/dist/contexts/UserEvents/Context.d.ts +2 -2
- package/dist/contexts/UserEvents/Context.js +2 -2
- package/dist/contexts/UserEvents/Context.js.map +1 -1
- package/dist/esm2017/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
- package/dist/esm2017/components/TokenAmount/TokenAmountProps.d.ts +1 -0
- package/dist/esm2017/contexts/Ethers/Context.d.ts +2 -2
- package/dist/esm2017/contexts/Ethers/Opera.d.ts +1 -1
- package/dist/esm2017/contexts/Ethers/Trust.d.ts +1 -1
- package/dist/esm2017/contexts/NetworkSettings/Context.d.ts +2 -2
- package/dist/esm2017/contexts/UserEvents/Context.d.ts +2 -2
- package/dist/esm2017/index.js +98 -173
- package/dist/esm2017/index.js.map +1 -1
- package/dist/esm2017/lib/Tracking/Facebook/Fbq.d.ts +2 -2
- package/dist/esm2017/lib/Tracking/Reddit/Rdt.d.ts +1 -1
- package/dist/esm2017/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
- package/dist/esm2017/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
- package/dist/esm5/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
- package/dist/esm5/components/TokenAmount/TokenAmountProps.d.ts +1 -0
- package/dist/esm5/contexts/Ethers/Context.d.ts +2 -2
- package/dist/esm5/contexts/Ethers/Opera.d.ts +1 -1
- package/dist/esm5/contexts/Ethers/Trust.d.ts +1 -1
- package/dist/esm5/contexts/NetworkSettings/Context.d.ts +2 -2
- package/dist/esm5/contexts/UserEvents/Context.d.ts +2 -2
- package/dist/esm5/index.js +98 -173
- package/dist/esm5/index.js.map +1 -1
- package/dist/esm5/lib/Tracking/Facebook/Fbq.d.ts +2 -2
- package/dist/esm5/lib/Tracking/Reddit/Rdt.d.ts +1 -1
- package/dist/esm5/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
- package/dist/esm5/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
- package/dist/lib/Tracking/Facebook/Fbq.d.ts +2 -2
- package/dist/lib/Tracking/Facebook/Fbq.js +3 -26
- package/dist/lib/Tracking/Facebook/Fbq.js.map +1 -1
- package/dist/lib/Tracking/Reddit/Rdt.d.ts +1 -1
- package/dist/lib/Tracking/Reddit/Rdt.js +7 -21
- package/dist/lib/Tracking/Reddit/Rdt.js.map +1 -1
- package/dist/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
- package/dist/lib/Tracking/Snapchat/Snaptr.js +2 -15
- package/dist/lib/Tracking/Snapchat/Snaptr.js.map +1 -1
- package/dist/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
- package/dist/lib/Tracking/Tiktok/Ttq.js +13 -40
- package/dist/lib/Tracking/Tiktok/Ttq.js.map +1 -1
- package/dist/lib/useAsyncEffect.js +5 -1
- package/dist/lib/useAsyncEffect.js.map +1 -1
- package/dist/node/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
- package/dist/node/components/TokenAmount/TokenAmountProps.d.ts +1 -0
- package/dist/node/contexts/Ethers/Context.d.ts +2 -2
- package/dist/node/contexts/Ethers/Opera.d.ts +1 -1
- package/dist/node/contexts/Ethers/Trust.d.ts +1 -1
- package/dist/node/contexts/NetworkSettings/Context.d.ts +2 -2
- package/dist/node/contexts/UserEvents/Context.d.ts +2 -2
- package/dist/node/index.js +142 -218
- package/dist/node/index.js.map +1 -1
- package/dist/node/lib/Tracking/Facebook/Fbq.d.ts +2 -2
- package/dist/node/lib/Tracking/Reddit/Rdt.d.ts +1 -1
- package/dist/node/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
- package/dist/node/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
- package/dist/node-esm/components/InvertableThemeProvider/InvertableThemeContext.d.ts +2 -2
- package/dist/node-esm/components/TokenAmount/TokenAmountProps.d.ts +1 -0
- package/dist/node-esm/contexts/Ethers/Context.d.ts +2 -2
- package/dist/node-esm/contexts/Ethers/Opera.d.ts +1 -1
- package/dist/node-esm/contexts/Ethers/Trust.d.ts +1 -1
- package/dist/node-esm/contexts/NetworkSettings/Context.d.ts +2 -2
- package/dist/node-esm/contexts/UserEvents/Context.d.ts +2 -2
- package/dist/node-esm/index.js +98 -173
- package/dist/node-esm/index.js.map +1 -1
- package/dist/node-esm/lib/Tracking/Facebook/Fbq.d.ts +2 -2
- package/dist/node-esm/lib/Tracking/Reddit/Rdt.d.ts +1 -1
- package/dist/node-esm/lib/Tracking/Snapchat/Snaptr.d.ts +1 -1
- package/dist/node-esm/lib/Tracking/Tiktok/Ttq.d.ts +2 -2
- package/package.json +6 -6
- package/src/components/Experiments/Experiments.tsx +7 -2
- package/src/components/InvertableThemeProvider/InvertableThemeContext.tsx +2 -2
- package/src/contexts/Ethers/Context.ts +2 -2
- package/src/contexts/Ethers/Opera.tsx +14 -20
- package/src/contexts/Ethers/Trust.tsx +10 -16
- package/src/contexts/NetworkSettings/Context.ts +2 -2
- package/src/contexts/UserEvents/Context.ts +2 -2
- package/src/lib/Tracking/Facebook/Fbq.ts +2 -6
- package/src/lib/Tracking/Reddit/Rdt.ts +1 -4
- package/src/lib/Tracking/Snapchat/Snaptr.ts +1 -4
- package/src/lib/Tracking/Tiktok/Ttq.ts +2 -6
- package/src/lib/useAsyncEffect.tsx +9 -5
- package/index.node.ts +0 -1
- 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
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 (
|
|
37
|
+
if (mounted()) {
|
|
39
38
|
setSigner(signer)
|
|
40
39
|
setProvider(provider)
|
|
41
40
|
setLocalAddress(localAddress)
|
|
42
41
|
}
|
|
43
42
|
} catch (ex) {
|
|
44
|
-
if (
|
|
43
|
+
if (mounted()) {
|
|
45
44
|
setError(Error(`localAddress: ${ex}`))
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
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
|
-
|
|
26
|
-
|
|
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 (
|
|
31
|
+
if (mounted()) {
|
|
33
32
|
setLocalAddress(localAddress)
|
|
34
33
|
}
|
|
35
34
|
} catch (ex) {
|
|
36
|
-
if (
|
|
35
|
+
if (mounted()) {
|
|
37
36
|
setError(Error(`localAddress: ${ex}`))
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
|
|
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
|
|
2
|
+
import { createContext } from 'react'
|
|
3
3
|
|
|
4
|
-
const NetworkSettingsContext =
|
|
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
|
|
2
|
+
import { createContext } from 'react'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
userEvents?: UserEventHandler<unknown>
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const UserEventsContext =
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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)
|
|
16
|
-
|
|
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'
|