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

feat: upgrade SC to 0.14 and erc725js #143

Merged
merged 4 commits into from
Jan 2, 2024
Merged
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"prepare": "husky install"
},
"dependencies": {
"@erc725/erc725.js": "0.21.3",
"@erc725/erc725.js": "0.22.0",
"@lukso/lsp-factory.js": "3.2.1",
"@lukso/lsp-smart-contracts": "0.12.1",
"@lukso/lsp-smart-contracts": "0.14.0",
"@lukso/web3-onboard-config": "1.1.1",
"@pinata/sdk": "^2.1.0",
"@tsndr/cloudflare-worker-jwt": "^2.3.2",
Expand Down
12 changes: 6 additions & 6 deletions src/components/endpoints/Assets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CustomSelect from '@/components/shared/CustomSelect.vue'
import { useLspFactory } from '@/compositions/useLspFactory'
import { addTokenToLocalStore, recalculateAssets } from '@/helpers/tokenUtils'
import { useERC20 } from '@/compositions/useErc20'
import { LSP8_TOKEN_ID_TYPES } from '@lukso/lsp-smart-contracts'
import { LSP8_TOKEN_ID_FORMAT } from '@lukso/lsp-smart-contracts'

const { notification, clearNotification, hasNotification, setNotification } =
useNotifications()
Expand Down Expand Up @@ -182,23 +182,23 @@ const create = async () => {
:options="[
{
display: 'NUMBER',
value: LSP8_TOKEN_ID_TYPES.NUMBER.toString(),
value: LSP8_TOKEN_ID_FORMAT.NUMBER.toString(),
},
{
display: 'STRING',
value: LSP8_TOKEN_ID_TYPES.STRING.toString(),
value: LSP8_TOKEN_ID_FORMAT.STRING.toString(),
},
{
display: 'UNIQUE_ID',
value: LSP8_TOKEN_ID_TYPES.UNIQUE_ID.toString(),
value: LSP8_TOKEN_ID_FORMAT.UNIQUE_ID.toString(),
},
{
display: 'HASH',
value: LSP8_TOKEN_ID_TYPES.HASH.toString(),
value: LSP8_TOKEN_ID_FORMAT.HASH.toString(),
},
{
display: 'ADDRESS',
value: LSP8_TOKEN_ID_TYPES.ADDRESS.toString(),
value: LSP8_TOKEN_ID_FORMAT.ADDRESS.toString(),
},
]"
@option-selected="handleSelectTokenIdType"
Expand Down
12 changes: 6 additions & 6 deletions src/components/endpoints/Mint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import useErc725 from '@/compositions/useErc725'
import LSP8IdentifiableDigitalAsset from '@erc725/erc725.js/schemas/LSP8IdentifiableDigitalAsset.json'
import { isHex } from 'web3-utils'
import { isAddress } from 'ethers/lib/utils'
import { LSP8_TOKEN_ID_TYPES } from '@lukso/lsp-smart-contracts'
import { LSP8_TOKEN_ID_FORMAT } from '@lukso/lsp-smart-contracts'
import { uploadAssetData } from '@/utils/uploadAssetData'

const { notification, clearNotification, hasNotification, setNotification } =
Expand Down Expand Up @@ -99,28 +99,28 @@ const handleChangeTokenId = (event: Event) => {
tokenIdTypeError.value = ''

switch (tokenIdType.value) {
case LSP8_TOKEN_ID_TYPES.NUMBER:
case LSP8_TOKEN_ID_FORMAT.NUMBER:
if (isNaN(parseInt(value))) {
return (tokenIdTypeError.value = 'Must be a number')
}
break
case LSP8_TOKEN_ID_TYPES.STRING:
case LSP8_TOKEN_ID_FORMAT.STRING:
if (value.length > 32) {
return (tokenIdTypeError.value =
'Must be a string with less than 32 characters')
}
break
case LSP8_TOKEN_ID_TYPES.UNIQUE_ID:
case LSP8_TOKEN_ID_FORMAT.UNIQUE_ID:
if (!isHex(value)) {
return (tokenIdTypeError.value = 'Must be a byte string')
}
break
case LSP8_TOKEN_ID_TYPES.HASH:
case LSP8_TOKEN_ID_FORMAT.HASH:
if (value.length !== 66 || !isHex(value)) {
return (tokenIdTypeError.value = 'Must be a 32byte hash')
}
break
case LSP8_TOKEN_ID_TYPES.ADDRESS:
case LSP8_TOKEN_ID_FORMAT.ADDRESS:
if (!isAddress(value)) {
return (tokenIdTypeError.value = 'Must be a valid address')
}
Expand Down
13 changes: 7 additions & 6 deletions src/helpers/tokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { store, setState } from '@/stores/index'
import { getSelectedNetworkConfig } from '@/helpers/config'
import useWeb3Connection from '@/compositions/useWeb3Connection'
import { rightPad, fromUtf8, leftPad } from 'web3-utils'
import { LSP8_TOKEN_ID_TYPES } from '@lukso/lsp-smart-contracts'
import { LSP8_TOKEN_ID_FORMAT } from '@lukso/lsp-smart-contracts'
import { LSP4MetadataUrlForEncoding } from '@lukso/lsp-factory.js/build/main/src/lib/interfaces/lsp4-digital-asset'

const { lsp7TokenDivisible, lsp7TokenNonDivisible } = getSelectedNetworkConfig()
Expand Down Expand Up @@ -327,16 +327,17 @@ export async function recalculateAssets() {
*/
export const padTokenId = (tokenIdType: number, tokenId: string) => {
switch (tokenIdType) {
case LSP8_TOKEN_ID_TYPES.NUMBER:
case LSP8_TOKEN_ID_FORMAT.NUMBER:
return `0x${leftPad(tokenId, 64)}`
case LSP8_TOKEN_ID_TYPES.STRING:
case LSP8_TOKEN_ID_FORMAT.STRING:
return rightPad(fromUtf8(tokenId), 64)
case LSP8_TOKEN_ID_TYPES.UNIQUE_ID:
case LSP8_TOKEN_ID_FORMAT.UNIQUE_ID:
return rightPad(tokenId, 64)
case LSP8_TOKEN_ID_TYPES.HASH:
case LSP8_TOKEN_ID_FORMAT.HASH:
return tokenId // it's 32 bytes already
case LSP8_TOKEN_ID_TYPES.ADDRESS:
case LSP8_TOKEN_ID_FORMAT.ADDRESS:
return leftPad(tokenId, 64)
// TODO we might want to add mixed formats too, tbc.
default:
break
}
Expand Down
33 changes: 22 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -568,16 +568,16 @@ __metadata:
languageName: node
linkType: hard

"@erc725/erc725.js@npm:0.21.3":
version: 0.21.3
resolution: "@erc725/erc725.js@npm:0.21.3"
"@erc725/erc725.js@npm:0.22.0":
version: 0.22.0
resolution: "@erc725/erc725.js@npm:0.22.0"
dependencies:
add: ^2.0.6
ethereumjs-util: ^7.1.5
web3-eth-abi: ^1.10.0
web3-providers-http: ^1.10.0
web3-utils: ^1.10.0
checksum: 2252eed206513a5fddcbdced11b89067f06b72ed395dd46d725acb0bcdcd74da3c3e44c6118bd54ea2013a32f9e7dafbf3dd995ab189e44f714e1ec160691f15
checksum: cadae178bf854f3c0c9b95187fb14dfc6fa1552e05ddb576cd317555d5eee3af91792f730bd8e89f8ed534b4abda0f5fe9ad206bbf0de700b9052ad1bb959609
languageName: node
linkType: hard

Expand All @@ -604,6 +604,17 @@ __metadata:
languageName: node
linkType: hard

"@erc725/smart-contracts@npm:^7.0.0":
version: 7.0.0
resolution: "@erc725/smart-contracts@npm:7.0.0"
dependencies:
"@openzeppelin/contracts": ^4.9.3
"@openzeppelin/contracts-upgradeable": ^4.9.3
solidity-bytes-utils: 0.8.0
checksum: 20fdca88eb7a33f4009c92d150c1c4b9b6ccd22bf4796c8b438d10afe5bf206ffa29b2b6c6aba7087b2117aeb2de533c1f4ce8d91ee21ff2012de95228c02bf5
languageName: node
linkType: hard

"@esbuild/android-arm64@npm:0.18.17":
version: 0.18.17
resolution: "@esbuild/android-arm64@npm:0.18.17"
Expand Down Expand Up @@ -2236,16 +2247,16 @@ __metadata:
languageName: node
linkType: hard

"@lukso/lsp-smart-contracts@npm:0.12.1":
version: 0.12.1
resolution: "@lukso/lsp-smart-contracts@npm:0.12.1"
"@lukso/lsp-smart-contracts@npm:0.14.0":
version: 0.14.0
resolution: "@lukso/lsp-smart-contracts@npm:0.14.0"
dependencies:
"@account-abstraction/contracts": ^0.6.0
"@erc725/smart-contracts": ^6.0.0
"@erc725/smart-contracts": ^7.0.0
"@openzeppelin/contracts": ^4.9.2
"@openzeppelin/contracts-upgradeable": ^4.9.2
solidity-bytes-utils: 0.8.0
checksum: dab9a972a2886789434bce8940b562bdd07fa5ac5287664a8f19cd41dd115ffa15d26a4fac8fc49448022c2b207feb84cd65a48cf0097963d1a0ff91b48fde40
checksum: 095cbc9f7f2ffaff6a2c05616c266731af735b485eb552b8e557b27e7aad39c80a770946ce6d4379fc51e1d434ef99628d7d4cf794dc6b5ab545ef6b62ca664e
languageName: node
linkType: hard

Expand Down Expand Up @@ -15126,9 +15137,9 @@ __metadata:
resolution: "universalprofile-test-dapp@workspace:."
dependencies:
"@depay/web3-mock": ^14.17.0
"@erc725/erc725.js": 0.21.3
"@erc725/erc725.js": 0.22.0
"@lukso/lsp-factory.js": 3.2.1
"@lukso/lsp-smart-contracts": 0.12.1
"@lukso/lsp-smart-contracts": 0.14.0
"@lukso/web3-onboard-config": 1.1.1
"@pinata/sdk": ^2.1.0
"@testing-library/jest-dom": 5.17.0
Expand Down