Skip to content

Commit

Permalink
v2.5.0 launch, with rewards!!! (#1814)
Browse files Browse the repository at this point in the history
* started adding dao rewards distributor create action

* added update reward distribution action

* added fund reward distribution action

* added withdraw reward distribution action

* added pause and resume actions, and use fund latest instead of funds field when creating distributions

* added rewards display and claim interface to DAO home

* updated dao rewards distributor schema to latest

* allow deploying only specific contracts

* updated rewards distributor code IDs to latest fixed v2.5.0

* added migaloo mainnet v2.5.0 code IDs

* added osmosis and terra mainnet v2.5.0 code IDs

* simplified reward distribution explanation

* added v2.5.0 for all chains (except stargaze mainnet, pending multisig), and improved deploy script

* show remaining undistributed funds when withdrawing

* removed unnecessary clone

* separate code IDs, code hashes, and polytone connections into JSON files, and store all versions of codes

* added scripts to validate code IDs and hashes in JSON config files

* added stargaze mainnet v2.5.0

* fixed prettier eslint issue

* added omniflix to osmosis and archway polytone connections

* updated versions to v2.5.0-rc.3
  • Loading branch information
NoahSaso committed Sep 18, 2024
1 parent e86669c commit b10decc
Show file tree
Hide file tree
Showing 126 changed files with 10,791 additions and 2,994 deletions.
4 changes: 4 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)

