@xyo-network/react-chain-transfer-plugin 1.20.14 → 1.20.16
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/README.md +9 -2219
- package/package.json +153 -38
- package/src/gloabl.d.ts +0 -1
- package/src/index.ts +0 -1
- package/src/transfer/Plugin.ts +0 -17
- package/src/transfer/box/Details.stories.tsx +0 -52
- package/src/transfer/box/Details.tsx +0 -28
- package/src/transfer/box/index.ts +0 -1
- package/src/transfer/card/ListItem.tsx +0 -58
- package/src/transfer/card/TransferRenderCard.stories.tsx +0 -54
- package/src/transfer/card/TransferRenderCard.tsx +0 -70
- package/src/transfer/card/TransferRenderCardHelper.tsx +0 -99
- package/src/transfer/card/TransferRenderTotalTypography.tsx +0 -38
- package/src/transfer/card/index.ts +0 -1
- package/src/transfer/index.ts +0 -3
- package/src/transfer/lib/TransferRenderOptions.ts +0 -5
- package/src/transfer/lib/index.ts +0 -1
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-transfer-plugin",
|
|
4
|
-
"version": "1.20.
|
|
4
|
+
"version": "1.20.16",
|
|
5
5
|
"description": "XYO Layer One API",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -25,80 +25,195 @@
|
|
|
25
25
|
"types": "./dist/browser/index.d.ts",
|
|
26
26
|
"browser": {
|
|
27
27
|
"types": "./dist/browser/index.d.ts",
|
|
28
|
-
"source": "./src/index.ts",
|
|
29
28
|
"default": "./dist/browser/index.mjs"
|
|
30
29
|
},
|
|
31
|
-
"source": "./src/index.ts",
|
|
32
30
|
"default": "./dist/browser/index.mjs"
|
|
33
31
|
},
|
|
34
32
|
"./Plugin": {
|
|
35
33
|
"types": "./dist/browser/transfer/Plugin.d.ts",
|
|
36
|
-
"source": "./src/transfer/Plugin.ts",
|
|
37
34
|
"default": "./dist/browser/transfer/Plugin.mjs"
|
|
38
35
|
},
|
|
39
36
|
"./package.json": "./package.json"
|
|
40
37
|
},
|
|
41
38
|
"module": "./dist/browser/index.mjs",
|
|
42
|
-
"source": "./src/index.ts",
|
|
43
39
|
"types": "./dist/browser/index.d.ts",
|
|
44
40
|
"files": [
|
|
45
41
|
"dist",
|
|
46
|
-
"src",
|
|
47
42
|
"!**/*.bench.*",
|
|
48
43
|
"!**/*.spec.*",
|
|
49
|
-
"!**/*.test.*"
|
|
44
|
+
"!**/*.test.*",
|
|
45
|
+
"README.md"
|
|
50
46
|
],
|
|
51
47
|
"dependencies": {
|
|
52
|
-
"@xylabs/react-flexbox": "~7.1.
|
|
53
|
-
"@xyo-network/react-chain-blockies": "~1.20.14",
|
|
54
|
-
"@xyo-network/react-chain-network": "~1.20.14",
|
|
48
|
+
"@xylabs/react-flexbox": "~7.1.20",
|
|
55
49
|
"@xyo-network/react-event": "~7.5.8",
|
|
56
|
-
"@xyo-network/react-payload-plugin": "~7.5.8"
|
|
50
|
+
"@xyo-network/react-payload-plugin": "~7.5.8",
|
|
51
|
+
"@xyo-network/xl1-sdk": "^1.26.19",
|
|
52
|
+
"@xyo-network/react-chain-network": "~1.20.16"
|
|
57
53
|
},
|
|
58
54
|
"devDependencies": {
|
|
59
55
|
"@emotion/react": "~11.14.0",
|
|
60
56
|
"@emotion/styled": "~11.14.1",
|
|
61
57
|
"@mui/icons-material": "^7.3.9",
|
|
62
58
|
"@mui/material": "^7.3.9",
|
|
63
|
-
"@
|
|
59
|
+
"@opentelemetry/api": "^1",
|
|
60
|
+
"@storybook/react-vite": "^10.3.5",
|
|
61
|
+
"@textea/json-viewer": "^4",
|
|
62
|
+
"@types/node": "^25.5.2",
|
|
64
63
|
"@types/react": "~19.2.14",
|
|
65
|
-
"@xylabs/
|
|
66
|
-
"@xylabs/
|
|
67
|
-
"@xylabs/
|
|
68
|
-
"@xylabs/
|
|
69
|
-
"@xylabs/
|
|
70
|
-
"@xylabs/
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
64
|
+
"@xylabs/express": "^5.0.95",
|
|
65
|
+
"@xylabs/mongo": "^5.0.95",
|
|
66
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
67
|
+
"@xylabs/react-dialogs": "~7.1.20",
|
|
68
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
69
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
70
|
+
"@xylabs/sdk-js": "~5.0.95",
|
|
71
|
+
"@xylabs/ts-scripts-common": "~7.9.3",
|
|
72
|
+
"@xylabs/ts-scripts-pnpm": "~7.9.3",
|
|
73
|
+
"@xylabs/tsconfig": "~7.9.3",
|
|
74
|
+
"@xylabs/tsconfig-dom": "~7.9.3",
|
|
75
|
+
"@xylabs/tsconfig-react": "~7.9.3",
|
|
76
|
+
"@xylabs/zod": "~5.0.95",
|
|
77
|
+
"@xyo-network/account": "~5.3.30",
|
|
78
|
+
"@xyo-network/account-model": "~5.3.30",
|
|
79
|
+
"@xyo-network/api-models": "~5.3.30",
|
|
80
|
+
"@xyo-network/archivist-abstract": "~5.3.30",
|
|
81
|
+
"@xyo-network/archivist-generic": "~5.3.30",
|
|
82
|
+
"@xyo-network/archivist-memory": "~5.3.30",
|
|
83
|
+
"@xyo-network/archivist-model": "~5.3.30",
|
|
84
|
+
"@xyo-network/archivist-view": "~5.3.30",
|
|
85
|
+
"@xyo-network/archivist-wrapper": "~5.3",
|
|
86
|
+
"@xyo-network/boundwitness-builder": "~5.3.30",
|
|
87
|
+
"@xyo-network/boundwitness-validator": "~5.3.30",
|
|
88
|
+
"@xyo-network/bridge-abstract": "~5.3.30",
|
|
89
|
+
"@xyo-network/bridge-model": "~5.3.30",
|
|
90
|
+
"@xyo-network/config-payload-plugin": "~5.3.30",
|
|
91
|
+
"@xyo-network/data": "~5.3.30",
|
|
92
|
+
"@xyo-network/diviner-abstract": "~5.3",
|
|
93
|
+
"@xyo-network/diviner-boundwitness-memory": "~5.3.30",
|
|
94
|
+
"@xyo-network/diviner-identity": "~5.3.30",
|
|
95
|
+
"@xyo-network/diviner-model": "~5.3.30",
|
|
96
|
+
"@xyo-network/diviner-payload-generic": "~5.3.30",
|
|
97
|
+
"@xyo-network/diviner-payload-model": "~5.3.30",
|
|
98
|
+
"@xyo-network/diviner-wrapper": "~5.3",
|
|
99
|
+
"@xyo-network/dns": "~5.3.30",
|
|
100
|
+
"@xyo-network/domain-payload-plugin": "~5.3.30",
|
|
101
|
+
"@xyo-network/elliptic": "~5.3.30",
|
|
102
|
+
"@xyo-network/hash": "~5.3.30",
|
|
103
|
+
"@xyo-network/huri": "~5.3.30",
|
|
104
|
+
"@xyo-network/manifest-model": "~5.3.30",
|
|
105
|
+
"@xyo-network/module-abstract": "~5.3.30",
|
|
106
|
+
"@xyo-network/module-model": "~5.3.30",
|
|
107
|
+
"@xyo-network/module-model-mongodb": "~5.3",
|
|
108
|
+
"@xyo-network/module-resolver": "~5.3.30",
|
|
109
|
+
"@xyo-network/module-wrapper": "~5.3",
|
|
110
|
+
"@xyo-network/network": "~5.3.30",
|
|
111
|
+
"@xyo-network/node-abstract": "~5.3.30",
|
|
112
|
+
"@xyo-network/node-memory": "~5.3.30",
|
|
113
|
+
"@xyo-network/node-model": "~5.3.30",
|
|
114
|
+
"@xyo-network/node-view": "~5.3.30",
|
|
115
|
+
"@xyo-network/node-wrapper": "~5.3",
|
|
116
|
+
"@xyo-network/payload-builder": "~5.3.30",
|
|
117
|
+
"@xyo-network/payload-model": "~5.3.30",
|
|
118
|
+
"@xyo-network/payload-validator": "~5.3.30",
|
|
119
|
+
"@xyo-network/previous-hash-store-model": "~5.3.30",
|
|
120
|
+
"@xyo-network/sdk-js": "~5.3.30",
|
|
121
|
+
"@xyo-network/sentinel-abstract": "~5.3.30",
|
|
122
|
+
"@xyo-network/sentinel-memory": "~5.3.30",
|
|
123
|
+
"@xyo-network/sentinel-model": "~5.3.30",
|
|
124
|
+
"@xyo-network/wallet-model": "~5.3.30",
|
|
125
|
+
"@xyo-network/wasm": "~5.3.30",
|
|
126
|
+
"@xyo-network/witness-adhoc": "~5.3.30",
|
|
127
|
+
"@xyo-network/witness-model": "~5.3.30",
|
|
128
|
+
"ajv": "^8",
|
|
129
|
+
"axios": "^1.14.0",
|
|
130
|
+
"dotenv": "~17.4.1",
|
|
131
|
+
"esbuild": "*",
|
|
75
132
|
"ethers": "^6.16.0",
|
|
133
|
+
"mongodb": "^7.1.1",
|
|
134
|
+
"pako": "~2.1.0",
|
|
76
135
|
"react": "^19.2.4",
|
|
77
136
|
"react-dom": "^19.2.4",
|
|
78
|
-
"
|
|
137
|
+
"react-router-dom": "^7",
|
|
138
|
+
"rollbar": "~2.26.4",
|
|
139
|
+
"storybook": "^10.3.5",
|
|
79
140
|
"typescript": "~5.9.3",
|
|
80
|
-
"vite": "^8.0.
|
|
81
|
-
"vitest": "^4.1.
|
|
82
|
-
"zod": "^4.3.6"
|
|
141
|
+
"vite": "^8.0.7",
|
|
142
|
+
"vitest": "^4.1.3",
|
|
143
|
+
"zod": "^4.3.6",
|
|
144
|
+
"@xyo-network/chain-telemetry": "~1.20.16",
|
|
145
|
+
"@xyo-network/chain-services": "~1.20.16",
|
|
146
|
+
"@xyo-network/react-chain-blockies": "~1.20.16",
|
|
147
|
+
"@xyo-network/react-chain-client": "~1.20.16"
|
|
83
148
|
},
|
|
84
149
|
"peerDependencies": {
|
|
85
|
-
"@mui/material": "^7",
|
|
86
|
-
"@xylabs/
|
|
87
|
-
"@
|
|
88
|
-
"@
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"zod": "
|
|
150
|
+
"@mui/material": "^7.3.9",
|
|
151
|
+
"@xylabs/express": "^5.0.95",
|
|
152
|
+
"@xylabs/react-async-effect": "~7.1.20",
|
|
153
|
+
"@xylabs/react-promise": "~7.1.20",
|
|
154
|
+
"@xylabs/react-quick-tip-button": "~7.1.20",
|
|
155
|
+
"@xylabs/sdk-js": "~5.0.93",
|
|
156
|
+
"@xylabs/zod": "~5.0.95",
|
|
157
|
+
"@xyo-network/account": "~5.3.30",
|
|
158
|
+
"@xyo-network/account-model": "~5.3.30",
|
|
159
|
+
"@xyo-network/api-models": "~5.3.30",
|
|
160
|
+
"@xyo-network/archivist-abstract": "~5.3.30",
|
|
161
|
+
"@xyo-network/archivist-generic": "~5.3.30",
|
|
162
|
+
"@xyo-network/archivist-memory": "~5.3.30",
|
|
163
|
+
"@xyo-network/archivist-model": "~5.3.30",
|
|
164
|
+
"@xyo-network/archivist-view": "~5.3.30",
|
|
165
|
+
"@xyo-network/boundwitness-builder": "~5.3.30",
|
|
166
|
+
"@xyo-network/boundwitness-validator": "~5.3.30",
|
|
167
|
+
"@xyo-network/bridge-abstract": "~5.3.30",
|
|
168
|
+
"@xyo-network/bridge-model": "~5.3.30",
|
|
169
|
+
"@xyo-network/config-payload-plugin": "~5.3.30",
|
|
170
|
+
"@xyo-network/data": "~5.3.30",
|
|
171
|
+
"@xyo-network/diviner-boundwitness-memory": "~5.3.30",
|
|
172
|
+
"@xyo-network/diviner-identity": "~5.3.30",
|
|
173
|
+
"@xyo-network/diviner-model": "~5.3.30",
|
|
174
|
+
"@xyo-network/diviner-payload-generic": "~5.3.30",
|
|
175
|
+
"@xyo-network/diviner-payload-model": "~5.3.30",
|
|
176
|
+
"@xyo-network/dns": "~5.3.30",
|
|
177
|
+
"@xyo-network/domain-payload-plugin": "~5.3.30",
|
|
178
|
+
"@xyo-network/elliptic": "~5.3.30",
|
|
179
|
+
"@xyo-network/hash": "~5.3.30",
|
|
180
|
+
"@xyo-network/huri": "~5.3.30",
|
|
181
|
+
"@xyo-network/manifest-model": "~5.3.30",
|
|
182
|
+
"@xyo-network/module-abstract": "~5.3.30",
|
|
183
|
+
"@xyo-network/module-model": "~5.3.30",
|
|
184
|
+
"@xyo-network/module-model-mongodb": "~5.3",
|
|
185
|
+
"@xyo-network/module-resolver": "~5.3.30",
|
|
186
|
+
"@xyo-network/network": "~5.3.30",
|
|
187
|
+
"@xyo-network/node-abstract": "~5.3.30",
|
|
188
|
+
"@xyo-network/node-memory": "~5.3.30",
|
|
189
|
+
"@xyo-network/node-model": "~5.3.30",
|
|
190
|
+
"@xyo-network/node-view": "~5.3.30",
|
|
191
|
+
"@xyo-network/payload-builder": "~5.3.30",
|
|
192
|
+
"@xyo-network/payload-model": "~5.3.30",
|
|
193
|
+
"@xyo-network/payload-validator": "~5.3.30",
|
|
194
|
+
"@xyo-network/previous-hash-store-model": "~5.3.30",
|
|
195
|
+
"@xyo-network/sdk-js": "~5.3.25",
|
|
196
|
+
"@xyo-network/sentinel-abstract": "~5.3.30",
|
|
197
|
+
"@xyo-network/sentinel-memory": "~5.3.30",
|
|
198
|
+
"@xyo-network/sentinel-model": "~5.3.30",
|
|
199
|
+
"@xyo-network/wallet-model": "~5.3.30",
|
|
200
|
+
"@xyo-network/wasm": "~5.3.30",
|
|
201
|
+
"@xyo-network/witness-adhoc": "~5.3.30",
|
|
202
|
+
"@xyo-network/witness-model": "~5.3.30",
|
|
203
|
+
"pako": "~2.1.0",
|
|
204
|
+
"react": "^19.2.4",
|
|
205
|
+
"@xyo-network/chain-services": "~1.20.16",
|
|
206
|
+
"@xyo-network/react-chain-blockies": "~1.20.16",
|
|
207
|
+
"@xyo-network/chain-telemetry": "~1.20.16",
|
|
208
|
+
"@xyo-network/react-chain-client": "~1.20.16"
|
|
92
209
|
},
|
|
93
|
-
"packageManager": "yarn@4.6.0",
|
|
94
210
|
"engines": {
|
|
95
|
-
"node": ">=
|
|
211
|
+
"node": ">=24"
|
|
96
212
|
},
|
|
97
213
|
"volta": {
|
|
98
|
-
"node": "
|
|
99
|
-
"yarn": "4.6.0"
|
|
214
|
+
"node": ">=24"
|
|
100
215
|
},
|
|
101
216
|
"publishConfig": {
|
|
102
217
|
"access": "public"
|
|
103
218
|
}
|
|
104
|
-
}
|
|
219
|
+
}
|
package/src/gloabl.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@mui/material/themeCssVarsAugmentation'
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './transfer/index.ts'
|
package/src/transfer/Plugin.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { PayloadRenderPlugin } from '@xyo-network/react-payload-plugin'
|
|
2
|
-
import { createPayloadRenderPlugin } from '@xyo-network/react-payload-plugin'
|
|
3
|
-
import type { Payload } from '@xyo-network/sdk-js'
|
|
4
|
-
import { TransferSchema } from '@xyo-network/xl1-sdk'
|
|
5
|
-
|
|
6
|
-
import { TransferRenderBoxDetails } from './box/index.ts'
|
|
7
|
-
import { TransferRenderCard } from './card/index.ts'
|
|
8
|
-
|
|
9
|
-
export const TransferRenderPlugin: PayloadRenderPlugin = {
|
|
10
|
-
...createPayloadRenderPlugin({
|
|
11
|
-
canRender: (payload?: Payload) => payload?.schema === TransferSchema,
|
|
12
|
-
components: { box: { detailsBox: TransferRenderBoxDetails, detailsCard: TransferRenderCard } },
|
|
13
|
-
name: 'Transfer',
|
|
14
|
-
}),
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default TransferRenderPlugin
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import {
|
|
3
|
-
type Address,
|
|
4
|
-
type Hex,
|
|
5
|
-
ZERO_ADDRESS,
|
|
6
|
-
} from '@xylabs/sdk-js'
|
|
7
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
8
|
-
import { type Transfer, TransferSchema } from '@xyo-network/xl1-sdk'
|
|
9
|
-
import React from 'react'
|
|
10
|
-
|
|
11
|
-
import { TransferRenderBoxDetails } from './Details.tsx'
|
|
12
|
-
|
|
13
|
-
const transfer: Transfer = {
|
|
14
|
-
schema: TransferSchema,
|
|
15
|
-
epoch: 1_755_723_852_247,
|
|
16
|
-
from: ZERO_ADDRESS,
|
|
17
|
-
transfers: {
|
|
18
|
-
'1111111111111111111111111111111111111111': '1b1ae4d6e2ef500000',
|
|
19
|
-
'1111111111111111111111111111111111111112': '5150ae84a8cdf00000',
|
|
20
|
-
'1111111111111111111111111111111111111113': '989680',
|
|
21
|
-
'1111111111111111111111111111111111111114': '1b1ae4d6e2ef500000',
|
|
22
|
-
} as Record<Address, Hex>,
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default {
|
|
26
|
-
title: 'Payloads/Transfer/Box/Details',
|
|
27
|
-
component: TransferRenderBoxDetails,
|
|
28
|
-
} as Meta
|
|
29
|
-
|
|
30
|
-
const Template: StoryFn<typeof TransferRenderBoxDetails> = (args) => {
|
|
31
|
-
const [ref] = useEvent<HTMLDivElement>((noun, verb, data) => {
|
|
32
|
-
alert(`${noun} ${verb} ${data}`)
|
|
33
|
-
})
|
|
34
|
-
return (
|
|
35
|
-
<span ref={ref}>
|
|
36
|
-
<TransferRenderBoxDetails {...args} />
|
|
37
|
-
</span>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const Default = Template.bind({})
|
|
42
|
-
Default.args = {}
|
|
43
|
-
|
|
44
|
-
const WithValue = Template.bind({})
|
|
45
|
-
WithValue.args = { payload: transfer }
|
|
46
|
-
|
|
47
|
-
const WithOptions = Template.bind({})
|
|
48
|
-
WithOptions.args = { payload: transfer, options: { links: new Set(['address']) } }
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
Default, WithOptions, WithValue,
|
|
52
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import type { PayloadDetailsRenderProps } from '@xyo-network/react-payload-plugin'
|
|
4
|
-
import type { Payload } from '@xyo-network/sdk-js'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import { TransferRenderCard } from '../card/index.ts'
|
|
8
|
-
import type { TransferRenderOptions } from '../lib/index.ts'
|
|
9
|
-
|
|
10
|
-
export interface TransferRenderBoxDetailsProps extends PayloadDetailsRenderProps, FlexBoxProps {
|
|
11
|
-
options?: TransferRenderOptions
|
|
12
|
-
payload?: Payload
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const TransferRenderBoxDetails: React.FC<TransferRenderBoxDetailsProps> = ({
|
|
16
|
-
options,
|
|
17
|
-
payload,
|
|
18
|
-
...props
|
|
19
|
-
}) => {
|
|
20
|
-
return (
|
|
21
|
-
<FlexCol {...props}>
|
|
22
|
-
<TransferRenderCard
|
|
23
|
-
options={options}
|
|
24
|
-
payload={payload}
|
|
25
|
-
/>
|
|
26
|
-
</FlexCol>
|
|
27
|
-
)
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Details.tsx'
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ListItem, ListItemAvatar, type ListItemProps, ListItemText, Stack, Typography,
|
|
3
|
-
useTheme,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import type { Address, Hex } from '@xylabs/sdk-js'
|
|
6
|
-
import {
|
|
7
|
-
asAddress, hexToBigInt, isDefined,
|
|
8
|
-
} from '@xylabs/sdk-js'
|
|
9
|
-
import { BlockiesAvatar } from '@xyo-network/react-chain-blockies'
|
|
10
|
-
import { NetworkIcon } from '@xyo-network/react-chain-network'
|
|
11
|
-
import { MainNetworkIconString } from '@xyo-network/xl1-sdk'
|
|
12
|
-
import React from 'react'
|
|
13
|
-
|
|
14
|
-
import type { TransferCardHelper } from './TransferRenderCardHelper.tsx'
|
|
15
|
-
|
|
16
|
-
export interface TransferRenderListItem extends ListItemProps {
|
|
17
|
-
address?: Address
|
|
18
|
-
amount?: Hex
|
|
19
|
-
transferCardHelper: TransferCardHelper
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const TransferRenderListItem: React.FC<TransferRenderListItem> = ({
|
|
23
|
-
address, amount, sx, transferCardHelper, ...props
|
|
24
|
-
}) => {
|
|
25
|
-
const theme = useTheme()
|
|
26
|
-
return (
|
|
27
|
-
<ListItem sx={{ px: 0, ...sx }} {...props}>
|
|
28
|
-
<ListItemAvatar sx={{ minWidth: 30, mr: theme.spacing(2) }}>
|
|
29
|
-
<BlockiesAvatar title={address} sx={{ width: 30, height: 30 }} blockiesOptions={{ seed: address }} />
|
|
30
|
-
</ListItemAvatar>
|
|
31
|
-
<ListItemText sx={{ borderBottom: `1px solid ${theme.vars.palette.divider}` }}>
|
|
32
|
-
<Stack direction="row" gap={2} justifyContent="space-between" width="100%">
|
|
33
|
-
<Typography component="span" fontFamily="monospace" variant="caption">
|
|
34
|
-
{transferCardHelper.addressComponent(asAddress(address), 'To')}
|
|
35
|
-
</Typography>
|
|
36
|
-
<Typography
|
|
37
|
-
component="span"
|
|
38
|
-
fontFamily="monospace"
|
|
39
|
-
variant="caption"
|
|
40
|
-
title={isDefined(amount) ? hexToBigInt(amount).toString() : ''}
|
|
41
|
-
sx={{
|
|
42
|
-
display: 'inline-flex', alignItems: 'center', gap: theme.spacing(0.25),
|
|
43
|
-
}}
|
|
44
|
-
>
|
|
45
|
-
{transferCardHelper.formatAmountToXl1(amount)}
|
|
46
|
-
<NetworkIcon
|
|
47
|
-
icon={MainNetworkIconString}
|
|
48
|
-
style={{
|
|
49
|
-
width: 16, height: 16, display: 'inline-flex', alignItems: 'end',
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
(XL1)
|
|
53
|
-
</Typography>
|
|
54
|
-
</Stack>
|
|
55
|
-
</ListItemText>
|
|
56
|
-
</ListItem>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import {
|
|
3
|
-
type Address,
|
|
4
|
-
type Hex,
|
|
5
|
-
toHex,
|
|
6
|
-
ZERO_ADDRESS,
|
|
7
|
-
} from '@xylabs/sdk-js'
|
|
8
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
9
|
-
import { type Transfer, TransferSchema } from '@xyo-network/xl1-sdk'
|
|
10
|
-
import React from 'react'
|
|
11
|
-
|
|
12
|
-
import { TransferRenderCard } from './TransferRenderCard.tsx'
|
|
13
|
-
|
|
14
|
-
const transfer: Transfer = {
|
|
15
|
-
schema: TransferSchema,
|
|
16
|
-
epoch: 1_755_723_852_247,
|
|
17
|
-
from: ZERO_ADDRESS,
|
|
18
|
-
transfers: {
|
|
19
|
-
'1111111111111111111111111111111111111111': '1b1ae4d6e2ef500000',
|
|
20
|
-
'1111111111111111111111111111111111111112': '5150ae84a8cdf00000',
|
|
21
|
-
'1111111111111111111111111111111111111113': '989680',
|
|
22
|
-
'1111111111111111111111111111111111111114': '1b1ae4d6e2ef500000',
|
|
23
|
-
'1111111111111111111111111111111111111115': toHex(742n),
|
|
24
|
-
} as Record<Address, Hex>,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
title: 'Payloads/Transfer/Card',
|
|
29
|
-
component: TransferRenderCard,
|
|
30
|
-
} as Meta
|
|
31
|
-
|
|
32
|
-
const Template: StoryFn<typeof TransferRenderCard> = (args) => {
|
|
33
|
-
const [ref] = useEvent<HTMLDivElement>((noun, verb, data) => {
|
|
34
|
-
alert(`${noun} ${verb} ${data}`)
|
|
35
|
-
})
|
|
36
|
-
return (
|
|
37
|
-
<span ref={ref}>
|
|
38
|
-
<TransferRenderCard {...args} />
|
|
39
|
-
</span>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const Default = Template.bind({})
|
|
44
|
-
Default.args = {}
|
|
45
|
-
|
|
46
|
-
const WithValue = Template.bind({})
|
|
47
|
-
WithValue.args = { payload: transfer }
|
|
48
|
-
|
|
49
|
-
const WithOptions = Template.bind({})
|
|
50
|
-
WithOptions.args = { payload: transfer, options: { links: new Set(['address']) } }
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
Default, WithOptions, WithValue,
|
|
54
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { CardProps } from '@mui/material'
|
|
2
|
-
import {
|
|
3
|
-
Card, CardContent, CardHeader, List, useMediaQuery, useTheme,
|
|
4
|
-
} from '@mui/material'
|
|
5
|
-
import { asAddress, asHex } from '@xylabs/sdk-js'
|
|
6
|
-
import { BlockiesAvatar } from '@xyo-network/react-chain-blockies'
|
|
7
|
-
import { useEvent } from '@xyo-network/react-event'
|
|
8
|
-
import type { PayloadDetailsRenderProps } from '@xyo-network/react-payload-plugin'
|
|
9
|
-
import type { Payload } from '@xyo-network/sdk-js'
|
|
10
|
-
import { asTransfer } from '@xyo-network/xl1-sdk'
|
|
11
|
-
import React, { useMemo } from 'react'
|
|
12
|
-
|
|
13
|
-
import type { TransferRenderOptions } from '../lib/index.ts'
|
|
14
|
-
import { TransferRenderListItem } from './ListItem.tsx'
|
|
15
|
-
import { TransferCardHelper } from './TransferRenderCardHelper.tsx'
|
|
16
|
-
import { TransferRenderTotalTypography } from './TransferRenderTotalTypography.tsx'
|
|
17
|
-
|
|
18
|
-
export interface TransferRenderCardProps extends PayloadDetailsRenderProps, CardProps {
|
|
19
|
-
options?: TransferRenderOptions
|
|
20
|
-
payload?: Payload
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const TransferRenderCard: React.FC<TransferRenderCardProps> = ({
|
|
24
|
-
options, payload, ...props
|
|
25
|
-
}) => {
|
|
26
|
-
const theme = useTheme()
|
|
27
|
-
const isMedium = useMediaQuery(theme => theme.breakpoints.up('sm'))
|
|
28
|
-
const [ref, dispatch] = useEvent<HTMLDivElement>()
|
|
29
|
-
const transfer = asTransfer(payload)
|
|
30
|
-
const { from, transfers } = transfer ?? {}
|
|
31
|
-
|
|
32
|
-
const transferCardHelper = useMemo(
|
|
33
|
-
() =>
|
|
34
|
-
new TransferCardHelper(isMedium, asTransfer(payload), dispatch, options),
|
|
35
|
-
[isMedium, payload, dispatch, options],
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<Card ref={ref} {...props}>
|
|
40
|
-
<CardHeader
|
|
41
|
-
title={transferCardHelper.addressComponent(from, 'From')}
|
|
42
|
-
slotProps={{
|
|
43
|
-
title: {
|
|
44
|
-
title: from, variant: 'body1', fontFamily: 'monospace',
|
|
45
|
-
},
|
|
46
|
-
}}
|
|
47
|
-
avatar={<BlockiesAvatar sx={{ width: 30, height: 30 }} title={from} blockiesOptions={{ seed: from }} />}
|
|
48
|
-
/>
|
|
49
|
-
<CardContent sx={{ '&:last-child': { pb: theme.spacing(0) } }}>
|
|
50
|
-
<List>
|
|
51
|
-
{Object.entries(transfers ?? {}).map(([address, amount]) => (
|
|
52
|
-
<TransferRenderListItem
|
|
53
|
-
key={address}
|
|
54
|
-
address={asAddress(address)}
|
|
55
|
-
amount={asHex(amount)}
|
|
56
|
-
transferCardHelper={transferCardHelper}
|
|
57
|
-
/>
|
|
58
|
-
))}
|
|
59
|
-
</List>
|
|
60
|
-
<TransferRenderTotalTypography
|
|
61
|
-
transferRenderHelper={transferCardHelper}
|
|
62
|
-
sx={{
|
|
63
|
-
// pt matches bottom padding of the ListItem
|
|
64
|
-
width: '100%', justifyContent: 'end', pt: 0.666_666_666_7, pb: theme.spacing(2),
|
|
65
|
-
}}
|
|
66
|
-
/>
|
|
67
|
-
</CardContent>
|
|
68
|
-
</Card>
|
|
69
|
-
)
|
|
70
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { Link } from '@mui/material'
|
|
2
|
-
import type { Address, Hex } from '@xylabs/sdk-js'
|
|
3
|
-
import {
|
|
4
|
-
ellipsize, hexToBigInt, isDefined, isHex, isUndefined,
|
|
5
|
-
} from '@xylabs/sdk-js'
|
|
6
|
-
import type { EventDispatch } from '@xyo-network/react-event'
|
|
7
|
-
import {
|
|
8
|
-
type AttoXL1, type Transfer, XL1Places,
|
|
9
|
-
} from '@xyo-network/xl1-sdk'
|
|
10
|
-
import { XL1Amount } from '@xyo-network/xl1-sdk'
|
|
11
|
-
import type { ReactNode } from 'react'
|
|
12
|
-
import React from 'react'
|
|
13
|
-
|
|
14
|
-
import type { TransferRenderOptions } from '../lib/index.ts'
|
|
15
|
-
|
|
16
|
-
export class TransferCardHelper {
|
|
17
|
-
private _dispatch: EventDispatch | undefined
|
|
18
|
-
private _isMedium: boolean
|
|
19
|
-
private _options: TransferRenderOptions | undefined
|
|
20
|
-
private _payload: Transfer | undefined
|
|
21
|
-
|
|
22
|
-
constructor(
|
|
23
|
-
isMedium: boolean,
|
|
24
|
-
payload?: Transfer,
|
|
25
|
-
dispatch?: EventDispatch,
|
|
26
|
-
options?: TransferRenderOptions,
|
|
27
|
-
) {
|
|
28
|
-
this._isMedium = isMedium
|
|
29
|
-
this._options = options
|
|
30
|
-
this._payload = payload
|
|
31
|
-
this._dispatch = dispatch
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
get dispatch() {
|
|
35
|
-
return this._dispatch
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get isMedium() {
|
|
39
|
-
return this._isMedium
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get linkedAddresses() {
|
|
43
|
-
return this.options?.links?.has('address')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get options() {
|
|
47
|
-
return this._options
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get payload(): Transfer | undefined {
|
|
51
|
-
return this._payload
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
addressComponent(address?: Address, prefix?: string): ReactNode {
|
|
55
|
-
const resolvedPrefix = isDefined(prefix) ? `${prefix}: ` : ''
|
|
56
|
-
const text = `${this.formatAddress(address) ?? 'Unknown'}`
|
|
57
|
-
if (this.options?.links?.has('address')) {
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
{resolvedPrefix}
|
|
61
|
-
{' '}
|
|
62
|
-
<Link
|
|
63
|
-
onClick={() => {
|
|
64
|
-
this.dispatch?.('address', 'click', address)
|
|
65
|
-
}}
|
|
66
|
-
sx={{ cursor: 'pointer' }}
|
|
67
|
-
>
|
|
68
|
-
{text}
|
|
69
|
-
</Link>
|
|
70
|
-
</>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
return `${resolvedPrefix}${text}`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
formatAddress(address?: Address): string {
|
|
77
|
-
return (address ? (this.isMedium ? address : ellipsize(address, 5)) : '')
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
formatAmountToXl1(amount?: Hex | bigint): string {
|
|
81
|
-
if (isUndefined(amount)) return ''
|
|
82
|
-
const amountBigInt = isHex(amount) ? hexToBigInt(amount) : amount
|
|
83
|
-
const xl1Amount = XL1Amount.fromAtto(amountBigInt as AttoXL1).toString(Number(XL1Places.xl1), {
|
|
84
|
-
maxDecimal: 18, maxCharacters: 19, minDecimals: 0, locale: navigator.language,
|
|
85
|
-
})
|
|
86
|
-
return xl1Amount
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
totalTransferred() {
|
|
90
|
-
if (isUndefined(this.payload?.transfers)) return '0'
|
|
91
|
-
let total = 0n
|
|
92
|
-
for (const [, amount] of Object.entries(this.payload.transfers)) {
|
|
93
|
-
if (isDefined(amount)) {
|
|
94
|
-
total += hexToBigInt(amount)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return this.formatAmountToXl1(total)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { TypographyProps } from '@mui/material'
|
|
2
|
-
import { Typography, useTheme } from '@mui/material'
|
|
3
|
-
import { NetworkIcon } from '@xyo-network/react-chain-network'
|
|
4
|
-
import { MainNetworkIconString } from '@xyo-network/xl1-sdk'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import type { TransferCardHelper } from './TransferRenderCardHelper.tsx'
|
|
8
|
-
|
|
9
|
-
export interface TransferRenderTotalTypographyProps extends TypographyProps {
|
|
10
|
-
transferRenderHelper: TransferCardHelper
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const TransferRenderTotalTypography: React.FC<TransferRenderTotalTypographyProps> = ({
|
|
14
|
-
transferRenderHelper, sx, ...props
|
|
15
|
-
}) => {
|
|
16
|
-
const theme = useTheme()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Typography
|
|
20
|
-
sx={{
|
|
21
|
-
display: 'inline-flex', gap: theme.spacing(0.25), fontFamily: 'monospace', ...sx,
|
|
22
|
-
}}
|
|
23
|
-
variant="caption"
|
|
24
|
-
{...props}
|
|
25
|
-
>
|
|
26
|
-
Total:
|
|
27
|
-
{' '}
|
|
28
|
-
<strong>{transferRenderHelper?.totalTransferred()}</strong>
|
|
29
|
-
<NetworkIcon
|
|
30
|
-
icon={MainNetworkIconString}
|
|
31
|
-
style={{
|
|
32
|
-
width: 16, height: 16, display: 'inline-flex', alignItems: 'end',
|
|
33
|
-
}}
|
|
34
|
-
/>
|
|
35
|
-
(XL1)
|
|
36
|
-
</Typography>
|
|
37
|
-
)
|
|
38
|
-
}
|