Skip to content

Commit afdd9ca

Browse files
committed
Merge branch 'main' of https://github.com/vechain/vechain-kit into jennifer/78-request---setup-analytics
2 parents 24cba62 + 6fc987a commit afdd9ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2240
-961
lines changed

.github/workflows/deploy-cloudfront.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ jobs:
2323
build-and-deploy:
2424
runs-on: ubuntu-latest
2525
env:
26-
BASE_PATH: ''
26+
NEXT_PUBLIC_BASE_PATH: ''
2727
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID }}
2828
NEXT_PUBLIC_PRIVY_APP_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_APP_ID }}
2929
NEXT_PUBLIC_PRIVY_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_CLIENT_ID }}
3030
NEXT_PUBLIC_DELEGATOR_URL: ${{ secrets.NEXT_PUBLIC_DELEGATOR_URL }}
3131
NEXT_PUBLIC_NETWORK_TYPE: 'main'
32+
AWS_REGION: eu-west-1
3233
steps:
3334
- name: Checkout
3435
uses: actions/checkout@v4
@@ -50,7 +51,7 @@ jobs:
5051
uses: aws-actions/configure-aws-credentials@v4
5152
with:
5253
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
53-
aws-region: eu-west-1
54+
aws-region: ${{ env.AWS_REGION }}
5455

5556
- name: Deploy to S3
5657
run: |
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Deploy Preview Environment
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths: ['examples/homepage/**', 'packages/vechain-kit/**', 'yarn.lock']
8+
9+
permissions:
10+
contents: read
11+
id-token: write
12+
pull-requests: write
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
env:
18+
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID }}
19+
NEXT_PUBLIC_PRIVY_APP_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_APP_ID }}
20+
NEXT_PUBLIC_PRIVY_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_PRIVY_CLIENT_ID }}
21+
NEXT_PUBLIC_DELEGATOR_URL: ${{ secrets.NEXT_PUBLIC_DELEGATOR_URL }}
22+
NEXT_PUBLIC_NETWORK_TYPE: 'main'
23+
AWS_REGION: eu-west-1
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Process Branch Name
29+
id: process-branch-name
30+
run: |
31+
sanitized_branch_name=$(echo "${{ github.event.pull_request.head.ref }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g')
32+
echo "processedBranchName=$sanitized_branch_name" >> $GITHUB_OUTPUT
33+
echo "NEXT_PUBLIC_BASE_PATH=/$sanitized_branch_name" >> $GITHUB_ENV
34+
35+
- name: Build App
36+
env:
37+
NODE_OPTIONS: '--max-old-space-size=8192'
38+
run: |
39+
yarn install:all
40+
yarn build
41+
42+
- name: Fix permissions
43+
run: |
44+
chmod -c -R +rX "./examples/homepage/dist" | while read line; do
45+
echo "::warning title=Invalid file permissions automatically fixed::$line"
46+
done
47+
48+
- name: Configure AWS credentials
49+
uses: aws-actions/configure-aws-credentials@v4
50+
with:
51+
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
52+
aws-region: ${{ env.AWS_REGION }}
53+
54+
- name: Deploy to S3
55+
run: |
56+
aws s3 sync ./examples/homepage/dist s3://${{ secrets.AWS_PREVIEW_BUCKET_NAME }}/${{ steps.process-branch-name.outputs.processedBranchName }} --delete
57+
58+
- name: Cloudfront Invalidation
59+
run: |
60+
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_PREVIEW_CLOUDFRONT_DISTRIBUTION_ID }} --paths '/' '/*'
61+
62+
- name: Create Deployment Comment
63+
if: github.event.action == 'opened' || github.event.action == 'reopened'
64+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
65+
with:
66+
issue-number: ${{ github.event.pull_request.number }}
67+
body: |
68+
# 🚀 Preview environment deployed!
69+
Preview URL: https://preview.vechainkit.vechain.org/${{ steps.process-branch-name.outputs.processedBranchName }}
70+
edit-mode: replace
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Destroy Preview Environment
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths: ['examples/homepage/**', 'packages/vechain-kit/**', 'yarn.lock']
8+
types: [closed]
9+
10+
permissions:
11+
contents: read
12+
id-token: write
13+
pull-requests: write
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Configure AWS credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
role-to-assume: ${{ secrets.AWS_ACC_ROLE }}
23+
aws-region: eu-west-1
24+
25+
- name: Process Branch Name
26+
id: process-branch-name
27+
run: |
28+
sanitized_branch_name=$(echo "${{ github.event.pull_request.head.ref }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]//g')
29+
echo "processedBranchName=$sanitized_branch_name" >> $GITHUB_OUTPUT
30+
31+
- name: Remove Preview Environment from S3
32+
run: |
33+
aws s3 rm s3://${{ secrets.AWS_PREVIEW_BUCKET_NAME }}/${{ steps.process-branch-name.outputs.processedBranchName }} --recursive
34+
35+
- name: Find Previous Deployment Comment
36+
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
37+
id: find-comment
38+
with:
39+
issue-number: ${{ github.event.pull_request.number }}
40+
comment-author: 'github-actions[bot]'
41+
body-includes: '🚀 Preview environment deployed!'
42+
43+
- name: Remove Deployment PR Comment
44+
run: gh api --method DELETE /repos/${{ github.repository }}/issues/comments/${{ steps.find-comment.outputs.comment-id }}
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

examples/homepage/next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const basePath = process.env.BASE_PATH ?? '';
1+
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? '';
22

33
/** @type {import('next').NextConfig} */
44
const nextConfig = {

examples/homepage/src/app/components/features/Introduction/Introduction.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function Introduction() {
3333
});
3434
};
3535

