@tari-project/ootle 0.9.0 → 0.10.0
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.ts +8 -0
- package/dist/index.js +123 -119
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { RistrettoPublicKeyBytes } from '@tari-project/ootle-ts-bindings';
|
|
|
32
32
|
import { StealthTransferStatement as StealthTransferStatement_2 } from '@tari-project/ootle-ts-bindings';
|
|
33
33
|
import { SubstateId } from '@tari-project/ootle-ts-bindings';
|
|
34
34
|
import { SubstateRequirement } from '@tari-project/ootle-ts-bindings';
|
|
35
|
+
import { SubstateValue } from '@tari-project/ootle-ts-bindings';
|
|
35
36
|
import { Transaction } from '@tari-project/ootle-ts-bindings';
|
|
36
37
|
import { TransactionEnvelope } from '@tari-project/ootle-ts-bindings';
|
|
37
38
|
import { TransactionSignature } from '@tari-project/ootle-ts-bindings';
|
|
@@ -1956,6 +1957,13 @@ export { UnsignedTransactionV1 }
|
|
|
1956
1957
|
*/
|
|
1957
1958
|
export declare type UnsignedTransactionWithBlobs = UnsignedTransactionV1;
|
|
1958
1959
|
|
|
1960
|
+
/**
|
|
1961
|
+
* The value of a fetched substate, or `null` if the indexer answered that the
|
|
1962
|
+
* requested version is down (only possible for a request with `include_proof`
|
|
1963
|
+
* that names the version).
|
|
1964
|
+
*/
|
|
1965
|
+
export declare function upSubstateValue(response: IndexerGetSubstateResponse): SubstateValue | null;
|
|
1966
|
+
|
|
1959
1967
|
/**
|
|
1960
1968
|
* CBOR-encode a `UtxoAddress` as `Tag(141, [ResourceAddress, UtxoId])`, where the
|
|
1961
1969
|
* `UtxoId` is the 32-byte commitment byte string.
|
package/dist/index.js
CHANGED
|
@@ -461,18 +461,21 @@ function Qe(e11) {
|
|
|
461
461
|
if (t2 !== void 0) return t2;
|
|
462
462
|
throw new v(`No default indexer URL is configured for ${u[e11]}. Pass an explicit URL via ProviderBuilder.withUrl(...) or IndexerProvider.connect({ url, network: Network.${u[e11]} }).`);
|
|
463
463
|
}
|
|
464
|
+
function V(e11) {
|
|
465
|
+
return "up" in e11.state ? e11.state.up.substate : null;
|
|
466
|
+
}
|
|
464
467
|
var $e = 132, et = 32;
|
|
465
468
|
function* tt(e11) {
|
|
466
469
|
let t2 = /* @__PURE__ */ new Set();
|
|
467
|
-
for (let n2 of
|
|
470
|
+
for (let n2 of H(e11, $e)) n2.length === et * 2 && !t2.has(n2) && (t2.add(n2), yield `vault_${n2}`);
|
|
468
471
|
}
|
|
469
472
|
async function nt(e11, t2) {
|
|
470
|
-
let n2 = (await e11.getSubstate(t2))
|
|
473
|
+
let n2 = V(await e11.getSubstate(t2));
|
|
471
474
|
return it(n2) ? Array.from(tt(n2.Component.body.state)) : [];
|
|
472
475
|
}
|
|
473
|
-
function*
|
|
476
|
+
function* H(e11, t2) {
|
|
474
477
|
if (Array.isArray(e11)) {
|
|
475
|
-
for (let n3 of e11) yield*
|
|
478
|
+
for (let n3 of e11) yield* H(n3, t2);
|
|
476
479
|
return;
|
|
477
480
|
}
|
|
478
481
|
if (typeof e11 != "object" || !e11) return;
|
|
@@ -484,14 +487,14 @@ function* V(e11, t2) {
|
|
|
484
487
|
let t3 = rt(e12);
|
|
485
488
|
t3 !== null && (yield t3);
|
|
486
489
|
}
|
|
487
|
-
yield*
|
|
490
|
+
yield* H(e12, t2);
|
|
488
491
|
} else if (r2 === "map") {
|
|
489
492
|
let e12 = n2.entries;
|
|
490
|
-
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield*
|
|
493
|
+
if (Array.isArray(e12)) for (let n3 of e12) Array.isArray(n3) && n3.length === 2 && (yield* H(n3[0], t2), yield* H(n3[1], t2));
|
|
491
494
|
}
|
|
492
495
|
return;
|
|
493
496
|
}
|
|
494
|
-
for (let e12 of Object.values(n2)) yield*
|
|
497
|
+
for (let e12 of Object.values(n2)) yield* H(e12, t2);
|
|
495
498
|
}
|
|
496
499
|
function rt(e11) {
|
|
497
500
|
if (typeof e11 != "object" || !e11) return null;
|
|
@@ -508,14 +511,14 @@ function ft(e11, t2) {
|
|
|
508
511
|
let n2 = e11.revealedInputBucket === null ? null : t2(e11.revealedInputBucket);
|
|
509
512
|
return { StealthTransfer: {
|
|
510
513
|
resource_address_ref: { Address: e11.resourceAddress },
|
|
511
|
-
statement:
|
|
514
|
+
statement: U(e11.statement),
|
|
512
515
|
revealed_input_bucket: n2
|
|
513
516
|
} };
|
|
514
517
|
}
|
|
515
|
-
function
|
|
518
|
+
function U(e11) {
|
|
516
519
|
return { [lt]: e11.toCompactJson() };
|
|
517
520
|
}
|
|
518
|
-
function
|
|
521
|
+
function pt(e11) {
|
|
519
522
|
return typeof e11 == "object" && !!e11 && "StealthTransfer" in e11;
|
|
520
523
|
}
|
|
521
524
|
function W(e11) {
|
|
@@ -542,14 +545,14 @@ async function G(e11, t2) {
|
|
|
542
545
|
inputs: n2
|
|
543
546
|
};
|
|
544
547
|
}
|
|
545
|
-
function
|
|
548
|
+
function mt() {
|
|
546
549
|
let { secret_key: e11, public_key: t2 } = a();
|
|
547
550
|
return {
|
|
548
551
|
secret_key: e11,
|
|
549
552
|
public_key: t2
|
|
550
553
|
};
|
|
551
554
|
}
|
|
552
|
-
function
|
|
555
|
+
function ht(e11, t2) {
|
|
553
556
|
return {
|
|
554
557
|
public_key: b(y(e11, 32, "publicKey")),
|
|
555
558
|
signature: {
|
|
@@ -573,10 +576,10 @@ async function K(e11, t2, n2) {
|
|
|
573
576
|
function q(e11) {
|
|
574
577
|
return t(e11.sealedJson);
|
|
575
578
|
}
|
|
576
|
-
async function
|
|
579
|
+
async function gt(e11, t2) {
|
|
577
580
|
return (await e11.submitTransaction(t2)).transaction_id;
|
|
578
581
|
}
|
|
579
|
-
function
|
|
582
|
+
function _t(e11) {
|
|
580
583
|
var _a, _b;
|
|
581
584
|
if (e11 === "Pending" || !("Finalized" in e11)) return null;
|
|
582
585
|
let t2 = e11.Finalized, n2 = t2.final_decision;
|
|
@@ -594,12 +597,12 @@ function gt(e11) {
|
|
|
594
597
|
}
|
|
595
598
|
throw new v(`Unexpected final_decision variant: ${JSON.stringify(n2)}`);
|
|
596
599
|
}
|
|
597
|
-
async function
|
|
600
|
+
async function vt(e11, t2, n2) {
|
|
598
601
|
let r2 = (n2 == null ? void 0 : n2.pollIntervalMs) ?? 500, i2 = (n2 == null ? void 0 : n2.timeoutMs) ?? 6e4, a2 = Date.now() + i2;
|
|
599
602
|
for (; ; ) {
|
|
600
603
|
let n3 = await e11.getTransactionResult(t2), o2 = n3.result;
|
|
601
604
|
if (o2 !== "Pending" && "Finalized" in o2) {
|
|
602
|
-
let { outcome: e12, reason: r3 } =
|
|
605
|
+
let { outcome: e12, reason: r3 } = _t(o2) ?? { outcome: "Reject" };
|
|
603
606
|
if (e12 === "Reject") throw new f(`Transaction ${t2} was rejected: ${r3}`, {
|
|
604
607
|
txId: t2,
|
|
605
608
|
reason: r3 ?? ""
|
|
@@ -614,17 +617,17 @@ async function _t(e11, t2, n2) {
|
|
|
614
617
|
await new Promise((e12) => setTimeout(e12, r2));
|
|
615
618
|
}
|
|
616
619
|
}
|
|
617
|
-
async function
|
|
620
|
+
async function yt(e11, t2, n2, r2) {
|
|
618
621
|
let i2 = await G(e11, n2);
|
|
619
|
-
return
|
|
622
|
+
return vt(e11, await gt(e11, q(await K(Array.isArray(t2) ? t2 : [t2], i2))), r2);
|
|
620
623
|
}
|
|
621
|
-
async function
|
|
622
|
-
return
|
|
624
|
+
async function bt(e11, t2, n2, r2) {
|
|
625
|
+
return yt(e11, t2, {
|
|
623
626
|
...n2,
|
|
624
627
|
dry_run: true
|
|
625
628
|
}, r2);
|
|
626
629
|
}
|
|
627
|
-
var
|
|
630
|
+
var xt = class {
|
|
628
631
|
constructor(e11, t2) {
|
|
629
632
|
__publicField(this, "builder");
|
|
630
633
|
this.builder = B.new(e11, t2);
|
|
@@ -650,7 +653,7 @@ var bt = class {
|
|
|
650
653
|
build() {
|
|
651
654
|
return this.builder.buildUnsignedTransaction();
|
|
652
655
|
}
|
|
653
|
-
},
|
|
656
|
+
}, St = class {
|
|
654
657
|
constructor(e11, t2, n2) {
|
|
655
658
|
__publicField(this, "builder");
|
|
656
659
|
__publicField(this, "faucetAddress");
|
|
@@ -687,7 +690,7 @@ var bt = class {
|
|
|
687
690
|
build() {
|
|
688
691
|
return this.builder.buildUnsignedTransaction();
|
|
689
692
|
}
|
|
690
|
-
},
|
|
693
|
+
}, Ct = class {
|
|
691
694
|
constructor() {
|
|
692
695
|
__publicField(this, "keyProviders");
|
|
693
696
|
__publicField(this, "defaultSignerAddress", null);
|
|
@@ -733,7 +736,7 @@ var bt = class {
|
|
|
733
736
|
if (n2 === void 0) throw new m(t2 === "default" ? `No key provider registered for default address: ${e11}. Call wallet.registerKeyProvider(address, signer) for that address, or pick a different default with setDefaultSigner(otherAddress).` : `No key provider registered for address: ${e11}. Call wallet.registerKeyProvider(${JSON.stringify(e11)}, signer) before signing.`, { address: e11 });
|
|
734
737
|
return n2;
|
|
735
738
|
}
|
|
736
|
-
},
|
|
739
|
+
}, wt = class {
|
|
737
740
|
constructor(e11, t2) {
|
|
738
741
|
__publicField(this, "bytes");
|
|
739
742
|
this.bytes = new Uint8Array(y(e11, 32, t2));
|
|
@@ -744,7 +747,7 @@ var bt = class {
|
|
|
744
747
|
toHex() {
|
|
745
748
|
return b(this.bytes);
|
|
746
749
|
}
|
|
747
|
-
}, J = class e3 extends
|
|
750
|
+
}, J = class e3 extends wt {
|
|
748
751
|
constructor(e11) {
|
|
749
752
|
super(e11, "Mask");
|
|
750
753
|
}
|
|
@@ -757,7 +760,7 @@ var bt = class {
|
|
|
757
760
|
static fromHex(t2) {
|
|
758
761
|
return new e3(x(t2));
|
|
759
762
|
}
|
|
760
|
-
},
|
|
763
|
+
}, Tt = class e4 {
|
|
761
764
|
constructor(e11) {
|
|
762
765
|
__publicField(this, "bytes");
|
|
763
766
|
this.bytes = new Uint8Array(e11);
|
|
@@ -771,8 +774,8 @@ var bt = class {
|
|
|
771
774
|
toHex() {
|
|
772
775
|
return b(this.bytes);
|
|
773
776
|
}
|
|
774
|
-
},
|
|
775
|
-
function
|
|
777
|
+
}, Et = Object.freeze({ StealthPublicKey: Object.freeze({}) });
|
|
778
|
+
function Dt(e11) {
|
|
776
779
|
if (e11.amount <= 0n) throw new v(`Output amount must be > 0, got ${e11.amount}`);
|
|
777
780
|
return {
|
|
778
781
|
destination: e11.destination,
|
|
@@ -780,19 +783,19 @@ function Et(e11) {
|
|
|
780
783
|
resourceAddress: e11.resourceAddress,
|
|
781
784
|
resourceViewKey: e11.resourceViewKey === void 0 ? void 0 : new Uint8Array(e11.resourceViewKey),
|
|
782
785
|
memo: e11.memo,
|
|
783
|
-
payTo: e11.payTo ??
|
|
786
|
+
payTo: e11.payTo ?? Et,
|
|
784
787
|
minimumValuePromise: e11.minimumValuePromise ?? 0n
|
|
785
788
|
};
|
|
786
789
|
}
|
|
787
|
-
function
|
|
790
|
+
function Ot(e11, t2) {
|
|
788
791
|
if (e11.trim() === "") throw new v(`${t2} must be a non-empty decimal string`);
|
|
789
792
|
return BigInt(e11);
|
|
790
793
|
}
|
|
791
|
-
function
|
|
794
|
+
function kt(e11, t2) {
|
|
792
795
|
let n2 = e11.trim();
|
|
793
796
|
if (!n2.startsWith("{") || !n2.endsWith("}")) throw new v(`StealthTransferStatement.toCompactJson: ${t2} fragment is not a JSON object (got: ${e11.slice(0, 60)}...)`);
|
|
794
797
|
}
|
|
795
|
-
var Y = class e5 extends
|
|
798
|
+
var Y = class e5 extends wt {
|
|
796
799
|
constructor(e11) {
|
|
797
800
|
super(e11, "StealthInput.commitment");
|
|
798
801
|
}
|
|
@@ -843,9 +846,9 @@ var Y = class e5 extends Ct {
|
|
|
843
846
|
};
|
|
844
847
|
}
|
|
845
848
|
static fromJSON(t2) {
|
|
846
|
-
return new e7(t2.inputs.map(Y.fromJSON),
|
|
849
|
+
return new e7(t2.inputs.map(Y.fromJSON), Ot(t2.revealed_amount, "revealed_amount"));
|
|
847
850
|
}
|
|
848
|
-
},
|
|
851
|
+
}, At = class e8 {
|
|
849
852
|
constructor(e11) {
|
|
850
853
|
__publicField(this, "statementJson");
|
|
851
854
|
this.statementJson = e11;
|
|
@@ -859,7 +862,7 @@ var Y = class e5 extends Ct {
|
|
|
859
862
|
static fromJSON(t2) {
|
|
860
863
|
return new e8(t2);
|
|
861
864
|
}
|
|
862
|
-
},
|
|
865
|
+
}, Q = class e9 {
|
|
863
866
|
constructor(e11, t2, n2) {
|
|
864
867
|
__publicField(this, "inputsStatement");
|
|
865
868
|
__publicField(this, "outputsStatement");
|
|
@@ -875,15 +878,15 @@ var Y = class e5 extends Ct {
|
|
|
875
878
|
}
|
|
876
879
|
toCompactJson() {
|
|
877
880
|
let e11 = this.inputsStatement.statementJson ?? JSON.stringify(this.inputsStatement.toJSON()), t2 = this.outputsStatement.statementJson;
|
|
878
|
-
|
|
881
|
+
kt(e11, "inputs_statement"), kt(t2, "outputs_statement");
|
|
879
882
|
let n2 = `{"inputs_statement":${e11},"outputs_statement":${t2},"covenant_claims":[]`;
|
|
880
883
|
return this.balanceProof !== void 0 && (n2 += `,"balance_proof":${JSON.stringify(this.balanceProof.toJSON())}`), n2 + "}";
|
|
881
884
|
}
|
|
882
885
|
static fromJSON(t2) {
|
|
883
|
-
return new e9(Z.fromJSON(t2.inputs),
|
|
886
|
+
return new e9(Z.fromJSON(t2.inputs), At.fromJSON(t2.outputs), t2.balance_proof === void 0 ? void 0 : X.fromJSON(t2.balance_proof));
|
|
884
887
|
}
|
|
885
888
|
};
|
|
886
|
-
function
|
|
889
|
+
function jt(e11, t2) {
|
|
887
890
|
let n2 = new Uint8Array(e11.length * 32);
|
|
888
891
|
for (let r2 = 0; r2 < e11.length; r2++) {
|
|
889
892
|
let i2 = e11[r2];
|
|
@@ -891,7 +894,7 @@ function kt(e11, t2) {
|
|
|
891
894
|
}
|
|
892
895
|
return n2;
|
|
893
896
|
}
|
|
894
|
-
var
|
|
897
|
+
var Mt = "[]", Nt = class {
|
|
895
898
|
constructor(e11 = u.LocalNet) {
|
|
896
899
|
__publicField(this, "network");
|
|
897
900
|
this.network = e11;
|
|
@@ -901,23 +904,23 @@ var At = "[]", jt = class {
|
|
|
901
904
|
t2 !== null && (y(t2.receiver, 32, "revealed output receiver"), r2 = t2.amount, i2 = t2.receiver);
|
|
902
905
|
let a2 = s(n2, r2, i2);
|
|
903
906
|
return y(a2.aggregated_output_mask, 32, "StealthOutputsResult.aggregated_output_mask"), {
|
|
904
|
-
statement:
|
|
907
|
+
statement: At.fromJSON(a2.statement_json),
|
|
905
908
|
outputMask: J.fromBytes(a2.aggregated_output_mask)
|
|
906
909
|
};
|
|
907
910
|
}
|
|
908
911
|
outputWitness(e11) {
|
|
909
|
-
let t2 = c(e11.destination), n2 =
|
|
912
|
+
let t2 = c(e11.destination), n2 = Pt(e11.payTo) ? null : JSON.stringify(e11.payTo), i2 = e11.memo === void 0 ? null : JSON.stringify(e11.memo), a2 = e11.resourceViewKey ?? null;
|
|
910
913
|
return r(this.network, t2.owner_key, t2.view_key, e11.amount, e11.resourceAddress, a2, i2, n2, e11.minimumValuePromise);
|
|
911
914
|
}
|
|
912
915
|
async buildInputsStatement(e11, t2) {
|
|
913
|
-
return new Z(e11, t2, n(
|
|
916
|
+
return new Z(e11, t2, n(jt(e11.map((e12) => e12.commitment), "input commitment"), t2));
|
|
914
917
|
}
|
|
915
918
|
async generateBalanceProofSignature(e11, t2, n2, r2) {
|
|
916
|
-
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2,
|
|
919
|
+
let i2 = o(e11.toBytes(), t2.toBytes(), n2, r2, Mt);
|
|
917
920
|
return y(i2.public_nonce, 32, "balance proof public_nonce"), y(i2.signature, 32, "balance proof signature"), new X(i2.public_nonce, i2.signature);
|
|
918
921
|
}
|
|
919
922
|
async validateBalanceProofSignature(e11, t2, n2) {
|
|
920
|
-
return ne(e11.publicNonce, e11.signature, t2, n2,
|
|
923
|
+
return ne(e11.publicNonce, e11.signature, t2, n2, Mt);
|
|
921
924
|
}
|
|
922
925
|
async deriveAeadKey(e11, t2) {
|
|
923
926
|
y(e11, 32, "deriveAeadKey privateKey"), y(t2, 32, "deriveAeadKey publicKey");
|
|
@@ -934,7 +937,7 @@ var At = "[]", jt = class {
|
|
|
934
937
|
};
|
|
935
938
|
}
|
|
936
939
|
async aggregateInputMasks(t2) {
|
|
937
|
-
let n2 = e(
|
|
940
|
+
let n2 = e(jt(t2.map((e11) => e11.toBytes()), "input mask"));
|
|
938
941
|
return J.fromBytes(n2);
|
|
939
942
|
}
|
|
940
943
|
async stealthDhSecret(e11, t2, n2) {
|
|
@@ -946,49 +949,49 @@ var At = "[]", jt = class {
|
|
|
946
949
|
re(e11.toCompactJson(), null);
|
|
947
950
|
}
|
|
948
951
|
};
|
|
949
|
-
function
|
|
952
|
+
function Pt(e11) {
|
|
950
953
|
let t2 = Object.keys(e11);
|
|
951
954
|
if (t2.length !== 1 || t2[0] !== "StealthPublicKey") return false;
|
|
952
955
|
let n2 = e11.StealthPublicKey;
|
|
953
956
|
return typeof n2 == "object" && !!n2 && Object.keys(n2).length === 0;
|
|
954
957
|
}
|
|
955
|
-
var
|
|
956
|
-
function
|
|
957
|
-
return `${
|
|
958
|
+
var Ft = "utxo";
|
|
959
|
+
function It(e11, t2) {
|
|
960
|
+
return `${Ft}_${e11.startsWith("resource_") ? e11.slice(9) : e11}_${b(t2)}`;
|
|
958
961
|
}
|
|
959
|
-
var
|
|
960
|
-
function
|
|
962
|
+
var Lt = 64;
|
|
963
|
+
function Rt(e11) {
|
|
961
964
|
return typeof e11 == "object" && !!e11 && "Utxo" in e11;
|
|
962
965
|
}
|
|
963
|
-
function
|
|
966
|
+
function zt(e11) {
|
|
964
967
|
return e11.length > 0 && /^[0-9a-fA-F]+$/.test(e11);
|
|
965
968
|
}
|
|
966
|
-
function
|
|
969
|
+
function Bt(e11) {
|
|
967
970
|
let t2 = e11.split("_");
|
|
968
|
-
if (t2.length < 3 || t2[0] !==
|
|
971
|
+
if (t2.length < 3 || t2[0] !== Ft) return null;
|
|
969
972
|
let n2 = t2[t2.length - 1];
|
|
970
|
-
return n2.length !==
|
|
973
|
+
return n2.length !== Lt || !zt(n2) ? null : x(n2);
|
|
971
974
|
}
|
|
972
|
-
function
|
|
973
|
-
let n2 = e11
|
|
974
|
-
if (!
|
|
975
|
+
function $(e11, t2) {
|
|
976
|
+
let n2 = V(e11);
|
|
977
|
+
if (n2 === null || !Rt(n2)) return null;
|
|
975
978
|
let r2 = n2.Utxo;
|
|
976
979
|
if (r2.output === null || r2.is_frozen) return null;
|
|
977
|
-
let i2 =
|
|
980
|
+
let i2 = Bt(t2);
|
|
978
981
|
return i2 === null ? null : {
|
|
979
982
|
commitment: i2,
|
|
980
983
|
body: r2.output.output
|
|
981
984
|
};
|
|
982
985
|
}
|
|
983
|
-
var
|
|
984
|
-
constructor(e11, t2, n2 = new
|
|
986
|
+
var Vt = 0, Ht = class {
|
|
987
|
+
constructor(e11, t2, n2 = new Nt(e11.network())) {
|
|
985
988
|
__publicField(this, "provider");
|
|
986
989
|
__publicField(this, "crypto");
|
|
987
990
|
__publicField(this, "builder");
|
|
988
991
|
__publicField(this, "state");
|
|
989
992
|
__publicField(this, "maxEpoch", null);
|
|
990
993
|
__publicField(this, "prepared", false);
|
|
991
|
-
this.provider = e11, this.crypto = n2, this.builder = B.new(e11.network(),
|
|
994
|
+
this.provider = e11, this.crypto = n2, this.builder = B.new(e11.network(), Vt), this.state = {
|
|
992
995
|
resource: t2,
|
|
993
996
|
revealedInput: null,
|
|
994
997
|
inputsToSpend: /* @__PURE__ */ new Map(),
|
|
@@ -1041,8 +1044,8 @@ var Bt = 0, Vt = class {
|
|
|
1041
1044
|
var _a;
|
|
1042
1045
|
if (this.prepared) throw new v("StealthTransfer.prepare: already prepared \u2014 create a new StealthTransfer to build again");
|
|
1043
1046
|
this.validate(), this.prepared = true;
|
|
1044
|
-
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new
|
|
1045
|
-
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch ===
|
|
1047
|
+
let { statement: e11, outputMask: t2 } = await this.crypto.generateOutputsStatement(this.state.outputs, this.state.revealedOutput), n2 = new Q(await this.crypto.buildInputsStatement([...this.state.inputsToSpend.values()].map((e12) => e12.input), ((_a = this.state.revealedInput) == null ? void 0 : _a.amount) ?? 0n), e11, void 0);
|
|
1048
|
+
this.emitInstructions(n2), this.maxEpoch === null && this.builder.buildUnsignedTransaction().max_epoch === Vt && this.builder.withMaxEpoch(await We(this.provider));
|
|
1046
1049
|
let r2 = /* @__PURE__ */ new Set();
|
|
1047
1050
|
if (this.state.revealedInput !== null) {
|
|
1048
1051
|
let e12 = this.state.revealedInput.source;
|
|
@@ -1057,7 +1060,7 @@ var Bt = 0, Vt = class {
|
|
|
1057
1060
|
}), r2.add(e13));
|
|
1058
1061
|
}
|
|
1059
1062
|
for (let { input: e12 } of this.state.inputsToSpend.values()) {
|
|
1060
|
-
let t3 =
|
|
1063
|
+
let t3 = It(this.state.resource, e12.commitment);
|
|
1061
1064
|
r2.has(t3) || (this.builder.addInput({
|
|
1062
1065
|
substate_id: t3,
|
|
1063
1066
|
version: null
|
|
@@ -1106,28 +1109,28 @@ var Bt = 0, Vt = class {
|
|
|
1106
1109
|
}, [{ Workspace: dt }]);
|
|
1107
1110
|
}
|
|
1108
1111
|
};
|
|
1109
|
-
function
|
|
1110
|
-
if (
|
|
1112
|
+
function Ut(e11) {
|
|
1113
|
+
if (Wt(e11) || e11.statementJson !== void 0) return e11.statementJson;
|
|
1111
1114
|
if (e11.inputs.length > 0) throw new _("inputs statement has confidential inputs but no WASM statementJson \u2014 call buildInputsStatement first", { context: "statementJsonFor" });
|
|
1112
1115
|
return JSON.stringify(e11.toJSON());
|
|
1113
1116
|
}
|
|
1114
|
-
function
|
|
1117
|
+
function Wt(e11) {
|
|
1115
1118
|
return !("inputs" in e11);
|
|
1116
1119
|
}
|
|
1117
|
-
async function
|
|
1118
|
-
let a2 =
|
|
1120
|
+
async function Gt(e11, t2, n2, r2, i2) {
|
|
1121
|
+
let a2 = Ut(r2), o2 = Ut(i2);
|
|
1119
1122
|
return e11.generateBalanceProofSignature(t2, n2, a2, o2);
|
|
1120
1123
|
}
|
|
1121
|
-
async function
|
|
1124
|
+
async function Kt(e11, t2, n2, r2) {
|
|
1122
1125
|
let i2 = await e11.deriveAeadKey(r2.viewSecret, r2.senderPublicNonce);
|
|
1123
1126
|
return e11.unblindOutput(t2, n2, i2, r2.skipMemo);
|
|
1124
1127
|
}
|
|
1125
|
-
async function
|
|
1126
|
-
let i2 =
|
|
1128
|
+
async function qt(e11, t2, n2, r2) {
|
|
1129
|
+
let i2 = $(n2, r2);
|
|
1127
1130
|
if (i2 === null) return null;
|
|
1128
1131
|
let a2 = x(i2.body.encrypted_data), o2 = x(i2.body.public_nonce);
|
|
1129
1132
|
try {
|
|
1130
|
-
return await
|
|
1133
|
+
return await Kt(e11, i2.commitment, a2, {
|
|
1131
1134
|
senderPublicNonce: o2,
|
|
1132
1135
|
viewSecret: t2,
|
|
1133
1136
|
skipMemo: false
|
|
@@ -1136,33 +1139,33 @@ async function Kt(e11, t2, n2, r2) {
|
|
|
1136
1139
|
return null;
|
|
1137
1140
|
}
|
|
1138
1141
|
}
|
|
1139
|
-
async function
|
|
1142
|
+
async function Jt(e11, t2, n2) {
|
|
1140
1143
|
if (t2.length === 0) throw new v("generateOutputsStatement: at least one stealth output is required");
|
|
1141
1144
|
let { statement: r2, outputMask: i2 } = await e11.generateOutputsStatement(t2, n2), a2 = await e11.buildInputsStatement([], 0n);
|
|
1142
|
-
return new
|
|
1145
|
+
return new Q(a2, r2, await Gt(e11, J.zero(), i2, a2, r2));
|
|
1143
1146
|
}
|
|
1144
|
-
var
|
|
1147
|
+
var Yt = class e10 {
|
|
1145
1148
|
constructor(e11, t2, n2, r2, i2) {
|
|
1146
1149
|
this.wallet = e11, this.spec = t2, this.crypto = n2, this.mustSignWithAccountKey = r2, this.viewSecret = i2;
|
|
1147
1150
|
}
|
|
1148
1151
|
static fromSpec(t2, n2, r2 = {}) {
|
|
1149
|
-
return new e10(t2, n2, r2.crypto ?? new
|
|
1152
|
+
return new e10(t2, n2, r2.crypto ?? new Nt(), r2.mustSignWithAccountKey ?? true, r2.viewSecret);
|
|
1150
1153
|
}
|
|
1151
1154
|
async prepare(e11) {
|
|
1152
|
-
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? J.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await
|
|
1155
|
+
let t2 = await this.resolveStealthInputs(e11), n2 = t2.length === 0 ? J.zero() : await this.crypto.aggregateInputMasks(t2.map((e12) => e12.mask)), r2 = await Gt(this.crypto, n2, this.spec.outputMask, this.spec.statement.inputsStatement, this.spec.statement.outputsStatement), i2 = new Q(this.spec.statement.inputsStatement, this.spec.statement.outputsStatement, r2);
|
|
1153
1156
|
await this.crypto.validateTransfer(i2);
|
|
1154
|
-
let a2 =
|
|
1157
|
+
let a2 = Zt(this.spec.unsignedTx, i2), o2 = {
|
|
1155
1158
|
...this.spec,
|
|
1156
1159
|
unsignedTx: a2,
|
|
1157
1160
|
statement: i2
|
|
1158
1161
|
};
|
|
1159
|
-
return new
|
|
1162
|
+
return new Xt({
|
|
1160
1163
|
wallet: this.wallet,
|
|
1161
1164
|
crypto: this.crypto,
|
|
1162
1165
|
spec: o2,
|
|
1163
1166
|
resolvedInputs: t2,
|
|
1164
1167
|
mustSignWithAccountKey: this.mustSignWithAccountKey,
|
|
1165
|
-
sealKeypair:
|
|
1168
|
+
sealKeypair: mt()
|
|
1166
1169
|
});
|
|
1167
1170
|
}
|
|
1168
1171
|
async resolveViewSecret() {
|
|
@@ -1187,11 +1190,11 @@ var Jt = class e10 {
|
|
|
1187
1190
|
let t2 = await this.resolveViewSecret(), n2 = this.spec.state.resource, r2 = await Promise.allSettled(this.spec.inputs.map(async ({ input: r3, owner: i3 }) => {
|
|
1188
1191
|
let a2 = b(r3.commitment), o2 = await e11.getStealthUtxo(n2, r3.commitment);
|
|
1189
1192
|
if (o2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input UTXO not found (spent or never created) for ${a2}`);
|
|
1190
|
-
let s2 =
|
|
1193
|
+
let s2 = $(o2, It(n2, r3.commitment));
|
|
1191
1194
|
if (s2 === null) throw new p(`WalletStealthAuthorizer.prepare: stealth input ${a2} is not a live, spendable UTXO`);
|
|
1192
1195
|
let c2 = x(s2.body.public_nonce), l2;
|
|
1193
1196
|
try {
|
|
1194
|
-
l2 = await
|
|
1197
|
+
l2 = await Kt(this.crypto, s2.commitment, x(s2.body.encrypted_data), {
|
|
1195
1198
|
senderPublicNonce: c2,
|
|
1196
1199
|
viewSecret: t2,
|
|
1197
1200
|
skipMemo: true
|
|
@@ -1212,7 +1215,7 @@ var Jt = class e10 {
|
|
|
1212
1215
|
if (i2 !== void 0) throw i2.reason;
|
|
1213
1216
|
return r2.map((e12) => e12.value);
|
|
1214
1217
|
}
|
|
1215
|
-
},
|
|
1218
|
+
}, Xt = class {
|
|
1216
1219
|
constructor(e11) {
|
|
1217
1220
|
__publicField(this, "wallet");
|
|
1218
1221
|
__publicField(this, "crypto");
|
|
@@ -1255,23 +1258,23 @@ var Jt = class e10 {
|
|
|
1255
1258
|
let e11 = (await this.createAuthorizations()).flatMap((e12) => e12.signatures), t2 = [];
|
|
1256
1259
|
this.mustSignWithAccountKey && t2.push(this.wallet);
|
|
1257
1260
|
let n2 = [...e11, ...this.extraSignatures];
|
|
1258
|
-
return n2.length > 0 && t2.push(new
|
|
1261
|
+
return n2.length > 0 && t2.push(new Qt(n2)), q(await K(t2, this.spec.unsignedTx, this.sealKeypair));
|
|
1259
1262
|
}
|
|
1260
1263
|
};
|
|
1261
|
-
function
|
|
1262
|
-
let n2 = e11.instructions.findIndex(
|
|
1264
|
+
function Zt(e11, t2) {
|
|
1265
|
+
let n2 = e11.instructions.findIndex(pt);
|
|
1263
1266
|
if (n2 < 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found 0 (not a stealth tx)");
|
|
1264
|
-
if (e11.instructions.slice(n2 + 1).findIndex(
|
|
1267
|
+
if (e11.instructions.slice(n2 + 1).findIndex(pt) >= 0) throw new v("patchStealthStatement: expected exactly one StealthTransfer instruction, found more than one (malformed)");
|
|
1265
1268
|
let r2 = { StealthTransfer: {
|
|
1266
1269
|
...e11.instructions[n2].StealthTransfer,
|
|
1267
|
-
statement:
|
|
1270
|
+
statement: U(t2)
|
|
1268
1271
|
} }, i2 = [...e11.instructions];
|
|
1269
1272
|
return i2[n2] = r2, {
|
|
1270
1273
|
...e11,
|
|
1271
1274
|
instructions: i2
|
|
1272
1275
|
};
|
|
1273
1276
|
}
|
|
1274
|
-
var
|
|
1277
|
+
var Qt = class {
|
|
1275
1278
|
constructor(e11) {
|
|
1276
1279
|
this.signatures = e11;
|
|
1277
1280
|
}
|
|
@@ -1286,14 +1289,14 @@ var Zt = class {
|
|
|
1286
1289
|
}
|
|
1287
1290
|
};
|
|
1288
1291
|
export {
|
|
1289
|
-
|
|
1290
|
-
|
|
1292
|
+
xt as AccountInvokeBuilder,
|
|
1293
|
+
Xt as AuthorizedTransfer,
|
|
1291
1294
|
X as BalanceProofSignature,
|
|
1292
1295
|
_ as CryptoBridgeError,
|
|
1293
1296
|
Ue as DEFAULT_TRANSACTION_VALIDITY_EPOCHS,
|
|
1294
1297
|
h as DefaultSignerNotSetError,
|
|
1295
|
-
|
|
1296
|
-
|
|
1298
|
+
Tt as EncryptedData,
|
|
1299
|
+
St as FaucetInvokeBuilder,
|
|
1297
1300
|
ie as IndexerClientError,
|
|
1298
1301
|
v as InvalidArgumentError,
|
|
1299
1302
|
m as KeyProviderNotFoundError,
|
|
@@ -1301,21 +1304,21 @@ export {
|
|
|
1301
1304
|
J as Mask,
|
|
1302
1305
|
u as Network,
|
|
1303
1306
|
d as OotleError,
|
|
1304
|
-
|
|
1307
|
+
Ct as OotleWallet,
|
|
1305
1308
|
oe as OperationCancelledError,
|
|
1306
1309
|
g as SignerError,
|
|
1307
1310
|
Y as StealthInput,
|
|
1308
1311
|
Z as StealthInputsStatement,
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
+
At as StealthOutputsStatement,
|
|
1313
|
+
Ht as StealthTransfer,
|
|
1314
|
+
Q as StealthTransferStatement,
|
|
1312
1315
|
at as TARI_RESOURCE_ADDRESS,
|
|
1313
1316
|
B as TransactionBuilder,
|
|
1314
1317
|
f as TransactionRejectedError,
|
|
1315
1318
|
ae as TransactionTimeoutError,
|
|
1316
1319
|
p as WalletError,
|
|
1317
|
-
|
|
1318
|
-
|
|
1320
|
+
Yt as WalletStealthAuthorizer,
|
|
1321
|
+
Nt as WasmStealthCrypto,
|
|
1319
1322
|
ct as XTR_FAUCET_CLAIM_RESOURCE_ADDRESS,
|
|
1320
1323
|
ot as XTR_FAUCET_COMPONENT_ADDRESS,
|
|
1321
1324
|
st as XTR_FAUCET_VAULT_ADDRESS,
|
|
@@ -1323,50 +1326,51 @@ export {
|
|
|
1323
1326
|
y as assertByteLength,
|
|
1324
1327
|
se as assertUnreachable,
|
|
1325
1328
|
De as boolLiteral,
|
|
1326
|
-
|
|
1329
|
+
ht as buildTransactionSignature,
|
|
1327
1330
|
A as bytesLiteral,
|
|
1328
1331
|
Me as claimedOutputTombstoneAddressLiteral,
|
|
1329
|
-
|
|
1330
|
-
|
|
1332
|
+
_t as classifyOutcome,
|
|
1333
|
+
Bt as commitmentOf,
|
|
1331
1334
|
Oe as componentAddressLiteral,
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
+
Dt as createOutput,
|
|
1336
|
+
Kt as decryptInputData,
|
|
1337
|
+
qt as decryptOwnedUtxo,
|
|
1335
1338
|
Qe as defaultIndexerUrl,
|
|
1336
1339
|
x as fromHexStr,
|
|
1337
|
-
|
|
1338
|
-
|
|
1340
|
+
Jt as generateOutputsStatement,
|
|
1341
|
+
mt as generateSealKeypair,
|
|
1339
1342
|
nt as getVaultIdsForAccount,
|
|
1340
1343
|
Te as intLiteral,
|
|
1341
|
-
|
|
1344
|
+
pt as isStealthTransferInstruction,
|
|
1342
1345
|
tt as iterVaultIdsInState,
|
|
1343
1346
|
Ce as literalArg,
|
|
1344
1347
|
ke as metadataLiteral,
|
|
1345
1348
|
R as microTariLiteral,
|
|
1346
1349
|
Be as microTariString,
|
|
1347
1350
|
Fe as nonFungibleAddressLiteral,
|
|
1348
|
-
|
|
1351
|
+
$ as parseSubstateUtxo,
|
|
1349
1352
|
Ve as parseWorkspaceStringKey,
|
|
1350
|
-
|
|
1353
|
+
Zt as patchStealthStatement,
|
|
1351
1354
|
Pe as publicKeyLiteral,
|
|
1352
1355
|
We as resolveMaxEpoch,
|
|
1353
1356
|
G as resolveTransaction,
|
|
1354
1357
|
j as resourceAddressLiteral,
|
|
1355
1358
|
q as sealTransaction,
|
|
1356
|
-
|
|
1357
|
-
|
|
1359
|
+
bt as sendDryRun,
|
|
1360
|
+
yt as sendTransaction,
|
|
1358
1361
|
W as serializeUnsignedTx,
|
|
1359
|
-
|
|
1362
|
+
Gt as signBalanceProof,
|
|
1360
1363
|
K as signTransaction,
|
|
1361
|
-
|
|
1364
|
+
U as statementAsWire,
|
|
1362
1365
|
ft as stealthTransferInstruction,
|
|
1363
|
-
|
|
1366
|
+
It as stealthUtxoSubstateId,
|
|
1364
1367
|
Ee as stringLiteral,
|
|
1365
|
-
|
|
1368
|
+
gt as submitTransaction,
|
|
1366
1369
|
je as templateAddressLiteral,
|
|
1367
1370
|
b as toHexStr,
|
|
1371
|
+
V as upSubstateValue,
|
|
1368
1372
|
Ie as utxoAddressLiteral,
|
|
1369
1373
|
Ne as validatorFeePoolAddressLiteral,
|
|
1370
1374
|
Ae as vaultIdLiteral,
|
|
1371
|
-
|
|
1375
|
+
vt as watchTransaction
|
|
1372
1376
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tari-project/ootle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/tari-project/ootle.ts.git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@tari-project/ootle-ts-bindings": "^1.
|
|
29
|
-
"@tari-project/ootle-wasm": "^0.
|
|
28
|
+
"@tari-project/ootle-ts-bindings": "^1.60.0",
|
|
29
|
+
"@tari-project/ootle-wasm": "^0.47.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^25.5.0",
|