Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update taquito #413

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,435 changes: 7,087 additions & 5,348 deletions package-lock.json

Large diffs are not rendered by default.

123 changes: 62 additions & 61 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,37 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@taquito/beacon-wallet": "^17.4.0",
"@taquito/michelson-encoder": "^17.4.0",
"@taquito/taquito": "^17.4.0",
"axios": "^0.27.2",
"@airgap/beacon-sdk": "4.2.2",
"@taquito/beacon-wallet": "19.2.1",
"@taquito/michelson-encoder": "^19.2.1",
"@taquito/taquito": "^19.2.1",
"axios": "^1.6.8",
"base-x": "^4.0.0",
"bs58check": "^2.1.2",
"classnames": "^2.3.2",
"compressorjs": "^1.1.1",
"fflate": "^0.7.4",
"framer-motion": "^9.0.1",
"graphql": "^16.4.0",
"graphql-request": "^4.2.0",
"bs58check": "^3.0.1",
"classnames": "^2.5.1",
"compressorjs": "^1.2.1",
"fflate": "^0.8.2",
"framer-motion": "^11.2.4",
"graphql": "^16.8.1",
"graphql-request": "^7.0.1",
"json5": "^2.2.3",
"keyboardjs": "^2.7.0",
"markdown-to-jsx": "^7.1.9",
"markdown-to-jsx": "^7.4.7",
"mime-types": "^2.1.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.43.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.51.4",
"react-infinite-scroller": "^1.2.6",
"react-intersection-observer": "^9.4.2",
"react-lazy-load-image-component": "^1.5.6",
"react-intersection-observer": "^9.10.2",
"react-lazy-load-image-component": "^1.6.0",
"react-masonry-css": "^1.0.16",
"react-router": "^6.8.1",
"react-router-dom": "^6.8.1",
"react-select": "^5.7.0",
"react-use": "^17.4.0",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"react-select": "^5.8.0",
"react-use": "^17.5.0",
"react-use-clipboard": "^1.0.9",
"screenfull": "^6.0.2",
"swr": "^1.3.0"
"swr": "^2.2.5"
},
"scripts": {
"analyze": "source-map-explorer 'build/assets/*.js'",
Expand Down Expand Up @@ -68,62 +69,62 @@
]
},
"devDependencies": {
"@airgap/beacon-types": "^3.3.3",
"@babel/preset-react": "^7.18.6",
"@google/model-viewer": "^3.0.1",
"@hookform/devtools": "^4.3.0",
"@storybook/addon-essentials": "^7.6.11",
"@storybook/addon-interactions": "^7.6.11",
"@storybook/addon-links": "^7.6.11",
"@storybook/blocks": "^7.6.11",
"@storybook/react": "^7.6.11",
"@storybook/react-vite": "^7.6.11",
"@airgap/beacon-types": "^4.2.2",
"@babel/preset-react": "^7.24.1",
"@google/model-viewer": "^3.5.0",
"@hookform/devtools": "^4.3.1",
"@storybook/addon-essentials": "^8.1.1",
"@storybook/addon-interactions": "^8.1.1",
"@storybook/addon-links": "^8.1.1",
"@storybook/blocks": "^8.1.1",
"@storybook/react": "^8.1.1",
"@storybook/react-vite": "^8.1.1",
"@storybook/testing-library": "^0.2.2",
"@testing-library/jest-dom": "^6.4.0",
"@testing-library/react": "^14.2.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.5.2",
"@vitejs/plugin-react": "^3.1.0",
"assert": "^2.0.0",
"@vitejs/plugin-react": "^4.2.1",
"assert": "^2.1.0",
"buffer": "^6.0.3",
"cross-env": "^7.0.3",
"cssnano": "^5.1.14",
"cssnano": "^7.0.1",
"eslint": "^8.34.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.1",
"fnv1a": "^1.1.1",
"fs-extra": "^11.1.0",
"husky": "^7.0.4",
"libsodium-wrappers": "^0.7.11",
"fs-extra": "^11.2.0",
"husky": "^9.0.11",
"libsodium-wrappers": "^0.7.13",
"lodash": "^4.17.21",
"path-browserify": "^1.0.1",
"postcss": "^8.4.21",
"postcss": "^8.4.38",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-preset-env": "^7.8.3",
"prettier": "^2.8.4",
"postcss-preset-env": "^9.5.13",
"prettier": "^3.2.5",
"process": "^0.11.10",
"prop-types": "^15.8.1",
"react-pdf": "^6.2.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-polyfill-node": "^0.12.0",
"sass": "^1.58.1",
"rollup-plugin-polyfill-node": "^0.13.0",
"sass": "^1.77.2",
"source-map-explorer": "^2.5.3",
"storybook": "^7.6.11",
"stylelint": "^14.16.1",
"stylelint-config-standard-scss": "^6.1.0",
"storybook": "^8.1.1",
"stylelint": "^16.5.0",
"stylelint-config-standard-scss": "^13.1.0",
"twemoji": "^14.0.2",
"typescript": "^4.9.5",
"vite": "^4.1.1",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite-compatible-readable-stream": "^3.6.1",
"vite-plugin-ejs": "^1.6.4",
"vite-plugin-ejs": "^1.7.0",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-filter-replace": "^0.1.10",
"vite-plugin-markdown": "^2.1.0",
"vite-plugin-node-polyfills": "^0.7.0",
"vite-plugin-node-stdlib-browser": "^0.1.1",
"vite-plugin-svgr": "^2.4.0",
"vite-tsconfig-paths": "^4.0.5",
"zustand": "^4.3.3"
"vite-plugin-filter-replace": "^0.1.13",
"vite-plugin-markdown": "^2.2.0",
"vite-plugin-node-polyfills": "^0.21.0",
"vite-plugin-node-stdlib-browser": "^0.2.1",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2",
"zustand": "^4.5.2"
},
"overrides": {
"vite-plugin-markdown": {
Expand All @@ -135,6 +136,6 @@
},
"module": "commonjs",
"optionalDependencies": {
"@playwright/test": "^1.41.1"
"@playwright/test": "^1.44.0"
}
}
42 changes: 22 additions & 20 deletions src/context/userStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { useModalStore } from './modalStore'
// import teiaSwapLambda from '@components/collab/lambdas/teiaMarketplaceSwap.json'
import teiaCancelSwapLambda from '@components/collab/lambdas/teiaMarketplaceCancelSwap.json'
import type { Listing, NFT, SubjktInfo, Tx } from '@types'
import { BeaconEvent } from '@airgap/beacon-dapp'

