Skip to content

Commit 01c8574

Browse files
chore: add sig to all credentials
1 parent bb2d17e commit 01c8574

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

examples/p-chain/etna/createChain.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { addTxSignatures, pvm, utils } from '../../../src';
1+
import { pvm, utils } from '../../../src';
22
import { setupEtnaExample } from './utils/etna-helper';
33
import { testGenesisData } from '../../../src/fixtures/transactions';
44
import { getEnvVars } from '../../utils/getEnvVars';
5+
import { addSigToAllCreds } from './utils/addSignatureToAllCred';
56

67
/**
78
* Create a new chain on the P-Chain.
@@ -38,10 +39,7 @@ const createChainTxExample = async () => {
3839
context,
3940
);
4041

41-
await addTxSignatures({
42-
unsignedTx: tx,
43-
privateKeys: [utils.hexToBuffer(PRIVATE_KEY)],
44-
});
42+
await addSigToAllCreds(tx, utils.hexToBuffer(PRIVATE_KEY));
4543

4644
return pvmApi.issueSignedTx(tx.getSignedTx());
4745
};

src/vms/common/unsignedTx.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,10 @@ export class UnsignedTx {
173173

174174
private addSignatureForPubKey(sig: Uint8Array, publicKey: Uint8Array) {
175175
const coordinates = this.getSigIndicesForPubKey(publicKey);
176-
for (let i = 0; i < this.getCredentials().length; i++) {
177-
if (coordinates[i]) {
178-
coordinates.forEach(([index, subIndex]) => {
179-
this.addSignatureAt(sig, index, subIndex);
180-
});
181-
} else {
182-
this.addSignatureAt(sig, i, 0);
183-
}
176+
if (coordinates) {
177+
coordinates.forEach(([index, subIndex]) => {
178+
this.addSignatureAt(sig, index, subIndex);
179+
});
184180
}
185181
}
186182

0 commit comments

Comments
 (0)