Skip to content

Commit

Permalink
chore: package updates (#39)
Browse files Browse the repository at this point in the history
chore: package updates
  • Loading branch information
neilcampbell authored Nov 25, 2024
1 parent 3de40ca commit e5dbf54
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 217 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
# set git user and email as test invoke git
git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Run tests
shell: bash
run: |
Expand Down
3 changes: 0 additions & 3 deletions examples/cloud_provider/production_react_netlify/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
</head>
<body>
<div id="root"></div>
<script>
global = globalThis
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
29 changes: 16 additions & 13 deletions examples/cloud_provider/production_react_netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"private": true,
"type": "module",
"engines": {
"node": ">=18.0",
"node": ">=20.0",
"npm": ">=9.0"
},
"devDependencies": {
"@algorandfoundation/algokit-client-generator": "^3.0.3",
"@algorandfoundation/algokit-client-generator": "^4.0.0",
"@types/node": "^18.17.14",
"@types/react": "^18.2.11",
"@types/react-dom": "^18.2.4",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.14",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"postcss": "^8.4.24",
"tailwindcss": "3.3.2",
"ts-jest": "^29.1.1",
Expand All @@ -31,16 +31,16 @@
"typescript": "^5.1.6",
"@playwright/test": "^1.35.0",
"playwright": "^1.35.0",
"vite": "^5.0.0"
"vite": "^5.0.0",
"vite-plugin-node-polyfills": "^0.22.0"
},
"dependencies": {
"@walletconnect/modal-sign-html": "^2.6.1",
"@algorandfoundation/algokit-utils": "^6.0.2",
"@algorandfoundation/algokit-utils": "^7.0.0",
"@blockshake/defly-connect": "^1.1.6",
"@daffiwallet/connect": "^1.0.3",
"@perawallet/connect": "^1.3.1",
"@txnlab/use-wallet": "^2.4.0",
"algosdk": "^2.7.0",
"@perawallet/connect": "^1.3.4",
"@txnlab/use-wallet": "^2.8.2",
"algosdk": ">=2.9.0 <3.0",
"daisyui": "^4.0.0",
"notistack": "^3.0.1",
"react": "^18.2.0",
Expand Down Expand Up @@ -74,5 +74,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"overrides": {
"ws@>7.0.0 <7.5.9": "7.5.10"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { algo, AlgorandClient } from '@algorandfoundation/algokit-utils'
import { useWallet } from '@txnlab/use-wallet'
import algosdk from 'algosdk'
import { useSnackbar } from 'notistack'
import { useState } from 'react'
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
Expand All @@ -15,15 +14,11 @@ const Transact = ({ openModal, setModalState }: TransactInterface) => {
const [receiverAddress, setReceiverAddress] = useState<string>('')

const algodConfig = getAlgodConfigFromViteEnvironment()
const algodClient = algokit.getAlgoClient({
server: algodConfig.server,
port: algodConfig.port,
token: algodConfig.token,
})
const algorand = AlgorandClient.fromConfig({ algodConfig })

const { enqueueSnackbar } = useSnackbar()

const { signer, activeAddress, signTransactions, sendTransactions } = useWallet()
const { signer, activeAddress } = useWallet()

const handleSubmitAlgo = async () => {
setLoading(true)
Expand All @@ -33,25 +28,15 @@ const Transact = ({ openModal, setModalState }: TransactInterface) => {
return
}

const suggestedParams = await algodClient.getTransactionParams().do()

const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: activeAddress,
to: receiverAddress,
amount: 1e6,
suggestedParams,
})

const encodedTransaction = algosdk.encodeUnsignedTransaction(transaction)

const signedTransactions = await signTransactions([encodedTransaction])

const waitRoundsToConfirm = 4

try {
enqueueSnackbar('Sending transaction...', { variant: 'info' })
const { id } = await sendTransactions(signedTransactions, waitRoundsToConfirm)
enqueueSnackbar(`Transaction sent: ${id}`, { variant: 'success' })
const result = await algorand.send.payment({
signer,
sender: activeAddress,
receiver: receiverAddress,
amount: algo(1),
})
enqueueSnackbar(`Transaction sent: ${result.txIds[0]}`, { variant: 'success' })
setReceiverAddress('')
} catch (e) {
enqueueSnackbar('Failed to send transaction', { variant: 'error' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { randomAccount } from '@algorandfoundation/algokit-utils'
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { expect, test } from '@playwright/test'

const localnet = algorandFixture()

test.beforeEach(async ({ page }) => {
await localnet.beforeEach()
await page.goto('http://localhost:5173/')
})

Expand All @@ -27,8 +30,7 @@ test('authentication and dummy payment transaction', async ({ page }) => {
// 2. Must be able to send a dummy payment transaction
await page.getByTestId('transactions-demo').click()

const dummyAccount = randomAccount()
await page.getByTestId('receiver-address').fill(dummyAccount.addr)
await page.getByTestId('receiver-address').fill(localnet.context.testAccount.addr)
await page.getByTestId('send-algo').click()

// 3. Must be able to see a notification that the transaction was sent
Expand Down
10 changes: 9 additions & 1 deletion examples/cloud_provider/production_react_netlify/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [
react(),
nodePolyfills({
globals: {
Buffer: true,
},
}),
],
})
3 changes: 0 additions & 3 deletions examples/cloud_provider/production_react_vercel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
</head>
<body>
<div id="root"></div>
<script>
global = globalThis
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
29 changes: 16 additions & 13 deletions examples/cloud_provider/production_react_vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
"private": true,
"type": "module",
"engines": {
"node": ">=18.0",
"node": ">=20.0",
"npm": ">=9.0"
},
"devDependencies": {
"@algorandfoundation/algokit-client-generator": "^3.0.3",
"@algorandfoundation/algokit-client-generator": "^4.0.0",
"@types/node": "^18.17.14",
"@types/react": "^18.2.11",
"@types/react-dom": "^18.2.4",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.14",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"postcss": "^8.4.24",
"tailwindcss": "3.3.2",
"ts-jest": "^29.1.1",
Expand All @@ -31,16 +31,16 @@
"typescript": "^5.1.6",
"@playwright/test": "^1.35.0",
"playwright": "^1.35.0",
"vite": "^5.0.0"
"vite": "^5.0.0",
"vite-plugin-node-polyfills": "^0.22.0"
},
"dependencies": {
"@walletconnect/modal-sign-html": "^2.6.1",
"@algorandfoundation/algokit-utils": "^6.0.2",
"@algorandfoundation/algokit-utils": "^7.0.0",
"@blockshake/defly-connect": "^1.1.6",
"@daffiwallet/connect": "^1.0.3",
"@perawallet/connect": "^1.3.1",
"@txnlab/use-wallet": "^2.4.0",
"algosdk": "^2.7.0",
"@perawallet/connect": "^1.3.4",
"@txnlab/use-wallet": "^2.8.2",
"algosdk": ">=2.9.0 <3.0",
"daisyui": "^4.0.0",
"notistack": "^3.0.1",
"react": "^18.2.0",
Expand Down Expand Up @@ -77,5 +77,8 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"overrides": {
"ws@>7.0.0 <7.5.9": "7.5.10"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as algokit from '@algorandfoundation/algokit-utils'
import { algo, AlgorandClient } from '@algorandfoundation/algokit-utils'
import { useWallet } from '@txnlab/use-wallet'
import algosdk from 'algosdk'
import { useSnackbar } from 'notistack'
import { useState } from 'react'
import { getAlgodConfigFromViteEnvironment } from '../utils/network/getAlgoClientConfigs'
Expand All @@ -15,15 +14,11 @@ const Transact = ({ openModal, setModalState }: TransactInterface) => {
const [receiverAddress, setReceiverAddress] = useState<string>('')

const algodConfig = getAlgodConfigFromViteEnvironment()
const algodClient = algokit.getAlgoClient({
server: algodConfig.server,
port: algodConfig.port,
token: algodConfig.token,
})
const algorand = AlgorandClient.fromConfig({ algodConfig })

const { enqueueSnackbar } = useSnackbar()

const { signer, activeAddress, signTransactions, sendTransactions } = useWallet()
const { signer, activeAddress } = useWallet()

const handleSubmitAlgo = async () => {
setLoading(true)
Expand All @@ -33,25 +28,15 @@ const Transact = ({ openModal, setModalState }: TransactInterface) => {
return
}

const suggestedParams = await algodClient.getTransactionParams().do()

const transaction = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
from: activeAddress,
to: receiverAddress,
amount: 1e6,
suggestedParams,
})

const encodedTransaction = algosdk.encodeUnsignedTransaction(transaction)

const signedTransactions = await signTransactions([encodedTransaction])

const waitRoundsToConfirm = 4

try {
enqueueSnackbar('Sending transaction...', { variant: 'info' })
const { id } = await sendTransactions(signedTransactions, waitRoundsToConfirm)
enqueueSnackbar(`Transaction sent: ${id}`, { variant: 'success' })
const result = await algorand.send.payment({
signer,
sender: activeAddress,
receiver: receiverAddress,
amount: algo(1),
})
enqueueSnackbar(`Transaction sent: ${result.txIds[0]}`, { variant: 'success' })
setReceiverAddress('')
} catch (e) {
enqueueSnackbar('Failed to send transaction', { variant: 'error' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { randomAccount } from '@algorandfoundation/algokit-utils'
import { algorandFixture } from '@algorandfoundation/algokit-utils/testing'
import { expect, test } from '@playwright/test'

const localnet = algorandFixture()

test.beforeEach(async ({ page }) => {
await localnet.beforeEach()
await page.goto('http://localhost:5173/')
})

Expand All @@ -27,8 +30,7 @@ test('authentication and dummy payment transaction', async ({ page }) => {
// 2. Must be able to send a dummy payment transaction
await page.getByTestId('transactions-demo').click()

const dummyAccount = randomAccount()
await page.getByTestId('receiver-address').fill(dummyAccount.addr)
await page.getByTestId('receiver-address').fill(localnet.context.testAccount.addr)
await page.getByTestId('send-algo').click()

// 3. Must be able to see a notification that the transaction was sent
Expand Down
10 changes: 9 additions & 1 deletion examples/cloud_provider/production_react_vercel/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [
react(),
nodePolyfills({
globals: {
Buffer: true,
},
}),
],
})
3 changes: 0 additions & 3 deletions examples/production_react/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
</head>
<body>
<div id="root"></div>
<script>
global = globalThis
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading

0 comments on commit e5dbf54

Please sign in to comment.