Skip to content

Commit

Permalink
Merge pull request #206 from docknetwork/bonus
Browse files Browse the repository at this point in the history
Bonus
  • Loading branch information
cykoder authored Nov 16, 2020
2 parents 5a21159 + e58764a commit b3f5f75
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/sdk",
"version": "0.3.7",
"version": "0.3.8",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
86 changes: 83 additions & 3 deletions src/modules/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ class TokenMigration {
return this.asSudoIfNeeded(txn, asSudo);
}

// Accepts recipients as an BtreeMap of address -> amount
/**
* Accepts recipients as an BTreeMap of address -> amount
* @param {*} recipients
*/
migrate(recipients) {
return this.api.tx.migrationModule.migrate(recipients);
}

// Accepts recipients as an array of pairs, each pair is (address, amount). Amount can either be a safe JS integer
// or a string which will be expected in decimal format. If an address is repeated, its intended amounts are added.
/**
* Accepts recipients as an array of pairs, each pair is (address, amount). Amount can either be a safe JS integer
* or a string which will be expected in decimal format. If an address is repeated, its intended amounts are added.
* @param {*} recipients
*/
migrateRecipAsList(recipients) {
// @ts-ignore
const recipMap = new BTreeMap();
Expand All @@ -56,10 +62,84 @@ class TokenMigration {
return this.api.tx.migrationModule.migrate(recipMap);
}

/**
* swapBonuses should be an array of arrays with each inner array of size 3 where first item is recipient account, 2nd item is bonus amount and 3rd item is offset (u32)
* vestingBonuses should be an array of arrays with each inner array of size 3 where first item is recipient account, 2nd item is bonus amount and 3rd item is offset (u32)
* @param {*} swapBonuses
* @param {*} vestingBonuses
*/
giveBonuses(swapBonuses, vestingBonuses) {
return this.api.tx.migrationModule.giveBonuses(swapBonuses, vestingBonuses);
}

/**
* Claim bonus for itself
*/
claimBonus() {
return this.api.tx.migrationModule.claimBonus();
}

/**
* Claim bonus for other account
* @param {*} other
*/
claimBonusForOther(other) {
return this.api.tx.migrationModule.claimBonusForOther(other);
}

/**
* Claim swap bonus for itself
*/
claimSwapBonus() {
return this.api.tx.migrationModule.claimSwapBonus();
}

/**
* Claim swap bonus for other account
* @param {*} other
*/
claimSwapBonusForOther(other) {
return this.api.tx.migrationModule.claimSwapBonusForOther(other);
}

/**
* Claim vesting bonus for itself
*/
claimVestingBonus() {
return this.api.tx.migrationModule.claimVestingBonus();
}

/**
* Claim vesting bonus for other account
* @param {*} other
*/
claimVestingBonusForOther(other) {
return this.api.tx.migrationModule.claimVestingBonusForOther(other);
}

/**
* Get details of all migrators
*/
async getMigrators() {
return this.api.query.migrationModule.migrators.entries();
}

/**
* Get detail of a given migrator
* @param {*} address
*/
async getMigrator(address) {
return this.api.query.migrationModule.migrators(address);
}

/**
* Get bonus of given account
* @param {*} address
*/
async getBonus(address) {
return this.api.query.migrationModule.bonuses(address);
}

/**
* Takes an extrinsic and returns a modified extrinsic if it needs to be sent by sudo otherwise returns the given
* extrinsic as it is
Expand Down
6 changes: 6 additions & 0 deletions src/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"EpochLen": "u32",
"SlotNo": "u64",
"Balance": "u64",
"BlockNumber": "u32",
"EpochDetail": {
"validator_count": "u8",
"starting_slot": "SlotNo",
Expand All @@ -92,6 +93,11 @@
"locked_reward": "Option<Balance>",
"unlocked_reward": "Option<Balance>"
},
"Bonus": {
"total_locked_bonus": "Balance",
"swap_bonuses": "Vec<(Balance, BlockNumber)>",
"vesting_bonuses": "Vec<(Balance, Balance, BlockNumber)>"
},
"Payload": {
"proposal": "Vec<u8>",
"round_no": "u64"
Expand Down

0 comments on commit b3f5f75

Please sign in to comment.