@rialo/ts-cdk 0.2.0-alpha.1 → 0.2.0-alpha.2
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.d.mts +2 -402
- package/dist/index.d.ts +2 -402
- package/dist/index.js +2 -416
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -402
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -4
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Chacha20Poly1305 } from '@hpke/chacha20poly1305';
|
|
2
|
-
import { CipherSuite, HkdfSha256, DhkemX25519HkdfSha256 } from '@hpke/core';
|
|
3
|
-
|
|
4
1
|
var __create = Object.create;
|
|
5
2
|
var __defProp = Object.defineProperty;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5481,302 +5478,6 @@ var RialoError = class _RialoError extends Error {
|
|
|
5481
5478
|
}
|
|
5482
5479
|
};
|
|
5483
5480
|
|
|
5484
|
-
// src/rex/errors.ts
|
|
5485
|
-
var HpkeErrorCode = /* @__PURE__ */ ((HpkeErrorCode2) => {
|
|
5486
|
-
HpkeErrorCode2["INVALID_KEY_LENGTH"] = "INVALID_KEY_LENGTH";
|
|
5487
|
-
HpkeErrorCode2["CIPHERTEXT_TOO_SHORT"] = "CIPHERTEXT_TOO_SHORT";
|
|
5488
|
-
HpkeErrorCode2["ENCRYPTION_FAILED"] = "ENCRYPTION_FAILED";
|
|
5489
|
-
HpkeErrorCode2["BORSH_DESERIALIZE_FAILED"] = "BORSH_DESERIALIZE_FAILED";
|
|
5490
|
-
HpkeErrorCode2["INVALID_ORACLE_VALUE"] = "INVALID_ORACLE_VALUE";
|
|
5491
|
-
return HpkeErrorCode2;
|
|
5492
|
-
})(HpkeErrorCode || {});
|
|
5493
|
-
var HpkeError = class _HpkeError extends Error {
|
|
5494
|
-
code;
|
|
5495
|
-
cause;
|
|
5496
|
-
constructor(code, message, cause) {
|
|
5497
|
-
super(message);
|
|
5498
|
-
this.name = "HpkeError";
|
|
5499
|
-
this.code = code;
|
|
5500
|
-
this.cause = cause;
|
|
5501
|
-
if (Error.captureStackTrace) {
|
|
5502
|
-
Error.captureStackTrace(this, _HpkeError);
|
|
5503
|
-
}
|
|
5504
|
-
}
|
|
5505
|
-
/**
|
|
5506
|
-
* Create an error for invalid key length.
|
|
5507
|
-
*
|
|
5508
|
-
* @param expected - Expected key length in bytes
|
|
5509
|
-
* @param actual - Actual key length in bytes
|
|
5510
|
-
* @param keyType - Description of the key type (e.g., "REX public key")
|
|
5511
|
-
*/
|
|
5512
|
-
static invalidKeyLength(expected, actual, keyType) {
|
|
5513
|
-
return new _HpkeError(
|
|
5514
|
-
"INVALID_KEY_LENGTH" /* INVALID_KEY_LENGTH */,
|
|
5515
|
-
`Invalid ${keyType} length: expected ${expected} bytes, got ${actual}`
|
|
5516
|
-
);
|
|
5517
|
-
}
|
|
5518
|
-
/**
|
|
5519
|
-
* Create an error for ciphertext that is too short.
|
|
5520
|
-
*
|
|
5521
|
-
* @param minLength - Minimum required length
|
|
5522
|
-
* @param actual - Actual length
|
|
5523
|
-
*/
|
|
5524
|
-
static ciphertextTooShort(minLength, actual) {
|
|
5525
|
-
return new _HpkeError(
|
|
5526
|
-
"CIPHERTEXT_TOO_SHORT" /* CIPHERTEXT_TOO_SHORT */,
|
|
5527
|
-
`Ciphertext too short: minimum ${minLength} bytes required, got ${actual}`
|
|
5528
|
-
);
|
|
5529
|
-
}
|
|
5530
|
-
/**
|
|
5531
|
-
* Create an error for encryption failure.
|
|
5532
|
-
*
|
|
5533
|
-
* @param cause - The underlying error
|
|
5534
|
-
*/
|
|
5535
|
-
static encryptionFailed(cause) {
|
|
5536
|
-
return new _HpkeError(
|
|
5537
|
-
"ENCRYPTION_FAILED" /* ENCRYPTION_FAILED */,
|
|
5538
|
-
`HPKE encryption failed: ${cause.message}`,
|
|
5539
|
-
cause
|
|
5540
|
-
);
|
|
5541
|
-
}
|
|
5542
|
-
/**
|
|
5543
|
-
* Create an error for Borsh deserialization failure.
|
|
5544
|
-
*
|
|
5545
|
-
* @param cause - The underlying error
|
|
5546
|
-
*/
|
|
5547
|
-
static borshDeserializeFailed(cause) {
|
|
5548
|
-
return new _HpkeError(
|
|
5549
|
-
"BORSH_DESERIALIZE_FAILED" /* BORSH_DESERIALIZE_FAILED */,
|
|
5550
|
-
`Borsh deserialization failed: ${cause.message}`,
|
|
5551
|
-
cause
|
|
5552
|
-
);
|
|
5553
|
-
}
|
|
5554
|
-
/**
|
|
5555
|
-
* Create an error for invalid RexValue variant.
|
|
5556
|
-
*
|
|
5557
|
-
* @param variant - The invalid variant byte
|
|
5558
|
-
*/
|
|
5559
|
-
static invalidRexValue(variant) {
|
|
5560
|
-
return new _HpkeError(
|
|
5561
|
-
"INVALID_ORACLE_VALUE" /* INVALID_ORACLE_VALUE */,
|
|
5562
|
-
`Invalid RexValue variant: ${variant}`
|
|
5563
|
-
);
|
|
5564
|
-
}
|
|
5565
|
-
};
|
|
5566
|
-
|
|
5567
|
-
// src/rex/constants.ts
|
|
5568
|
-
var USER_SECRET_AAD = new TextEncoder().encode("rex-secret-v1");
|
|
5569
|
-
var SECRET_SHARING_HPKE_INFO = new TextEncoder().encode(
|
|
5570
|
-
"rialo/tee/secret-sharing-hpke/v1"
|
|
5571
|
-
);
|
|
5572
|
-
var X25519_PUBLIC_KEY_LENGTH = 32;
|
|
5573
|
-
var ED25519_PUBLIC_KEY_LENGTH = 32;
|
|
5574
|
-
var HPKE_ENC_LENGTH = 32;
|
|
5575
|
-
var CHACHA20_POLY1305_TAG_LENGTH = 16;
|
|
5576
|
-
var HPKE_OVERHEAD_LENGTH = HPKE_ENC_LENGTH + CHACHA20_POLY1305_TAG_LENGTH;
|
|
5577
|
-
|
|
5578
|
-
// src/rex/rex-value.ts
|
|
5579
|
-
var RexValueVariant = /* @__PURE__ */ ((RexValueVariant2) => {
|
|
5580
|
-
RexValueVariant2[RexValueVariant2["Plain"] = 0] = "Plain";
|
|
5581
|
-
RexValueVariant2[RexValueVariant2["Encrypted"] = 1] = "Encrypted";
|
|
5582
|
-
return RexValueVariant2;
|
|
5583
|
-
})(RexValueVariant || {});
|
|
5584
|
-
var RexValue = class _RexValue {
|
|
5585
|
-
variant;
|
|
5586
|
-
data;
|
|
5587
|
-
constructor(variant, data) {
|
|
5588
|
-
this.variant = variant;
|
|
5589
|
-
this.data = data;
|
|
5590
|
-
}
|
|
5591
|
-
/**
|
|
5592
|
-
* Create a plain (unencrypted) RexValue from raw bytes.
|
|
5593
|
-
*
|
|
5594
|
-
* @param data - The raw byte data
|
|
5595
|
-
* @returns A new RexValue with Plain variant
|
|
5596
|
-
*/
|
|
5597
|
-
static plain(data) {
|
|
5598
|
-
return new _RexValue(0 /* Plain */, data);
|
|
5599
|
-
}
|
|
5600
|
-
/**
|
|
5601
|
-
* Create a plain (unencrypted) RexValue from a UTF-8 string.
|
|
5602
|
-
*
|
|
5603
|
-
* @param s - The string to encode
|
|
5604
|
-
* @returns A new RexValue with Plain variant
|
|
5605
|
-
*/
|
|
5606
|
-
static plainString(s) {
|
|
5607
|
-
return new _RexValue(
|
|
5608
|
-
0 /* Plain */,
|
|
5609
|
-
new TextEncoder().encode(s)
|
|
5610
|
-
);
|
|
5611
|
-
}
|
|
5612
|
-
/**
|
|
5613
|
-
* Create an encrypted RexValue from HPKE ciphertext.
|
|
5614
|
-
*
|
|
5615
|
-
* @param ciphertext - The HPKE-encrypted ciphertext (enc || ct || tag)
|
|
5616
|
-
* @returns A new RexValue with Encrypted variant
|
|
5617
|
-
*/
|
|
5618
|
-
static encrypted(ciphertext) {
|
|
5619
|
-
return new _RexValue(1 /* Encrypted */, ciphertext);
|
|
5620
|
-
}
|
|
5621
|
-
/**
|
|
5622
|
-
* Check if this is a plain (unencrypted) value.
|
|
5623
|
-
*/
|
|
5624
|
-
isPlain() {
|
|
5625
|
-
return this.variant === 0 /* Plain */;
|
|
5626
|
-
}
|
|
5627
|
-
/**
|
|
5628
|
-
* Check if this is an encrypted value.
|
|
5629
|
-
*/
|
|
5630
|
-
isEncrypted() {
|
|
5631
|
-
return this.variant === 1 /* Encrypted */;
|
|
5632
|
-
}
|
|
5633
|
-
/**
|
|
5634
|
-
* Get the variant type.
|
|
5635
|
-
*/
|
|
5636
|
-
getVariant() {
|
|
5637
|
-
return this.variant;
|
|
5638
|
-
}
|
|
5639
|
-
/**
|
|
5640
|
-
* Get the raw bytes (plaintext or ciphertext).
|
|
5641
|
-
*
|
|
5642
|
-
* For Plain values, returns the plaintext.
|
|
5643
|
-
* For Encrypted values, returns the ciphertext.
|
|
5644
|
-
*/
|
|
5645
|
-
asBytes() {
|
|
5646
|
-
return this.data;
|
|
5647
|
-
}
|
|
5648
|
-
/**
|
|
5649
|
-
* Try to decode the plain value as a UTF-8 string.
|
|
5650
|
-
*
|
|
5651
|
-
* @returns The decoded string, or null if encrypted or not valid UTF-8
|
|
5652
|
-
*/
|
|
5653
|
-
asString() {
|
|
5654
|
-
if (!this.isPlain()) {
|
|
5655
|
-
return null;
|
|
5656
|
-
}
|
|
5657
|
-
try {
|
|
5658
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(this.data);
|
|
5659
|
-
} catch {
|
|
5660
|
-
return null;
|
|
5661
|
-
}
|
|
5662
|
-
}
|
|
5663
|
-
/**
|
|
5664
|
-
* Serialize to Borsh format.
|
|
5665
|
-
*
|
|
5666
|
-
* Format: `[variant: u8] [length: u32 LE] [data bytes]`
|
|
5667
|
-
*
|
|
5668
|
-
* @returns The Borsh-serialized bytes
|
|
5669
|
-
*/
|
|
5670
|
-
toBorsh() {
|
|
5671
|
-
const result = new Uint8Array(1 + 4 + this.data.length);
|
|
5672
|
-
result[0] = this.variant;
|
|
5673
|
-
const dataView = new DataView(result.buffer);
|
|
5674
|
-
dataView.setUint32(1, this.data.length, true);
|
|
5675
|
-
result.set(this.data, 5);
|
|
5676
|
-
return result;
|
|
5677
|
-
}
|
|
5678
|
-
/**
|
|
5679
|
-
* Deserialize from Borsh format.
|
|
5680
|
-
*
|
|
5681
|
-
* @param data - The Borsh-serialized bytes
|
|
5682
|
-
* @returns A new RexValue
|
|
5683
|
-
* @throws {HpkeError} If deserialization fails
|
|
5684
|
-
*/
|
|
5685
|
-
static fromBorsh(data) {
|
|
5686
|
-
if (data.length < 5) {
|
|
5687
|
-
throw HpkeError.borshDeserializeFailed(
|
|
5688
|
-
new Error(`Buffer too short: expected at least 5 bytes, got ${data.length}`)
|
|
5689
|
-
);
|
|
5690
|
-
}
|
|
5691
|
-
const variant = data[0];
|
|
5692
|
-
if (variant !== 0 /* Plain */ && variant !== 1 /* Encrypted */) {
|
|
5693
|
-
throw HpkeError.invalidRexValue(variant);
|
|
5694
|
-
}
|
|
5695
|
-
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
5696
|
-
const length = dataView.getUint32(1, true);
|
|
5697
|
-
if (data.length < 5 + length) {
|
|
5698
|
-
throw HpkeError.borshDeserializeFailed(
|
|
5699
|
-
new Error(`Buffer too short: expected ${5 + length} bytes, got ${data.length}`)
|
|
5700
|
-
);
|
|
5701
|
-
}
|
|
5702
|
-
const payload = data.slice(5, 5 + length);
|
|
5703
|
-
return new _RexValue(variant, payload);
|
|
5704
|
-
}
|
|
5705
|
-
};
|
|
5706
|
-
var hpkeSuite = new CipherSuite({
|
|
5707
|
-
kem: new DhkemX25519HkdfSha256(),
|
|
5708
|
-
kdf: new HkdfSha256(),
|
|
5709
|
-
aead: new Chacha20Poly1305()
|
|
5710
|
-
});
|
|
5711
|
-
function buildAad(senderPubkey) {
|
|
5712
|
-
const aad = new Uint8Array(USER_SECRET_AAD.length + senderPubkey.length);
|
|
5713
|
-
aad.set(USER_SECRET_AAD, 0);
|
|
5714
|
-
aad.set(senderPubkey, USER_SECRET_AAD.length);
|
|
5715
|
-
return aad;
|
|
5716
|
-
}
|
|
5717
|
-
async function hpkeEncrypt(rexPubkey, data, senderPubkey) {
|
|
5718
|
-
if (rexPubkey.length !== X25519_PUBLIC_KEY_LENGTH) {
|
|
5719
|
-
throw HpkeError.invalidKeyLength(
|
|
5720
|
-
X25519_PUBLIC_KEY_LENGTH,
|
|
5721
|
-
rexPubkey.length,
|
|
5722
|
-
"REX public key"
|
|
5723
|
-
);
|
|
5724
|
-
}
|
|
5725
|
-
if (senderPubkey.length !== ED25519_PUBLIC_KEY_LENGTH) {
|
|
5726
|
-
throw HpkeError.invalidKeyLength(
|
|
5727
|
-
ED25519_PUBLIC_KEY_LENGTH,
|
|
5728
|
-
senderPubkey.length,
|
|
5729
|
-
"sender public key"
|
|
5730
|
-
);
|
|
5731
|
-
}
|
|
5732
|
-
try {
|
|
5733
|
-
const recipientKey = await hpkeSuite.kem.importKey(
|
|
5734
|
-
"raw",
|
|
5735
|
-
rexPubkey.buffer.slice(
|
|
5736
|
-
rexPubkey.byteOffset,
|
|
5737
|
-
rexPubkey.byteOffset + rexPubkey.byteLength
|
|
5738
|
-
)
|
|
5739
|
-
);
|
|
5740
|
-
const sender = await hpkeSuite.createSenderContext({
|
|
5741
|
-
recipientPublicKey: recipientKey,
|
|
5742
|
-
info: SECRET_SHARING_HPKE_INFO.buffer.slice(
|
|
5743
|
-
SECRET_SHARING_HPKE_INFO.byteOffset,
|
|
5744
|
-
SECRET_SHARING_HPKE_INFO.byteOffset + SECRET_SHARING_HPKE_INFO.byteLength
|
|
5745
|
-
)
|
|
5746
|
-
});
|
|
5747
|
-
const aad = buildAad(senderPubkey);
|
|
5748
|
-
const ciphertext = await sender.seal(
|
|
5749
|
-
data.buffer.slice(
|
|
5750
|
-
data.byteOffset,
|
|
5751
|
-
data.byteOffset + data.byteLength
|
|
5752
|
-
),
|
|
5753
|
-
aad.buffer.slice(
|
|
5754
|
-
aad.byteOffset,
|
|
5755
|
-
aad.byteOffset + aad.byteLength
|
|
5756
|
-
)
|
|
5757
|
-
);
|
|
5758
|
-
const enc = new Uint8Array(sender.enc);
|
|
5759
|
-
const result = new Uint8Array(enc.length + ciphertext.byteLength);
|
|
5760
|
-
result.set(enc, 0);
|
|
5761
|
-
result.set(new Uint8Array(ciphertext), enc.length);
|
|
5762
|
-
return result;
|
|
5763
|
-
} catch (error) {
|
|
5764
|
-
throw HpkeError.encryptionFailed(
|
|
5765
|
-
error instanceof Error ? error : new Error(String(error))
|
|
5766
|
-
);
|
|
5767
|
-
}
|
|
5768
|
-
}
|
|
5769
|
-
async function encryptForRex(rexPubkey, data, senderPubkey) {
|
|
5770
|
-
const ciphertext = await hpkeEncrypt(rexPubkey, data, senderPubkey);
|
|
5771
|
-
return RexValue.encrypted(ciphertext);
|
|
5772
|
-
}
|
|
5773
|
-
function getCiphertextLength(plaintextLength) {
|
|
5774
|
-
return HPKE_OVERHEAD_LENGTH + plaintextLength;
|
|
5775
|
-
}
|
|
5776
|
-
function isValidCiphertextLength(ciphertext) {
|
|
5777
|
-
return ciphertext.length >= HPKE_OVERHEAD_LENGTH;
|
|
5778
|
-
}
|
|
5779
|
-
|
|
5780
5481
|
// src/rpc/errors.ts
|
|
5781
5482
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
5782
5483
|
RpcErrorCode2["REQUEST_TIMEOUT"] = "REQUEST_TIMEOUT";
|
|
@@ -6464,64 +6165,6 @@ var QueryRpcClient = class extends BaseRpcClient {
|
|
|
6464
6165
|
blockNumber: BigInt(tx.block_number)
|
|
6465
6166
|
}));
|
|
6466
6167
|
}
|
|
6467
|
-
/**
|
|
6468
|
-
* Retrieve the REX X25519 public key for secret sharing encryption.
|
|
6469
|
-
*
|
|
6470
|
-
* This key is used for HPKE encryption when sending encrypted data
|
|
6471
|
-
* that should only be decryptable within the REX execution environment.
|
|
6472
|
-
*
|
|
6473
|
-
* @returns The REX X25519 public key as a 32-byte Uint8Array
|
|
6474
|
-
*
|
|
6475
|
-
* @example
|
|
6476
|
-
* ```typescript
|
|
6477
|
-
* import { encryptForRex } from "@rialo/ts-cdk";
|
|
6478
|
-
*
|
|
6479
|
-
* // Get the REX public key
|
|
6480
|
-
* const rexPubkey = await client.getSecretSharingPubkey();
|
|
6481
|
-
*
|
|
6482
|
-
* // Use it for HPKE encryption
|
|
6483
|
-
* const encrypted = await encryptForRex(
|
|
6484
|
-
* rexPubkey,
|
|
6485
|
-
* new TextEncoder().encode("secret data"),
|
|
6486
|
-
* keypair.publicKey.toBytes()
|
|
6487
|
-
* );
|
|
6488
|
-
* ```
|
|
6489
|
-
*/
|
|
6490
|
-
async getSecretSharingPubkey() {
|
|
6491
|
-
const result = await this.call(
|
|
6492
|
-
"getSecretSharingPubkey",
|
|
6493
|
-
[]
|
|
6494
|
-
);
|
|
6495
|
-
const hexString = result.public_key;
|
|
6496
|
-
const bytes = new Uint8Array(hexString.length / 2);
|
|
6497
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
6498
|
-
bytes[i] = Number.parseInt(hexString.slice(i * 2, i * 2 + 2), 16);
|
|
6499
|
-
}
|
|
6500
|
-
return bytes;
|
|
6501
|
-
}
|
|
6502
|
-
/**
|
|
6503
|
-
* Get the config hash prefix for replay protection.
|
|
6504
|
-
*
|
|
6505
|
-
* Returns the first 64 bits of the config hash, which is used
|
|
6506
|
-
* for transaction replay protection across chains.
|
|
6507
|
-
*
|
|
6508
|
-
* @returns The config hash prefix as a bigint
|
|
6509
|
-
*
|
|
6510
|
-
* @example
|
|
6511
|
-
* ```typescript
|
|
6512
|
-
* const configHashPrefix = await client.getConfigHashPrefix();
|
|
6513
|
-
* const tx = TransactionBuilder.create()
|
|
6514
|
-
* .setPayer(payer)
|
|
6515
|
-
* .setValidFrom(validFrom)
|
|
6516
|
-
* .setConfigHashPrefix(configHashPrefix)
|
|
6517
|
-
* .addInstruction(instruction)
|
|
6518
|
-
* .build();
|
|
6519
|
-
* ```
|
|
6520
|
-
*/
|
|
6521
|
-
async getConfigHashPrefix() {
|
|
6522
|
-
const result = await this.call("getRecentValidatorConfigHash", [{}]);
|
|
6523
|
-
return BigInt(result.config_hash_prefix);
|
|
6524
|
-
}
|
|
6525
6168
|
};
|
|
6526
6169
|
|
|
6527
6170
|
// src/rpc/clients/transaction-client.ts
|
|
@@ -9333,17 +8976,14 @@ var Message = class _Message {
|
|
|
9333
8976
|
accountKeys;
|
|
9334
8977
|
/** Transaction valid from (milliseconds since Unix epoch) */
|
|
9335
8978
|
validFrom;
|
|
9336
|
-
/** Config hash prefix for replay protection across chains */
|
|
9337
|
-
configHashPrefix;
|
|
9338
8979
|
/** Compiled instructions with account indices */
|
|
9339
8980
|
instructions;
|
|
9340
8981
|
/** Cached serialized bytes */
|
|
9341
8982
|
serializedCache;
|
|
9342
|
-
constructor(header, accountKeys, validFrom,
|
|
8983
|
+
constructor(header, accountKeys, validFrom, instructions) {
|
|
9343
8984
|
this.header = Object.freeze({ ...header });
|
|
9344
8985
|
this.accountKeys = Object.freeze([...accountKeys]);
|
|
9345
8986
|
this.validFrom = validFrom;
|
|
9346
|
-
this.configHashPrefix = configHashPrefix;
|
|
9347
8987
|
this.instructions = Object.freeze(
|
|
9348
8988
|
instructions.map((ix) => Object.freeze({ ...ix }))
|
|
9349
8989
|
);
|
|
@@ -9403,18 +9043,6 @@ var Message = class _Message {
|
|
|
9403
9043
|
new DataView(validFromBytes.buffer).getBigUint64(0, true)
|
|
9404
9044
|
);
|
|
9405
9045
|
cursor += 8;
|
|
9406
|
-
if (data.length < cursor + 8) {
|
|
9407
|
-
throw new TransactionError(
|
|
9408
|
-
"INSUFFICIENT_DATA" /* INSUFFICIENT_DATA */,
|
|
9409
|
-
"Insufficient data for configHashPrefix"
|
|
9410
|
-
);
|
|
9411
|
-
}
|
|
9412
|
-
const configHashPrefixBytes = data.slice(cursor, cursor + 8);
|
|
9413
|
-
const configHashPrefix = BigInt.asUintN(
|
|
9414
|
-
64,
|
|
9415
|
-
new DataView(configHashPrefixBytes.buffer).getBigUint64(0, true)
|
|
9416
|
-
);
|
|
9417
|
-
cursor += 8;
|
|
9418
9046
|
const [instructionsLength, newCursor2] = deserializeCompactU16(
|
|
9419
9047
|
data,
|
|
9420
9048
|
cursor
|
|
@@ -9460,7 +9088,7 @@ var Message = class _Message {
|
|
|
9460
9088
|
data: instructionData
|
|
9461
9089
|
});
|
|
9462
9090
|
}
|
|
9463
|
-
return new _Message(header, accountKeys, validFrom,
|
|
9091
|
+
return new _Message(header, accountKeys, validFrom, instructions);
|
|
9464
9092
|
}
|
|
9465
9093
|
serializeInternal() {
|
|
9466
9094
|
const buffer = [];
|
|
@@ -9477,13 +9105,6 @@ var Message = class _Message {
|
|
|
9477
9105
|
true
|
|
9478
9106
|
);
|
|
9479
9107
|
buffer.push(...new Uint8Array(validFromBuffer));
|
|
9480
|
-
const configHashPrefixBuffer = new ArrayBuffer(8);
|
|
9481
|
-
new DataView(configHashPrefixBuffer).setBigUint64(
|
|
9482
|
-
0,
|
|
9483
|
-
this.configHashPrefix,
|
|
9484
|
-
true
|
|
9485
|
-
);
|
|
9486
|
-
buffer.push(...new Uint8Array(configHashPrefixBuffer));
|
|
9487
9108
|
this.serializeCompactArray(buffer, this.instructions, (buf, ix) => {
|
|
9488
9109
|
buf.push(ix.programIdIndex);
|
|
9489
9110
|
this.serializeCompactArray(buf, ix.accountKeyIndexes, (b, idx) => {
|
|
@@ -9868,7 +9489,6 @@ var Transaction = class _Transaction {
|
|
|
9868
9489
|
var TransactionBuilder = class _TransactionBuilder {
|
|
9869
9490
|
payer;
|
|
9870
9491
|
validFrom;
|
|
9871
|
-
configHashPrefix;
|
|
9872
9492
|
instructions = [];
|
|
9873
9493
|
constructor() {
|
|
9874
9494
|
}
|
|
@@ -9902,18 +9522,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9902
9522
|
this.validFrom = validFrom;
|
|
9903
9523
|
return this;
|
|
9904
9524
|
}
|
|
9905
|
-
/**
|
|
9906
|
-
* Set the config hash prefix for replay protection.
|
|
9907
|
-
*
|
|
9908
|
-
* This is the first 64 bits of the config hash, used to ensure
|
|
9909
|
-
* transactions cannot be replayed on different chains.
|
|
9910
|
-
*
|
|
9911
|
-
* @param configHashPrefix - config hash prefix as a u64
|
|
9912
|
-
*/
|
|
9913
|
-
setConfigHashPrefix(configHashPrefix) {
|
|
9914
|
-
this.configHashPrefix = configHashPrefix;
|
|
9915
|
-
return this;
|
|
9916
|
-
}
|
|
9917
9525
|
/**
|
|
9918
9526
|
* Add an instruction to the transaction.
|
|
9919
9527
|
*
|
|
@@ -9959,12 +9567,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9959
9567
|
"Transaction must have a valid from. Use setValidFrom() to set the valid from."
|
|
9960
9568
|
);
|
|
9961
9569
|
}
|
|
9962
|
-
if (this.configHashPrefix === void 0) {
|
|
9963
|
-
throw new TransactionError(
|
|
9964
|
-
"INVALID_MESSAGE_FORMAT" /* INVALID_MESSAGE_FORMAT */,
|
|
9965
|
-
"Transaction must have a config hash prefix. Use setConfigHashPrefix() to set the config hash prefix."
|
|
9966
|
-
);
|
|
9967
|
-
}
|
|
9968
9570
|
if (this.instructions.length === 0) {
|
|
9969
9571
|
throw TransactionError.noInstructions();
|
|
9970
9572
|
}
|
|
@@ -10013,7 +9615,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
10013
9615
|
header,
|
|
10014
9616
|
accountKeys,
|
|
10015
9617
|
this.validFrom,
|
|
10016
|
-
this.configHashPrefix,
|
|
10017
9618
|
compiledInstructions
|
|
10018
9619
|
);
|
|
10019
9620
|
return Transaction.fromMessage(message);
|
|
@@ -10117,6 +9718,6 @@ var KeypairSigner = class {
|
|
|
10117
9718
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
10118
9719
|
*/
|
|
10119
9720
|
|
|
10120
|
-
export { AccountMetaTable, BASE_DERIVATION_PATH, BaseRpcClient, BincodeReader, BincodeWriter,
|
|
9721
|
+
export { AccountMetaTable, BASE_DERIVATION_PATH, BaseRpcClient, BincodeReader, BincodeWriter, CryptoError, CryptoErrorCode, DEFAULT_NUM_ACCOUNTS, HttpTransport, KELVIN_PER_RLO, Keypair, KeypairSigner, Message, Mnemonic, PUBLIC_KEY_LENGTH, PublicKey, QueryRpcClient, RIALO_DEVNET_CHAIN, RIALO_LOCALNET_CHAIN, RIALO_MAINNET_CHAIN, RIALO_SHITNET_CHAIN, RIALO_TESTNET_CHAIN, RialoClient, RialoError, RialoErrorType, RpcError, RpcErrorCode, SECRET_KEY_LENGTH, SIGNATURE_LENGTH, SYSTEM_PROGRAM_ID, Schema, Signature, SystemInstruction, Transaction, TransactionBuilder, TransactionError, TransactionErrorCode, TransactionRpcClient, URL_DEVNET, URL_LOCALNET, URL_MAINNET, URL_SHITNET, URL_TESTNET, allocateInstruction, assignInstruction, calculateBackoff, concatBytes2 as concatBytes, createAccount, createBorshInstruction, createRialoClient, deserialize, deserializeBorsh, deserializeCompactU162 as deserializeCompactU16, deserializeStrict, encodeBorshData, field, fixedArray, fromBase64, getDefaultRialoClientConfig, getDevnetUrl, getLocalnetUrl, getMainnetUrl, getTestnetUrl, isOnCurve, option, seedToBytes, serialize, serializeBorsh, serializeCompactU16, sleep, toBase64, transferInstruction, vec, writeCompactU16 };
|
|
10121
9722
|
//# sourceMappingURL=index.mjs.map
|
|
10122
9723
|
//# sourceMappingURL=index.mjs.map
|