@solana/transactions 2.0.0-experimental.cc545f9 → 2.0.0-experimental.ce145c8
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/dist/index.browser.cjs +201 -149
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +203 -152
- package/dist/index.browser.js.map +1 -1
- package/dist/index.development.js +820 -162
- package/dist/index.development.js.map +1 -1
- package/dist/index.native.js +203 -152
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +203 -147
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +203 -152
- 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/serializers/address-table-lookup.d.ts +5 -3
- package/dist/types/serializers/header.d.ts +4 -2
- package/dist/types/serializers/instruction.d.ts +4 -2
- package/dist/types/serializers/transaction-version.d.ts +4 -4
- package/package.json +10 -7
- package/dist/types/accounts.d.ts.map +0 -1
- package/dist/types/blockhash.d.ts.map +0 -1
- package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
- package/dist/types/compile-header.d.ts.map +0 -1
- package/dist/types/compile-instructions.d.ts.map +0 -1
- package/dist/types/compile-lifetime-token.d.ts.map +0 -1
- package/dist/types/compile-static-accounts.d.ts.map +0 -1
- package/dist/types/compile-transaction.d.ts.map +0 -1
- package/dist/types/create-transaction.d.ts.map +0 -1
- package/dist/types/durable-nonce.d.ts.map +0 -1
- package/dist/types/fee-payer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/instructions.d.ts.map +0 -1
- package/dist/types/message.d.ts.map +0 -1
- package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
- package/dist/types/serializers/header.d.ts.map +0 -1
- package/dist/types/serializers/index.d.ts.map +0 -1
- package/dist/types/serializers/instruction.d.ts.map +0 -1
- package/dist/types/serializers/message.d.ts.map +0 -1
- package/dist/types/serializers/transaction-version.d.ts.map +0 -1
- package/dist/types/serializers/transaction.d.ts.map +0 -1
- package/dist/types/serializers/unimplemented.d.ts.map +0 -1
- package/dist/types/signatures.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/unsigned-transaction.d.ts.map +0 -1
- package/dist/types/wire-transaction.d.ts.map +0 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { base58, struct, array, bytes, shortU16, mapSerializer, string
|
|
2
|
-
import { getAddressFromPublicKey, getAddressComparator, getAddressCodec } from '@solana/addresses';
|
|
1
|
+
import { base58, struct, array, bytes, shortU16, mapSerializer, string } from '@metaplex-foundation/umi-serializers';
|
|
2
|
+
import { getAddressFromPublicKey, getAddressComparator, getAddressCodec, getAddressEncoder, getAddressDecoder } from '@solana/addresses';
|
|
3
|
+
import { combineCodec, mapEncoder, mapDecoder } from '@solana/codecs-core';
|
|
4
|
+
import { getStructCodec, getStructEncoder, getArrayEncoder, getStructDecoder, getArrayDecoder, getBytesEncoder, getBytesDecoder } from '@solana/codecs-data-structures';
|
|
5
|
+
import { getU8Encoder, getShortU16Encoder, getU8Decoder, getShortU16Decoder, getU8Codec } from '@solana/codecs-numbers';
|
|
3
6
|
import { signBytes } from '@solana/keys';
|
|
4
7
|
|
|
5
8
|
// ../build-scripts/env-shim.ts
|
|
@@ -29,8 +32,8 @@ function assertIsBlockhash(putativeBlockhash) {
|
|
|
29
32
|
) {
|
|
30
33
|
throw new Error("Expected input string to decode to a byte array of length 32.");
|
|
31
34
|
}
|
|
32
|
-
const
|
|
33
|
-
const numBytes =
|
|
35
|
+
const bytes2 = base58.serialize(putativeBlockhash);
|
|
36
|
+
const numBytes = bytes2.byteLength;
|
|
34
37
|
if (numBytes !== 32) {
|
|
35
38
|
throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
|
|
36
39
|
}
|
|
@@ -460,151 +463,170 @@ function getCompiledTransaction(transaction) {
|
|
|
460
463
|
signatures
|
|
461
464
|
};
|
|
462
465
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
var lookupTableAddressDescription = __DEV__ ? "The address of the address lookup table account from which instruction addresses should be looked up" : "lookupTableAddress";
|
|
467
|
+
var writableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as writeable" : "writableIndices";
|
|
468
|
+
var readableIndicesDescription = __DEV__ ? "The indices of the accounts in the lookup table that should be loaded as read-only" : "readableIndices";
|
|
469
|
+
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";
|
|
470
|
+
var memoizedAddressTableLookupEncoder;
|
|
471
|
+
function getAddressTableLookupEncoder() {
|
|
472
|
+
if (!memoizedAddressTableLookupEncoder) {
|
|
473
|
+
memoizedAddressTableLookupEncoder = getStructEncoder(
|
|
466
474
|
[
|
|
467
|
-
"lookupTableAddress",
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
475
|
+
["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
|
|
476
|
+
[
|
|
477
|
+
"writableIndices",
|
|
478
|
+
getArrayEncoder(getU8Encoder(), {
|
|
479
|
+
description: writableIndicesDescription,
|
|
480
|
+
size: getShortU16Encoder()
|
|
481
|
+
})
|
|
482
|
+
],
|
|
483
|
+
[
|
|
484
|
+
"readableIndices",
|
|
485
|
+
getArrayEncoder(getU8Encoder(), {
|
|
486
|
+
description: readableIndicesDescription,
|
|
487
|
+
size: getShortU16Encoder()
|
|
488
|
+
})
|
|
489
|
+
]
|
|
473
490
|
],
|
|
491
|
+
{ description: addressTableLookupDescription }
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
return memoizedAddressTableLookupEncoder;
|
|
495
|
+
}
|
|
496
|
+
var memoizedAddressTableLookupDecoder;
|
|
497
|
+
function getAddressTableLookupDecoder() {
|
|
498
|
+
if (!memoizedAddressTableLookupDecoder) {
|
|
499
|
+
memoizedAddressTableLookupDecoder = getStructDecoder(
|
|
474
500
|
[
|
|
475
|
-
"
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
501
|
+
["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
|
|
502
|
+
[
|
|
503
|
+
"writableIndices",
|
|
504
|
+
getArrayDecoder(getU8Decoder(), {
|
|
505
|
+
description: writableIndicesDescription,
|
|
506
|
+
size: getShortU16Decoder()
|
|
507
|
+
})
|
|
508
|
+
],
|
|
509
|
+
[
|
|
510
|
+
"readableIndices",
|
|
511
|
+
getArrayDecoder(getU8Decoder(), {
|
|
512
|
+
description: readableIndicesDescription,
|
|
513
|
+
size: getShortU16Decoder()
|
|
514
|
+
})
|
|
515
|
+
]
|
|
482
516
|
],
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
517
|
+
{ description: addressTableLookupDescription }
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
return memoizedAddressTableLookupDecoder;
|
|
521
|
+
}
|
|
522
|
+
function getAddressTableLookupCodec() {
|
|
523
|
+
return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
|
|
524
|
+
}
|
|
525
|
+
var memoizedU8Codec;
|
|
526
|
+
function getMemoizedU8Codec() {
|
|
527
|
+
if (!memoizedU8Codec)
|
|
528
|
+
memoizedU8Codec = getU8Codec();
|
|
529
|
+
return memoizedU8Codec;
|
|
530
|
+
}
|
|
531
|
+
function getMemoizedU8CodecDescription(description) {
|
|
532
|
+
const codec = getMemoizedU8Codec();
|
|
533
|
+
return {
|
|
534
|
+
...codec,
|
|
535
|
+
description: description ?? codec.description
|
|
536
|
+
};
|
|
497
537
|
}
|
|
538
|
+
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;
|
|
539
|
+
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;
|
|
540
|
+
var numReadonlyNonSignerAccountsDescription = __DEV__ ? "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" : void 0;
|
|
541
|
+
var messageHeaderDescription = __DEV__ ? "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" : void 0;
|
|
498
542
|
function getMessageHeaderCodec() {
|
|
499
|
-
return
|
|
543
|
+
return getStructCodec(
|
|
500
544
|
[
|
|
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
|
-
]
|
|
545
|
+
["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
|
|
546
|
+
["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
|
|
547
|
+
["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
|
|
525
548
|
],
|
|
526
|
-
|
|
527
|
-
description:
|
|
528
|
-
}
|
|
549
|
+
{
|
|
550
|
+
description: messageHeaderDescription
|
|
551
|
+
}
|
|
529
552
|
);
|
|
530
553
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
)
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
)
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
]
|
|
561
|
-
]),
|
|
562
|
-
(value) => {
|
|
563
|
-
if (value.accountIndices !== void 0 && value.data !== void 0) {
|
|
564
|
-
return value;
|
|
554
|
+
var programAddressIndexDescription = __DEV__ ? "The index of the program being called, according to the well-ordered accounts list for this transaction" : "programAddressIndex";
|
|
555
|
+
var accountIndexDescription = __DEV__ ? "The index of an account, according to the well-ordered accounts list for this transaction" : void 0;
|
|
556
|
+
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";
|
|
557
|
+
var dataDescription = __DEV__ ? "An optional buffer of data passed to the instruction" : "data";
|
|
558
|
+
var memoizedGetInstructionEncoder;
|
|
559
|
+
function getInstructionEncoder() {
|
|
560
|
+
if (!memoizedGetInstructionEncoder) {
|
|
561
|
+
memoizedGetInstructionEncoder = mapEncoder(
|
|
562
|
+
getStructEncoder([
|
|
563
|
+
["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
|
|
564
|
+
[
|
|
565
|
+
"accountIndices",
|
|
566
|
+
getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
|
|
567
|
+
description: accountIndicesDescription,
|
|
568
|
+
size: getShortU16Encoder()
|
|
569
|
+
})
|
|
570
|
+
],
|
|
571
|
+
["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
|
|
572
|
+
]),
|
|
573
|
+
// Convert an instruction to have all fields defined
|
|
574
|
+
(instruction) => {
|
|
575
|
+
if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
|
|
576
|
+
return instruction;
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
...instruction,
|
|
580
|
+
accountIndices: instruction.accountIndices ?? [],
|
|
581
|
+
data: instruction.data ?? new Uint8Array(0)
|
|
582
|
+
};
|
|
565
583
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
return memoizedGetInstructionEncoder;
|
|
587
|
+
}
|
|
588
|
+
var memoizedGetInstructionDecoder;
|
|
589
|
+
function getInstructionDecoder() {
|
|
590
|
+
if (!memoizedGetInstructionDecoder) {
|
|
591
|
+
memoizedGetInstructionDecoder = mapDecoder(
|
|
592
|
+
getStructDecoder([
|
|
593
|
+
["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
|
|
594
|
+
[
|
|
595
|
+
"accountIndices",
|
|
596
|
+
getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
|
|
597
|
+
description: accountIndicesDescription,
|
|
598
|
+
size: getShortU16Decoder()
|
|
599
|
+
})
|
|
600
|
+
],
|
|
601
|
+
["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
|
|
602
|
+
]),
|
|
603
|
+
// Convert an instruction to exclude optional fields if they are empty
|
|
604
|
+
(instruction) => {
|
|
605
|
+
if (instruction.accountIndices.length && instruction.data.byteLength) {
|
|
606
|
+
return instruction;
|
|
607
|
+
}
|
|
608
|
+
const { accountIndices, data, ...rest } = instruction;
|
|
609
|
+
return {
|
|
610
|
+
...rest,
|
|
611
|
+
...accountIndices.length ? { accountIndices } : null,
|
|
612
|
+
...data.byteLength ? { data } : null
|
|
613
|
+
};
|
|
575
614
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
...accountIndices.length ? { accountIndices } : null,
|
|
580
|
-
...data.byteLength ? { data } : null
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// src/serializers/unimplemented.ts
|
|
587
|
-
function getError(type, name) {
|
|
588
|
-
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
589
|
-
return new Error(
|
|
590
|
-
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
591
|
-
);
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
return memoizedGetInstructionDecoder;
|
|
592
618
|
}
|
|
593
|
-
function
|
|
594
|
-
return ()
|
|
595
|
-
throw getError("decoder", name);
|
|
596
|
-
};
|
|
619
|
+
function getInstructionCodec() {
|
|
620
|
+
return combineCodec(getInstructionEncoder(), getInstructionDecoder());
|
|
597
621
|
}
|
|
598
|
-
|
|
599
|
-
// src/serializers/transaction-version.ts
|
|
600
622
|
var VERSION_FLAG_MASK = 128;
|
|
601
623
|
var BASE_CONFIG = {
|
|
602
624
|
description: __DEV__ ? "A single byte that encodes the version of the transaction" : "",
|
|
603
625
|
fixedSize: null,
|
|
604
626
|
maxSize: 1
|
|
605
627
|
};
|
|
606
|
-
function
|
|
607
|
-
const firstByte =
|
|
628
|
+
function decode(bytes2, offset = 0) {
|
|
629
|
+
const firstByte = bytes2[offset];
|
|
608
630
|
if ((firstByte & VERSION_FLAG_MASK) === 0) {
|
|
609
631
|
return ["legacy", offset];
|
|
610
632
|
} else {
|
|
@@ -612,7 +634,7 @@ function deserialize(bytes3, offset = 0) {
|
|
|
612
634
|
return [version, offset + 1];
|
|
613
635
|
}
|
|
614
636
|
}
|
|
615
|
-
function
|
|
637
|
+
function encode(value) {
|
|
616
638
|
if (value === "legacy") {
|
|
617
639
|
return new Uint8Array();
|
|
618
640
|
}
|
|
@@ -621,11 +643,32 @@ function serialize(value) {
|
|
|
621
643
|
}
|
|
622
644
|
return new Uint8Array([value | VERSION_FLAG_MASK]);
|
|
623
645
|
}
|
|
624
|
-
function
|
|
646
|
+
function getTransactionVersionDecoder() {
|
|
625
647
|
return {
|
|
626
648
|
...BASE_CONFIG,
|
|
627
|
-
|
|
628
|
-
|
|
649
|
+
decode
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function getTransactionVersionEncoder() {
|
|
653
|
+
return {
|
|
654
|
+
...BASE_CONFIG,
|
|
655
|
+
encode
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function getTransactionVersionCodec() {
|
|
659
|
+
return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// src/serializers/unimplemented.ts
|
|
663
|
+
function getError(type, name) {
|
|
664
|
+
const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
|
|
665
|
+
return new Error(
|
|
666
|
+
`No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
function getUnimplementedDecoder(name) {
|
|
670
|
+
return () => {
|
|
671
|
+
throw getError("decoder", name);
|
|
629
672
|
};
|
|
630
673
|
}
|
|
631
674
|
|
|
@@ -635,7 +678,7 @@ var BASE_CONFIG2 = {
|
|
|
635
678
|
fixedSize: null,
|
|
636
679
|
maxSize: null
|
|
637
680
|
};
|
|
638
|
-
function
|
|
681
|
+
function serialize(compiledMessage) {
|
|
639
682
|
if (compiledMessage.version === "legacy") {
|
|
640
683
|
return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
|
|
641
684
|
} else {
|
|
@@ -656,13 +699,22 @@ function serialize2(compiledMessage) {
|
|
|
656
699
|
).serialize(compiledMessage);
|
|
657
700
|
}
|
|
658
701
|
}
|
|
702
|
+
function toSerializer(codec) {
|
|
703
|
+
return {
|
|
704
|
+
description: codec.description,
|
|
705
|
+
deserialize: codec.decode,
|
|
706
|
+
fixedSize: codec.fixedSize,
|
|
707
|
+
maxSize: codec.maxSize,
|
|
708
|
+
serialize: codec.encode
|
|
709
|
+
};
|
|
710
|
+
}
|
|
659
711
|
function getPreludeStructSerializerTuple() {
|
|
660
712
|
return [
|
|
661
|
-
["version", getTransactionVersionCodec()],
|
|
662
|
-
["header", getMessageHeaderCodec()],
|
|
713
|
+
["version", toSerializer(getTransactionVersionCodec())],
|
|
714
|
+
["header", toSerializer(getMessageHeaderCodec())],
|
|
663
715
|
[
|
|
664
716
|
"staticAccounts",
|
|
665
|
-
array(getAddressCodec(), {
|
|
717
|
+
array(toSerializer(getAddressCodec()), {
|
|
666
718
|
description: __DEV__ ? "A compact-array of static account addresses belonging to this transaction" : "",
|
|
667
719
|
size: shortU16()
|
|
668
720
|
})
|
|
@@ -677,7 +729,7 @@ function getPreludeStructSerializerTuple() {
|
|
|
677
729
|
],
|
|
678
730
|
[
|
|
679
731
|
"instructions",
|
|
680
|
-
array(getInstructionCodec(), {
|
|
732
|
+
array(toSerializer(getInstructionCodec()), {
|
|
681
733
|
description: __DEV__ ? "A compact-array of instructions belonging to this transaction" : "",
|
|
682
734
|
size: shortU16()
|
|
683
735
|
})
|
|
@@ -685,7 +737,7 @@ function getPreludeStructSerializerTuple() {
|
|
|
685
737
|
];
|
|
686
738
|
}
|
|
687
739
|
function getAddressTableLookupsSerializer() {
|
|
688
|
-
return array(getAddressTableLookupCodec(), {
|
|
740
|
+
return array(toSerializer(getAddressTableLookupCodec()), {
|
|
689
741
|
...__DEV__ ? { description: "A compact array of address table lookups belonging to this transaction" } : null,
|
|
690
742
|
size: shortU16()
|
|
691
743
|
});
|
|
@@ -694,7 +746,7 @@ function getCompiledMessageEncoder() {
|
|
|
694
746
|
return {
|
|
695
747
|
...BASE_CONFIG2,
|
|
696
748
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
697
|
-
serialize
|
|
749
|
+
serialize
|
|
698
750
|
};
|
|
699
751
|
}
|
|
700
752
|
|
|
@@ -704,7 +756,7 @@ var BASE_CONFIG3 = {
|
|
|
704
756
|
fixedSize: null,
|
|
705
757
|
maxSize: null
|
|
706
758
|
};
|
|
707
|
-
function
|
|
759
|
+
function serialize2(transaction) {
|
|
708
760
|
const compiledTransaction = getCompiledTransaction(transaction);
|
|
709
761
|
return struct([
|
|
710
762
|
[
|
|
@@ -721,7 +773,7 @@ function getTransactionEncoder() {
|
|
|
721
773
|
return {
|
|
722
774
|
...BASE_CONFIG3,
|
|
723
775
|
deserialize: getUnimplementedDecoder("CompiledMessage"),
|
|
724
|
-
serialize:
|
|
776
|
+
serialize: serialize2
|
|
725
777
|
};
|
|
726
778
|
}
|
|
727
779
|
function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
@@ -733,8 +785,8 @@ function assertIsTransactionSignature(putativeTransactionSignature) {
|
|
|
733
785
|
) {
|
|
734
786
|
throw new Error("Expected input string to decode to a byte array of length 64.");
|
|
735
787
|
}
|
|
736
|
-
const
|
|
737
|
-
const numBytes =
|
|
788
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
789
|
+
const numBytes = bytes2.byteLength;
|
|
738
790
|
if (numBytes !== 64) {
|
|
739
791
|
throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
|
|
740
792
|
}
|
|
@@ -752,8 +804,8 @@ function isTransactionSignature(putativeTransactionSignature) {
|
|
|
752
804
|
) {
|
|
753
805
|
return false;
|
|
754
806
|
}
|
|
755
|
-
const
|
|
756
|
-
const numBytes =
|
|
807
|
+
const bytes2 = base58.serialize(putativeTransactionSignature);
|
|
808
|
+
const numBytes = bytes2.byteLength;
|
|
757
809
|
if (numBytes !== 64) {
|
|
758
810
|
return false;
|
|
759
811
|
}
|
|
@@ -765,13 +817,14 @@ async function getCompiledMessageSignature(message, secretKey) {
|
|
|
765
817
|
return signature;
|
|
766
818
|
}
|
|
767
819
|
function getSignatureFromTransaction(transaction) {
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
820
|
+
const signatureBytes = transaction.signatures[transaction.feePayer];
|
|
821
|
+
if (!signatureBytes) {
|
|
770
822
|
throw new Error(
|
|
771
823
|
"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
|
|
772
824
|
);
|
|
773
825
|
}
|
|
774
|
-
|
|
826
|
+
const transactionSignature2 = base58.deserialize(signatureBytes)[0];
|
|
827
|
+
return transactionSignature2;
|
|
775
828
|
}
|
|
776
829
|
async function signTransaction(keyPairs, transaction) {
|
|
777
830
|
const compiledMessage = compileMessage(transaction);
|
|
@@ -807,6 +860,4 @@ function getBase64EncodedWireTransaction(transaction) {
|
|
|
807
860
|
}
|
|
808
861
|
}
|
|
809
862
|
|
|
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
|
|
863
|
+
export { appendTransactionInstruction, assertIsBlockhash, assertIsDurableNonceTransaction, assertIsTransactionSignature, createTransaction, getBase64EncodedWireTransaction, getSignatureFromTransaction, getTransactionEncoder, isAdvanceNonceAccountInstruction, isTransactionSignature, prependTransactionInstruction, setTransactionFeePayer, setTransactionLifetimeUsingBlockhash, setTransactionLifetimeUsingDurableNonce, signTransaction, transactionSignature };
|