Skip to content

Commit

Permalink
Contracts sept (#4463)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeolianeth authored Sep 23, 2024
1 parent 5112824 commit c23b15b
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 80 deletions.
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@
"graphql": "^16.8.1",
"he": "^1.2.0",
"jsonwebtoken": "^9.0.0",
"juice-sdk-core": "^10.0.3-alpha",
"juice-sdk-react": "^10.0.1-alpha",
"juice-sdk-core": "^11.0.0-alpha",
"juice-sdk-react": "^11.0.0-alpha",
"juicebox-metadata-helper": "0.1.7",
"less": "4.1.2",
"lodash": "^4.17.21",
Expand Down
1 change: 0 additions & 1 deletion src/lib/api/supabase/projects/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export async function queryAllSGProjectsForServer() {
...p,
id: getSubgraphIdForProject(PV_V4, p.projectId), // Patch in the subgraph ID for V4 projects (to be consitent with legacy subgraph)
pv: PV_V4, // Patch in the PV for V4 projects,
metadataUri: p.metadata,
chainId: sepolia.id,
}
}) as unknown as Json<Pick<Project & { chainId: number }, SGSBCompareKey>>[]
Expand Down
2 changes: 1 addition & 1 deletion src/packages/v4/graphql/queries/dbV4Projects.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ query DBV4Projects($first: Int, $skip: Int) {
id
projectId
handle
metadata
metadataUri
currentBalance
volume
volumeUSD
Expand Down
2 changes: 1 addition & 1 deletion src/packages/v4/graphql/queries/project.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
query Projects($where: Project_filter, $first: Int, $skip: Int, $block: Block_height) {
projects(where: $where, first: $first, skip: $skip, block: $block) {
projectId
metadata
metadataUri
handle
contributorsCount
createdAt
Expand Down
1 change: 1 addition & 0 deletions src/packages/v4/utils/editRuleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function transformEditCycleFormFieldsToTxArgs({
useDataHookForRedeem: false, // Defaulting to false as it's not in formValues
dataHook: "0x0000000000000000000000000000000000000000" as `0x${string}`, // Defaulting to a null address
metadata: 0, // Assuming no additional metadata is provided
allowCrosschainSuckerExtension: false
},

splitGroups: [
Expand Down
142 changes: 76 additions & 66 deletions src/packages/v4/utils/launchProject.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { V2FundingCycleMetadata } from "packages/v2/models/fundingCycle";
import { V2V3FundAccessConstraint, V2V3FundingCycleData } from "packages/v2v3/models/fundingCycle";
import { GroupedSplits, SplitGroup } from "packages/v2v3/models/splits";
import { V3FundingCycleMetadata } from "packages/v3/models/fundingCycle";
import { V2FundingCycleMetadata } from 'packages/v2/models/fundingCycle'
import {
V2V3FundAccessConstraint,
V2V3FundingCycleData,
} from 'packages/v2v3/models/fundingCycle'
import { GroupedSplits, SplitGroup } from 'packages/v2v3/models/splits'
import { V3FundingCycleMetadata } from 'packages/v3/models/fundingCycle'

export type LaunchV2V3ProjectArgs = [
string, // _owner
Expand All @@ -12,15 +15,15 @@ export type LaunchV2V3ProjectArgs = [
GroupedSplits<SplitGroup>[], // _groupedSplits
V2V3FundAccessConstraint[], // _fundAccessConstraints
string[], // _terminals
string // _memo
];
string, // _memo
]

export function transformV2V3CreateArgsToV4({
v2v3Args,
primaryNativeTerminal,
currencyTokenAddress
currencyTokenAddress,
}: {
v2v3Args: LaunchV2V3ProjectArgs,
v2v3Args: LaunchV2V3ProjectArgs
primaryNativeTerminal: `0x${string}`
currencyTokenAddress: `0x${string}`
}) {
Expand All @@ -33,84 +36,91 @@ export function transformV2V3CreateArgsToV4({
_groupedSplits,
_fundAccessConstraints,
_terminals,
_memo
] = v2v3Args;
_memo,
] = v2v3Args

const mustStartAtOrAfterNum = parseInt(_mustStartAtOrAfter)

const rulesetConfigurations = [{
mustStartAtOrAfter: mustStartAtOrAfterNum ?? 0, // 0 denotes start immediately
duration: _data.duration.toNumber(),
weight: _data.weight.toBigInt(),
decayPercent: _data.discountRate.toNumber(),
approvalHook: _data.ballot as `0x${string}`,
const rulesetConfigurations = [
{
mustStartAtOrAfter: mustStartAtOrAfterNum ?? 0, // 0 denotes start immediately
duration: _data.duration.toNumber(),
weight: _data.weight.toBigInt(),
decayPercent: _data.discountRate.toNumber(),
approvalHook: _data.ballot as `0x${string}`,

metadata: {
reservedPercent: _metadata.reservedRate.toNumber(),
redemptionRate: _metadata.redemptionRate.toNumber(),
baseCurrency: 1, // Not present in v2v3, passing 1 by default
pausePay: _metadata.pausePay,
pauseRedeem: _metadata.pauseRedeem,
pauseCreditTransfers: Boolean(_metadata.global.pauseTransfers),
allowOwnerMinting: _metadata.allowMinting,
allowSetCustomToken: false, // Assuming false by default
allowTerminalMigration: _metadata.allowTerminalMigration,
allowSetTerminals: _metadata.global.allowSetTerminals,
allowSetController: _metadata.global.allowSetController,
allowAddAccountingContext: false, // Not present in v2v3, passing false by default
allowAddPriceFeed: false, // Not present in v2v3, passing false by default
ownerMustSendPayouts: false, // Not present in v2v3, passing false by default
holdFees: _metadata.holdFees,
useTotalSurplusForRedemptions: _metadata.useTotalOverflowForRedemptions,
useDataHookForPay: _metadata.useDataSourceForPay,
useDataHookForRedeem: _metadata.useDataSourceForRedeem,
dataHook: _metadata.dataSource as `0x${string}`,
metadata: 0,
},
metadata: {
reservedPercent: _metadata.reservedRate.toNumber(),
redemptionRate: _metadata.redemptionRate.toNumber(),
baseCurrency: 1, // Not present in v2v3, passing 1 by default
pausePay: _metadata.pausePay,
pauseRedeem: _metadata.pauseRedeem,
pauseCreditTransfers: Boolean(_metadata.global.pauseTransfers),
allowOwnerMinting: _metadata.allowMinting,
allowSetCustomToken: false, // Assuming false by default
allowTerminalMigration: _metadata.allowTerminalMigration,
allowSetTerminals: _metadata.global.allowSetTerminals,
allowSetController: _metadata.global.allowSetController,
allowAddAccountingContext: false, // Not present in v2v3, passing false by default
allowAddPriceFeed: false, // Not present in v2v3, passing false by default
ownerMustSendPayouts: false, // Not present in v2v3, passing false by default
holdFees: _metadata.holdFees,
useTotalSurplusForRedemptions: _metadata.useTotalOverflowForRedemptions,
useDataHookForPay: _metadata.useDataSourceForPay,
useDataHookForRedeem: _metadata.useDataSourceForRedeem,
dataHook: _metadata.dataSource as `0x${string}`,
metadata: 0,
allowCrosschainSuckerExtension: false,
},

splitGroups: _groupedSplits.map(group => ({
groupId: BigInt(group.group),
splits: group.splits.map(split => ({
preferAddToBalance: Boolean(split.preferClaimed),
percent: split.percent,
projectId: BigInt(parseInt(split.projectId ?? '0x00', 16)),
beneficiary: split.beneficiary as `0x${string}`,
lockedUntil: split.lockedUntil ?? 0,
hook: split.allocator as `0x${string}`,
splitGroups: _groupedSplits.map(group => ({
groupId: BigInt(group.group),
splits: group.splits.map(split => ({
preferAddToBalance: Boolean(split.preferClaimed),
percent: split.percent,
projectId: BigInt(parseInt(split.projectId ?? '0x00', 16)),
beneficiary: split.beneficiary as `0x${string}`,
lockedUntil: split.lockedUntil ?? 0,
hook: split.allocator as `0x${string}`,
})),
})),
})),

fundAccessLimitGroups: _fundAccessConstraints.map(constraint => ({
terminal: primaryNativeTerminal,
token: currencyTokenAddress,
payoutLimits: [{
amount: constraint.distributionLimit.toBigInt(),
currency: constraint.distributionLimitCurrency.toNumber(),
}] as const,
surplusAllowances: [{
amount: constraint.overflowAllowance.toBigInt(),
currency: constraint.overflowAllowanceCurrency.toNumber(),
}] as const,
}))
}];
fundAccessLimitGroups: _fundAccessConstraints.map(constraint => ({
terminal: primaryNativeTerminal,
token: currencyTokenAddress,
payoutLimits: [
{
amount: constraint.distributionLimit.toBigInt(),
currency: constraint.distributionLimitCurrency.toNumber(),
},
] as const,
surplusAllowances: [
{
amount: constraint.overflowAllowance.toBigInt(),
currency: constraint.overflowAllowanceCurrency.toNumber(),
},
] as const,
})),
},
]

const terminalConfigurations = _terminals.map(terminal => ({
terminal: terminal as `0x${string}`,
accountingContextsToAccept: [
// @v4todo:
// {
// token: currencyTokenAddress,
// decimals: 18,
// {
// token: currencyTokenAddress,
// decimals: 18,
// currency: 0
// }
] as const,
}));
}))

return [
_owner as `0x${string}`,
_projectMetadata[0],
rulesetConfigurations,
terminalConfigurations,
_memo,
] as const;
] as const
}
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12837,18 +12837,18 @@ jsx-ast-utils@^3.3.5:
object.assign "^4.1.4"
object.values "^1.1.6"

juice-sdk-core@^10.0.3-alpha:
version "10.0.3-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-core/-/juice-sdk-core-10.0.3-alpha.tgz#dcd1afa2faa13f42559ced3b308e5e886892c7bd"
integrity sha512-E+Wx7zv/PCOWrY9Co62ilyHa/6ge44xltTsNeaF96a3d3jWhWlkLlrDBrHDnT48VvClw0LbnRWOFvaB662OyFg==
juice-sdk-core@^11.0.0-alpha:
version "11.0.0-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-core/-/juice-sdk-core-11.0.0-alpha.tgz#dd0228158de3c3a2799ea6ba3b1f22c8c0635d60"
integrity sha512-wqKAb9f88579CiTZP6MNb08TOStQ4OqgLQYh7cwmONcpon09+A9tyHPCxhgKjGHGevzF80Wv2Z0dPjgujMRI2Q==
dependencies:
bs58 "^5.0.0"
fpnum "^1.0.0"

juice-sdk-react@^10.0.1-alpha:
version "10.0.1-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-react/-/juice-sdk-react-10.0.1-alpha.tgz#a1a9273292ed7b6f2f97e87e60c131b8cd53ee03"
integrity sha512-Lpdymh4bt2YBba2htXn/RB+Kohs1iMhu2mqzadwAtrYpsFz+dKkL5GFA1YLLSC96d31KSVJX/bArX46Uc5hnoA==
juice-sdk-react@^11.0.0-alpha:
version "11.0.0-alpha"
resolved "https://registry.yarnpkg.com/juice-sdk-react/-/juice-sdk-react-11.0.0-alpha.tgz#15b93be75d80e9e83a0f45b4cc8c81d3f1828e49"
integrity sha512-G0zCPMCozfAK0Y9mxGMtMOYW8Bm3ml5bEEr/pKFbrrxIs+sEUnK4f5CZWiaA6fZlN8QnUbXbIRteFjv+RB2Yzg==

juice@^10.0.0:
version "10.0.0"
Expand Down

0 comments on commit c23b15b

Please sign in to comment.