Skip to content

Commit

Permalink
Merge branch 'main' into jules/feat/wert.bk
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesGuesnon committed Nov 13, 2023
2 parents 5ff8a58 + 6be50c5 commit ba86b88
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
13 changes: 6 additions & 7 deletions components/proposalSignForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function ProposalSignForm({
() =>
proposal.ui.content.map(v =>
contentToData(
state.contracts[state.currentContract ?? ""]?.version ??
state.contracts[currentContract]?.version ??
state.currentStorage?.version,
v,
walletTokens
Expand Down Expand Up @@ -172,17 +172,16 @@ function ProposalSignForm({
);
}

const allSigners = signers(state.contracts[currentContract]);
const allSigners = signers(
state.contracts[currentContract] ?? state.currentStorage
);

const signatures = proposal.ui.signatures.filter(({ signer }) =>
allSigners.includes(signer)
);

const isExecutable = canExecute(signatures, threshold);
const isRejectable = canReject(
signatures,
threshold,
signers(state.contracts[currentContract]).length
);
const isRejectable = canReject(signatures, threshold, allSigners.length);
const isSignOrResolve =
(typeof modalState === "boolean" && modalState) ||
(typeof modalState !== "boolean" && isExecutable);
Expand Down
22 changes: 8 additions & 14 deletions context/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ type typeHash = string;
type codeHash = string;

const HASHES: { [k in version]: `${typeHash}:${codeHash}` | undefined } = {
"0.0.6": undefined,
"0.0.8": undefined,
"0.0.9": undefined,
"0.0.10": undefined,
"0.0.6": "1047066606:471411811",
"0.0.8": "2045366626:-1526481454",
"0.0.9": "1273323151:735333822",
"0.0.10": "-357299388:2102290129",
"0.0.11": "-483287042:521053333",
"0.1.1": "-483287042:-426350137",
"0.3.0": "-933474574:1358594366",
Expand All @@ -37,9 +37,12 @@ const HASHES: { [k in version]: `${typeHash}:${codeHash}` | undefined } = {
"unknown version": undefined,
};

// Before 0.0.11, the version is stored on the contract so tzip16 won't failed to retrieve it
// typeHash and codeHash are provided by tzkt API
const VERSION_HASH: { [k: `${typeHash}:${codeHash}`]: version } = {
[HASHES["0.0.6"]!]: "0.0.6",
[HASHES["0.0.8"]!]: "0.0.8",
[HASHES["0.0.9"]!]: "0.0.9",
[HASHES["0.0.10"]!]: "0.0.10",
[HASHES["0.0.11"]!]: "0.0.11",
[HASHES["0.1.1"]!]: "0.1.1",
[HASHES["0.3.0"]!]: "0.3.0",
Expand Down Expand Up @@ -68,15 +71,6 @@ async function fetchVersion(
}[]) => VERSION_HASH[`${typeHash}:${codeHash}`] ?? "unknown version"
);

if (version === "unknown version") {
version = (await metadata
.tzip16()
.getMetadata()
.then(metadata => {
return metadata?.metadata?.version ?? "unknown version";
})) as version;
}

return dispatch[version] ?? "unknown version";
} catch {
return "unknown version";
Expand Down
4 changes: 3 additions & 1 deletion pages/[walletAddress]/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ const History = () => {

const proposals: [number, any][] = bigmap.map(({ key, value }) => {
return [
Number.parseInt(key),
version === "0.3.0" || version === "0.3.1" || version === "0.3.2"
? Number.parseInt(`0x${key}`)
: Number.parseInt(key),
{ ui: toProposal(version, value), og: value },
];
});
Expand Down
12 changes: 8 additions & 4 deletions pages/[walletAddress]/proposals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,14 @@ const Proposals = () => {
dispatch({ type: "setCanFetchMore", payload: false });
}

const proposals: [number, any][] = bigmap.map(({ key, value }) => [
Number.parseInt(key),
{ ui: toProposal(version, value), og: value },
]);
const proposals: [number, any][] = bigmap.map(({ key, value }) => {
return [
version === "0.3.0" || version === "0.3.1" || version === "0.3.2"
? Number.parseInt(`0x${key}`)
: Number.parseInt(key),
{ ui: toProposal(version, value), og: value },
];
});

if (globalState.contracts[globalState.currentContract ?? ""]) {
const balance = await globalState.connection.tz.getBalance(
Expand Down
10 changes: 9 additions & 1 deletion utils/contractParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
encodeKeyHash,
} from "@taquito/utils";
import { assertNever } from "assert-never";
import { BigNumber } from "bignumber.js";
import { generateExecuteContractMichelson } from "../context/generateLambda";
import { version } from "../types/display";

Expand Down Expand Up @@ -422,12 +423,19 @@ function evalTaquitoParam(
case "mutez":
case "timestamp": {
const value = tableValue[getFieldName(token.counter)];
if (typeof value !== "string")
throw new Error(
`The value get from UI should be in string, ${showName(
token.type,
token.name
)}`
);
if (!value) {
throw new Error(
`Incorrect or empty value, ${showName(token.type, token.name)}`
);
}
return Number(value);
return new BigNumber(value);
}
case "never":
return undefined;
Expand Down

0 comments on commit ba86b88

Please sign in to comment.