36+
const basePath = process.env.basePath ?? '';
3637
return (
3738
<Box
3839
p={8}
@@ -160,42 +161,42 @@ export function Introduction() {
160161
<Icon as={SiFarcaster} boxSize={6} />
161162
<Icon as={FaApple} boxSize={6} />
162163
<Image
163-
src="/images/veworld-logo.png"
164+
src={`${basePath}/images/veworld-logo.png`}
164165
alt="VeWorld"
165166
height={6}
166167
width="auto"
167168
borderRadius="md"
168169
/>
169170
<Image
170-
src="/images/wallet-connect-logo.png"
171+
src={`${basePath}/images/wallet-connect-logo.png`}
171172
alt="WalletConnect"
172173
height={6}
173174
width="auto"
174175
borderRadius="md"
175176
/>
176177
<Image
177-
src="/images/rabby-logo.png"
178+
src={`${basePath}/images/rabby-logo.png`}
178179
alt="Rabby Wallet"
179180
height={6}
180181
width="auto"
181182
borderRadius="md"
182183
/>
183184
<Image
184-
src="/images/metamask-logo.png"
185+
src={`${basePath}/images/metamask-logo.png`}
185186
alt="MetaMask"
186187
height={6}
187188
width="auto"
188189
borderRadius="md"
189190
/>
190191
<Image
191-
src="/images/coinbase-wallet-logo.webp"
192+
src={`${basePath}/images/coinbase-wallet-logo.webp`}
192193
alt="Coinbase Wallet"
193194
height={6}
194195
width="auto"
195196
borderRadius="md"
196197
/>
197198
<Image
198-
src="/images/rainbow-logo.webp"
199+
src={`${basePath}/images/rainbow-logo.webp`}
199200
alt="Rainbow"
200201
height={6}
201202
width="auto"

examples/homepage/src/app/components/features/Signing/SigningExample.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const exampleTypedData = {
4141
};
4242

4343
export function SigningExample(): ReactElement {
44-
const { connection } = useWallet();
44+
const { connection, account } = useWallet();
4545
const toast = useToast();
4646

4747
const {
@@ -80,7 +80,9 @@ export function SigningExample(): ReactElement {
8080

8181
const handleSignTypedData = useCallback(async () => {
8282
try {
83-
const signature = await signTypedData(exampleTypedData);
83+
const signature = await signTypedData(exampleTypedData, {
84+
signer: account?.address,
85+
});
8486
toast({
8587
title: 'Typed data signed!',
8688
description: `Signature: ${signature.slice(0, 20)}...`,
@@ -98,7 +100,7 @@ export function SigningExample(): ReactElement {
98100
isClosable: true,
99101
});
100102
}
101-
}, [signTypedData, toast]);
103+
}, [signTypedData, toast, account]);
102104

103105
if (!connection.isConnected) {
104106
return (

examples/homepage/src/app/components/features/UIControls/UIControls.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ export function UIControls() {
226226
specific sections. (Customize your profile to see how
227227
this card changes)
228228
</Text>
229-
<VStack w={'fit-content'}>
229+
<Grid
230+
templateColumns={['repeat(1, 1fr)', 'repeat(2, 1fr)']}
231+
gap={4}
232+
w="full"
233+
>
230234
<ProfileCard
231235
address={account?.address ?? ''}
232236
showEdit={false}
@@ -239,7 +243,15 @@ export function UIControls() {
239243
},
240244
}}
241245
/>
242-
</VStack>
246+
247+
<ProfileCard
248+
address={
249+
'0x73D1d7e67B9696Be68F53fb80C7e6e50b314a62f'
250+
}
251+
showEdit={false}
252+
showHeader={false}
253+
/>
254+
</Grid>
243255
</VStack>
244256
</VStack>
245257
</CollapsibleCard>

examples/homepage/src/app/layout.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function RootLayout({
2323
}: Readonly<{
2424
children: React.ReactNode;
2525
}>) {
26+
const basePath = process.env.basePath ?? '';
2627
return (
2728
<html
2829
lang="en"
@@ -41,15 +42,15 @@ export default function RootLayout({
4142
name="viewport"
4243
content="width=device-width, initial-scale=1.0"
4344
/>
44-
<link rel="icon" href="/images/logo.png" type="image/png" />
45+
<link rel="icon" href={`${basePath}/images/logo.png`} type="image/png" />
4546
<link
4647
rel="apple-touch-icon"
4748
sizes="57x57"
48-
href="/images/favicon/apple-touch-icon.png"
49+
href={`${basePath}/images/favicon/apple-touch-icon.png`}
4950
/>
5051
<meta
5152
name="msapplication-TileImage"
52-
content="/images/favicon/apple-touch-icon.png"
53+
content={`${basePath}/images/favicon/apple-touch-icon.png`}
5354
/>
5455

5556
{/* Open Graph Metadata */}
@@ -66,7 +67,7 @@ export default function RootLayout({
6667
<meta property="og:site_name" content="VeChain Kit" />
6768
<meta
6869
property="og:image"
69-
content="/images/vechain-kit-long.png"
70+
content={`${basePath}/images/vechain-kit-long.png`}
7071
/>
7172
<meta property="og:image:type" content="image/png" />
7273
<meta property="og:image:width" content="1200" />
@@ -82,7 +83,7 @@ export default function RootLayout({
8283
/>
8384
<meta
8485
name="twitter:image"
85-
content="/images/vechain-kit-long.png"
86+
content={`${basePath}/images/vechain-kit-long.png`}
8687
/>
8788
<meta name="twitter:image:alt" content="VeChain Kit" />
8889
</head>

examples/next-template/src/app/components/features/SigningExample/SigningExample.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const exampleTypedData = {
3737
};
3838

3939
export function SigningExample(): ReactElement {
40-
const { connection } = useWallet();
40+
const { connection, account } = useWallet();
4141
const toast = useToast();
4242

4343
const {
@@ -76,7 +76,9 @@ export function SigningExample(): ReactElement {
7676

7777
const handleSignTypedData = useCallback(async () => {
7878
try {
79-
const signature = await signTypedData(exampleTypedData);
79+
const signature = await signTypedData(exampleTypedData, {
80+
signer: account?.address,
81+
});
8082
toast({
8183
title: 'Typed data signed!',
8284
description: `Signature: ${signature.slice(0, 20)}...`,
@@ -94,7 +96,7 @@ export function SigningExample(): ReactElement {
9496
isClosable: true,
9597
});
9698
}
97-
}, [signTypedData, toast]);
99+
}, [signTypedData, toast, account]);
98100

99101
if (!connection.isConnected) {
100102
return (

packages/vechain-kit/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vechain/vechain-kit",
3-
"version": "1.5.7",
3+
"version": "1.5.13",
44
"private": false,
55
"homepage": "https://github.com/vechain/vechain-kit",
66
"repository": "github:vechain/vechain-kit",
@@ -93,7 +93,9 @@
9393
},
9494
"resolutions": {
9595
"@vechain/sdk-core": "^1.0.0-rc.5",
96-
"@vechain/sdk-network": "^1.0.0-rc.5"
96+
"@vechain/sdk-network": "^1.0.0-rc.5",
97+
"@vechain/dapp-kit-ui": "1.5.0",
98+
"@vechain/dapp-kit": "1.5.0"
9799
},
98100
"overrides": {
99101
"@vechain/sdk-core": "^1.0.0-rc.5",

0 commit comments

Comments
 (0)