Skip to content

Commit

Permalink
fix scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sarmatdev committed Mar 15, 2023
1 parent b7f78a2 commit 4daf328
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
28 changes: 21 additions & 7 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ function getBatchOfData(data: LegacyData, start: number, end: number) {
}

function prepareAllBatches(data: LegacyData) {
const batchStep = 10
const batchStep = 5
const batches: LegacyData[] = []
for (let i = 0; i < data.length; i += batchStep) {
const batch = getBatchOfData(data, i, i + batchStep)
console.log(batch)
batches.push(batch)
}
return batches
Expand Down Expand Up @@ -102,7 +101,10 @@ async function main() {
)
const adminAddress = await upgrades.erc1967.getAdminAddress(contract.address)

const deployedContract = factory.attach(contract.address).connect(provider)
const deployedContract = factory
.attach(contract.address)
.connect(provider)
.connect(deployer)

console.log('OBSSStorage Proxy address:', contract.address)
console.log('Implementation address:', implementationAddress)
Expand All @@ -115,18 +117,30 @@ async function main() {
const legacyReactions = JSON.parse(
readFileSync(resolve(cwd(), 'data', 'legacy-reactions.json'), 'utf-8')
)
const legacyPostsBatches = prepareAllBatches(legacyPosts)
const legacyReactionsBatches = prepareAllBatches(legacyReactions)
const legacyPostsBatches = prepareAllBatches(legacyPosts).slice(0, 5)
const legacyReactionsBatches = prepareAllBatches(legacyReactions).slice(0, 5)

for (let i = 0; i < legacyPosts.length; i++) {
for (let i = 0; i < 3; i++) {
console.log(`Loading data batch ${i}`)
const tx = await deployedContract.migrateLegacyData(
legacyPostsBatches[i] as OBSSStorage.LegacyPostStruct[],
[] as OBSSStorage.LegacyReactionStruct[]
)
const receipt = await tx.wait()
console.log(
`Batch ${i} loaded `,
`https://mumbai.polygonscan.com/tx/${receipt.transactionHash}`
)
}
for (let i = 0; i < 3; i++) {
console.log(`Loading data batch ${i}`)
const tx = await deployedContract.migrateLegacyData(
[] as OBSSStorage.LegacyPostStruct[],
legacyReactionsBatches[i] as OBSSStorage.LegacyReactionStruct[]
)
const receipt = await tx.wait()
console.log(
`Batch ${i} minted `,
`Batch ${i} loaded `,
`https://mumbai.polygonscan.com/tx/${receipt.transactionHash}`
)
}
Expand Down
1 change: 0 additions & 1 deletion scripts/dump-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ async function main() {

const feedPosts = await contract.getFeedPosts(i, 0, postsInFeed.toNumber())
console.log(`Feed ID: ${i}`)
// console.log(feedPosts)
feedPosts.forEach(async (post: OBSSStorage.PostStructOutput, j) => {
legacyPosts.push({
author: post.author,
Expand Down

0 comments on commit 4daf328

Please sign in to comment.