Skip to content

Commit 226459e

Browse files
authored
Add redeem to CL4R (#577)
* Package version 0.2.85 * add redeem to cl4rep * bump version * update jest-ts
1 parent ec64c17 commit 226459e

File tree

3 files changed

+183
-28
lines changed

3 files changed

+183
-28
lines changed

package-lock.json

Lines changed: 154 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daostack/arc.js",
3-
"version": "0.2.85",
3+
"version": "0.2.86",
44
"description": "",
55
"keywords": [],
66
"main": "dist/lib/index.js",
@@ -95,7 +95,7 @@
9595
"rollup-plugin-node-resolve": "^3.4.0",
9696
"rollup-plugin-sourcemaps": "^0.4.2",
9797
"rollup-plugin-typescript2": "^0.20.1",
98-
"ts-jest": "^24.0.2",
98+
"ts-jest": "^26.4.4",
9999
"ts-node": "^7.0.1",
100100
"tslint": "^5.18.0",
101101
"tslint-config-standard": "^8.0.1",

src/schemes/cl4rep.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export class CL4RScheme {
3535
const constB = new Decimal(realMathToNumber(new BN(repRewardConstB)))
3636
const constA = new Decimal(realMathToBN(new BN(repRewardConstA)).toString())
3737
return constA.times(constB.toPower(batchIndex))
38-
3938
}
4039

4140
public async getAgreementHash(): Promise<string> {
@@ -149,6 +148,33 @@ export class CL4RScheme {
149148
return toIOperationObservable(observable)
150149
}
151150

151+
public redeem(beneficiary: Address, lockingId: number): Operation<any> {
152+
const mapReceipt = (receipt: any) => {
153+
return receipt
154+
}
155+
156+
const observable = from(this.getContract())
157+
.pipe(
158+
concatMap((contract) => {
159+
let transaction: any
160+
transaction = contract.methods.redeem(
161+
beneficiary,
162+
lockingId
163+
)
164+
const errorHandler = async (error: Error) => {
165+
try {
166+
await transaction.call()
167+
} catch (err) {
168+
throw err
169+
}
170+
return error
171+
}
172+
return this.scheme.context.sendTransaction(transaction, mapReceipt, errorHandler)
173+
})
174+
)
175+
return toIOperationObservable(observable)
176+
}
177+
152178
public async getContract() {
153179
const state = await this.scheme.fetchStaticState()
154180
await this.scheme.context.fetchContractInfos({fetchPolicy: 'network-only'})

0 commit comments

Comments
 (0)