Skip to content

Commit

Permalink
some improvement for signing process
Browse files Browse the repository at this point in the history
  • Loading branch information
vorujack committed Apr 3, 2024
1 parent 6282f7e commit 6422882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/action/multi-sig/commitment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const generateCommitments = async (
const hintBagToArray = async (
wallet: StateWallet,
signerWallet: StateWallet,
tx: wasm.UnsignedTransaction,
tx: wasm.UnsignedTransaction | wasm.Transaction,
boxes: Array<wasm.ErgoBox>,
commitment: wasm.TransactionHintsBag,
password?: string,
Expand Down
20 changes: 8 additions & 12 deletions src/action/multi-sig/signing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,8 @@ const extractAndAddSignedHints = async (
partial?: wasm.Transaction,
boxes: Array<wasm.ErgoBox> = [],
) => {
const simulatedPropositions = new wasm.Propositions();
simulated.forEach((item) => {
simulatedPropositions.add_proposition_from_byte(
Uint8Array.from(Buffer.from('cd' + item, 'hex')),
);
});
const realPropositions = new wasm.Propositions();
signed.forEach((item) => {
realPropositions.add_proposition_from_byte(
Uint8Array.from(Buffer.from('cd' + item, 'hex')),
);
});
const simulatedPropositions = arrayToProposition(simulated);
const realPropositions = arrayToProposition(signed);
const context = await getChain(wallet.networkType).fakeContext();
if (partial) {
const ergoBoxes = wasm.ErgoBoxes.empty();
Expand Down Expand Up @@ -337,3 +327,9 @@ export const sign = async (
currentTime,
};
};

export const arrayToProposition = (input: Array<string>): wasm.Propositions => {
const output = new wasm.Propositions()
input.forEach(pk => Uint8Array.from(Buffer.from('cd' + pk, 'hex')),)
return output
}
2 changes: 1 addition & 1 deletion src/action/multi-sig/wallet-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const getMultiSigWalletMyPublicKeys = async (
const getInputPks = async (
wallet: StateWallet,
signerWallet: StateWallet,
tx: wasm.UnsignedTransaction,
tx: wasm.UnsignedTransaction | wasm.Transaction,
boxes: Array<wasm.ErgoBox>,
): Promise<Array<Array<string>>> => {
const pks = await getMultiSigWalletPublicKeys(wallet, signerWallet);
Expand Down

0 comments on commit 6422882

Please sign in to comment.