packages/types/protobuf/
node_modules/
16 changes: 8 additions & 8 deletions apps/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dao-dao/dapp",
"version": "2.5.0-rc.2",
"version": "2.5.0-rc.3",
"license": "AGPL-3.0-only",
"scripts": {
"analyze": "ANALYZE=true next build",
Expand All @@ -20,12 +20,12 @@
"ts:watch": "ts --watch"
},
"dependencies": {
"@dao-dao/i18n": "2.5.0-rc.2",
"@dao-dao/state": "2.5.0-rc.2",
"@dao-dao/stateful": "2.5.0-rc.2",
"@dao-dao/stateless": "2.5.0-rc.2",
"@dao-dao/types": "2.5.0-rc.2",
"@dao-dao/utils": "2.5.0-rc.2",
"@dao-dao/i18n": "2.5.0-rc.3",
"@dao-dao/state": "2.5.0-rc.3",
"@dao-dao/stateful": "2.5.0-rc.3",
"@dao-dao/stateless": "2.5.0-rc.3",
"@dao-dao/types": "2.5.0-rc.3",
"@dao-dao/utils": "2.5.0-rc.3",
"@fontsource/inter": "^4.5.7",
"@fontsource/jetbrains-mono": "^4.5.5",
"@keplr-wallet/common": "^0.11.49",
Expand All @@ -52,7 +52,7 @@
"sharp": "^0.31.1"
},
"devDependencies": {
"@dao-dao/config": "2.5.0-rc.2",
"@dao-dao/config": "2.5.0-rc.3",
"@next/bundle-analyzer": "^14.1.0",
"@playwright/test": "^1.44.1",
"@sentry/cli": "^2.21.3",
Expand Down
16 changes: 8 additions & 8 deletions apps/sda/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dao-dao/sda",
"version": "2.5.0-rc.2",
"version": "2.5.0-rc.3",
"license": "AGPL-3.0-only",
"scripts": {
"analyze": "ANALYZE=true next build",
Expand All @@ -17,12 +17,12 @@
"ts:watch": "ts --watch"
},
"dependencies": {
"@dao-dao/i18n": "2.5.0-rc.2",
"@dao-dao/state": "2.5.0-rc.2",
"@dao-dao/stateful": "2.5.0-rc.2",
"@dao-dao/stateless": "2.5.0-rc.2",
"@dao-dao/types": "2.5.0-rc.2",
"@dao-dao/utils": "2.5.0-rc.2",
"@dao-dao/i18n": "2.5.0-rc.3",
"@dao-dao/state": "2.5.0-rc.3",
"@dao-dao/stateful": "2.5.0-rc.3",
"@dao-dao/stateless": "2.5.0-rc.3",
"@dao-dao/types": "2.5.0-rc.3",
"@dao-dao/utils": "2.5.0-rc.3",
"@fontsource/inter": "^4.5.7",
"@fontsource/jetbrains-mono": "^4.5.5",
"@keplr-wallet/common": "^0.11.49",
Expand All @@ -48,7 +48,7 @@
"sharp": "^0.31.1"
},
"devDependencies": {
"@dao-dao/config": "2.5.0-rc.2",
"@dao-dao/config": "2.5.0-rc.3",
"@next/bundle-analyzer": "^12.1.0",
"@sentry/cli": "^2.21.3",
"@solana/web3.js": "^1.75.0",
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useWorkspaces": true,
"version": "2.5.0-rc.2"
"version": "2.5.0-rc.3"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dao-dao-ui",
"version": "2.5.0-rc.2",
"version": "2.5.0-rc.3",
"workspaces": [
"apps/*",
"packages/*"
Expand Down
6 changes: 3 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@dao-dao/config",
"version": "2.5.0-rc.2",
"version": "2.5.0-rc.3",
"license": "BSD-3-Clause-Clear",
"scripts": {
"cwgen": "ts-node ./scripts/cwgen.ts"
"cwgen": "tsx ./scripts/cwgen.ts"
},
"dependencies": {
"@tailwindcss/typography": "^0.5.1",
Expand All @@ -30,7 +30,7 @@
"devDependencies": {
"@cosmwasm/ts-codegen": "^1.10.0",
"commander": "^12.1.0",
"ts-node": "^10.9.2"
"tsx": "^4.19.0"
},
"prettier": "./prettier/index.js",
"gitHead": "d7b959f412c3990123b0e2afb11f32acd9c3764c"
Expand Down
16 changes: 8 additions & 8 deletions packages/dispatch/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "@dao-dao/dispatch",
"version": "2.5.0-rc.2",
"version": "2.5.0-rc.3",
"license": "BSD-3-Clause-Clear",
"private": true,
"scripts": {
"format": "eslint . --fix",
"lint": "eslint .",
"deploy": "ts-node ./scripts/deploy.ts",
"polytone": "ts-node ./scripts/polytone.ts"
"deploy": "tsx ./scripts/deploy.ts",
"polytone": "tsx ./scripts/polytone.ts"
},
"devDependencies": {
"@confio/relayer": "^0.12.0",
"@dao-dao/config": "2.5.0-rc.2",
"@dao-dao/state": "2.5.0-rc.2",
"@dao-dao/types": "2.5.0-rc.2",
"@dao-dao/utils": "2.5.0-rc.2",
"@dao-dao/config": "2.5.0-rc.3",
"@dao-dao/state": "2.5.0-rc.3",
"@dao-dao/types": "2.5.0-rc.3",
"@dao-dao/utils": "2.5.0-rc.3",
"chalk": "^4",
"commander": "^11.0.0",
"dotenv": "^16.4.5",
"eslint": "^8.23.1",
"sinon": "^18.0.0",
"ts-node": "^10.9.1",
"tsx": "^4.19.0",
"typescript": "5.3.3"
},
"prettier": "@dao-dao/config/prettier",
Expand Down
164 changes: 103 additions & 61 deletions packages/dispatch/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,27 @@ program.option(
'-x, --exclude <substrings>',
'ignore contracts containing any of these comma-separated substrings (e.g. cw721)'
)
program.option(
'-i, --include <substrings>',
'only deploy contracts containing any of these comma-separated substrings (e.g. cw721)'
)
program.option(
'-r, --restrict-instantiation',
'restrict instantiation to only the uploader; this must be used on some chains to upload contracts, like Kujira'
)

program.parse(process.argv)
const { chain: chainId, mode, authz, exclude: _exclude } = program.opts()
const {
chain: chainId,
mode,
authz,
exclude: _exclude,
include: _include,
restrictInstantiation,
} = program.opts()

const exclude: string[] | undefined = _exclude?.split(',')
const include: string[] | undefined = _include?.split(',')

if (!Object.values(Mode).includes(mode)) {
log(
Expand Down Expand Up @@ -118,21 +134,28 @@ const main = async () => {
id,
file,
prefixLength,
restrictInstantiation,
}: {
id: string
file: string
prefixLength: number
restrictInstantiation?: boolean
}) => {
const wasmData = new Uint8Array(fs.readFileSync(file).buffer)
const compressedWasmData = await gzipCompress(wasmData)

const msgStoreCode = MsgStoreCode.fromPartial({
sender: authz || sender,
wasmByteCode: compressedWasmData,
instantiatePermission: {
permission: AccessType.Everybody,
addresses: [],
},
instantiatePermission: restrictInstantiation
? {
permission: AccessType.AnyOfAddresses,
addresses: [authz || sender],
}
: {
permission: AccessType.Everybody,
addresses: [],
},
})

const msg: EncodeObject = authz
Expand Down Expand Up @@ -250,6 +273,7 @@ const main = async () => {
id: contract,
file,
prefixLength: 32,
restrictInstantiation,
})
}

Expand All @@ -271,29 +295,46 @@ const main = async () => {
// and longest ID suffix (CONTRACT).
consolePrefixLength = Math.max(...contracts.map((file) => file.length)) + 10

for (const contract of contracts) {
const id = contract.slice(0, -5)
if (exclude?.some((substring) => id.includes(substring))) {
continue
}

const file = path.join(DAO_CONTRACTS_DIR, contract)
try {
for (const contract of contracts) {
const id = contract.slice(0, -5)
if (exclude?.some((substring) => id.includes(substring))) {
continue
}
if (include && !include.some((substring) => id.includes(substring))) {
continue
}

if (!(id in codeIdMap)) {
codeIdMap[id] = await uploadContract({
id,
file,
prefixLength: consolePrefixLength,
})
} else {
log(
chalk.green(
`[${id}.CODE_ID]${' '.repeat(
consolePrefixLength - id.length - 10
)}${codeIdMap[id]}`
const file = path.join(DAO_CONTRACTS_DIR, contract)

if (!(id in codeIdMap)) {
codeIdMap[id] = await uploadContract({
id,
file,
prefixLength: consolePrefixLength,
restrictInstantiation,
})
} else {
log(
chalk.green(
`[${id}.CODE_ID]${' '.repeat(
consolePrefixLength - id.length - 10
)}${codeIdMap[id]}`
)
)
)
}
}
} catch (err) {
// Log current Code ID Map to make it easy to restart the script and reuse
// already uploaded contracts.
log(
chalk.red(
'Error uploading contracts. Current Code ID Map: \n' +
JSON.stringify(codeIdMap, null, 2)
)
)

throw err
}
}

Expand All @@ -309,34 +350,39 @@ const main = async () => {
id: 'cw_admin_factory',
file,
prefixLength: consolePrefixLength,
restrictInstantiation,
})
}

// Instantiate admin factory.
const cwAdminFactoryCodeId = codeIdMap['cw_admin_factory']
if (!cwAdminFactoryCodeId) {
log(chalk.red('cw_admin_factory.CODE_ID not found'))
process.exit(1)
log()
log(
chalk.blueBright('cw_admin_factory.CODE_ID not found, not instantiating')
)
}

const adminFactoryAddress = await instantiateContract({
client,
sender,
chainId,
id: 'cw_admin_factory',
codeId: cwAdminFactoryCodeId,
msg: {},
label: 'daodao_admin_factory',
prefixLength: consolePrefixLength,
})
const adminFactoryAddress = cwAdminFactoryCodeId
? await instantiateContract({
client,
sender,
chainId,
id: 'cw_admin_factory',
codeId: cwAdminFactoryCodeId,
msg: {},
label: 'daodao_admin_factory',
prefixLength: consolePrefixLength,
})
: ''

log()
log(chalk.green('Done! UI config entry:'))
log(chalk.green('Done! Config entries:'))

const mainnet = networkType === 'mainnet'
const explorerUrlDomain = mainnet ? 'ping.pub' : 'testnet.ping.pub'

const config: SupportedChainConfig = {
const config: Omit<SupportedChainConfig, 'codeIds' | 'allCodeIds'> = {
chainId,
name: chainName,
mainnet,
Expand All @@ -348,32 +394,28 @@ const main = async () => {
govProp: `https://${explorerUrlDomain}/${chainName}/gov/REPLACE`,
wallet: `https://${explorerUrlDomain}/${chainName}/account/REPLACE`,
},
codeIdsVersion: ContractVersion.Unknown,
codeIds: {
Cw1Whitelist: codeIdMap['cw1_whitelist'] ?? -1,
Cw4Group: codeIdMap['cw4_group'] ?? -1,
Cw721Base: codeIdMap['cw721_base'] ?? -1,
CwPayrollFactory: codeIdMap['cw_payroll_factory'] ?? -1,
CwTokenSwap: codeIdMap['cw_token_swap'] ?? -1,
CwTokenfactoryIssuerMain: codeIdMap['cw_tokenfactory_issuer'] ?? -1,
CwVesting: codeIdMap['cw_vesting'] ?? -1,
DaoCore: codeIdMap['dao_dao_core'] ?? -1,
DaoMigrator: -1,
DaoPreProposeApprovalSingle:
codeIdMap['dao_pre_propose_approval_single'] ?? -1,
DaoPreProposeApprover: codeIdMap['dao_pre_propose_approver'] ?? -1,
DaoPreProposeMultiple: codeIdMap['dao_pre_propose_multiple'] ?? -1,
DaoPreProposeSingle: codeIdMap['dao_pre_propose_single'] ?? -1,
DaoProposalMultiple: codeIdMap['dao_proposal_multiple'] ?? -1,
DaoProposalSingle: codeIdMap['dao_proposal_single'] ?? -1,
DaoRewardsDistributor: codeIdMap['dao_rewards_distributor'] ?? -1,
DaoVotingCw4: codeIdMap['dao_voting_cw4'] ?? -1,
DaoVotingCw721Staked: codeIdMap['dao_voting_cw721_staked'] ?? -1,
DaoVotingTokenStaked: codeIdMap['dao_voting_token_staked'] ?? -1,
latestVersion: ContractVersion.Unknown,
}

const allCodeIds = {
[chainId]: {
[ContractVersion.Unknown]: Object.fromEntries(
Object.entries(codeIdMap).map(([key, value]) => [
key
.split('_')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(''),
value ?? -1,
])
),
},
}

log(JSON.stringify(config, null, 2))

log()

log(JSON.stringify(allCodeIds, null, 2))
}

main()
Expand Down
Loading

0 comments on commit b10decc

Please sign in to comment.