@solana/transactions 2.0.0-experimental.dacecb7 → 2.0.0-experimental.df45965
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +314 -5
- package/dist/index.browser.cjs +170 -217
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +172 -220
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +643 -649
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +172 -218
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +172 -215
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +172 -220
- package/dist/index.node.js.map +1 -1
- package/dist/index.production.min.js +17 -16
- package/dist/types/durable-nonce.d.ts +1 -0
- package/dist/types/durable-nonce.d.ts.map +1 -1
- package/dist/types/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/address-table-lookup.d.ts.map +1 -1
- package/dist/types/serializers/header.d.ts +4 -2
- package/dist/types/serializers/header.d.ts.map +1 -1
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts.map +1 -1
- package/dist/types/serializers/message.d.ts +4 -4
- package/dist/types/serializers/message.d.ts.map +1 -1
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/dist/types/serializers/transaction-version.d.ts.map +1 -1
- package/dist/types/serializers/transaction.d.ts +5 -4
- package/dist/types/serializers/transaction.d.ts.map +1 -1
- package/dist/types/signatures.d.ts.map +1 -1
- package/dist/types/wire-transaction.d.ts +1 -1
- package/dist/types/wire-transaction.d.ts.map +1 -1
- package/package.json +11 -7
- package/dist/types/serializers/unimplemented.d.ts +0 -3
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { base58
|
|
2
|
-
import {
|
|
1
|
+
import { base58 } from '@metaplex-foundation/umi-serializers';
|
|
2
|
+
import { mapEncoder } from '@solana/codecs-core';
|
|
3
|
+
import { getStructEncoder, getArrayEncoder, getBytesEncoder } from '@solana/codecs-data-structures';
|
|
4
|
+
import { getShortU16Encoder, getU8Encoder } from '@solana/codecs-numbers';
|
|
5
|
+
import { getAddressFromPublicKey, getAddressComparator, getAddressEncoder } from '@solana/addresses';
|
|
6
|
+
import { getStringEncoder, getBase58Encoder } from '@solana/codecs-strings';
|
|
3
7
|
import { signBytes } from '@solana/keys';
|
|
4
8
|
|
|
5
9
|
// ../build-scripts/env-shim.ts
|
|
@@ -29,8 +33,8 @@ function assertIsBlockhash(putativeBlockhash) {
|
|
|
29
33
|
) {
|
|
30
34
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
31
35
|
}
|
|
32
|
-
const
|
|
33
|
-
const numBytes =
|
|
36
|
+
const bytes = base58.serialize(putativeBlockhash);
|
|
37
|
+
const numBytes = bytes.byteLength;
|
|
34
38
|
if (numBytes !== 32) {
|
|
35
39
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
36
40
|
}
|
|
@@ -460,159 +464,106 @@ function getCompiledTransaction(transaction) {
|
|
|
460
464
|
signatures
|
|
461
465
|
};
|
|
462
466
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
} : void 0
|
|
472
|
-
)
|
|
473
|
-
],
|
|
467
|
+
var lookupTableAddressDescription = __DEV__ ? "The address of the address lookup table account from which instruction addresses should be looked up" : "lookupTableAddress";
|
|
468
|
+
var writableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as writeable" : "writableIndices";
|
|
469
|
+
var readableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as read-only" : "readableIndices";
|
|
470
|
+
var addressTableLookupDescription = __DEV__ ? "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" : "addressTableLookup";
|
|
471
|
+
var memoizedAddressTableLookupEncoder;
|
|
472
|
+
function getAddressTableLookupEncoder() {
|
|
473
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
474
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
474
475
|
[
|
|
475
|
-
"
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
476
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
477
|
+
[
|
|
478
|
+
"writableIndices",
|
|
479
|
+
getArrayEncoder(getU8Encoder(), {
|
|
480
|
+
description: writableIndicesDescription,
|
|
481
|
+
size: getShortU16Encoder()
|
|
482
|
+
})
|
|
483
|
+
],
|
|
484
|
+
[
|
|
485
|
+
"readableIndices",
|
|
486
|
+
getArrayEncoder(getU8Encoder(), {
|
|
487
|
+
description: readableIndicesDescription,
|
|
488
|
+
size: getShortU16Encoder()
|
|
489
|
+
})
|
|
490
|
+
]
|
|
482
491
|
],
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
__DEV__ ? {
|
|
494
|
-
description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
|
|
495
|
-
} : void 0
|
|
496
|
-
);
|
|
492
|
+
{ description: addressTableLookupDescription }
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
return memoizedAddressTableLookupEncoder;
|
|
496
|
+
}
|
|
497
|
+
var memoizedU8Encoder;
|
|
498
|
+
function getMemoizedU8Encoder() {
|
|
499
|
+
if (!memoizedU8Encoder)
|
|
500
|
+
memoizedU8Encoder = getU8Encoder();
|
|
501
|
+
return memoizedU8Encoder;
|
|
497
502
|
}
|
|
498
|
-
function
|
|
499
|
-
|
|
503
|
+
function getMemoizedU8EncoderDescription(description) {
|
|
504
|
+
const encoder = getMemoizedU8Encoder();
|
|
505
|
+
return {
|
|
506
|
+
...encoder,
|
|
507
|
+
description: description ?? encoder.description
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
var numSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" : void 0;
|
|
511
|
+
var numReadonlySignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" : void 0;
|
|
512
|
+
var numReadonlyNonSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" : void 0;
|
|
513
|
+
var messageHeaderDescription = __DEV__ ? "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" : void 0;
|
|
514
|
+
function getMessageHeaderEncoder() {
|
|
515
|
+
return getStructEncoder(
|
|
500
516
|
[
|
|
501
|
-
[
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
__DEV__ ? {
|
|
505
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
|
|
506
|
-
} : void 0
|
|
507
|
-
)
|
|
508
|
-
],
|
|
509
|
-
[
|
|
510
|
-
"numReadonlySignerAccounts",
|
|
511
|
-
u8(
|
|
512
|
-
__DEV__ ? {
|
|
513
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
|
|
514
|
-
} : void 0
|
|
515
|
-
)
|
|
516
|
-
],
|
|
517
|
-
[
|
|
518
|
-
"numReadonlyNonSignerAccounts",
|
|
519
|
-
u8(
|
|
520
|
-
__DEV__ ? {
|
|
521
|
-
description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
|
|
522
|
-
} : void 0
|
|
523
|
-
)
|
|
524
|
-
]
|
|
517
|
+
["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
|
|
518
|
+
["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
|
|
519
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
|
|
525
520
|
],
|
|
526
|
-
|
|
527
|
-
description:
|
|
528
|
-
} : void 0
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
function getInstructionCodec() {
|
|
532
|
-
return mapSerializer(
|
|
533
|
-
struct([
|
|
534
|
-
[
|
|
535
|
-
"programAddressIndex",
|
|
536
|
-
u8(
|
|
537
|
-
__DEV__ ? {
|
|
538
|
-
description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
|
|
539
|
-
} : void 0
|
|
540
|
-
)
|
|
541
|
-
],
|
|
542
|
-
[
|
|
543
|
-
"accountIndices",
|
|
544
|
-
array(
|
|
545
|
-
u8({
|
|
546
|
-
description: __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : ""
|
|
547
|
-
}),
|
|
548
|
-
{
|
|
549
|
-
description: __DEV__ ? "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" : "",
|
|
550
|
-
size: shortU16()
|
|
551
|
-
}
|
|
552
|
-
)
|
|
553
|
-
],
|
|
554
|
-
[
|
|
555
|
-
"data",
|
|
556
|
-
bytes({
|
|
557
|
-
description: __DEV__ ? "An optional buffer of data passed to the instruction" : "",
|
|
558
|
-
size: shortU16()
|
|
559
|
-
})
|
|
560
|
-
]
|
|
561
|
-
]),
|
|
562
|
-
(value) => {
|
|
563
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
564
|
-
return value;
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
...value,
|
|
568
|
-
accountIndices: value.accountIndices ?? [],
|
|
569
|
-
data: value.data ?? new Uint8Array(0)
|
|
570
|
-
};
|
|
571
|
-
},
|
|
572
|
-
(value) => {
|
|
573
|
-
if (value.accountIndices.length && value.data.byteLength) {
|
|
574
|
-
return value;
|
|
575
|
-
}
|
|
576
|
-
const { accountIndices, data, ...rest } = value;
|
|
577
|
-
return {
|
|
578
|
-
...rest,
|
|
579
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
580
|
-
...data.byteLength ? { data } : null
|
|
581
|
-
};
|
|
521
|
+
{
|
|
522
|
+
description: messageHeaderDescription
|
|
582
523
|
}
|
|
583
524
|
);
|
|
584
525
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
)
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
526
|
+
var programAddressIndexDescription = __DEV__ ? "The index of the program being called, according to the well-ordered accounts list for this transaction" : "programAddressIndex";
|
|
527
|
+
var accountIndexDescription = __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : void 0;
|
|
528
|
+
var accountIndicesDescription = __DEV__ ? "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" : "accountIndices";
|
|
529
|
+
var dataDescription = __DEV__ ? "An optional buffer of data passed to the instruction" : "data";
|
|
530
|
+
var memoizedGetInstructionEncoder;
|
|
531
|
+
function getInstructionEncoder() {
|
|
532
|
+
if (!memoizedGetInstructionEncoder) {
|
|
533
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
534
|
+
getStructEncoder([
|
|
535
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
536
|
+
[
|
|
537
|
+
"accountIndices",
|
|
538
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
539
|
+
description: accountIndicesDescription,
|
|
540
|
+
size: getShortU16Encoder()
|
|
541
|
+
})
|
|
542
|
+
],
|
|
543
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
544
|
+
]),
|
|
545
|
+
// Convert an instruction to have all fields defined
|
|
546
|
+
(instruction) => {
|
|
547
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
548
|
+
return instruction;
|
|
549
|
+
}
|
|
550
|
+
return {
|
|
551
|
+
...instruction,
|
|
552
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
553
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
return memoizedGetInstructionEncoder;
|
|
597
559
|
}
|
|
598
|
-
|
|
599
|
-
// src/serializers/transaction-version.ts
|
|
600
560
|
var VERSION_FLAG_MASK = 128;
|
|
601
561
|
var BASE_CONFIG = {
|
|
602
562
|
description: __DEV__ ? "A single byte that encodes the version of the transaction" : "",
|
|
603
563
|
fixedSize: null,
|
|
604
564
|
maxSize: 1
|
|
605
565
|
};
|
|
606
|
-
function
|
|
607
|
-
const firstByte = bytes3[offset];
|
|
608
|
-
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
609
|
-
return ["legacy", offset];
|
|
610
|
-
} else {
|
|
611
|
-
const version = firstByte ^ VERSION_FLAG_MASK;
|
|
612
|
-
return [version, offset + 1];
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
function serialize(value) {
|
|
566
|
+
function encode(value) {
|
|
616
567
|
if (value === "legacy") {
|
|
617
568
|
return new Uint8Array();
|
|
618
569
|
}
|
|
@@ -621,108 +572,110 @@ function serialize(value) {
|
|
|
621
572
|
}
|
|
622
573
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
623
574
|
}
|
|
624
|
-
function
|
|
575
|
+
function getTransactionVersionEncoder() {
|
|
625
576
|
return {
|
|
626
577
|
...BASE_CONFIG,
|
|
627
|
-
|
|
628
|
-
serialize
|
|
578
|
+
encode
|
|
629
579
|
};
|
|
630
580
|
}
|
|
631
581
|
|
|
632
582
|
// src/serializers/message.ts
|
|
633
|
-
var
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
(value)
|
|
648
|
-
|
|
649
|
-
return value;
|
|
650
|
-
}
|
|
651
|
-
return {
|
|
652
|
-
...value,
|
|
653
|
-
addressTableLookups: value.addressTableLookups ?? []
|
|
654
|
-
};
|
|
583
|
+
var staticAccountsDescription = __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "staticAccounts";
|
|
584
|
+
var lifetimeTokenDescription = __DEV__ ? "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" : "lifetimeToken";
|
|
585
|
+
var instructionsDescription = __DEV__ ? "A compact-array of instructions belonging to this transaction" : "instructions";
|
|
586
|
+
var addressTableLookupsDescription = __DEV__ ? "A compact array of address table lookups belonging to this transaction" : "addressTableLookups";
|
|
587
|
+
function getCompiledMessageLegacyEncoder() {
|
|
588
|
+
return getStructEncoder(getPreludeStructEncoderTuple());
|
|
589
|
+
}
|
|
590
|
+
function getCompiledMessageVersionedEncoder() {
|
|
591
|
+
return mapEncoder(
|
|
592
|
+
getStructEncoder([
|
|
593
|
+
...getPreludeStructEncoderTuple(),
|
|
594
|
+
["addressTableLookups", getAddressTableLookupArrayEncoder()]
|
|
595
|
+
]),
|
|
596
|
+
(value) => {
|
|
597
|
+
if (value.version === "legacy") {
|
|
598
|
+
return value;
|
|
655
599
|
}
|
|
656
|
-
|
|
657
|
-
|
|
600
|
+
return {
|
|
601
|
+
...value,
|
|
602
|
+
addressTableLookups: value.addressTableLookups ?? []
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
);
|
|
658
606
|
}
|
|
659
|
-
function
|
|
607
|
+
function getPreludeStructEncoderTuple() {
|
|
660
608
|
return [
|
|
661
|
-
["version",
|
|
662
|
-
["header",
|
|
609
|
+
["version", getTransactionVersionEncoder()],
|
|
610
|
+
["header", getMessageHeaderEncoder()],
|
|
663
611
|
[
|
|
664
612
|
"staticAccounts",
|
|
665
|
-
|
|
666
|
-
description:
|
|
667
|
-
size:
|
|
613
|
+
getArrayEncoder(getAddressEncoder(), {
|
|
614
|
+
description: staticAccountsDescription,
|
|
615
|
+
size: getShortU16Encoder()
|
|
668
616
|
})
|
|
669
617
|
],
|
|
670
618
|
[
|
|
671
619
|
"lifetimeToken",
|
|
672
|
-
|
|
673
|
-
description:
|
|
674
|
-
encoding:
|
|
620
|
+
getStringEncoder({
|
|
621
|
+
description: lifetimeTokenDescription,
|
|
622
|
+
encoding: getBase58Encoder(),
|
|
675
623
|
size: 32
|
|
676
624
|
})
|
|
677
625
|
],
|
|
678
626
|
[
|
|
679
627
|
"instructions",
|
|
680
|
-
|
|
681
|
-
description:
|
|
682
|
-
size:
|
|
628
|
+
getArrayEncoder(getInstructionEncoder(), {
|
|
629
|
+
description: instructionsDescription,
|
|
630
|
+
size: getShortU16Encoder()
|
|
683
631
|
})
|
|
684
632
|
]
|
|
685
633
|
];
|
|
686
634
|
}
|
|
687
|
-
function
|
|
688
|
-
return
|
|
689
|
-
|
|
690
|
-
size:
|
|
635
|
+
function getAddressTableLookupArrayEncoder() {
|
|
636
|
+
return getArrayEncoder(getAddressTableLookupEncoder(), {
|
|
637
|
+
description: addressTableLookupsDescription,
|
|
638
|
+
size: getShortU16Encoder()
|
|
691
639
|
});
|
|
692
640
|
}
|
|
641
|
+
var messageDescription = __DEV__ ? "The wire format of a Solana transaction message" : "message";
|
|
693
642
|
function getCompiledMessageEncoder() {
|
|
694
643
|
return {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
644
|
+
description: messageDescription,
|
|
645
|
+
encode: (compiledMessage) => {
|
|
646
|
+
if (compiledMessage.version === "legacy") {
|
|
647
|
+
return getCompiledMessageLegacyEncoder().encode(compiledMessage);
|
|
648
|
+
} else {
|
|
649
|
+
return getCompiledMessageVersionedEncoder().encode(compiledMessage);
|
|
650
|
+
}
|
|
651
|
+
},
|
|
652
|
+
fixedSize: null,
|
|
653
|
+
maxSize: null
|
|
698
654
|
};
|
|
699
655
|
}
|
|
700
656
|
|
|
701
657
|
// src/serializers/transaction.ts
|
|
702
|
-
var
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
};
|
|
707
|
-
function serialize3(transaction) {
|
|
708
|
-
const compiledTransaction = getCompiledTransaction(transaction);
|
|
709
|
-
return struct([
|
|
658
|
+
var transactionDescription = __DEV__ ? "The wire format of a Solana transaction" : "transaction";
|
|
659
|
+
var signaturesDescription = __DEV__ ? "A compact array of 64-byte, base-64 encoded Ed25519 signatures" : "signatures";
|
|
660
|
+
function getCompiledTransactionEncoder() {
|
|
661
|
+
return getStructEncoder(
|
|
710
662
|
[
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
663
|
+
[
|
|
664
|
+
"signatures",
|
|
665
|
+
getArrayEncoder(getBytesEncoder({ size: 64 }), {
|
|
666
|
+
description: signaturesDescription,
|
|
667
|
+
size: getShortU16Encoder()
|
|
668
|
+
})
|
|
669
|
+
],
|
|
670
|
+
["compiledMessage", getCompiledMessageEncoder()]
|
|
716
671
|
],
|
|
717
|
-
|
|
718
|
-
|
|
672
|
+
{
|
|
673
|
+
description: transactionDescription
|
|
674
|
+
}
|
|
675
|
+
);
|
|
719
676
|
}
|
|
720
677
|
function getTransactionEncoder() {
|
|
721
|
-
return
|
|
722
|
-
...BASE_CONFIG3,
|
|
723
|
-
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
724
|
-
serialize: serialize3
|
|
725
|
-
};
|
|
678
|
+
return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
|
|
726
679
|
}
|
|
727
680
|
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
728
681
|
try {
|
|
@@ -733,8 +686,8 @@ function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
|
733
686
|
) {
|
|
734
687
|
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
735
688
|
}
|
|
736
|
-
const
|
|
737
|
-
const numBytes =
|
|
689
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
690
|
+
const numBytes = bytes.byteLength;
|
|
738
691
|
if (numBytes !== 64) {
|
|
739
692
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
740
693
|
}
|
|
@@ -752,26 +705,27 @@ function isTransactionSignature(putativeTransactionSignature) {
|
|
|
752
705
|
) {
|
|
753
706
|
return false;
|
|
754
707
|
}
|
|
755
|
-
const
|
|
756
|
-
const numBytes =
|
|
708
|
+
const bytes = base58.serialize(putativeTransactionSignature);
|
|
709
|
+
const numBytes = bytes.byteLength;
|
|
757
710
|
if (numBytes !== 64) {
|
|
758
711
|
return false;
|
|
759
712
|
}
|
|
760
713
|
return true;
|
|
761
714
|
}
|
|
762
715
|
async function getCompiledMessageSignature(message, secretKey) {
|
|
763
|
-
const wireMessageBytes = getCompiledMessageEncoder().
|
|
716
|
+
const wireMessageBytes = getCompiledMessageEncoder().encode(message);
|
|
764
717
|
const signature = await signBytes(secretKey, wireMessageBytes);
|
|
765
718
|
return signature;
|
|
766
719
|
}
|
|
767
720
|
function getSignatureFromTransaction(transaction) {
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
721
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
722
|
+
if (!signatureBytes) {
|
|
770
723
|
throw new Error(
|
|
771
724
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
772
725
|
);
|
|
773
726
|
}
|
|
774
|
-
|
|
727
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
728
|
+
return transactionSignature2;
|
|
775
729
|
}
|
|
776
730
|
async function signTransaction(keyPairs, transaction) {
|
|
777
731
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -801,12 +755,10 @@ function transactionSignature(putativeTransactionSignature) {
|
|
|
801
755
|
|
|
802
756
|
// src/wire-transaction.ts
|
|
803
757
|
function getBase64EncodedWireTransaction(transaction) {
|
|
804
|
-
const wireTransactionBytes = getTransactionEncoder().
|
|
758
|
+
const wireTransactionBytes = getTransactionEncoder().encode(transaction);
|
|
805
759
|
{
|
|
806
760
|
return btoa(String.fromCharCode(...wireTransactionBytes));
|
|
807
761
|
}
|
|
808
762
|
}
|
|
809
763
|
|
|
810
|
-
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertIsTransactionSignature, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionEncoder, isTransactionSignature, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction, transactionSignature };
|
|
811
|
-
//# sourceMappingURL=out.js.map
|
|
812
|
-
//# sourceMappingURL=index.browser.js.map
|
|
764
|
+
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertIsTransactionSignature, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionEncoder, isAdvanceNonceAccountInstruction, isTransactionSignature, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction, transactionSignature };
|