Skip to content

Commit

Permalink
add script and task for migration
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Oct 11, 2023
1 parent ca6433a commit e420562
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ import 'hardhat-contract-sizer';
import 'hardhat-gas-reporter';
import { removeConsoleLog } from 'hardhat-preprocessor';

task('copy', 'Use copyBatch function from postageStamp contract')
.addParam('owner', "The account's address")
.addParam('initialbalance', "The account's address")
.addParam('depth', "The account's address")
.addParam('bucketDepth', "The account's address")
.addParam('batchid', "The account's address")
.addParam('immutable', "The account's address")

.setAction(async (taskArgs: any) => {
const currentPostage = '0xf86b48B65355D292dDE7da8B4ad1913a72ad45C9';

const stamp = await ethers.getContractAt('PostageStamp', currentPostage);
const tx = await stamp.copyBatch(...taskArgs);

console.log('Created new CopyBatch at : ', tx.hash);
});

// Set Private RPCs if added, otherwise use Public that are hardcoded in this config

const PRIVATE_RPC_MAINNET = !process.env.PRIVATE_RPC_MAINNET ? undefined : process.env.PRIVATE_RPC_MAINNET;
Expand Down
21 changes: 21 additions & 0 deletions scripts/stamp_migration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
postagecontract="0x822828dC7978ed03fd793B36E7a0cb9bce7e2048"
tokenaddress="0x2ac3c1d3e24b45c6c310534bc2dd84b5ed576335"

for row in $(cat ./private_testnet_batches.json | jq -c '.batches[]'); do
_field() {
echo ${1} | jq -r ${2}
}
owner=$(_field $row ".owner")
balance=$(_field $row ".remainingBalance")
depth=$(_field $row ".depth")
bucketDepth=16
batchid=$(_field $row ".batchid")
immutable=$(_field $row ".immutable")

echo "current balance #####"
echo ${balance}

cmd="npx hardhat --network testnet copy --owner ${owner} --initialbalance ${balance} --depth ${depth} --bucketDepth ${bucketDepth} --batchid ${batchid} --immutable ${immutable}"
$cmd
[ $? -eq 0 ] && echo "${batchid} migration successful" || echo "${batchid} migration failure"
done

0 comments on commit e420562

Please sign in to comment.