Skip to content

Commit

Permalink
Update welldone.ts
Browse files Browse the repository at this point in the history
- avoid the ternary operator
  • Loading branch information
sunny0529 committed Oct 6, 2023
1 parent ba99960 commit 7aec7c2
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions packages/welldone-wallet/src/lib/welldone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,30 +314,25 @@ const WelldoneWallet: WalletBehaviourFactory<InjectedWallet> = async ({
throw new Error("Failed to find account for signing");
}

const serializedTx = serializeNep413(message as SignMessageParams);
const serializedTx = serializeNep413(message);
const signed = await _state.wallet.request("near", {
method: "dapp:signMessage",
params: ["0x" + serializedTx.toString("hex")],
});

return (message as SignMessageParams).state
? {
accountId,
publicKey: signed[0].publicKey,
signature: Buffer.from(
signed[0].signature.substr(2),
"hex"
).toString("base64"),
state: (message as SignMessageParams).state,
}
: {
accountId,
publicKey: signed[0].publicKey,
signature: Buffer.from(
signed[0].signature.substr(2),
"hex"
).toString("base64"),
};
const result = {
accountId,
publicKey: signed[0].publicKey,
signature: Buffer.from(signed[0].signature.substr(2), "hex").toString(
"base64"
),
};

if (message.state) {
return { ...result, state: message.state };
}

return result;
},

async signAndSendTransaction({ signerId, receiverId, actions }) {
Expand Down

0 comments on commit 7aec7c2

Please sign in to comment.