Skip to content

Commit

Permalink
feat: Parse relevant arguments as NEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley committed Mar 17, 2022
1 parent f5149fd commit 7372346
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ const formatNear = (amount) => {

const rawPublicKeyToString = ({ keyType, data }) => new PublicKey({ keyType, data }).toString();

const parseAndFormatArguments = (argsBuffer) => {
const args = JSON.parse(Buffer.from(argsBuffer).toString());

const parsedArgs = {
...args,
...(args.amount && { amount: formatNear(args.amount) }),
...(args.deposit && { deposit: formatNear(args.deposit )}),
};

return JSON.stringify(parsedArgs, null, 2);
};

export default function getTranslationsFromMultisigRequest({ actions, receiverId, accountId }) {
const fullAccessKeyAction = actions.find(({ enum: type, permission }) => type === 'addKey' && !permission);
if (fullAccessKeyAction) {
Expand Down Expand Up @@ -63,7 +75,7 @@ export default function getTranslationsFromMultisigRequest({ actions, receiverId
receiverId,
methodName: action.methodName,
deposit: formatNear(action.deposit),
args: JSON.stringify(JSON.parse(Buffer.from(action.args).toString()), null, 2),
args: parseAndFormatArguments(action.args),
}
};
case 'transfer':
Expand Down

0 comments on commit 7372346

Please sign in to comment.