Skip to content

Commit

Permalink
Merge pull request #1633 from qwadratic/fix/rosetta-combine
Browse files Browse the repository at this point in the history
fix rosettaCombinePayload
  • Loading branch information
mitschabaude authored May 6, 2024
2 parents 4578b7d + 5b6d149 commit 062a2c4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/mina-signer/mina-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,8 @@ class Client {
* @param privateKey The private key used to sign the transaction
* @returns A string with the resulting payload for /construction/combine.
*/
rosettaCombinePayload(signingPayload: string, privateKey: Json.PrivateKey) {
let parsedPayload = JSON.parse(signingPayload);
return JSON.stringify(Rosetta.rosettaCombinePayload(parsedPayload, privateKey, this.network));
rosettaCombinePayload(signingPayload: Rosetta.UnsignedPayload, privateKey: Json.PrivateKey) {
return Rosetta.rosettaCombinePayload(signingPayload, privateKey, this.network);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/mina-signer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/mina-signer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mina-signer",
"description": "Node API for signing transactions on various networks for Mina Protocol",
"version": "3.0.6",
"version": "3.0.7",
"type": "module",
"scripts": {
"build": "tsc -p ../../tsconfig.mina-signer.json",
Expand Down
4 changes: 2 additions & 2 deletions src/mina-signer/src/rosetta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function rosettaCombinePayload(
network: NetworkId
) {
let signature = signTransaction(
unsignedPayload.unsigned_transaction,
JSON.parse(unsignedPayload.unsigned_transaction),
privateKey,
network
);
Expand Down Expand Up @@ -282,7 +282,7 @@ function rosettaTransactionToSignedCommand({
}

type UnsignedPayload = {
unsigned_transaction: UnsignedTransaction;
unsigned_transaction: string;
payloads: unknown[];
};

Expand Down
8 changes: 4 additions & 4 deletions src/mina-signer/tests/rosetta.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Rosetta', () => {

const rosettaUnsignedTxn: UnsignedTransaction = { "randomOracleInput": "0000000333E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E33E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E33E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E000002570242F000000000008000000000000000C00000007FFFFFFFC00000000000000000000000000000000000000000000000000000000000000000000E0000000000000000014D677000000000", "signerInput": { "prefix": ["33E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E", "33E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E", "33E1F14C6155B706D4EA12CF70685B8DCD3342A8B36A27CC3EB61B5871F9219E"], "suffix": ["0000000000000007FFFFFFFC00000006000000000000000200000000001E8480", "0000000003800000000000000000000000000000000000000000000000000000", "00000000000000000000000000000000000000000000000001DCD65000000000"] }, "payment": { "to": "B62qqQomCgjaKhayN79wWqDNsSJKFaZjrkuCp8Kcrt36ubXb14XHU2X", "from": "B62qqQomCgjaKhayN79wWqDNsSJKFaZjrkuCp8Kcrt36ubXb14XHU2X", "fee": "1000000", "token": "wSHV2S4qX9jFsLjQo8r1BsMLH2ZRKsZx6EJd1sbozGPieEC4Jf", "nonce": "1", "memo": null, "amount": "1000000000", "valid_until": null }, "stakeDelegation": null };
const rosettaUnsignedPayload = {
unsigned_transaction: rosettaUnsignedTxn,
unsigned_transaction: JSON.stringify(rosettaUnsignedTxn),
payloads: [
{
account_identifier: {
Expand Down Expand Up @@ -101,10 +101,10 @@ describe('Rosetta', () => {
});

it('generates valid combine payload', () => {
const combinePayload = client.rosettaCombinePayload(JSON.stringify(rosettaUnsignedPayload), privateKey);
const combinePayload = client.rosettaCombinePayload(rosettaUnsignedPayload, privateKey);
const expectedCombinePayload = {
network_identifier: { blockchain: 'mina', network: 'mainnet' },
unsigned_transaction: rosettaUnsignedTxn,
unsigned_transaction: JSON.stringify(rosettaUnsignedTxn),
signatures: [
{
hex_bytes: mainnetSignatureHex,
Expand All @@ -118,6 +118,6 @@ describe('Rosetta', () => {
}
]
};
expect(combinePayload).toBe(JSON.stringify(expectedCombinePayload));
expect(JSON.stringify(combinePayload)).toBe(JSON.stringify(expectedCombinePayload));
});
});

0 comments on commit 062a2c4

Please sign in to comment.