-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support drain_delegate operation in contract api
re #2068
- Loading branch information
1 parent
8be5b27
commit efc0272
Showing
7 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/taquito/src/operations/drain-delegate-operation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { OperationContentsAndResult, OperationContentsAndResultDrainDelegate } from '@taquito/rpc'; | ||
import { Context } from '../context'; | ||
import { Operation } from './operations'; | ||
import { ForgedBytes, RPCDrainDelegateOperation } from './types'; | ||
|
||
/** | ||
* | ||
* @description DrainDelegateOperation provides utility functions to fetch a new operation of kind drain_delegate | ||
* | ||
*/ | ||
|
||
export class DrainDelegateOperation extends Operation { | ||
constructor( | ||
hash: string, | ||
private readonly params: RPCDrainDelegateOperation, | ||
public readonly source: string, | ||
raw: ForgedBytes, | ||
results: OperationContentsAndResult[], | ||
context: Context | ||
) { | ||
super(hash, raw, results, context); | ||
} | ||
|
||
get operationResults() { | ||
const DrainDelegateOp = | ||
Array.isArray(this.results) && | ||
(this.results.find( | ||
(op) => op.kind === 'drain_delegate' | ||
) as OperationContentsAndResultDrainDelegate); | ||
const result = | ||
DrainDelegateOp && DrainDelegateOp.metadata && DrainDelegateOp.metadata.balance_updates; | ||
return result ? result : undefined; | ||
} | ||
|
||
get consensusKey() { | ||
return this.params.consensus_key; | ||
} | ||
|
||
get delegate() { | ||
return this.params.delegate; | ||
} | ||
|
||
get detination() { | ||
return this.params.destination; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters