@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.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chacha20poly1305 = require('@hpke/chacha20poly1305');
|
|
4
|
-
var core = require('@hpke/core');
|
|
5
|
-
|
|
6
3
|
var __create = Object.create;
|
|
7
4
|
var __defProp = Object.defineProperty;
|
|
8
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -5483,302 +5480,6 @@ var RialoError = class _RialoError extends Error {
|
|
|
5483
5480
|
}
|
|
5484
5481
|
};
|
|
5485
5482
|
|
|
5486
|
-
// src/rex/errors.ts
|
|
5487
|
-
var HpkeErrorCode = /* @__PURE__ */ ((HpkeErrorCode2) => {
|
|
5488
|
-
HpkeErrorCode2["INVALID_KEY_LENGTH"] = "INVALID_KEY_LENGTH";
|
|
5489
|
-
HpkeErrorCode2["CIPHERTEXT_TOO_SHORT"] = "CIPHERTEXT_TOO_SHORT";
|
|
5490
|
-
HpkeErrorCode2["ENCRYPTION_FAILED"] = "ENCRYPTION_FAILED";
|
|
5491
|
-
HpkeErrorCode2["BORSH_DESERIALIZE_FAILED"] = "BORSH_DESERIALIZE_FAILED";
|
|
5492
|
-
HpkeErrorCode2["INVALID_ORACLE_VALUE"] = "INVALID_ORACLE_VALUE";
|
|
5493
|
-
return HpkeErrorCode2;
|
|
5494
|
-
})(HpkeErrorCode || {});
|
|
5495
|
-
var HpkeError = class _HpkeError extends Error {
|
|
5496
|
-
code;
|
|
5497
|
-
cause;
|
|
5498
|
-
constructor(code, message, cause) {
|
|
5499
|
-
super(message);
|
|
5500
|
-
this.name = "HpkeError";
|
|
5501
|
-
this.code = code;
|
|
5502
|
-
this.cause = cause;
|
|
5503
|
-
if (Error.captureStackTrace) {
|
|
5504
|
-
Error.captureStackTrace(this, _HpkeError);
|
|
5505
|
-
}
|
|
5506
|
-
}
|
|
5507
|
-
/**
|
|
5508
|
-
* Create an error for invalid key length.
|
|
5509
|
-
*
|
|
5510
|
-
* @param expected - Expected key length in bytes
|
|
5511
|
-
* @param actual - Actual key length in bytes
|
|
5512
|
-
* @param keyType - Description of the key type (e.g., "REX public key")
|
|
5513
|
-
*/
|
|
5514
|
-
static invalidKeyLength(expected, actual, keyType) {
|
|
5515
|
-
return new _HpkeError(
|
|
5516
|
-
"INVALID_KEY_LENGTH" /* INVALID_KEY_LENGTH */,
|
|
5517
|
-
`Invalid ${keyType} length: expected ${expected} bytes, got ${actual}`
|
|
5518
|
-
);
|
|
5519
|
-
}
|
|
5520
|
-
/**
|
|
5521
|
-
* Create an error for ciphertext that is too short.
|
|
5522
|
-
*
|
|
5523
|
-
* @param minLength - Minimum required length
|
|
5524
|
-
* @param actual - Actual length
|
|
5525
|
-
*/
|
|
5526
|
-
static ciphertextTooShort(minLength, actual) {
|
|
5527
|
-
return new _HpkeError(
|
|
5528
|
-
"CIPHERTEXT_TOO_SHORT" /* CIPHERTEXT_TOO_SHORT */,
|
|
5529
|
-
`Ciphertext too short: minimum ${minLength} bytes required, got ${actual}`
|
|
5530
|
-
);
|
|
5531
|
-
}
|
|
5532
|
-
/**
|
|
5533
|
-
* Create an error for encryption failure.
|
|
5534
|
-
*
|
|
5535
|
-
* @param cause - The underlying error
|
|
5536
|
-
*/
|
|
5537
|
-
static encryptionFailed(cause) {
|
|
5538
|
-
return new _HpkeError(
|
|
5539
|
-
"ENCRYPTION_FAILED" /* ENCRYPTION_FAILED */,
|
|
5540
|
-
`HPKE encryption failed: ${cause.message}`,
|
|
5541
|
-
cause
|
|
5542
|
-
);
|
|
5543
|
-
}
|
|
5544
|
-
/**
|
|
5545
|
-
* Create an error for Borsh deserialization failure.
|
|
5546
|
-
*
|
|
5547
|
-
* @param cause - The underlying error
|
|
5548
|
-
*/
|
|
5549
|
-
static borshDeserializeFailed(cause) {
|
|
5550
|
-
return new _HpkeError(
|
|
5551
|
-
"BORSH_DESERIALIZE_FAILED" /* BORSH_DESERIALIZE_FAILED */,
|
|
5552
|
-
`Borsh deserialization failed: ${cause.message}`,
|
|
5553
|
-
cause
|
|
5554
|
-
);
|
|
5555
|
-
}
|
|
5556
|
-
/**
|
|
5557
|
-
* Create an error for invalid RexValue variant.
|
|
5558
|
-
*
|
|
5559
|
-
* @param variant - The invalid variant byte
|
|
5560
|
-
*/
|
|
5561
|
-
static invalidRexValue(variant) {
|
|
5562
|
-
return new _HpkeError(
|
|
5563
|
-
"INVALID_ORACLE_VALUE" /* INVALID_ORACLE_VALUE */,
|
|
5564
|
-
`Invalid RexValue variant: ${variant}`
|
|
5565
|
-
);
|
|
5566
|
-
}
|
|
5567
|
-
};
|
|
5568
|
-
|
|
5569
|
-
// src/rex/constants.ts
|
|
5570
|
-
var USER_SECRET_AAD = new TextEncoder().encode("rex-secret-v1");
|
|
5571
|
-
var SECRET_SHARING_HPKE_INFO = new TextEncoder().encode(
|
|
5572
|
-
"rialo/tee/secret-sharing-hpke/v1"
|
|
5573
|
-
);
|
|
5574
|
-
var X25519_PUBLIC_KEY_LENGTH = 32;
|
|
5575
|
-
var ED25519_PUBLIC_KEY_LENGTH = 32;
|
|
5576
|
-
var HPKE_ENC_LENGTH = 32;
|
|
5577
|
-
var CHACHA20_POLY1305_TAG_LENGTH = 16;
|
|
5578
|
-
var HPKE_OVERHEAD_LENGTH = HPKE_ENC_LENGTH + CHACHA20_POLY1305_TAG_LENGTH;
|
|
5579
|
-
|
|
5580
|
-
// src/rex/rex-value.ts
|
|
5581
|
-
var RexValueVariant = /* @__PURE__ */ ((RexValueVariant2) => {
|
|
5582
|
-
RexValueVariant2[RexValueVariant2["Plain"] = 0] = "Plain";
|
|
5583
|
-
RexValueVariant2[RexValueVariant2["Encrypted"] = 1] = "Encrypted";
|
|
5584
|
-
return RexValueVariant2;
|
|
5585
|
-
})(RexValueVariant || {});
|
|
5586
|
-
var RexValue = class _RexValue {
|
|
5587
|
-
variant;
|
|
5588
|
-
data;
|
|
5589
|
-
constructor(variant, data) {
|
|
5590
|
-
this.variant = variant;
|
|
5591
|
-
this.data = data;
|
|
5592
|
-
}
|
|
5593
|
-
/**
|
|
5594
|
-
* Create a plain (unencrypted) RexValue from raw bytes.
|
|
5595
|
-
*
|
|
5596
|
-
* @param data - The raw byte data
|
|
5597
|
-
* @returns A new RexValue with Plain variant
|
|
5598
|
-
*/
|
|
5599
|
-
static plain(data) {
|
|
5600
|
-
return new _RexValue(0 /* Plain */, data);
|
|
5601
|
-
}
|
|
5602
|
-
/**
|
|
5603
|
-
* Create a plain (unencrypted) RexValue from a UTF-8 string.
|
|
5604
|
-
*
|
|
5605
|
-
* @param s - The string to encode
|
|
5606
|
-
* @returns A new RexValue with Plain variant
|
|
5607
|
-
*/
|
|
5608
|
-
static plainString(s) {
|
|
5609
|
-
return new _RexValue(
|
|
5610
|
-
0 /* Plain */,
|
|
5611
|
-
new TextEncoder().encode(s)
|
|
5612
|
-
);
|
|
5613
|
-
}
|
|
5614
|
-
/**
|
|
5615
|
-
* Create an encrypted RexValue from HPKE ciphertext.
|
|
5616
|
-
*
|
|
5617
|
-
* @param ciphertext - The HPKE-encrypted ciphertext (enc || ct || tag)
|
|
5618
|
-
* @returns A new RexValue with Encrypted variant
|
|
5619
|
-
*/
|
|
5620
|
-
static encrypted(ciphertext) {
|
|
5621
|
-
return new _RexValue(1 /* Encrypted */, ciphertext);
|
|
5622
|
-
}
|
|
5623
|
-
/**
|
|
5624
|
-
* Check if this is a plain (unencrypted) value.
|
|
5625
|
-
*/
|
|
5626
|
-
isPlain() {
|
|
5627
|
-
return this.variant === 0 /* Plain */;
|
|
5628
|
-
}
|
|
5629
|
-
/**
|
|
5630
|
-
* Check if this is an encrypted value.
|
|
5631
|
-
*/
|
|
5632
|
-
isEncrypted() {
|
|
5633
|
-
return this.variant === 1 /* Encrypted */;
|
|
5634
|
-
}
|
|
5635
|
-
/**
|
|
5636
|
-
* Get the variant type.
|
|
5637
|
-
*/
|
|
5638
|
-
getVariant() {
|
|
5639
|
-
return this.variant;
|
|
5640
|
-
}
|
|
5641
|
-
/**
|
|
5642
|
-
* Get the raw bytes (plaintext or ciphertext).
|
|
5643
|
-
*
|
|
5644
|
-
* For Plain values, returns the plaintext.
|
|
5645
|
-
* For Encrypted values, returns the ciphertext.
|
|
5646
|
-
*/
|
|
5647
|
-
asBytes() {
|
|
5648
|
-
return this.data;
|
|
5649
|
-
}
|
|
5650
|
-
/**
|
|
5651
|
-
* Try to decode the plain value as a UTF-8 string.
|
|
5652
|
-
*
|
|
5653
|
-
* @returns The decoded string, or null if encrypted or not valid UTF-8
|
|
5654
|
-
*/
|
|
5655
|
-
asString() {
|
|
5656
|
-
if (!this.isPlain()) {
|
|
5657
|
-
return null;
|
|
5658
|
-
}
|
|
5659
|
-
try {
|
|
5660
|
-
return new TextDecoder("utf-8", { fatal: true }).decode(this.data);
|
|
5661
|
-
} catch {
|
|
5662
|
-
return null;
|
|
5663
|
-
}
|
|
5664
|
-
}
|
|
5665
|
-
/**
|
|
5666
|
-
* Serialize to Borsh format.
|
|
5667
|
-
*
|
|
5668
|
-
* Format: `[variant: u8] [length: u32 LE] [data bytes]`
|
|
5669
|
-
*
|
|
5670
|
-
* @returns The Borsh-serialized bytes
|
|
5671
|
-
*/
|
|
5672
|
-
toBorsh() {
|
|
5673
|
-
const result = new Uint8Array(1 + 4 + this.data.length);
|
|
5674
|
-
result[0] = this.variant;
|
|
5675
|
-
const dataView = new DataView(result.buffer);
|
|
5676
|
-
dataView.setUint32(1, this.data.length, true);
|
|
5677
|
-
result.set(this.data, 5);
|
|
5678
|
-
return result;
|
|
5679
|
-
}
|
|
5680
|
-
/**
|
|
5681
|
-
* Deserialize from Borsh format.
|
|
5682
|
-
*
|
|
5683
|
-
* @param data - The Borsh-serialized bytes
|
|
5684
|
-
* @returns A new RexValue
|
|
5685
|
-
* @throws {HpkeError} If deserialization fails
|
|
5686
|
-
*/
|
|
5687
|
-
static fromBorsh(data) {
|
|
5688
|
-
if (data.length < 5) {
|
|
5689
|
-
throw HpkeError.borshDeserializeFailed(
|
|
5690
|
-
new Error(`Buffer too short: expected at least 5 bytes, got ${data.length}`)
|
|
5691
|
-
);
|
|
5692
|
-
}
|
|
5693
|
-
const variant = data[0];
|
|
5694
|
-
if (variant !== 0 /* Plain */ && variant !== 1 /* Encrypted */) {
|
|
5695
|
-
throw HpkeError.invalidRexValue(variant);
|
|
5696
|
-
}
|
|
5697
|
-
const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
5698
|
-
const length = dataView.getUint32(1, true);
|
|
5699
|
-
if (data.length < 5 + length) {
|
|
5700
|
-
throw HpkeError.borshDeserializeFailed(
|
|
5701
|
-
new Error(`Buffer too short: expected ${5 + length} bytes, got ${data.length}`)
|
|
5702
|
-
);
|
|
5703
|
-
}
|
|
5704
|
-
const payload = data.slice(5, 5 + length);
|
|
5705
|
-
return new _RexValue(variant, payload);
|
|
5706
|
-
}
|
|
5707
|
-
};
|
|
5708
|
-
var hpkeSuite = new core.CipherSuite({
|
|
5709
|
-
kem: new core.DhkemX25519HkdfSha256(),
|
|
5710
|
-
kdf: new core.HkdfSha256(),
|
|
5711
|
-
aead: new chacha20poly1305.Chacha20Poly1305()
|
|
5712
|
-
});
|
|
5713
|
-
function buildAad(senderPubkey) {
|
|
5714
|
-
const aad = new Uint8Array(USER_SECRET_AAD.length + senderPubkey.length);
|
|
5715
|
-
aad.set(USER_SECRET_AAD, 0);
|
|
5716
|
-
aad.set(senderPubkey, USER_SECRET_AAD.length);
|
|
5717
|
-
return aad;
|
|
5718
|
-
}
|
|
5719
|
-
async function hpkeEncrypt(rexPubkey, data, senderPubkey) {
|
|
5720
|
-
if (rexPubkey.length !== X25519_PUBLIC_KEY_LENGTH) {
|
|
5721
|
-
throw HpkeError.invalidKeyLength(
|
|
5722
|
-
X25519_PUBLIC_KEY_LENGTH,
|
|
5723
|
-
rexPubkey.length,
|
|
5724
|
-
"REX public key"
|
|
5725
|
-
);
|
|
5726
|
-
}
|
|
5727
|
-
if (senderPubkey.length !== ED25519_PUBLIC_KEY_LENGTH) {
|
|
5728
|
-
throw HpkeError.invalidKeyLength(
|
|
5729
|
-
ED25519_PUBLIC_KEY_LENGTH,
|
|
5730
|
-
senderPubkey.length,
|
|
5731
|
-
"sender public key"
|
|
5732
|
-
);
|
|
5733
|
-
}
|
|
5734
|
-
try {
|
|
5735
|
-
const recipientKey = await hpkeSuite.kem.importKey(
|
|
5736
|
-
"raw",
|
|
5737
|
-
rexPubkey.buffer.slice(
|
|
5738
|
-
rexPubkey.byteOffset,
|
|
5739
|
-
rexPubkey.byteOffset + rexPubkey.byteLength
|
|
5740
|
-
)
|
|
5741
|
-
);
|
|
5742
|
-
const sender = await hpkeSuite.createSenderContext({
|
|
5743
|
-
recipientPublicKey: recipientKey,
|
|
5744
|
-
info: SECRET_SHARING_HPKE_INFO.buffer.slice(
|
|
5745
|
-
SECRET_SHARING_HPKE_INFO.byteOffset,
|
|
5746
|
-
SECRET_SHARING_HPKE_INFO.byteOffset + SECRET_SHARING_HPKE_INFO.byteLength
|
|
5747
|
-
)
|
|
5748
|
-
});
|
|
5749
|
-
const aad = buildAad(senderPubkey);
|
|
5750
|
-
const ciphertext = await sender.seal(
|
|
5751
|
-
data.buffer.slice(
|
|
5752
|
-
data.byteOffset,
|
|
5753
|
-
data.byteOffset + data.byteLength
|
|
5754
|
-
),
|
|
5755
|
-
aad.buffer.slice(
|
|
5756
|
-
aad.byteOffset,
|
|
5757
|
-
aad.byteOffset + aad.byteLength
|
|
5758
|
-
)
|
|
5759
|
-
);
|
|
5760
|
-
const enc = new Uint8Array(sender.enc);
|
|
5761
|
-
const result = new Uint8Array(enc.length + ciphertext.byteLength);
|
|
5762
|
-
result.set(enc, 0);
|
|
5763
|
-
result.set(new Uint8Array(ciphertext), enc.length);
|
|
5764
|
-
return result;
|
|
5765
|
-
} catch (error) {
|
|
5766
|
-
throw HpkeError.encryptionFailed(
|
|
5767
|
-
error instanceof Error ? error : new Error(String(error))
|
|
5768
|
-
);
|
|
5769
|
-
}
|
|
5770
|
-
}
|
|
5771
|
-
async function encryptForRex(rexPubkey, data, senderPubkey) {
|
|
5772
|
-
const ciphertext = await hpkeEncrypt(rexPubkey, data, senderPubkey);
|
|
5773
|
-
return RexValue.encrypted(ciphertext);
|
|
5774
|
-
}
|
|
5775
|
-
function getCiphertextLength(plaintextLength) {
|
|
5776
|
-
return HPKE_OVERHEAD_LENGTH + plaintextLength;
|
|
5777
|
-
}
|
|
5778
|
-
function isValidCiphertextLength(ciphertext) {
|
|
5779
|
-
return ciphertext.length >= HPKE_OVERHEAD_LENGTH;
|
|
5780
|
-
}
|
|
5781
|
-
|
|
5782
5483
|
// src/rpc/errors.ts
|
|
5783
5484
|
var RpcErrorCode = /* @__PURE__ */ ((RpcErrorCode2) => {
|
|
5784
5485
|
RpcErrorCode2["REQUEST_TIMEOUT"] = "REQUEST_TIMEOUT";
|
|
@@ -6466,64 +6167,6 @@ var QueryRpcClient = class extends BaseRpcClient {
|
|
|
6466
6167
|
blockNumber: BigInt(tx.block_number)
|
|
6467
6168
|
}));
|
|
6468
6169
|
}
|
|
6469
|
-
/**
|
|
6470
|
-
* Retrieve the REX X25519 public key for secret sharing encryption.
|
|
6471
|
-
*
|
|
6472
|
-
* This key is used for HPKE encryption when sending encrypted data
|
|
6473
|
-
* that should only be decryptable within the REX execution environment.
|
|
6474
|
-
*
|
|
6475
|
-
* @returns The REX X25519 public key as a 32-byte Uint8Array
|
|
6476
|
-
*
|
|
6477
|
-
* @example
|
|
6478
|
-
* ```typescript
|
|
6479
|
-
* import { encryptForRex } from "@rialo/ts-cdk";
|
|
6480
|
-
*
|
|
6481
|
-
* // Get the REX public key
|
|
6482
|
-
* const rexPubkey = await client.getSecretSharingPubkey();
|
|
6483
|
-
*
|
|
6484
|
-
* // Use it for HPKE encryption
|
|
6485
|
-
* const encrypted = await encryptForRex(
|
|
6486
|
-
* rexPubkey,
|
|
6487
|
-
* new TextEncoder().encode("secret data"),
|
|
6488
|
-
* keypair.publicKey.toBytes()
|
|
6489
|
-
* );
|
|
6490
|
-
* ```
|
|
6491
|
-
*/
|
|
6492
|
-
async getSecretSharingPubkey() {
|
|
6493
|
-
const result = await this.call(
|
|
6494
|
-
"getSecretSharingPubkey",
|
|
6495
|
-
[]
|
|
6496
|
-
);
|
|
6497
|
-
const hexString = result.public_key;
|
|
6498
|
-
const bytes = new Uint8Array(hexString.length / 2);
|
|
6499
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
6500
|
-
bytes[i] = Number.parseInt(hexString.slice(i * 2, i * 2 + 2), 16);
|
|
6501
|
-
}
|
|
6502
|
-
return bytes;
|
|
6503
|
-
}
|
|
6504
|
-
/**
|
|
6505
|
-
* Get the config hash prefix for replay protection.
|
|
6506
|
-
*
|
|
6507
|
-
* Returns the first 64 bits of the config hash, which is used
|
|
6508
|
-
* for transaction replay protection across chains.
|
|
6509
|
-
*
|
|
6510
|
-
* @returns The config hash prefix as a bigint
|
|
6511
|
-
*
|
|
6512
|
-
* @example
|
|
6513
|
-
* ```typescript
|
|
6514
|
-
* const configHashPrefix = await client.getConfigHashPrefix();
|
|
6515
|
-
* const tx = TransactionBuilder.create()
|
|
6516
|
-
* .setPayer(payer)
|
|
6517
|
-
* .setValidFrom(validFrom)
|
|
6518
|
-
* .setConfigHashPrefix(configHashPrefix)
|
|
6519
|
-
* .addInstruction(instruction)
|
|
6520
|
-
* .build();
|
|
6521
|
-
* ```
|
|
6522
|
-
*/
|
|
6523
|
-
async getConfigHashPrefix() {
|
|
6524
|
-
const result = await this.call("getRecentValidatorConfigHash", [{}]);
|
|
6525
|
-
return BigInt(result.config_hash_prefix);
|
|
6526
|
-
}
|
|
6527
6170
|
};
|
|
6528
6171
|
|
|
6529
6172
|
// src/rpc/clients/transaction-client.ts
|
|
@@ -9335,17 +8978,14 @@ var Message = class _Message {
|
|
|
9335
8978
|
accountKeys;
|
|
9336
8979
|
/** Transaction valid from (milliseconds since Unix epoch) */
|
|
9337
8980
|
validFrom;
|
|
9338
|
-
/** Config hash prefix for replay protection across chains */
|
|
9339
|
-
configHashPrefix;
|
|
9340
8981
|
/** Compiled instructions with account indices */
|
|
9341
8982
|
instructions;
|
|
9342
8983
|
/** Cached serialized bytes */
|
|
9343
8984
|
serializedCache;
|
|
9344
|
-
constructor(header, accountKeys, validFrom,
|
|
8985
|
+
constructor(header, accountKeys, validFrom, instructions) {
|
|
9345
8986
|
this.header = Object.freeze({ ...header });
|
|
9346
8987
|
this.accountKeys = Object.freeze([...accountKeys]);
|
|
9347
8988
|
this.validFrom = validFrom;
|
|
9348
|
-
this.configHashPrefix = configHashPrefix;
|
|
9349
8989
|
this.instructions = Object.freeze(
|
|
9350
8990
|
instructions.map((ix) => Object.freeze({ ...ix }))
|
|
9351
8991
|
);
|
|
@@ -9405,18 +9045,6 @@ var Message = class _Message {
|
|
|
9405
9045
|
new DataView(validFromBytes.buffer).getBigUint64(0, true)
|
|
9406
9046
|
);
|
|
9407
9047
|
cursor += 8;
|
|
9408
|
-
if (data.length < cursor + 8) {
|
|
9409
|
-
throw new TransactionError(
|
|
9410
|
-
"INSUFFICIENT_DATA" /* INSUFFICIENT_DATA */,
|
|
9411
|
-
"Insufficient data for configHashPrefix"
|
|
9412
|
-
);
|
|
9413
|
-
}
|
|
9414
|
-
const configHashPrefixBytes = data.slice(cursor, cursor + 8);
|
|
9415
|
-
const configHashPrefix = BigInt.asUintN(
|
|
9416
|
-
64,
|
|
9417
|
-
new DataView(configHashPrefixBytes.buffer).getBigUint64(0, true)
|
|
9418
|
-
);
|
|
9419
|
-
cursor += 8;
|
|
9420
9048
|
const [instructionsLength, newCursor2] = deserializeCompactU16(
|
|
9421
9049
|
data,
|
|
9422
9050
|
cursor
|
|
@@ -9462,7 +9090,7 @@ var Message = class _Message {
|
|
|
9462
9090
|
data: instructionData
|
|
9463
9091
|
});
|
|
9464
9092
|
}
|
|
9465
|
-
return new _Message(header, accountKeys, validFrom,
|
|
9093
|
+
return new _Message(header, accountKeys, validFrom, instructions);
|
|
9466
9094
|
}
|
|
9467
9095
|
serializeInternal() {
|
|
9468
9096
|
const buffer = [];
|
|
@@ -9479,13 +9107,6 @@ var Message = class _Message {
|
|
|
9479
9107
|
true
|
|
9480
9108
|
);
|
|
9481
9109
|
buffer.push(...new Uint8Array(validFromBuffer));
|
|
9482
|
-
const configHashPrefixBuffer = new ArrayBuffer(8);
|
|
9483
|
-
new DataView(configHashPrefixBuffer).setBigUint64(
|
|
9484
|
-
0,
|
|
9485
|
-
this.configHashPrefix,
|
|
9486
|
-
true
|
|
9487
|
-
);
|
|
9488
|
-
buffer.push(...new Uint8Array(configHashPrefixBuffer));
|
|
9489
9110
|
this.serializeCompactArray(buffer, this.instructions, (buf, ix) => {
|
|
9490
9111
|
buf.push(ix.programIdIndex);
|
|
9491
9112
|
this.serializeCompactArray(buf, ix.accountKeyIndexes, (b, idx) => {
|
|
@@ -9870,7 +9491,6 @@ var Transaction = class _Transaction {
|
|
|
9870
9491
|
var TransactionBuilder = class _TransactionBuilder {
|
|
9871
9492
|
payer;
|
|
9872
9493
|
validFrom;
|
|
9873
|
-
configHashPrefix;
|
|
9874
9494
|
instructions = [];
|
|
9875
9495
|
constructor() {
|
|
9876
9496
|
}
|
|
@@ -9904,18 +9524,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9904
9524
|
this.validFrom = validFrom;
|
|
9905
9525
|
return this;
|
|
9906
9526
|
}
|
|
9907
|
-
/**
|
|
9908
|
-
* Set the config hash prefix for replay protection.
|
|
9909
|
-
*
|
|
9910
|
-
* This is the first 64 bits of the config hash, used to ensure
|
|
9911
|
-
* transactions cannot be replayed on different chains.
|
|
9912
|
-
*
|
|
9913
|
-
* @param configHashPrefix - config hash prefix as a u64
|
|
9914
|
-
*/
|
|
9915
|
-
setConfigHashPrefix(configHashPrefix) {
|
|
9916
|
-
this.configHashPrefix = configHashPrefix;
|
|
9917
|
-
return this;
|
|
9918
|
-
}
|
|
9919
9527
|
/**
|
|
9920
9528
|
* Add an instruction to the transaction.
|
|
9921
9529
|
*
|
|
@@ -9961,12 +9569,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
9961
9569
|
"Transaction must have a valid from. Use setValidFrom() to set the valid from."
|
|
9962
9570
|
);
|
|
9963
9571
|
}
|
|
9964
|
-
if (this.configHashPrefix === void 0) {
|
|
9965
|
-
throw new TransactionError(
|
|
9966
|
-
"INVALID_MESSAGE_FORMAT" /* INVALID_MESSAGE_FORMAT */,
|
|
9967
|
-
"Transaction must have a config hash prefix. Use setConfigHashPrefix() to set the config hash prefix."
|
|
9968
|
-
);
|
|
9969
|
-
}
|
|
9970
9572
|
if (this.instructions.length === 0) {
|
|
9971
9573
|
throw TransactionError.noInstructions();
|
|
9972
9574
|
}
|
|
@@ -10015,7 +9617,6 @@ var TransactionBuilder = class _TransactionBuilder {
|
|
|
10015
9617
|
header,
|
|
10016
9618
|
accountKeys,
|
|
10017
9619
|
this.validFrom,
|
|
10018
|
-
this.configHashPrefix,
|
|
10019
9620
|
compiledInstructions
|
|
10020
9621
|
);
|
|
10021
9622
|
return Transaction.fromMessage(message);
|
|
@@ -10124,15 +9725,9 @@ exports.BASE_DERIVATION_PATH = BASE_DERIVATION_PATH;
|
|
|
10124
9725
|
exports.BaseRpcClient = BaseRpcClient;
|
|
10125
9726
|
exports.BincodeReader = BincodeReader;
|
|
10126
9727
|
exports.BincodeWriter = BincodeWriter;
|
|
10127
|
-
exports.CHACHA20_POLY1305_TAG_LENGTH = CHACHA20_POLY1305_TAG_LENGTH;
|
|
10128
9728
|
exports.CryptoError = CryptoError;
|
|
10129
9729
|
exports.CryptoErrorCode = CryptoErrorCode;
|
|
10130
9730
|
exports.DEFAULT_NUM_ACCOUNTS = DEFAULT_NUM_ACCOUNTS;
|
|
10131
|
-
exports.ED25519_PUBLIC_KEY_LENGTH = ED25519_PUBLIC_KEY_LENGTH;
|
|
10132
|
-
exports.HPKE_ENC_LENGTH = HPKE_ENC_LENGTH;
|
|
10133
|
-
exports.HPKE_OVERHEAD_LENGTH = HPKE_OVERHEAD_LENGTH;
|
|
10134
|
-
exports.HpkeError = HpkeError;
|
|
10135
|
-
exports.HpkeErrorCode = HpkeErrorCode;
|
|
10136
9731
|
exports.HttpTransport = HttpTransport;
|
|
10137
9732
|
exports.KELVIN_PER_RLO = KELVIN_PER_RLO;
|
|
10138
9733
|
exports.Keypair = Keypair;
|
|
@@ -10147,15 +9742,12 @@ exports.RIALO_LOCALNET_CHAIN = RIALO_LOCALNET_CHAIN;
|
|
|
10147
9742
|
exports.RIALO_MAINNET_CHAIN = RIALO_MAINNET_CHAIN;
|
|
10148
9743
|
exports.RIALO_SHITNET_CHAIN = RIALO_SHITNET_CHAIN;
|
|
10149
9744
|
exports.RIALO_TESTNET_CHAIN = RIALO_TESTNET_CHAIN;
|
|
10150
|
-
exports.RexValue = RexValue;
|
|
10151
|
-
exports.RexValueVariant = RexValueVariant;
|
|
10152
9745
|
exports.RialoClient = RialoClient;
|
|
10153
9746
|
exports.RialoError = RialoError;
|
|
10154
9747
|
exports.RialoErrorType = RialoErrorType;
|
|
10155
9748
|
exports.RpcError = RpcError;
|
|
10156
9749
|
exports.RpcErrorCode = RpcErrorCode;
|
|
10157
9750
|
exports.SECRET_KEY_LENGTH = SECRET_KEY_LENGTH;
|
|
10158
|
-
exports.SECRET_SHARING_HPKE_INFO = SECRET_SHARING_HPKE_INFO;
|
|
10159
9751
|
exports.SIGNATURE_LENGTH = SIGNATURE_LENGTH;
|
|
10160
9752
|
exports.SYSTEM_PROGRAM_ID = SYSTEM_PROGRAM_ID;
|
|
10161
9753
|
exports.Schema = Schema;
|
|
@@ -10171,8 +9763,6 @@ exports.URL_LOCALNET = URL_LOCALNET;
|
|
|
10171
9763
|
exports.URL_MAINNET = URL_MAINNET;
|
|
10172
9764
|
exports.URL_SHITNET = URL_SHITNET;
|
|
10173
9765
|
exports.URL_TESTNET = URL_TESTNET;
|
|
10174
|
-
exports.USER_SECRET_AAD = USER_SECRET_AAD;
|
|
10175
|
-
exports.X25519_PUBLIC_KEY_LENGTH = X25519_PUBLIC_KEY_LENGTH;
|
|
10176
9766
|
exports.allocateInstruction = allocateInstruction;
|
|
10177
9767
|
exports.assignInstruction = assignInstruction;
|
|
10178
9768
|
exports.calculateBackoff = calculateBackoff;
|
|
@@ -10185,19 +9775,15 @@ exports.deserializeBorsh = deserializeBorsh;
|
|
|
10185
9775
|
exports.deserializeCompactU16 = deserializeCompactU162;
|
|
10186
9776
|
exports.deserializeStrict = deserializeStrict;
|
|
10187
9777
|
exports.encodeBorshData = encodeBorshData;
|
|
10188
|
-
exports.encryptForRex = encryptForRex;
|
|
10189
9778
|
exports.field = field;
|
|
10190
9779
|
exports.fixedArray = fixedArray;
|
|
10191
9780
|
exports.fromBase64 = fromBase64;
|
|
10192
|
-
exports.getCiphertextLength = getCiphertextLength;
|
|
10193
9781
|
exports.getDefaultRialoClientConfig = getDefaultRialoClientConfig;
|
|
10194
9782
|
exports.getDevnetUrl = getDevnetUrl;
|
|
10195
9783
|
exports.getLocalnetUrl = getLocalnetUrl;
|
|
10196
9784
|
exports.getMainnetUrl = getMainnetUrl;
|
|
10197
9785
|
exports.getTestnetUrl = getTestnetUrl;
|
|
10198
|
-
exports.hpkeEncrypt = hpkeEncrypt;
|
|
10199
9786
|
exports.isOnCurve = isOnCurve;
|
|
10200
|
-
exports.isValidCiphertextLength = isValidCiphertextLength;
|
|
10201
9787
|
exports.option = option;
|
|
10202
9788
|
exports.seedToBytes = seedToBytes;
|
|
10203
9789
|
exports.serialize = serialize;
|