-
Notifications
You must be signed in to change notification settings - Fork 38
Script Usage Examples
Benjamin Smith edited this page Feb 22, 2019
·
9 revisions
Most, if not all of these commands will require one to run Environment Setup (which registers accounts and tokens on the contract and funds each of the accounts for all the tokens)
truffle migrate
npm run setup
The following example demonstrates usage of many different scripts. Although here they are run with npx truffle exec
they are also part of the node package and can be run with npm run
.
IN order to claim withdraws, you will need to ensure the database is correctly synchronized to match the following scenario
A quick way to "prepare" you database is as follows in a python shell
from pymongo import MongoClient
client = MongoClient()
db = client.test_db
collection = db.withdraws
new_posts = [
{
"accountId": 1,
"tokenId": 1,
"amount": 1,
"slot": 1,
"slotIndex": 0,
"valid": True
},
{
"accountId": 2,
"tokenId": 1,
"amount": 1,
"slot": 1,
"slotIndex": 1,
"valid": False
},
{
"accountId": 3,
"tokenId": 2,
"amount": 1,
"slot": 1,
"slotIndex": 2,
"valid": True
}
]
result = posts.insert_many(new_posts)
npx truffle exec scripts/deposit.js 1 1 1
npx truffle exec scripts/deposit.js 1 2 1
npx truffle exec scripts/mine_blocks.js 20
npx truffle exec scripts/apply_deposits.js 0 0x0
npx truffle exec scripts/apply_deposits.js 1 0x0
npx truffle exec scripts/request_withdraw.js 1 1 1
npx truffle exec scripts/request_withdraw.js 1 1 1
npx truffle exec scripts/request_withdraw.js 1 2 1
npx truffle exec scripts/mine_blocks.js 20
npx truffle exec scripts/apply_withdrawals.js 0 0x0 0x0
npx truffle exec scripts/apply_withdrawals.js 1 0x39da249ab5f6f35898571f1351320f1042414ebfc22fa2666cfed72683d1e958 0x0
# [Generic Claim]
npx truffle exec scripts/claim_withdraw.js 1 1 1
# [Invalid: Will fail]
npx truffle exec scripts/claim_withdraw.js 1 1 2
# [Double Claim: Will fail]
npx truffle exec scripts/claim_withdraw.js 1 1 1