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

Upgraded beacon-sdk, taquito/* and dayjs #849

Merged
merged 2 commits into from
Jun 4, 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
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"prepare": "husky install"
},
"dependencies": {
"@airgap/beacon-sdk": "^4.0.10",
"@airgap/beacon-sdk": "^4.2.2",
"@craco/craco": "^7.1.0",
"@date-io/dayjs": "1.x",
"@emotion/react": "^11.11.1",
Expand All @@ -28,11 +28,12 @@
"@mui/icons-material": "^5.14.14",
"@mui/material": "^5.14.14",
"@mui/x-date-pickers": "^5.0.2",
"@taquito/beacon-wallet": "^17.3.1",
"@taquito/signer": "^17.3.1",
"@taquito/taquito": "^17.3.1",
"@taquito/tzip12": "^17.3.1",
"@taquito/tzip16": "^17.3.1",
"@taquito/beacon-wallet": "^20.0.0",
"@taquito/signer": "^20.0.0",
"@taquito/taquito": "^20.0.0",
"@taquito/tzip12": "^20.0.0",
"@taquito/tzip16": "^20.0.0",
"@taquito/utils": "^20.0.0",
"@types/mixpanel-browser": "^2.35.7",
"@types/prismjs": "^1.26.0",
"@types/react-paginate": "^7.1.2",
Expand All @@ -42,7 +43,7 @@
"bignumber.js": "^9.0.1",
"blockies-ts": "^1.0.0",
"crypto-browserify": "^3.12.0",
"dayjs": "^1.10.4",
"dayjs": "^1.11.11",
"export-to-csv": "^1.2.4",
"formik": "^2.2.6",
"formik-material-ui": "^3.0.1",
Expand Down Expand Up @@ -86,7 +87,7 @@
"yup": "^0.32.9"
},
"devDependencies": {
"@types/jest": "^26.0.21",
"@types/jest": "^29.5.12",
"@types/node": "^14.14.35",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.2",
Expand All @@ -101,9 +102,11 @@
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "8.0.3",
"jest": "^29.7.0",
"lint-staged": "15.2.2",
"prettier": "^2.2.0",
"source-map-explorer": "2.5.2",
"ts-jest": "^29.1.4",
"typescript": "^5.0.4"
},
"resolutions": {
Expand Down
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { DAOCreatorRouter } from "modules/creator/router"
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"
import { CommunityCreator } from "modules/lite/creator"
import { hexStringToBytes } from "services/utils/utils"

const queryClient = new QueryClient({
defaultOptions: {
Expand Down
4 changes: 2 additions & 2 deletions src/services/baseDAODocker/mappers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BaseStorageParams } from "services/contracts/baseDAO"
import { formatUnits, xtzToMutez } from "services/contracts/utils"
import { GeneratorArgs } from "./types"
import { char2Bytes } from "@taquito/tzip16"
import { stringToBytes } from "@taquito/utils"
import { MetadataDeploymentResult } from "services/contracts/metadataCarrier/deploy"
import { BigNumber } from "bignumber.js"
import { Token } from "models/Token"
Expand Down Expand Up @@ -38,6 +38,6 @@ export const storageParamsToBaseDAODockerArgs = (

const formatMetadata = ({ deployAddress, keyName }: MetadataDeploymentResult) => {
return `'(Big_map.literal [
("", 0x${char2Bytes(`tezos-storage://${deployAddress}/${keyName}`)});
("", 0x${stringToBytes(`tezos-storage://${deployAddress}/${keyName}`)});
])'`
}
11 changes: 6 additions & 5 deletions src/services/contracts/baseDAO/lambdaDAO/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TezosToolkit } from "@taquito/taquito"
import { Schema } from "@taquito/michelson-encoder"
import { BaseDAO, BaseDAOData, getContract } from ".."
import { RegistryProposeArgs } from "./types"
import { bytes2Char, char2Bytes } from "@taquito/tzip16"
import { stringToBytes } from "@taquito/utils"
import proposeCode from "./michelson/propose"
import proposelambda from "./michelson/proposelambda"
import { LambdaExtraDTO, RegistryExtraDTO } from "services/services/types"
Expand All @@ -18,6 +18,7 @@ import update_contract_delegate_type_michelson from "./michelson/supported_lambd
import update_guardian_type_michelson from "./michelson/supported_lambda_types/update_guardian_proposal.json"
import { Community } from "models/Community"
import { HUMANITEZ_DAO } from "services/config"
import { hexStringToBytes } from "services/utils/utils"

const parser = new Parser()

Expand Down Expand Up @@ -47,8 +48,8 @@ const mapStorageRegistryList = (
}) as RegistryItemDTO[]

return data.map(item => ({
key: bytes2Char(item.args[0].string),
value: bytes2Char(item.args[1].string)
key: hexStringToBytes(item.args[0].string),
value: hexStringToBytes(item.args[1].string)
}))
}

Expand All @@ -63,7 +64,7 @@ const mapStorageRegistryAffectedList = (
}) as RegistryAffectedDTO[]

return data.map(item => ({
key: bytes2Char(item.args[0].string),
key: hexStringToBytes(item.args[0].string),
proposalId: item.args[1].bytes
}))
}
Expand Down Expand Up @@ -170,7 +171,7 @@ export class LambdaDAO extends BaseDAO {
const transfer_arg_schema = new Schema(transfer_michelson as MichelsonData)
const transfer_proposal_args = {
transfers: mapTransfersArgs(transfer_proposal.transfers, this.data.address),
registry_diff: transfer_proposal.registry_diff.map(item => [char2Bytes(item.key), char2Bytes(item.value)]),
registry_diff: transfer_proposal.registry_diff.map(item => [stringToBytes(item.key), stringToBytes(item.value)]),
agora_post_id: agoraPostId
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/contracts/metadataCarrier/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContractAbstraction, ContractProvider, MichelsonMap, TezosToolkit, Wallet } from "@taquito/taquito"
import { char2Bytes } from "@taquito/tzip16"
import { stringToBytes } from "@taquito/utils"

import { code } from "services/contracts/metadataCarrier/code"
import { setMetadataJSON } from "services/contracts/metadataCarrier/metadata"
Expand All @@ -9,7 +9,7 @@ const setMetadataMap = (keyName: string, metadata: MetadataParams) => {
const map = new MichelsonMap()
const json = setMetadataJSON(metadata)

map.set(keyName, char2Bytes(JSON.stringify(json)))
map.set(keyName, stringToBytes(JSON.stringify(json)))

return map
}
Expand Down
8 changes: 4 additions & 4 deletions src/services/contracts/metadataCarrier/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MichelsonMap, TezosToolkit } from "@taquito/taquito"
import { bytes2Char } from "@taquito/tzip16"
import { DAOListMetadata } from "services/contracts/metadataCarrier/types"
import { getContract } from "../baseDAO"
import { hexStringToBytes } from "services/utils/utils"

export const getDAOListMetadata = async (contractAddress: string, tezos: TezosToolkit): Promise<DAOListMetadata> => {
const contract = await getContract(tezos, contractAddress)
Expand All @@ -21,9 +21,9 @@ export const getDAOListMetadata = async (contractAddress: string, tezos: TezosTo
description: metadata.metadata.description || "",
template: (metadata.metadata as any).template,
unfrozenToken: {
symbol: bytes2Char(fa2Map.get("symbol") as string),
name: bytes2Char(fa2Map.get("name") as string),
decimals: bytes2Char(fa2Map.get("decimals") as string)
symbol: hexStringToBytes(fa2Map.get("symbol") as string),
name: hexStringToBytes(fa2Map.get("name") as string),
decimals: hexStringToBytes(fa2Map.get("decimals") as string)
}
}
}
8 changes: 4 additions & 4 deletions src/services/lite/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { bytes2Char, char2Bytes } from "@taquito/tzip16"
import { stringToBytes } from "@taquito/utils"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
import updateLocale from "dayjs/plugin/updateLocale"
import { Choice, WalletAddress } from "models/Choice"
import { Choice } from "models/Choice"
import { networkNameMap } from "services/bakingBad"
import { BeaconWallet } from "@taquito/beacon-wallet"
import { RequestSignPayloadInput, SigningType } from "@airgap/beacon-sdk"
Expand Down Expand Up @@ -180,8 +180,8 @@ export const getSignature = async (userAddress: string, wallet: BeaconWallet, da
data
].join(" ")

const bytes = char2Bytes(formattedInput)
const payloadBytes = "05" + "0100" + char2Bytes(bytes.length.toString()) + bytes
const bytes = stringToBytes(formattedInput)
const payloadBytes = "05" + "0100" + stringToBytes(bytes.length.toString()) + bytes

const payload: RequestSignPayloadInput = {
signingType: SigningType.MICHELINE,
Expand Down
6 changes: 3 additions & 3 deletions src/services/services/dao/mappers/proposal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Parser, Expr, unpackDataBytes, MichelsonType, MichelsonData } from "@ta
import { parseUnits } from "services/contracts/utils"
import { ProposalDTO } from "services/services/types"
import { extractTransfersData } from "."
import { bytes2Char } from "@taquito/tzip16"
import { BaseDAO } from "services/contracts/baseDAO"
import { DAOTemplate } from "modules/creator/state"
import transfer_arg_type_michelson from "../../../../contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type.json"
Expand All @@ -16,6 +15,7 @@ import update_guardian_type_michelson from "../../../../contracts/baseDAO/lambda
import configuration_proposal_type_michelson from "../../../../contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/configuration_proposal_type.json"
import { PMLambdaProposal } from "services/contracts/baseDAO/lambdaDAO/types"
import { HUMANITEZ_DAO } from "services/config"
import { hexStringToBytes } from "services/utils/utils"

export enum IndexerStatus {
CREATED = "created",
Expand Down Expand Up @@ -349,8 +349,8 @@ export class LambdaProposal extends Proposal {

if (registry_diff) {
lambdaMetadata.list = registry_diff.map((item: any) => ({
key: bytes2Char(item[0]),
value: bytes2Char(item[1])
key: hexStringToBytes(item[0]),
value: hexStringToBytes(item[1])
}))
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/services/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bytes2Char, char2Bytes } from "@taquito/tzip16"
import { stringToBytes, hex2buf } from "@taquito/utils"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
import updateLocale from "dayjs/plugin/updateLocale"
Expand All @@ -9,6 +9,10 @@ import BigNumber from "bignumber.js"
import { Network } from "services/beacon"
import { networkNameMap } from "services/bakingBad"

export const hexStringToBytes = (hex: string): string => {
return Buffer.from(hex2buf(hex)).toString("utf8")
}

export const getCurrentBlock = async (network: Network) => {
const url = `https://api.${networkNameMap[network]}.tzkt.io/v1/head`
const response = await fetch(url)
Expand Down Expand Up @@ -178,8 +182,8 @@ export const getSignature = async (userAddress: string, wallet: BeaconWallet, da
data
].join(" ")

const bytes = char2Bytes(formattedInput)
const payloadBytes = "05" + "0100" + char2Bytes(bytes.length.toString()) + bytes
const bytes = stringToBytes(formattedInput)
const payloadBytes = "05" + "0100" + stringToBytes(bytes.length.toString()) + bytes

const payload: RequestSignPayloadInput = {
signingType: SigningType.MICHELINE,
Expand Down
Loading
Loading