Skip to content

Commit

Permalink
Remove OrderedMap export and use SignatureSMap
Browse files Browse the repository at this point in the history
Not sure what I was doing here, but OrderedMap is just used for SignaturesMap, and all the uses were just using it as that
  • Loading branch information
mcintyre94 committed Apr 18, 2024
1 parent b2bbe56 commit e528995
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 7 additions & 7 deletions packages/transactions/src/__tests__/signatures-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
partiallySignTransaction,
signTransaction,
} from '../signatures';
import { OrderedMap, Transaction, TransactionMessageBytes } from '../transaction';
import { SignaturesMap, Transaction, TransactionMessageBytes } from '../transaction';

jest.mock('@solana/addresses');
jest.mock('@solana/keys');

describe('getSignatureFromTransaction', () => {
it("returns the signature associated with a transaction's fee payer", () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
signatures['123' as Address] = new Uint8Array(new Array(64).fill(9)) as SignatureBytes;
const transactionWithFeePayerSignature: Transaction = {
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
Expand Down Expand Up @@ -405,7 +405,7 @@ describe('assertTransactionIsFullySigned', () => {
const mockSignatureB = new Uint8Array(1) as SignatureBytes;

it('throws if the transaction has no signature for the fee payer', () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
signatures[mockPublicKeyAddressA] = null;
const transaction: Transaction = {
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
Expand All @@ -420,7 +420,7 @@ describe('assertTransactionIsFullySigned', () => {
});

it('throws all missing signers if the transaction has no signature for multiple signers', () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
signatures[mockPublicKeyAddressA] = null;
signatures[mockPublicKeyAddressB] = null;
const transaction: Transaction = {
Expand All @@ -436,7 +436,7 @@ describe('assertTransactionIsFullySigned', () => {
});

it('does not throw if the transaction is signed by its only signer', () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
signatures[mockPublicKeyAddressA] = mockSignatureA;
const transaction: Transaction = {
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
Expand All @@ -447,7 +447,7 @@ describe('assertTransactionIsFullySigned', () => {
});

it('does not throw if the transaction is signed by all its signers', () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
signatures[mockPublicKeyAddressA] = mockSignatureA;
signatures[mockPublicKeyAddressB] = mockSignatureB;
const transaction: Transaction = {
Expand All @@ -459,7 +459,7 @@ describe('assertTransactionIsFullySigned', () => {
});

it('does not throw if the transaction has no signatures', () => {
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
const transaction: Transaction = {
messageBytes: new Uint8Array() as ReadonlyUint8Array as TransactionMessageBytes,
signatures,
Expand Down
6 changes: 2 additions & 4 deletions packages/transactions/src/compile-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Address } from '@solana/addresses';
import { ReadonlyUint8Array } from '@solana/codecs-core';
import { SignatureBytes } from '@solana/keys';
import {
CompilableTransactionMessage,
getCompiledTransactionMessageEncoder,
Expand All @@ -15,7 +13,7 @@ import {
TransactionWithDurableNonceLifetime,
TransactionWithLifetime,
} from './lifetime';
import { OrderedMap, Transaction, TransactionMessageBytes } from './transaction';
import { SignaturesMap, Transaction, TransactionMessageBytes } from './transaction';

export function compileTransaction(
transactionMessage: CompilableTransactionMessage & ITransactionMessageWithBlockhashLifetime,
Expand All @@ -38,7 +36,7 @@ export function compileTransaction(
) as ReadonlyUint8Array as TransactionMessageBytes;

const transactionSigners = compiledMessage.staticAccounts.slice(0, compiledMessage.header.numSignerAccounts);
const signatures: OrderedMap<Address, SignatureBytes | null> = {};
const signatures: SignaturesMap = {};
for (const signerAddress of transactionSigners) {
signatures[signerAddress] = null;
}
Expand Down

0 comments on commit e528995

Please sign in to comment.