Skip to content

Commit

Permalink
Merge pull request #586 from dOrgTech/humanitez-fix
Browse files Browse the repository at this point in the history
Fix for humanitez DAO
  • Loading branch information
Man-Jain authored Jun 4, 2023
2 parents 215252a + a0c5fde commit 7383848
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ActionSheetProvider } from "modules/explorer/context/ActionSheets"
import { legacyTheme } from "theme/legacy"
import { Footer } from "modules/common/Footer"
import { FAQ } from "modules/home/FAQ"
import { EnvKey, getEnv } from "services/config"
import { EnvKey, HUMANITEZ_DAO, getEnv } from "services/config"
import { DAOCreatorRouter } from "modules/creator/router"
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider"
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"
Expand Down Expand Up @@ -124,7 +124,7 @@ const App: React.FC = () => {
<DAOExplorerRouter />
</TZKTSubscriptionsProvider>

{window.location.href.indexOf("KT1PY9PXm8NMAgSEZg7bUtFjmV2Sj64bKuVV") !== -1 ? (
{window.location.href.indexOf(HUMANITEZ_DAO) !== -1 ? (
<>
{/* Special case for this DAO which was created before FA1.2 fix was created for the smart contract */}
<WarningFooter
Expand Down
2 changes: 2 additions & 0 deletions src/services/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export enum EnvKey {
export enum FeatureFlag {
lambdaDao = "lambdaDao"
}

export const HUMANITEZ_DAO = "KT1PY9PXm8NMAgSEZg7bUtFjmV2Sj64bKuVV"
7 changes: 6 additions & 1 deletion src/services/contracts/baseDAO/lambdaDAO/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { formatUnits } from "../../utils"
import { LambdaAddArgs, LambdaExecuteArgs, LambdaRemoveArgs } from "./types"

import transfer_arg_type_michelson from "./michelson/supported_lambda_types/transfer_proposal_type.json"
import transfer_proposal_type_before_fa12 from "./michelson/supported_lambda_types/transfer_proposal_type_before_fa1.2.json"
import update_contract_delegate_type_michelson from "./michelson/supported_lambda_types/update_contract_delegate_proposal.json"
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"

const parser = new Parser()

Expand Down Expand Up @@ -162,7 +164,10 @@ export class LambdaDAO extends BaseDAO {
const contract = await getContract(tezos, this.data.address)
const p = new Parser()

const transfer_arg_schema = new Schema(transfer_arg_type_michelson as MichelsonData)
const transfer_michelson =
this.data.address === HUMANITEZ_DAO ? transfer_proposal_type_before_fa12 : transfer_arg_type_michelson

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)]),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"prim": "pair",
"args": [
{
"prim": "pair",
"args": [
{
"prim": "nat",
"annots": [
"%agora_post_id"
]
},
{
"prim": "list",
"annots": [
"%registry_diff"
],
"args": [
{
"prim": "pair",
"args": [
{
"prim": "string"
},
{
"prim": "option",
"args": [
{
"prim": "string"
}
]
}
]
}
]
}
]
},
{
"prim": "list",
"annots": [
"%transfers"
],
"args": [
{
"prim": "or",
"args": [
{
"prim": "pair",
"annots": [
"%xtz_transfer_type"
],
"args": [
{
"prim": "mutez",
"annots": [
"%amount"
]
},
{
"prim": "address",
"annots": [
"%recipient"
]
}
]
},
{
"prim": "pair",
"annots": [
"%token_transfer_type"
],
"args": [
{
"prim": "address",
"annots": [
"%contract_address"
]
},
{
"prim": "list",
"annots": [
"%transfer_list"
],
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%from_"
]
},
{
"prim": "list",
"annots": [
"%txs"
],
"args": [
{
"prim": "pair",
"args": [
{
"prim": "address",
"annots": [
"%to_"
]
},
{
"prim": "nat",
"annots": [
"%token_id"
]
},
{
"prim": "nat",
"annots": [
"%amount"
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
6 changes: 5 additions & 1 deletion src/services/services/dao/mappers/proposal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ 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"
import transfer_proposal_type_before_fa12 from "../../../../contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/transfer_proposal_type_before_fa1.2.json"
import update_contract_delegate_type_michelson from "../../../../contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/update_contract_delegate_proposal.json"
import update_guardian_type_michelson from "../../../../contracts/baseDAO/lambdaDAO/michelson/supported_lambda_types/update_guardian_proposal.json"
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"

export enum IndexerStatus {
CREATED = "created",
Expand Down Expand Up @@ -324,7 +326,9 @@ export class LambdaProposal extends Proposal {
)

if (lambdaMetadata.lambdaHandler.handler_name === "transfer_proposal") {
const transfer_arg_schema = new Schema(transfer_arg_type_michelson as MichelsonData)
const transfer_michelson =
this.dao.data.address === HUMANITEZ_DAO ? transfer_proposal_type_before_fa12 : transfer_arg_type_michelson
const transfer_arg_schema = new Schema(transfer_michelson as MichelsonData)
const transfer_proposal_data = transfer_arg_schema.Execute(lambdaMetadata.lambdaHandler.unpacked_argument)

const { agora_post_id, registry_diff, transfers } = transfer_proposal_data
Expand Down

0 comments on commit 7383848

Please sign in to comment.