// type OperationReturn = Promise<string | TransactionWalletOperation | undefined>
type OperationReturn = Promise<string | undefined>
Expand Down Expand Up @@ -123,9 +124,9 @@ export const Tezos = new TezosToolkit(useLocalSettings.getState().getRpcNode())
const Packer = new MichelCodecPacker()

const wallet = new BeaconWallet({
name: 'teia.art',
appUrl: 'https://teia.art',
iconUrl: 'https://teia.art/icons/android-chrome-512x512.png',
name: window.location.hostname,
appUrl: window.location.origin,
iconUrl: window.location.origin + '/icons/android-chrome-512x512.png',
preferredNetwork: NetworkType.MAINNET,
})

Expand Down Expand Up @@ -190,23 +191,24 @@ export const useUserStore = create<UserState>()(
// We check the storage and only do a permission request if we don't have an active account yet
// This piece of code should be called on startup to "load" the current address from the user
// If the activeAccount is present, no "permission request" is required again, unless the user "disconnects" first.
let activeAccount = await wallet.client.getActiveAccount()
if (
activeAccount === undefined ||
activeAccount?.network?.rpcUrl !== network.rpcUrl
) {
await wallet.requestPermissions({ network })
activeAccount = await wallet.client.getActiveAccount()
}
const current = await wallet.getPKH()
if (current) {
const info = await getUser(current)
console.log('getting user info', info)
set({
address: current,
userInfo: await getUser(current),
})
}
let current
await wallet.client.subscribeToEvent(
BeaconEvent.ACTIVE_ACCOUNT_SET,
async (account) => {
// An active account has been set, update the dApp UI
console.log(`${BeaconEvent.ACTIVE_ACCOUNT_SET} triggered: `, account);
if(account) {
current = account.address
const info = await getUser(current)
console.log('getting user info', info)
set({
address: current,
userInfo: await getUser(current),
})
}
},
);
await wallet.requestPermissions({ network })

// console.log(this.state)
return current
Expand Down
1 change: 1 addition & 0 deletions src/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export const GetUserMetadata = async (walletAddr: string) => {
*/
export async function getTzktData(query: string, parameters = {}, debug = false) {
const url = import.meta.env.VITE_TZKT_API + query

const response = await axios
.get(url, { params: parameters })
.catch((error) =>
Expand Down
34 changes: 17 additions & 17 deletions src/data/swr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function reorderBigmapData(data, subKey, decode = false) {
(item) =>
(bigmapData[subKey ? item.key[subKey] : item.key] = decode
? bytes2Char(item.value)
: item.value)
: item.value),
)

return bigmapData
Expand All @@ -18,7 +18,7 @@ function reorderBigmapData(data, subKey, decode = false) {
export function useBalance(address) {
const { data, mutate } = useSWR(
address ? `/v1/accounts/${address}/balance` : null,
getTzktData
(url) => getTzktData(url),
)

return [data ? data / 1000000 : 0, mutate]
Expand All @@ -33,7 +33,7 @@ export function useDaoTokenBalance(address) {
}
const { data, mutate } = useSWR(
address ? [`/v1/tokens/balances`, parameters] : null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [data?.[0] ? parseInt(data[0]) / DAO_TOKEN_DECIMALS : 0, mutate]
Expand All @@ -42,7 +42,7 @@ export function useDaoTokenBalance(address) {
export function useStorage(contractAddress) {
const { data, mutate } = useSWR(
contractAddress ? `/v1/contracts/${contractAddress}/storage` : null,
getTzktData
(url) => getTzktData(url),
)

return [data, mutate]
Expand All @@ -58,7 +58,7 @@ export function useDaoGovernanceParameters(daoStorage) {
daoStorage?.governance_parameters
? [`/v1/bigmaps/${daoStorage.governance_parameters}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data), mutate]
Expand All @@ -74,7 +74,7 @@ export function useDaoProposals(daoStorage) {
daoStorage?.proposals
? [`/v1/bigmaps/${daoStorage.proposals}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data), mutate]
Expand All @@ -85,7 +85,7 @@ export function useDaoRepresentatives(daoStorage) {
daoStorage?.representatives
? `/v1/contracts/${daoStorage.representatives}/storage`
: null,
getTzktData
(url) => getTzktData(url),
)

const representatives = data?.representatives
Expand All @@ -94,7 +94,7 @@ export function useDaoRepresentatives(daoStorage) {
if (com1 < com2) return -1
if (com1 > com2) return 1
return 0
})
}),
)
: undefined

Expand All @@ -112,7 +112,7 @@ export function useDaoUserVotes(address, daoStorage) {
address && daoStorage?.token_votes
? [`/v1/bigmaps/${daoStorage.token_votes}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data, 'nat'), mutate]
Expand All @@ -129,7 +129,7 @@ export function useDaoCommunityVotes(community, daoStorage) {
community && daoStorage?.representatives_votes
? [`/v1/bigmaps/${daoStorage.representatives_votes}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data, 'nat'), mutate]
Expand All @@ -146,7 +146,7 @@ export function useAliases(addresses) {
}
const { data, mutate } = useSWR(
addresses?.length > 0 ? [`/v1/bigmaps/3919/keys`, parameters] : null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data, undefined, true), mutate]
Expand All @@ -169,11 +169,11 @@ export function useDaoUsersAliases(userAddress, representatives, proposals) {

if (proposal.kind.transfer_mutez) {
proposal.kind.transfer_mutez.forEach((transfer) =>
addresses.add(transfer.destination)
addresses.add(transfer.destination),
)
} else if (proposal.kind.transfer_token)
proposal.kind.transfer_token.distribution.forEach((transfer) =>
addresses.add(transfer.destination)
addresses.add(transfer.destination),
)
})
}
Expand All @@ -189,7 +189,7 @@ export function useDaoMemberCount(minTokens) {
}
const { data, mutate } = useSWR(
['/v1/tokens/balances/count', parameters],
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [data ? parseInt(data) : 0, mutate]
Expand All @@ -205,7 +205,7 @@ export function usePolls(pollsStorage) {
pollsStorage?.polls
? [`/v1/bigmaps/${pollsStorage.polls}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data), mutate]
Expand All @@ -222,7 +222,7 @@ export function useUserPollVotes(address, pollsStorage) {
address && pollsStorage?.votes
? [`/v1/bigmaps/${pollsStorage.votes}/keys`, parameters]
: null,
getTzktData
([url, parameters]) => getTzktData(url, parameters),
)

return [reorderBigmapData(data, 'nat'), mutate]
Expand Down Expand Up @@ -251,7 +251,7 @@ export function useObjkt(id) {
{
revalidateIfStale: false,
revalidateOnFocus: false,
}
},
)

return [data, mutate]
Expand Down
Loading
Loading