|
2 | 2 |
|
3 | 3 | ### Project Scope - Technical Requirements |
4 | 4 |
|
5 | | -Each grantee will implement CIP-149 functionality tailored to their platform: |
| 5 | +Each grantee will implement [CIP-149 | Optional DRep Compensation](https://github.com/cardano-foundation/CIPs/blob/master/CIP-0149/README.md) functionality tailored to their platform: |
6 | 6 |
|
7 | 7 | **a) Wallets** |
8 | 8 |
|
9 | | -* Implement CIP-149 Optional DRep Compensation during staking reward withdrawals. |
| 9 | +* Implement CIP-149 Optional DRep Compensation during staking reward withdrawal. |
10 | 10 | * Provide supporting UI to inform users about donating to their DRep. |
11 | 11 | * (Optional) Enable creation of DRep delegations containing CIP-149 metadata. |
12 | 12 |
|
13 | 13 | **b) Governance Tools** |
14 | 14 |
|
15 | 15 | * Enable creation of DRep delegations with CIP-149 metadata. |
16 | | -* (Optional) Display compensation amounts received by DReps. |
| 16 | + * See example transaction: [8c86970a2431a9f43a0363b116b4c60471a29cc35d253c0ed8c18c1dff3dcf10](https://preview.cardanoscan.io/transaction/8c86970a2431a9f43a0363b116b4c60471a29cc35d253c0ed8c18c1dff3dcf10?tab=metadata) |
| 17 | +* (Optional) Display compensation amounts received by DReps and a wallet's donation history. |
17 | 18 |
|
18 | 19 | **c) SDKs/Libraries** |
19 | 20 |
|
20 | | -* Add functions for creating CIP-149 DRep delegation transactions. |
21 | | -* Add functions for indexing CIP-149 delegation transactions. |
| 21 | +Due to variance within SDK/Library design and functionality, there is flexibility with proposed implementations, suggested functions: |
| 22 | + |
| 23 | +* Add functions for creating CIP-149 DRep delegation transactions. |
| 24 | + |
| 25 | + * The motivation for this is to governance tool makers a straight forward way to build DRep delegation transactions, containing CIP-149 compliant metadata. |
| 26 | + * i.e. As a part of transaction building, give users methods to add CIP149 compliant metadata `transaction.addCIP149Delegation(stakeAddr, dRepID, donationBasisPoints)` |
| 27 | + |
| 28 | + ```typescript |
| 29 | + // Eample of what interfaces and functions could look like |
| 30 | + // SDKs and libraries are free to interpret and implement as suits their implementation |
| 31 | + |
| 32 | + // values based on (preview): 8c86970a2431a9f43a0363b116b4c60471a29cc35d253c0ed8c18c1dff3dcf10 |
| 33 | + |
| 34 | + const stakeAddr = "stake1u8sa8kegf22wcjqqlc0230rtlemck5lhqycd3u8lattqh2cdjuzs4" |
| 35 | + const dRepID = "drep1yfhx2j5j7q989gfvj6cg04htakpqn32a3yuhtytjxt9m80qt5ekm3" |
| 36 | + const donationBasisPoints = 150 // 15% donation |
| 37 | + |
| 38 | + /** |
| 39 | + * Where transaction is an existing object from library (something else can be used) |
| 40 | + * addCIP149Metadata adds a VoteDelegation certificate and CIP149 compliant metadata |
| 41 | + */ |
| 42 | + transaction.addCIP149Delegation(stakeAddr, dRepID, donationBasisPoints) |
| 43 | + |
| 44 | + console.log(transaction.toJson()) |
| 45 | + /** |
| 46 | + ... |
| 47 | + "certs":[ |
| 48 | + 0:{ |
| 49 | + "VoteDelegation":{ |
| 50 | + "stake_credential":{ |
| 51 | + "Key":"e1d3db284a94ec4800fe1ea8bc6bfe778b53f70130d8f0ffea…" |
| 52 | + } |
| 53 | + "drep":{ |
| 54 | + "KeyHash":"6e654a92f00a72a12c96b087d6ebed8209c55d893975917232…" |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + ] |
| 59 | + ... |
| 60 | + "auxiliary_data":{ |
| 61 | + "metadata":{ |
| 62 | + "3692": { |
| 63 | + donationBasisPoints: 150 |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + ... |
| 68 | + */ |
| 69 | + ``` |
| 70 | +* Add functions for indexing CIP-149 delegation transactions. |
| 71 | + |
| 72 | + * The motivation for this is to wallets and governance tool makers an example implementation of how to index chain to find a given stake credential's CIP-149 delegations. |
| 73 | + * i.e. When a wallet is building a staking reward withdrawal transaction `getLastestCIP149Delegation()` |
| 74 | + |
| 75 | + ```typescript |
| 76 | + // Example of what interfaces and functions could look like |
| 77 | + // SDKs and libraries are free to interpret and implement as suits their implementation |
| 78 | +
|
| 79 | + interface CIP149Delegation { |
| 80 | + txId: string; |
| 81 | + drepId: string; |
| 82 | + drepPaymentAddr: string; |
| 83 | + basisPoints: number; |
| 84 | + } |
| 85 | +
|
| 86 | + /** |
| 87 | + * NoCIP149Delegation: The stakeKey has not delegated to a DRep using CIP149 correctly |
| 88 | + * NoDRepPaymentAddr: The DRep has not included payment address in their metadata |
| 89 | + */ |
| 90 | + interface CIP149DelegationError { |
| 91 | + type: "NoCIP149Delegation" | "NoDRepPaymentAddr" ; // some more error cases |
| 92 | + message: string; |
| 93 | + } |
| 94 | +
|
| 95 | + /** |
| 96 | + * getLastestCIP149Delegation triggers a chain query (using a given provider) |
| 97 | + * to find the most recent valid CIP149 delegation. |
| 98 | + * Indexing will invovle indexing the stakeKey's most recent vote delegation transacion |
| 99 | + * its transaction metadata and the DRep's latest metadata (to find DRep's payment address) |
| 100 | + */ |
| 101 | + const cip149Delegation: CIP149Delegation | CIP149DelegationError = getLastestCIP149Delegation("stake1u8sa8kegf22wcjqqlc0230rtlemck5lhqycd3u8lattqh2cdjuzs4") |
| 102 | +
|
| 103 | + const rewardsAvaliable = 100 // 100 ada avaliable in rewards account |
| 104 | +
|
| 105 | + /** |
| 106 | + * Where withdrawalTransaction is an existing object from library (something else can be used) |
| 107 | + * The wallet can then use this information, to build the withdrawal transaction |
| 108 | + * using drepPaymentAddr and basisPoints to donate to the DRep |
| 109 | + */ |
| 110 | + withdarawalTransaction.addRewardsWithdrawal(rewardsAvaliable) |
| 111 | + withdrawalTransaction.addOutput(cip149Delegation.drepPaymentAddr, (rewardsAvaliable/100 * cip149Delegation.basisPoints/10)) |
| 112 | +
|
| 113 | + ``` |
22 | 114 |
|
23 | 115 | ### Eligibility |
24 | 116 |
|
|
0 commit comments