Skip to content

Commit

Permalink
Add missing ramtransfer opteration
Browse files Browse the repository at this point in the history
ramtransfer operation added in march introduced to beeteos
  • Loading branch information
grctest committed May 14, 2024
1 parent b9decb2 commit 69610eb
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 42 deletions.
104 changes: 65 additions & 39 deletions src/lib/blockchains/EOS/beautify.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,20 @@ const allowedOperations = [
"rmvproducer",
"updtrevision",
"bidname",
"bidrefund"
"bidrefund",
"ramtransfer",
];

/**
* Convert an array of operations into a readable format
* @param {Object} operation
* @returns
* @param {Object} operation
* @returns
*/
export default async function beautify (operation) {
export default async function beautify(operation) {
if (!operation || !operation.name) {
return;
}

const opType = operation.name;

if (!allowedOperations.includes(opType)) {
Expand All @@ -74,9 +75,9 @@ export default async function beautify (operation) {
if (opType === "transfer") {
/**
* Transferring tokens action.
*
*
* @details Transfer tokens from account to account.
*
*
* @param from - the account to transfer from,
* @param to - the account to be transferred to,
* @param quantity - the quantity of tokens to be transferred,
Expand All @@ -92,7 +93,6 @@ export default async function beautify (operation) {
{ key: "quantity", params: { quantity: quantity } },
{ key: "memo", params: { memo: memo ?? "" } },
];

} else if (opType === "setalimits") {
/**
* Set account limits action.
Expand Down Expand Up @@ -169,7 +169,10 @@ export default async function beautify (operation) {
*/
const feature_digest = operation.data.feature_digest;
currentOperation["rows"] = [
{ key: "feature_digest", params: { feature_digest: feature_digest } },
{
key: "feature_digest",
params: { feature_digest: feature_digest },
},
];
} else if (opType === "delegatebw") {
// functions defined in delegate_bandwidth.cpp
Expand Down Expand Up @@ -197,11 +200,16 @@ export default async function beautify (operation) {
currentOperation["rows"] = [
{ key: "from", params: { from: from } },
{ key: "receiver", params: { receiver: receiver } },
{ key: "stake_net_quantity", params: { stake_net_quantity: stake_net_quantity } },
{ key: "stake_cpu_quantity", params: { stake_cpu_quantity: stake_cpu_quantity } },
{
key: "stake_net_quantity",
params: { stake_net_quantity: stake_net_quantity },
},
{
key: "stake_cpu_quantity",
params: { stake_cpu_quantity: stake_cpu_quantity },
},
{ key: "transfer", params: { transfer: transfer } },
];

} else if (opType === "setrex") {
/**
* Setrex action.
Expand Down Expand Up @@ -333,9 +341,7 @@ export default async function beautify (operation) {
* @pre Order cannot be cancelled once it's been filled.
*/
const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "rentcpu") {
/**
* Rentcpu action.
Expand Down Expand Up @@ -469,7 +475,7 @@ export default async function beautify (operation) {
{ key: "from", params: { from: from } },
{ key: "loan_num", params: { loan_num: loan_num } },
{ key: "amount", params: { amount: amount } },
];
];
} else if (opType === "updaterex") {
/**
* Updaterex action.
Expand All @@ -478,11 +484,9 @@ export default async function beautify (operation) {
*
* @param owner - REX owner account.
*/

const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "rexexec") {
/**
* Rexexec action.
Expand All @@ -509,9 +513,7 @@ export default async function beautify (operation) {
* @param owner - REX owner account name.
*/
const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "mvtosavings") {
/**
* Mvtosavings action.
Expand Down Expand Up @@ -561,9 +563,7 @@ export default async function beautify (operation) {
* REX fund entry is deleted.
*/
const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "undelegatebw") {
/**
* Undelegate bandwitdh action.
Expand Down Expand Up @@ -601,8 +601,14 @@ export default async function beautify (operation) {
currentOperation["rows"] = [
{ key: "from", params: { from: from } },
{ key: "receiver", params: { receiver: receiver } },
{ key: "unstake_net_quantity", params: { unstake_net_quantity: unstake_net_quantity } },
{ key: "unstake_cpu_quantity", params: { unstake_cpu_quantity: unstake_cpu_quantity } },
{
key: "unstake_net_quantity",
params: { unstake_net_quantity: unstake_net_quantity },
},
{
key: "unstake_cpu_quantity",
params: { unstake_cpu_quantity: unstake_cpu_quantity },
},
];
} else if (opType === "buyram") {
/**
Expand Down Expand Up @@ -669,9 +675,7 @@ export default async function beautify (operation) {
* @param owner - the owner of the tokens claimed.
*/
const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "regproducer") {
// functions defined in voting.cpp

Expand Down Expand Up @@ -711,7 +715,7 @@ export default async function beautify (operation) {
const producer = operation.data.producer;
currentOperation["rows"] = [
{ key: "producer", params: { producer: producer } },
];
];
} else if (opType === "setram") {
/**
* Set ram action.
Expand All @@ -735,7 +739,10 @@ export default async function beautify (operation) {
*/
const bytes_per_block = operation.data.bytes_per_block;
currentOperation["rows"] = [
{ key: "bytes_per_block", params: { bytes_per_block: bytes_per_block } },
{
key: "bytes_per_block",
params: { bytes_per_block: bytes_per_block },
},
];
} else if (opType === "voteproducer") {
/**
Expand Down Expand Up @@ -770,7 +777,7 @@ export default async function beautify (operation) {
{ key: "voter", params: { voter: voter } },
{ key: "proxy", params: { proxy: proxy } },
{ key: "producers", params: { producers: producers } },
];
];
} else if (opType === "regproxy") {
/**
* Register proxy action.
Expand Down Expand Up @@ -803,7 +810,10 @@ export default async function beautify (operation) {
*/
const params = JSON.stringify(operation.data.params, null, 2);
currentOperation["rows"] = [
{ key: "params", params: { params: JSON.stringify(params, null, 2) } },
{
key: "params",
params: { params: JSON.stringify(params, null, 2) },
},
];
} else if (opType === "claimrewards") {
// functions defined in producer_pay.cpp
Expand All @@ -814,9 +824,7 @@ export default async function beautify (operation) {
* @param owner - producer account claiming per-block and per-vote rewards.
*/
const owner = operation.data.owner;
currentOperation["rows"] = [
{ key: "owner", params: { owner: owner } },
];
currentOperation["rows"] = [{ key: "owner", params: { owner: owner } }];
} else if (opType === "setpriv") {
/**
* Set privilege status for an account.
Expand Down Expand Up @@ -898,7 +906,25 @@ export default async function beautify (operation) {
{ key: "bidder", params: { bidder: bidder } },
{ key: "newname", params: { newname: newname } },
];
} else if (opType === "ramtransfer") {
/**
* Ram transfer action.
*
* @details Allows an account `from` to transfer ram to another account `to`.
*
* @param from - the account sending ram,
* @param to - the account receiving ram,
* @param bytes - the amount of ram to be sent.
*/
const from = operation.data.from;
const to = operation.data.to;
const bytes = operation.data.bytes;
currentOperation["rows"] = [
{ key: "from", params: { from: from } },
{ key: "to", params: { to: to } },
{ key: "bytes", params: { bytes: bytes } },
];
}

return currentOperation;
}
}
3 changes: 2 additions & 1 deletion src/lib/blockchains/EOSmainnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const operations = [
"rmvproducer",
"updtrevision",
"bidname",
"bidrefund"
"bidrefund",
"ramtransfer"
];

export default class EOS extends BlockchainAPI {
Expand Down
15 changes: 15 additions & 0 deletions src/translations/operations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,21 @@
"newname": "Nyt navn: {newname}"
},
"tooltip": "Tilbagebetaling af budoperation"
},
"ramtransfer": {
"method": "RAM-overførsel",
"title": "RAM-overførselsanmodning",
"result": "Resultat af RAM-overførsel",
"headers": {
"request": "Overføre RAM fra en konto til en anden?",
"result": "RAM blev overført fra en konto til en anden:"
},
"rows": {
"from": "Fra: {from}",
"to": "Til: {to}",
"bytes": "Bytes: {bytes}"
},
"tooltip": "Overførsel af RAM-drift"
}
}
}
Expand Down
17 changes: 16 additions & 1 deletion src/translations/operations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,22 @@
"newname": "Neuer Name: {newname}"
},
"tooltip": "Rückerstattung des Gebotsvorgangs"
}
},
"ramtransfer": {
"method": "RAM-Übertragung",
"title": "RAM-Übertragungsanforderung",
"result": "RAM-Übertragungsergebnis",
"headers": {
"request": "RAM von einem Konto auf ein anderes übertragen?",
"result": "RAM wurde von einem Konto auf ein anderes übertragen:"
},
"rows": {
"from": "Von: {von}",
"to": "An: {an}",
"bytes": "Bytes: {Bytes}"
},
"tooltip": "RAM-Betrieb übertragen"
}
}
}
}
17 changes: 16 additions & 1 deletion src/translations/operations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,22 @@
"newname": "New Name: {newname}"
},
"tooltip": "Refunding Bid operation"
}
},
"ramtransfer": {
"method": "RAM Transfer",
"title": "RAM Transfer Request",
"result": "RAM Transfer Result",
"headers": {
"request": "Transfer RAM from one account to another?",
"result": "RAM was transferred from one account to another:"
},
"rows": {
"from": "From: {from}",
"to": "To: {to}",
"bytes": "Bytes: {bytes}"
},
"tooltip": "Transferring RAM operation"
}
},
"BTS": {
"getAccount": {
Expand Down
15 changes: 15 additions & 0 deletions src/translations/operations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,21 @@
"newname": "Nuevo nombre: {newname}"
},
"tooltip": "Operación de oferta de reembolso"
},
"ramtransfer": {
"method": "Transferencia de RAM",
"title": "Solicitud de transferencia de RAM",
"result": "Resultado de la transferencia de RAM",
"headers": {
"request": "¿Transferir RAM de una cuenta a otra?",
"result": "La RAM se transfirió de una cuenta a otra:"
},
"rows": {
"from": "De: {de}",
"to": "Para: {a}",
"bytes": "Bytes: {bytes}"
},
"tooltip": "Operación de transferencia de RAM"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/translations/operations/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,21 @@
"newname": "Uus nimi: {newname}"
},
"tooltip": "Pakkumise tagasimakse toiming"
},
"ramtransfer": {
"method": "RAM-i ülekanne",
"title": "RAM-i ülekande taotlus",
"result": "RAM-i ülekande tulemus",
"headers": {
"request": "Kas teisaldada RAM-i ühelt kontolt teisele?",
"result": "RAM kanti ühelt kontolt teisele:"
},
"rows": {
"from": "Saatja: {from}",
"to": "Saaja: {to}",
"bytes": "Baidid: {baiti}"
},
"tooltip": "RAM-i toimingute edastamine"
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/translations/operations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2225,6 +2225,21 @@
"newname": "Nouveau nom : {newname}"
},
"tooltip": "Opération d’offre de remboursement"
},
"ramtransfer": {
"method": "Transfert de RAM",
"title": "Demande de transfert de RAM",
"result": "Résultat du transfert de RAM",
"headers": {
"request": "Transférer de la RAM d'un compte à un autre ?",
"result": "La RAM a été transférée d'un compte à un autre :"
},
"rows": {
"from": "De : {de}",
"to": "À : {à}",
"bytes": "Octets : {octets}"
},
"tooltip": "Opération de transfert de RAM"
}
}
}
Expand Down
Loading

0 comments on commit 69610eb

Please sign in to comment.