@thru/programs 0.2.25 → 0.2.28
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/multicall/index.cjs +166 -24
- package/dist/multicall/index.cjs.map +1 -1
- package/dist/multicall/index.d.cts +39 -3
- package/dist/multicall/index.d.ts +39 -3
- package/dist/multicall/index.js +166 -25
- package/dist/multicall/index.js.map +1 -1
- package/dist/passkey-manager/index.cjs +1235 -345
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.d.cts +45 -11
- package/dist/passkey-manager/index.d.ts +45 -11
- package/dist/passkey-manager/index.js +1225 -346
- package/dist/passkey-manager/index.js.map +1 -1
- package/package.json +2 -2
- package/src/multicall/abi/thru/common/primitives/types.ts +14 -9
- package/src/multicall/abi/thru/program/multicall/types.ts +136 -4
- package/src/multicall/index.ts +6 -17
- package/src/passkey-manager/abi/thru/blockchain/state_proof/types.ts +11 -6
- package/src/passkey-manager/abi/thru/common/primitives/types.ts +19 -14
- package/src/passkey-manager/abi/thru/program/passkey_manager/types.ts +1069 -271
- package/src/passkey-manager/accounts.ts +79 -40
- package/src/passkey-manager/constants.ts +10 -1
- package/src/passkey-manager/index.ts +18 -2
- package/src/passkey-manager/instructions/add-authority.ts +31 -3
- package/src/passkey-manager/instructions/create.ts +106 -11
- package/src/passkey-manager/instructions/invoke.ts +9 -0
- package/src/passkey-manager/instructions/shared.ts +15 -0
- package/src/passkey-manager/instructions/transfer.ts +1 -1
- package/src/passkey-manager/instructions/validate.ts +13 -43
- package/src/passkey-manager/types.ts +7 -2
- package/src/passkey-manager/validate.test.ts +71 -3
|
@@ -2,17 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var helpers = require('@thru/sdk/helpers');
|
|
4
4
|
|
|
5
|
-
// src/passkey-manager/constants.ts
|
|
6
|
-
var PASSKEY_MANAGER_PROGRAM_ADDRESS = "taUDdQyFxvM5i0HFRkEK3W45kWLyblAHSnMg4zplgUnz6Z";
|
|
7
|
-
var INSTRUCTION_CREATE = 0;
|
|
8
|
-
var INSTRUCTION_VALIDATE = 1;
|
|
9
|
-
var INSTRUCTION_TRANSFER = 2;
|
|
10
|
-
var INSTRUCTION_ADD_AUTHORITY = 4;
|
|
11
|
-
var INSTRUCTION_REMOVE_AUTHORITY = 5;
|
|
12
|
-
var INSTRUCTION_REGISTER_CREDENTIAL = 6;
|
|
13
|
-
var AUTHORITY_TAG_PASSKEY = 1;
|
|
14
|
-
var AUTHORITY_TAG_PUBKEY = 2;
|
|
15
|
-
|
|
16
5
|
// src/passkey-manager/abi/thru/common/primitives/types.ts
|
|
17
6
|
var __tnWarnings = /* @__PURE__ */ new Set();
|
|
18
7
|
var __tnHasNativeBigInt = typeof BigInt === "function";
|
|
@@ -632,7 +621,8 @@ __tnRegisterFootprint("Date", (params) => Date.__tnInvokeFootprint(params));
|
|
|
632
621
|
__tnRegisterValidate("Date", (buffer, params) => Date.__tnInvokeValidate(buffer, params));
|
|
633
622
|
__tnRegisterDynamicValidate("Date", (buffer) => {
|
|
634
623
|
const result = Date.validate(buffer);
|
|
635
|
-
|
|
624
|
+
const params = result.params;
|
|
625
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
636
626
|
});
|
|
637
627
|
var __tn_ir_Duration = {
|
|
638
628
|
typeName: "Duration",
|
|
@@ -760,7 +750,8 @@ __tnRegisterFootprint("Duration", (params) => Duration.__tnInvokeFootprint(param
|
|
|
760
750
|
__tnRegisterValidate("Duration", (buffer, params) => Duration.__tnInvokeValidate(buffer, params));
|
|
761
751
|
__tnRegisterDynamicValidate("Duration", (buffer) => {
|
|
762
752
|
const result = Duration.validate(buffer);
|
|
763
|
-
|
|
753
|
+
const params = result.params;
|
|
754
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
764
755
|
});
|
|
765
756
|
var __tn_ir_FixedPoint = {
|
|
766
757
|
typeName: "FixedPoint",
|
|
@@ -888,7 +879,8 @@ __tnRegisterFootprint("FixedPoint", (params) => FixedPoint.__tnInvokeFootprint(p
|
|
|
888
879
|
__tnRegisterValidate("FixedPoint", (buffer, params) => FixedPoint.__tnInvokeValidate(buffer, params));
|
|
889
880
|
__tnRegisterDynamicValidate("FixedPoint", (buffer) => {
|
|
890
881
|
const result = FixedPoint.validate(buffer);
|
|
891
|
-
|
|
882
|
+
const params = result.params;
|
|
883
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
892
884
|
});
|
|
893
885
|
var __tn_ir_Hash = {
|
|
894
886
|
typeName: "Hash",
|
|
@@ -1003,7 +995,8 @@ __tnRegisterFootprint("Hash", (params) => Hash.__tnInvokeFootprint(params));
|
|
|
1003
995
|
__tnRegisterValidate("Hash", (buffer, params) => Hash.__tnInvokeValidate(buffer, params));
|
|
1004
996
|
__tnRegisterDynamicValidate("Hash", (buffer) => {
|
|
1005
997
|
const result = Hash.validate(buffer);
|
|
1006
|
-
|
|
998
|
+
const params = result.params;
|
|
999
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1007
1000
|
});
|
|
1008
1001
|
var __tn_ir_InstructionData = {
|
|
1009
1002
|
typeName: "InstructionData",
|
|
@@ -1275,7 +1268,7 @@ var InstructionDataBuilder = class {
|
|
|
1275
1268
|
const elementCount = bytes.length;
|
|
1276
1269
|
this.__tnFam_data = bytes;
|
|
1277
1270
|
this.__tnFam_dataCount = elementCount;
|
|
1278
|
-
this.set_data_size(elementCount);
|
|
1271
|
+
this.set_data_size(__tnToBigInt(elementCount));
|
|
1279
1272
|
this.__tnInvalidate();
|
|
1280
1273
|
});
|
|
1281
1274
|
}
|
|
@@ -1343,7 +1336,8 @@ __tnRegisterFootprint("InstructionData", (params) => InstructionData.__tnInvokeF
|
|
|
1343
1336
|
__tnRegisterValidate("InstructionData", (buffer, params) => InstructionData.__tnInvokeValidate(buffer, params));
|
|
1344
1337
|
__tnRegisterDynamicValidate("InstructionData", (buffer) => {
|
|
1345
1338
|
const result = InstructionData.validate(buffer);
|
|
1346
|
-
|
|
1339
|
+
const params = result.params;
|
|
1340
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1347
1341
|
});
|
|
1348
1342
|
var __tn_ir_Pubkey = {
|
|
1349
1343
|
typeName: "Pubkey",
|
|
@@ -1458,7 +1452,8 @@ __tnRegisterFootprint("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
|
1458
1452
|
__tnRegisterValidate("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
|
|
1459
1453
|
__tnRegisterDynamicValidate("Pubkey", (buffer) => {
|
|
1460
1454
|
const result = Pubkey.validate(buffer);
|
|
1461
|
-
|
|
1455
|
+
const params = result.params;
|
|
1456
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1462
1457
|
});
|
|
1463
1458
|
var __tn_ir_Signature = {
|
|
1464
1459
|
typeName: "Signature",
|
|
@@ -1573,7 +1568,8 @@ __tnRegisterFootprint("Signature", (params) => Signature.__tnInvokeFootprint(par
|
|
|
1573
1568
|
__tnRegisterValidate("Signature", (buffer, params) => Signature.__tnInvokeValidate(buffer, params));
|
|
1574
1569
|
__tnRegisterDynamicValidate("Signature", (buffer) => {
|
|
1575
1570
|
const result = Signature.validate(buffer);
|
|
1576
|
-
|
|
1571
|
+
const params = result.params;
|
|
1572
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1577
1573
|
});
|
|
1578
1574
|
var __tn_ir_Timestamp = {
|
|
1579
1575
|
typeName: "Timestamp",
|
|
@@ -1682,7 +1678,8 @@ __tnRegisterFootprint("Timestamp", (params) => Timestamp.__tnInvokeFootprint(par
|
|
|
1682
1678
|
__tnRegisterValidate("Timestamp", (buffer, params) => Timestamp.__tnInvokeValidate(buffer, params));
|
|
1683
1679
|
__tnRegisterDynamicValidate("Timestamp", (buffer) => {
|
|
1684
1680
|
const result = Timestamp.validate(buffer);
|
|
1685
|
-
|
|
1681
|
+
const params = result.params;
|
|
1682
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1686
1683
|
});
|
|
1687
1684
|
|
|
1688
1685
|
// src/passkey-manager/abi/thru/blockchain/state_proof/types.ts
|
|
@@ -2175,13 +2172,15 @@ __tnRegisterFootprint2("Hash", (params) => Hash.__tnInvokeFootprint(params));
|
|
|
2175
2172
|
__tnRegisterValidate2("Hash", (buffer, params) => Hash.__tnInvokeValidate(buffer, params));
|
|
2176
2173
|
__tnRegisterDynamicValidate2("Hash", (buffer) => {
|
|
2177
2174
|
const result = Hash.validate(buffer);
|
|
2178
|
-
|
|
2175
|
+
const params = result.params;
|
|
2176
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2179
2177
|
});
|
|
2180
2178
|
__tnRegisterFootprint2("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
2181
2179
|
__tnRegisterValidate2("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
|
|
2182
2180
|
__tnRegisterDynamicValidate2("Pubkey", (buffer) => {
|
|
2183
2181
|
const result = Pubkey.validate(buffer);
|
|
2184
|
-
|
|
2182
|
+
const params = result.params;
|
|
2183
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2185
2184
|
});
|
|
2186
2185
|
var __tn_ir_StateProofHeader = {
|
|
2187
2186
|
typeName: "StateProofHeader",
|
|
@@ -2305,7 +2304,8 @@ __tnRegisterFootprint2("StateProofHeader", (params) => StateProofHeader.__tnInvo
|
|
|
2305
2304
|
__tnRegisterValidate2("StateProofHeader", (buffer, params) => StateProofHeader.__tnInvokeValidate(buffer, params));
|
|
2306
2305
|
__tnRegisterDynamicValidate2("StateProofHeader", (buffer) => {
|
|
2307
2306
|
const result = StateProofHeader.validate(buffer);
|
|
2308
|
-
|
|
2307
|
+
const params = result.params;
|
|
2308
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2309
2309
|
});
|
|
2310
2310
|
var __tn_ir_StateProof = {
|
|
2311
2311
|
typeName: "StateProof",
|
|
@@ -2988,7 +2988,8 @@ __tnRegisterFootprint2("StateProof", (params) => StateProof.__tnInvokeFootprint(
|
|
|
2988
2988
|
__tnRegisterValidate2("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
2989
2989
|
__tnRegisterDynamicValidate2("StateProof", (buffer) => {
|
|
2990
2990
|
const result = StateProof.validate(buffer);
|
|
2991
|
-
|
|
2991
|
+
const params = result.params;
|
|
2992
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2992
2993
|
});
|
|
2993
2994
|
|
|
2994
2995
|
// src/passkey-manager/abi/thru/program/passkey_manager/types.ts
|
|
@@ -3076,6 +3077,33 @@ function __tnCreateVariantSelector2(parent, descriptors, assign) {
|
|
|
3076
3077
|
}
|
|
3077
3078
|
};
|
|
3078
3079
|
}
|
|
3080
|
+
function __tnCreateFamWriter2(parent, fieldName, assign) {
|
|
3081
|
+
let hasWritten = false;
|
|
3082
|
+
return {
|
|
3083
|
+
write(payload) {
|
|
3084
|
+
const bytes = __tnResolveBuilderInput3(
|
|
3085
|
+
payload,
|
|
3086
|
+
`flexible array '${fieldName}'`
|
|
3087
|
+
);
|
|
3088
|
+
const copy = new Uint8Array(bytes);
|
|
3089
|
+
assign(copy);
|
|
3090
|
+
hasWritten = true;
|
|
3091
|
+
return {
|
|
3092
|
+
finish() {
|
|
3093
|
+
return parent;
|
|
3094
|
+
}
|
|
3095
|
+
};
|
|
3096
|
+
},
|
|
3097
|
+
finish() {
|
|
3098
|
+
if (!hasWritten) {
|
|
3099
|
+
throw new Error(
|
|
3100
|
+
`flexible array '${fieldName}' requires write() before finish()`
|
|
3101
|
+
);
|
|
3102
|
+
}
|
|
3103
|
+
return parent;
|
|
3104
|
+
}
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3079
3107
|
var __tnMask323 = __tnHasNativeBigInt3 ? (BigInt(1) << BigInt(32)) - BigInt(1) : 4294967295;
|
|
3080
3108
|
var __tnSignBit323 = __tnHasNativeBigInt3 ? BigInt(1) << BigInt(31) : 2147483648;
|
|
3081
3109
|
function __tnToBigInt3(value) {
|
|
@@ -3499,19 +3527,22 @@ __tnRegisterFootprint3("InstructionData", (params) => InstructionData.__tnInvoke
|
|
|
3499
3527
|
__tnRegisterValidate3("InstructionData", (buffer, params) => InstructionData.__tnInvokeValidate(buffer, params));
|
|
3500
3528
|
__tnRegisterDynamicValidate3("InstructionData", (buffer) => {
|
|
3501
3529
|
const result = InstructionData.validate(buffer);
|
|
3502
|
-
|
|
3530
|
+
const params = result.params;
|
|
3531
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3503
3532
|
});
|
|
3504
3533
|
__tnRegisterFootprint3("Pubkey", (params) => Pubkey.__tnInvokeFootprint(params));
|
|
3505
3534
|
__tnRegisterValidate3("Pubkey", (buffer, params) => Pubkey.__tnInvokeValidate(buffer, params));
|
|
3506
3535
|
__tnRegisterDynamicValidate3("Pubkey", (buffer) => {
|
|
3507
3536
|
const result = Pubkey.validate(buffer);
|
|
3508
|
-
|
|
3537
|
+
const params = result.params;
|
|
3538
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3509
3539
|
});
|
|
3510
3540
|
__tnRegisterFootprint3("StateProof", (params) => StateProof.__tnInvokeFootprint(params));
|
|
3511
3541
|
__tnRegisterValidate3("StateProof", (buffer, params) => StateProof.__tnInvokeValidate(buffer, params));
|
|
3512
3542
|
__tnRegisterDynamicValidate3("StateProof", (buffer) => {
|
|
3513
3543
|
const result = StateProof.validate(buffer);
|
|
3514
|
-
|
|
3544
|
+
const params = result.params;
|
|
3545
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3515
3546
|
});
|
|
3516
3547
|
var __tn_ir_Authority = {
|
|
3517
3548
|
typeName: "Authority",
|
|
@@ -3644,6 +3675,131 @@ __tnRegisterFootprint3("Authority", (params) => Authority.__tnInvokeFootprint(pa
|
|
|
3644
3675
|
__tnRegisterValidate3("Authority", (buffer, params) => Authority.__tnInvokeValidate(buffer, params));
|
|
3645
3676
|
__tnRegisterDynamicValidate3("Authority", (buffer) => {
|
|
3646
3677
|
const result = Authority.validate(buffer);
|
|
3678
|
+
const params = result.params;
|
|
3679
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3680
|
+
});
|
|
3681
|
+
var __tn_ir_AuthorityRecord = {
|
|
3682
|
+
typeName: "AuthorityRecord",
|
|
3683
|
+
root: { op: "const", value: 73n }
|
|
3684
|
+
};
|
|
3685
|
+
var AuthorityRecord = class _AuthorityRecord {
|
|
3686
|
+
constructor(buffer) {
|
|
3687
|
+
this.buffer = buffer;
|
|
3688
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3689
|
+
}
|
|
3690
|
+
static __tnCreateView(buffer, opts) {
|
|
3691
|
+
if (!buffer || buffer.length === void 0) throw new Error("AuthorityRecord.__tnCreateView requires a Uint8Array");
|
|
3692
|
+
return new _AuthorityRecord(new Uint8Array(buffer));
|
|
3693
|
+
}
|
|
3694
|
+
static builder() {
|
|
3695
|
+
return new AuthorityRecordBuilder();
|
|
3696
|
+
}
|
|
3697
|
+
static fromBuilder(builder) {
|
|
3698
|
+
const buffer = builder.build();
|
|
3699
|
+
return _AuthorityRecord.from_array(buffer);
|
|
3700
|
+
}
|
|
3701
|
+
get_authority() {
|
|
3702
|
+
const offset = 0;
|
|
3703
|
+
const slice = this.buffer.subarray(offset, offset + 65);
|
|
3704
|
+
return Authority.from_array(slice);
|
|
3705
|
+
}
|
|
3706
|
+
set_authority(value) {
|
|
3707
|
+
const sourceBytes = value.buffer;
|
|
3708
|
+
const offset = 0;
|
|
3709
|
+
this.buffer.set(sourceBytes, offset);
|
|
3710
|
+
}
|
|
3711
|
+
get authority() {
|
|
3712
|
+
return this.get_authority();
|
|
3713
|
+
}
|
|
3714
|
+
set authority(value) {
|
|
3715
|
+
this.set_authority(value);
|
|
3716
|
+
}
|
|
3717
|
+
get_expires_at_block_time_seconds() {
|
|
3718
|
+
const offset = 65;
|
|
3719
|
+
return this.view.getBigUint64(offset, true);
|
|
3720
|
+
}
|
|
3721
|
+
set_expires_at_block_time_seconds(value) {
|
|
3722
|
+
const offset = 65;
|
|
3723
|
+
this.view.setBigUint64(offset, value, true);
|
|
3724
|
+
}
|
|
3725
|
+
get expires_at_block_time_seconds() {
|
|
3726
|
+
return this.get_expires_at_block_time_seconds();
|
|
3727
|
+
}
|
|
3728
|
+
set expires_at_block_time_seconds(value) {
|
|
3729
|
+
this.set_expires_at_block_time_seconds(value);
|
|
3730
|
+
}
|
|
3731
|
+
static __tnFootprintInternal(__tnParams) {
|
|
3732
|
+
return __tnEvalFootprint3(__tn_ir_AuthorityRecord.root, { params: __tnParams });
|
|
3733
|
+
}
|
|
3734
|
+
static __tnValidateInternal(buffer, __tnParams) {
|
|
3735
|
+
return __tnValidateIrTree3(__tn_ir_AuthorityRecord, buffer, __tnParams);
|
|
3736
|
+
}
|
|
3737
|
+
static __tnInvokeFootprint(__tnParams) {
|
|
3738
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
3739
|
+
}
|
|
3740
|
+
static __tnInvokeValidate(buffer, __tnParams) {
|
|
3741
|
+
return this.__tnValidateInternal(buffer, __tnParams);
|
|
3742
|
+
}
|
|
3743
|
+
static footprintIr() {
|
|
3744
|
+
return this.__tnFootprintInternal(/* @__PURE__ */ Object.create(null));
|
|
3745
|
+
}
|
|
3746
|
+
static footprint() {
|
|
3747
|
+
const irResult = this.footprintIr();
|
|
3748
|
+
const maxSafe = __tnToBigInt3(Number.MAX_SAFE_INTEGER);
|
|
3749
|
+
if (__tnBigIntGreaterThan3(irResult, maxSafe)) {
|
|
3750
|
+
throw new Error("footprint exceeds Number.MAX_SAFE_INTEGER for AuthorityRecord");
|
|
3751
|
+
}
|
|
3752
|
+
return __tnBigIntToNumber3(irResult, "AuthorityRecord::footprint");
|
|
3753
|
+
}
|
|
3754
|
+
static validate(buffer, _opts) {
|
|
3755
|
+
if (buffer.length < 73) return { ok: false, code: "tn.buffer_too_small", consumed: 73 };
|
|
3756
|
+
return { ok: true, consumed: 73 };
|
|
3757
|
+
}
|
|
3758
|
+
static from_array(buffer) {
|
|
3759
|
+
if (!buffer || buffer.length === void 0) {
|
|
3760
|
+
return null;
|
|
3761
|
+
}
|
|
3762
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
3763
|
+
const validation = this.validate(buffer);
|
|
3764
|
+
if (!validation.ok) {
|
|
3765
|
+
return null;
|
|
3766
|
+
}
|
|
3767
|
+
return new _AuthorityRecord(buffer);
|
|
3768
|
+
}
|
|
3769
|
+
};
|
|
3770
|
+
var AuthorityRecordBuilder = class {
|
|
3771
|
+
constructor() {
|
|
3772
|
+
this.buffer = new Uint8Array(73);
|
|
3773
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
3774
|
+
}
|
|
3775
|
+
set_authority(value) {
|
|
3776
|
+
if (value.length !== 65) throw new Error("authority expects 65 bytes");
|
|
3777
|
+
this.buffer.set(value, 0);
|
|
3778
|
+
return this;
|
|
3779
|
+
}
|
|
3780
|
+
set_expires_at_block_time_seconds(value) {
|
|
3781
|
+
const cast = __tnToBigInt3(value);
|
|
3782
|
+
this.view.setBigUint64(65, cast, true);
|
|
3783
|
+
return this;
|
|
3784
|
+
}
|
|
3785
|
+
build() {
|
|
3786
|
+
return this.buffer.slice();
|
|
3787
|
+
}
|
|
3788
|
+
buildInto(target, offset = 0) {
|
|
3789
|
+
if (target.length - offset < this.buffer.length) throw new Error("target buffer too small");
|
|
3790
|
+
target.set(this.buffer, offset);
|
|
3791
|
+
return target;
|
|
3792
|
+
}
|
|
3793
|
+
finish() {
|
|
3794
|
+
const view = AuthorityRecord.from_array(this.buffer.slice());
|
|
3795
|
+
if (!view) throw new Error("failed to build AuthorityRecord");
|
|
3796
|
+
return view;
|
|
3797
|
+
}
|
|
3798
|
+
};
|
|
3799
|
+
__tnRegisterFootprint3("AuthorityRecord", (params) => AuthorityRecord.__tnInvokeFootprint(params));
|
|
3800
|
+
__tnRegisterValidate3("AuthorityRecord", (buffer, params) => AuthorityRecord.__tnInvokeValidate(buffer, params));
|
|
3801
|
+
__tnRegisterDynamicValidate3("AuthorityRecord", (buffer) => {
|
|
3802
|
+
const result = AuthorityRecord.validate(buffer);
|
|
3647
3803
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed) };
|
|
3648
3804
|
});
|
|
3649
3805
|
var __tn_ir_P256Point = {
|
|
@@ -3729,7 +3885,8 @@ __tnRegisterFootprint3("P256Point", (params) => P256Point.__tnInvokeFootprint(pa
|
|
|
3729
3885
|
__tnRegisterValidate3("P256Point", (buffer, params) => P256Point.__tnInvokeValidate(buffer, params));
|
|
3730
3886
|
__tnRegisterDynamicValidate3("P256Point", (buffer) => {
|
|
3731
3887
|
const result = P256Point.validate(buffer);
|
|
3732
|
-
|
|
3888
|
+
const params = result.params;
|
|
3889
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3733
3890
|
});
|
|
3734
3891
|
var __tn_ir_RemoveAuthorityArgs = {
|
|
3735
3892
|
typeName: "RemoveAuthorityArgs",
|
|
@@ -3856,7 +4013,8 @@ __tnRegisterFootprint3("RemoveAuthorityArgs", (params) => RemoveAuthorityArgs.__
|
|
|
3856
4013
|
__tnRegisterValidate3("RemoveAuthorityArgs", (buffer, params) => RemoveAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
3857
4014
|
__tnRegisterDynamicValidate3("RemoveAuthorityArgs", (buffer) => {
|
|
3858
4015
|
const result = RemoveAuthorityArgs.validate(buffer);
|
|
3859
|
-
|
|
4016
|
+
const params = result.params;
|
|
4017
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3860
4018
|
});
|
|
3861
4019
|
var __tn_ir_Seed32 = {
|
|
3862
4020
|
typeName: "Seed32",
|
|
@@ -3941,7 +4099,8 @@ __tnRegisterFootprint3("Seed32", (params) => Seed32.__tnInvokeFootprint(params))
|
|
|
3941
4099
|
__tnRegisterValidate3("Seed32", (buffer, params) => Seed32.__tnInvokeValidate(buffer, params));
|
|
3942
4100
|
__tnRegisterDynamicValidate3("Seed32", (buffer) => {
|
|
3943
4101
|
const result = Seed32.validate(buffer);
|
|
3944
|
-
|
|
4102
|
+
const params = result.params;
|
|
4103
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
3945
4104
|
});
|
|
3946
4105
|
var __tn_ir_TransferArgs = {
|
|
3947
4106
|
typeName: "TransferArgs",
|
|
@@ -4088,7 +4247,8 @@ __tnRegisterFootprint3("TransferArgs", (params) => TransferArgs.__tnInvokeFootpr
|
|
|
4088
4247
|
__tnRegisterValidate3("TransferArgs", (buffer, params) => TransferArgs.__tnInvokeValidate(buffer, params));
|
|
4089
4248
|
__tnRegisterDynamicValidate3("TransferArgs", (buffer) => {
|
|
4090
4249
|
const result = TransferArgs.validate(buffer);
|
|
4091
|
-
|
|
4250
|
+
const params = result.params;
|
|
4251
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4092
4252
|
});
|
|
4093
4253
|
var __tn_ir_ValidateArgs = {
|
|
4094
4254
|
typeName: "ValidateArgs",
|
|
@@ -4144,9 +4304,18 @@ var _ValidateArgs = class _ValidateArgs {
|
|
|
4144
4304
|
}
|
|
4145
4305
|
throw new Error("ValidateArgs: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
4146
4306
|
}
|
|
4307
|
+
static builder() {
|
|
4308
|
+
return new ValidateArgsBuilder();
|
|
4309
|
+
}
|
|
4310
|
+
static fromBuilder(builder) {
|
|
4311
|
+
const buffer = builder.build();
|
|
4312
|
+
const params = builder.dynamicParams();
|
|
4313
|
+
return _ValidateArgs.from_array(buffer, { params });
|
|
4314
|
+
}
|
|
4147
4315
|
static __tnComputeSequentialLayout(view, buffer) {
|
|
4148
4316
|
const offsets = /* @__PURE__ */ Object.create(null);
|
|
4149
4317
|
const __tnLength = buffer.length;
|
|
4318
|
+
let __tnParamSeq_data_data_size = null;
|
|
4150
4319
|
let __tnFieldValue_authenticator_data_len = null;
|
|
4151
4320
|
let __tnFieldValue_client_data_len = null;
|
|
4152
4321
|
let __tnCursorMutable = 0;
|
|
@@ -4181,7 +4350,17 @@ var _ValidateArgs = class _ValidateArgs {
|
|
|
4181
4350
|
offsets["client_data"] = __tnCursorMutable;
|
|
4182
4351
|
if (__tnCursorMutable + __tnArrayBytes_client_data > __tnLength) return null;
|
|
4183
4352
|
__tnCursorMutable += __tnArrayBytes_client_data;
|
|
4184
|
-
|
|
4353
|
+
offsets["target_instruction"] = __tnCursorMutable;
|
|
4354
|
+
const __tnTyperefResult_target_instruction = __tnInvokeDynamicValidate3("InstructionData", buffer.subarray(__tnCursorMutable));
|
|
4355
|
+
if (!__tnTyperefResult_target_instruction.ok || __tnTyperefResult_target_instruction.consumed === void 0) return null;
|
|
4356
|
+
const __tnTyperefParams_target_instruction = __tnTyperefResult_target_instruction.params ?? null;
|
|
4357
|
+
if (!__tnTyperefParams_target_instruction || __tnTyperefParams_target_instruction["data_data_size"] === void 0) return null;
|
|
4358
|
+
__tnParamSeq_data_data_size = __tnTyperefParams_target_instruction["data_data_size"];
|
|
4359
|
+
__tnCursorMutable += __tnBigIntToNumber3(__tnTyperefResult_target_instruction.consumed, "ValidateArgs::target_instruction");
|
|
4360
|
+
const params = /* @__PURE__ */ Object.create(null);
|
|
4361
|
+
if (__tnParamSeq_data_data_size === null) return null;
|
|
4362
|
+
params["data_data_size"] = __tnParamSeq_data_data_size;
|
|
4363
|
+
return { params, offsets, derived: null };
|
|
4185
4364
|
}
|
|
4186
4365
|
static __tnExtractParams(view, buffer) {
|
|
4187
4366
|
if (buffer.length < 69) {
|
|
@@ -4192,9 +4371,15 @@ var _ValidateArgs = class _ValidateArgs {
|
|
|
4192
4371
|
return null;
|
|
4193
4372
|
}
|
|
4194
4373
|
const __tnParam_client_data_client_data_len = __tnToBigInt3(view.getUint16(69, true));
|
|
4374
|
+
const __tnLayout = _ValidateArgs.__tnComputeSequentialLayout(view, buffer);
|
|
4375
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
4376
|
+
const __tnSeqParams = __tnLayout.params;
|
|
4377
|
+
const __tnParamSeq_data_data_size = __tnSeqParams["data_data_size"];
|
|
4378
|
+
if (__tnParamSeq_data_data_size === void 0) return null;
|
|
4195
4379
|
const __tnExtractedParams = _ValidateArgs.Params.fromValues({
|
|
4196
4380
|
authenticator_data_authenticator_data_len: __tnParam_authenticator_data_authenticator_data_len,
|
|
4197
|
-
client_data_client_data_len: __tnParam_client_data_client_data_len
|
|
4381
|
+
client_data_client_data_len: __tnParam_client_data_client_data_len,
|
|
4382
|
+
data_data_size: __tnParamSeq_data_data_size
|
|
4198
4383
|
});
|
|
4199
4384
|
return { params: __tnExtractedParams, derived: null };
|
|
4200
4385
|
}
|
|
@@ -4400,10 +4585,11 @@ var _ValidateArgs = class _ValidateArgs {
|
|
|
4400
4585
|
static __tnInvokeValidate(buffer, __tnParams) {
|
|
4401
4586
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
4402
4587
|
}
|
|
4403
|
-
static footprintIr(authenticator_data_authenticator_data_len, client_data_client_data_len) {
|
|
4588
|
+
static footprintIr(authenticator_data_authenticator_data_len, client_data_client_data_len, data_data_size) {
|
|
4404
4589
|
const params = _ValidateArgs.Params.fromValues({
|
|
4405
4590
|
authenticator_data_authenticator_data_len,
|
|
4406
|
-
client_data_client_data_len
|
|
4591
|
+
client_data_client_data_len,
|
|
4592
|
+
data_data_size
|
|
4407
4593
|
});
|
|
4408
4594
|
return this.footprintIrFromParams(params);
|
|
4409
4595
|
}
|
|
@@ -4411,6 +4597,7 @@ var _ValidateArgs = class _ValidateArgs {
|
|
|
4411
4597
|
const record = /* @__PURE__ */ Object.create(null);
|
|
4412
4598
|
record["authenticator_data.authenticator_data_len"] = params.authenticator_data_authenticator_data_len;
|
|
4413
4599
|
record["client_data.client_data_len"] = params.client_data_client_data_len;
|
|
4600
|
+
record["data.data_size"] = params.data_data_size;
|
|
4414
4601
|
return record;
|
|
4415
4602
|
}
|
|
4416
4603
|
static footprintIrFromParams(params) {
|
|
@@ -4477,13 +4664,15 @@ var ValidateArgs = _ValidateArgs;
|
|
|
4477
4664
|
((ValidateArgs2) => {
|
|
4478
4665
|
ValidateArgs2.ParamKeys = Object.freeze({
|
|
4479
4666
|
authenticator_data_authenticator_data_len: "authenticator_data.authenticator_data_len",
|
|
4480
|
-
client_data_client_data_len: "client_data.client_data_len"
|
|
4667
|
+
client_data_client_data_len: "client_data.client_data_len",
|
|
4668
|
+
data_data_size: "data.data_size"
|
|
4481
4669
|
});
|
|
4482
4670
|
ValidateArgs2.Params = {
|
|
4483
4671
|
fromValues(input) {
|
|
4484
4672
|
return {
|
|
4485
4673
|
authenticator_data_authenticator_data_len: __tnToBigInt3(input.authenticator_data_authenticator_data_len),
|
|
4486
|
-
client_data_client_data_len: __tnToBigInt3(input.client_data_client_data_len)
|
|
4674
|
+
client_data_client_data_len: __tnToBigInt3(input.client_data_client_data_len),
|
|
4675
|
+
data_data_size: __tnToBigInt3(input.data_data_size)
|
|
4487
4676
|
};
|
|
4488
4677
|
},
|
|
4489
4678
|
fromBuilder(source) {
|
|
@@ -4501,139 +4690,408 @@ var ValidateArgs = _ValidateArgs;
|
|
|
4501
4690
|
}
|
|
4502
4691
|
ValidateArgs2.params = params;
|
|
4503
4692
|
})(ValidateArgs || (ValidateArgs = {}));
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
this.
|
|
4517
|
-
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4693
|
+
var ValidateArgsBuilder = class {
|
|
4694
|
+
constructor() {
|
|
4695
|
+
this.__tnCachedParams = null;
|
|
4696
|
+
this.__tnLastBuffer = null;
|
|
4697
|
+
this.__tnLastParams = null;
|
|
4698
|
+
this.__tnFam_authenticator_data = null;
|
|
4699
|
+
this.__tnFam_authenticator_dataCount = null;
|
|
4700
|
+
this.__tnFam_client_data = null;
|
|
4701
|
+
this.__tnFam_client_dataCount = null;
|
|
4702
|
+
this.__tnTail_target_instruction = null;
|
|
4703
|
+
this.__tnTailParams_target_instruction = null;
|
|
4704
|
+
this.buffer = new Uint8Array(71);
|
|
4705
|
+
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
4518
4706
|
}
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4707
|
+
__tnInvalidate() {
|
|
4708
|
+
this.__tnCachedParams = null;
|
|
4709
|
+
this.__tnLastBuffer = null;
|
|
4710
|
+
this.__tnLastParams = null;
|
|
4522
4711
|
}
|
|
4523
|
-
|
|
4524
|
-
|
|
4712
|
+
set_wallet_account_idx(value) {
|
|
4713
|
+
this.view.setUint16(0, value, true);
|
|
4714
|
+
this.__tnInvalidate();
|
|
4715
|
+
return this;
|
|
4525
4716
|
}
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4717
|
+
set_auth_idx(value) {
|
|
4718
|
+
this.view.setUint8(2, value);
|
|
4719
|
+
this.__tnInvalidate();
|
|
4720
|
+
return this;
|
|
4529
4721
|
}
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4722
|
+
set_signature_r(value) {
|
|
4723
|
+
if (value.length !== 32) throw new Error("signature_r expects 32 bytes");
|
|
4724
|
+
this.buffer.set(value, 3);
|
|
4725
|
+
this.__tnInvalidate();
|
|
4726
|
+
return this;
|
|
4533
4727
|
}
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
this.
|
|
4728
|
+
set_signature_s(value) {
|
|
4729
|
+
if (value.length !== 32) throw new Error("signature_s expects 32 bytes");
|
|
4730
|
+
this.buffer.set(value, 35);
|
|
4731
|
+
this.__tnInvalidate();
|
|
4732
|
+
return this;
|
|
4537
4733
|
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4734
|
+
set_authenticator_data_len(value) {
|
|
4735
|
+
this.view.setUint16(67, value, true);
|
|
4736
|
+
this.__tnInvalidate();
|
|
4737
|
+
return this;
|
|
4540
4738
|
}
|
|
4541
|
-
|
|
4542
|
-
this.
|
|
4739
|
+
set_client_data_len(value) {
|
|
4740
|
+
this.view.setUint16(69, value, true);
|
|
4741
|
+
this.__tnInvalidate();
|
|
4742
|
+
return this;
|
|
4543
4743
|
}
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4744
|
+
authenticator_data() {
|
|
4745
|
+
if (!this.__tnFamWriter_authenticator_data) {
|
|
4746
|
+
this.__tnFamWriter_authenticator_data = __tnCreateFamWriter2(this, "authenticator_data", (payload) => {
|
|
4747
|
+
const bytes = new Uint8Array(payload);
|
|
4748
|
+
const elementCount = bytes.length;
|
|
4749
|
+
this.__tnFam_authenticator_data = bytes;
|
|
4750
|
+
this.__tnFam_authenticator_dataCount = elementCount;
|
|
4751
|
+
this.set_authenticator_data_len(elementCount);
|
|
4752
|
+
this.__tnInvalidate();
|
|
4753
|
+
});
|
|
4754
|
+
}
|
|
4755
|
+
return this.__tnFamWriter_authenticator_data;
|
|
4547
4756
|
}
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4757
|
+
client_data() {
|
|
4758
|
+
if (!this.__tnFamWriter_client_data) {
|
|
4759
|
+
this.__tnFamWriter_client_data = __tnCreateFamWriter2(this, "client_data", (payload) => {
|
|
4760
|
+
const bytes = new Uint8Array(payload);
|
|
4761
|
+
const elementCount = bytes.length;
|
|
4762
|
+
this.__tnFam_client_data = bytes;
|
|
4763
|
+
this.__tnFam_client_dataCount = elementCount;
|
|
4764
|
+
this.set_client_data_len(elementCount);
|
|
4765
|
+
this.__tnInvalidate();
|
|
4766
|
+
});
|
|
4767
|
+
}
|
|
4768
|
+
return this.__tnFamWriter_client_data;
|
|
4551
4769
|
}
|
|
4552
|
-
|
|
4553
|
-
|
|
4770
|
+
set_target_instruction(value) {
|
|
4771
|
+
const bytes = __tnResolveStructFieldInput(value, "ValidateArgsBuilder::target_instruction");
|
|
4772
|
+
const validation = __tnInvokeDynamicValidate3("InstructionData", bytes);
|
|
4773
|
+
if (!validation.ok || validation.consumed === void 0) throw new Error("ValidateArgsBuilder: field 'target_instruction' failed validation");
|
|
4774
|
+
if (__tnBigIntToNumber3(validation.consumed, "ValidateArgsBuilder::target_instruction") !== bytes.length) throw new Error("ValidateArgsBuilder: field 'target_instruction' validation did not consume the full buffer");
|
|
4775
|
+
this.__tnTail_target_instruction = bytes;
|
|
4776
|
+
this.__tnTailParams_target_instruction = validation.params ?? null;
|
|
4777
|
+
this.__tnInvalidate();
|
|
4778
|
+
return this;
|
|
4554
4779
|
}
|
|
4555
|
-
|
|
4556
|
-
this.
|
|
4780
|
+
build() {
|
|
4781
|
+
const params = this.__tnComputeParams();
|
|
4782
|
+
const size = ValidateArgs.footprintFromParams(params);
|
|
4783
|
+
const buffer = new Uint8Array(size);
|
|
4784
|
+
this.__tnWriteInto(buffer);
|
|
4785
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
4786
|
+
return buffer;
|
|
4557
4787
|
}
|
|
4558
|
-
|
|
4559
|
-
|
|
4788
|
+
buildInto(target, offset = 0) {
|
|
4789
|
+
const params = this.__tnComputeParams();
|
|
4790
|
+
const size = ValidateArgs.footprintFromParams(params);
|
|
4791
|
+
if (target.length - offset < size) throw new Error("ValidateArgsBuilder: target buffer too small");
|
|
4792
|
+
const slice = target.subarray(offset, offset + size);
|
|
4793
|
+
this.__tnWriteInto(slice);
|
|
4794
|
+
this.__tnValidateOrThrow(slice, params);
|
|
4795
|
+
return target;
|
|
4560
4796
|
}
|
|
4561
|
-
|
|
4562
|
-
|
|
4797
|
+
finish() {
|
|
4798
|
+
const buffer = this.build();
|
|
4799
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
4800
|
+
const view = ValidateArgs.from_array(buffer, { params });
|
|
4801
|
+
if (!view) throw new Error("ValidateArgsBuilder: failed to finalize view");
|
|
4802
|
+
return view;
|
|
4563
4803
|
}
|
|
4564
|
-
|
|
4565
|
-
return this.
|
|
4804
|
+
finishView() {
|
|
4805
|
+
return this.finish();
|
|
4566
4806
|
}
|
|
4567
|
-
|
|
4568
|
-
return this.
|
|
4807
|
+
dynamicParams() {
|
|
4808
|
+
return this.__tnComputeParams();
|
|
4569
4809
|
}
|
|
4570
|
-
|
|
4571
|
-
|
|
4810
|
+
__tnComputeParams() {
|
|
4811
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
4812
|
+
const params = ValidateArgs.Params.fromValues({
|
|
4813
|
+
authenticator_data_authenticator_data_len: (() => {
|
|
4814
|
+
if (this.__tnFam_authenticator_dataCount === null) throw new Error("ValidateArgsBuilder: field 'authenticator_data' must be written before computing params");
|
|
4815
|
+
return __tnToBigInt3(this.__tnFam_authenticator_dataCount);
|
|
4816
|
+
})(),
|
|
4817
|
+
client_data_client_data_len: (() => {
|
|
4818
|
+
if (this.__tnFam_client_dataCount === null) throw new Error("ValidateArgsBuilder: field 'client_data' must be written before computing params");
|
|
4819
|
+
return __tnToBigInt3(this.__tnFam_client_dataCount);
|
|
4820
|
+
})(),
|
|
4821
|
+
data_data_size: (() => {
|
|
4822
|
+
const params2 = this.__tnTailParams_target_instruction;
|
|
4823
|
+
if (!params2 || params2["data_data_size"] === void 0) throw new Error("ValidateArgsBuilder: field 'target_instruction' must be written before computing params");
|
|
4824
|
+
return params2["data_data_size"];
|
|
4825
|
+
})()
|
|
4826
|
+
});
|
|
4827
|
+
this.__tnCachedParams = params;
|
|
4828
|
+
return params;
|
|
4572
4829
|
}
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4830
|
+
__tnWriteInto(target) {
|
|
4831
|
+
target.set(this.buffer, 0);
|
|
4832
|
+
let cursor = this.buffer.length;
|
|
4833
|
+
const __tnLocal_authenticator_data_bytes = this.__tnFam_authenticator_data;
|
|
4834
|
+
if (!__tnLocal_authenticator_data_bytes) throw new Error("ValidateArgsBuilder: field 'authenticator_data' must be written before build");
|
|
4835
|
+
target.set(__tnLocal_authenticator_data_bytes, cursor);
|
|
4836
|
+
cursor += __tnLocal_authenticator_data_bytes.length;
|
|
4837
|
+
const __tnLocal_client_data_bytes = this.__tnFam_client_data;
|
|
4838
|
+
if (!__tnLocal_client_data_bytes) throw new Error("ValidateArgsBuilder: field 'client_data' must be written before build");
|
|
4839
|
+
target.set(__tnLocal_client_data_bytes, cursor);
|
|
4840
|
+
cursor += __tnLocal_client_data_bytes.length;
|
|
4841
|
+
const __tnLocal_target_instruction_bytes = this.__tnTail_target_instruction;
|
|
4842
|
+
if (!__tnLocal_target_instruction_bytes) throw new Error("ValidateArgsBuilder: field 'target_instruction' must be written before build");
|
|
4843
|
+
target.set(__tnLocal_target_instruction_bytes, cursor);
|
|
4844
|
+
cursor += __tnLocal_target_instruction_bytes.length;
|
|
4845
|
+
}
|
|
4846
|
+
__tnValidateOrThrow(buffer, params) {
|
|
4847
|
+
const result = ValidateArgs.validate(buffer, { params });
|
|
4848
|
+
if (!result.ok) {
|
|
4849
|
+
throw new Error(`${ValidateArgs}Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
4578
4850
|
}
|
|
4579
|
-
|
|
4851
|
+
this.__tnLastParams = result.params ?? params;
|
|
4852
|
+
this.__tnLastBuffer = buffer;
|
|
4580
4853
|
}
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4854
|
+
};
|
|
4855
|
+
__tnRegisterFootprint3("ValidateArgs", (params) => ValidateArgs.__tnInvokeFootprint(params));
|
|
4856
|
+
__tnRegisterValidate3("ValidateArgs", (buffer, params) => ValidateArgs.__tnInvokeValidate(buffer, params));
|
|
4857
|
+
__tnRegisterDynamicValidate3("ValidateArgs", (buffer) => {
|
|
4858
|
+
const result = ValidateArgs.validate(buffer);
|
|
4859
|
+
const params = result.params;
|
|
4860
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4861
|
+
});
|
|
4862
|
+
var __tn_ir_WalletAccount = {
|
|
4863
|
+
typeName: "WalletAccount",
|
|
4864
|
+
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "align", alignment: 1, node: { op: "const", value: 1n } }, right: { op: "align", alignment: 8, node: { op: "const", value: 8n } } }, right: { op: "align", alignment: 1, node: { op: "mul", left: { op: "add", left: { op: "field", param: "authorities.num_auth" }, right: { op: "const", value: 1n } }, right: { op: "const", value: 73n } } } } }
|
|
4865
|
+
};
|
|
4866
|
+
var WalletAccount = class _WalletAccount {
|
|
4867
|
+
constructor(buffer, params, fieldContext) {
|
|
4868
|
+
this.buffer = buffer;
|
|
4869
|
+
this.__tnFieldContext = null;
|
|
4870
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4871
|
+
this.__tnFieldContext = fieldContext ?? null;
|
|
4872
|
+
if (params) {
|
|
4873
|
+
this.__tnParams = params;
|
|
4874
|
+
} else {
|
|
4875
|
+
const derived = _WalletAccount.__tnExtractParams(this.view, buffer);
|
|
4876
|
+
if (!derived) {
|
|
4877
|
+
throw new Error("WalletAccount: failed to derive dynamic parameters");
|
|
4878
|
+
}
|
|
4879
|
+
this.__tnParams = derived.params;
|
|
4880
|
+
}
|
|
4584
4881
|
}
|
|
4585
|
-
static
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4882
|
+
static __tnCreateView(buffer, opts) {
|
|
4883
|
+
if (!buffer || buffer.length === void 0) throw new Error("WalletAccount.__tnCreateView requires a Uint8Array");
|
|
4884
|
+
let params = opts?.params ?? null;
|
|
4885
|
+
if (!params) {
|
|
4886
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
4887
|
+
const derived = _WalletAccount.__tnExtractParams(view, buffer);
|
|
4888
|
+
if (!derived) throw new Error("WalletAccount.__tnCreateView: failed to derive params");
|
|
4889
|
+
params = derived.params;
|
|
4890
|
+
}
|
|
4891
|
+
const instance = new _WalletAccount(new Uint8Array(buffer), params, opts?.fieldContext);
|
|
4892
|
+
return instance;
|
|
4591
4893
|
}
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4894
|
+
dynamicParams() {
|
|
4895
|
+
return this.__tnParams;
|
|
4896
|
+
}
|
|
4897
|
+
withFieldContext(context) {
|
|
4898
|
+
this.__tnFieldContext = context;
|
|
4899
|
+
return this;
|
|
4900
|
+
}
|
|
4901
|
+
__tnResolveFieldRef(path) {
|
|
4902
|
+
const getterName = `get_${path.replace(/[.]/g, "_")}`;
|
|
4903
|
+
const getter = this[getterName];
|
|
4904
|
+
if (typeof getter === "function") {
|
|
4905
|
+
const value = getter.call(this);
|
|
4906
|
+
return typeof value === "bigint" ? __tnBigIntToNumber3(value, "WalletAccount::__tnResolveFieldRef") : value;
|
|
4595
4907
|
}
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4908
|
+
if (this.__tnFieldContext && Object.prototype.hasOwnProperty.call(this.__tnFieldContext, path)) {
|
|
4909
|
+
const contextValue = this.__tnFieldContext[path];
|
|
4910
|
+
return typeof contextValue === "bigint" ? __tnBigIntToNumber3(contextValue, "WalletAccount::__tnResolveFieldRef") : contextValue;
|
|
4911
|
+
}
|
|
4912
|
+
throw new Error("WalletAccount: field reference '" + path + "' is not available; provide fieldContext when creating this view");
|
|
4913
|
+
}
|
|
4914
|
+
static __tnExtractParams(view, buffer) {
|
|
4915
|
+
if (buffer.length < 1) {
|
|
4599
4916
|
return null;
|
|
4600
4917
|
}
|
|
4601
|
-
|
|
4918
|
+
const __tnParam_authorities_num_auth = __tnToBigInt3(view.getUint8(0));
|
|
4919
|
+
const __tnExtractedParams = _WalletAccount.Params.fromValues({
|
|
4920
|
+
authorities_num_auth: __tnParam_authorities_num_auth
|
|
4921
|
+
});
|
|
4922
|
+
return { params: __tnExtractedParams, derived: null };
|
|
4602
4923
|
}
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
this.buffer = new Uint8Array(9);
|
|
4607
|
-
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
4924
|
+
get_num_auth() {
|
|
4925
|
+
const offset = 0;
|
|
4926
|
+
return this.view.getUint8(offset);
|
|
4608
4927
|
}
|
|
4609
4928
|
set_num_auth(value) {
|
|
4610
|
-
|
|
4611
|
-
|
|
4929
|
+
const offset = 0;
|
|
4930
|
+
this.view.setUint8(offset, value);
|
|
4931
|
+
}
|
|
4932
|
+
get num_auth() {
|
|
4933
|
+
return this.get_num_auth();
|
|
4934
|
+
}
|
|
4935
|
+
set num_auth(value) {
|
|
4936
|
+
this.set_num_auth(value);
|
|
4937
|
+
}
|
|
4938
|
+
get_nonce() {
|
|
4939
|
+
const offset = 1;
|
|
4940
|
+
return this.view.getBigUint64(offset, true);
|
|
4612
4941
|
}
|
|
4613
4942
|
set_nonce(value) {
|
|
4614
|
-
const
|
|
4615
|
-
this.view.setBigUint64(
|
|
4616
|
-
return this;
|
|
4943
|
+
const offset = 1;
|
|
4944
|
+
this.view.setBigUint64(offset, value, true);
|
|
4617
4945
|
}
|
|
4618
|
-
|
|
4619
|
-
return this.
|
|
4946
|
+
get nonce() {
|
|
4947
|
+
return this.get_nonce();
|
|
4620
4948
|
}
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
target.set(this.buffer, offset);
|
|
4624
|
-
return target;
|
|
4949
|
+
set nonce(value) {
|
|
4950
|
+
this.set_nonce(value);
|
|
4625
4951
|
}
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4952
|
+
get_authorities_length() {
|
|
4953
|
+
return this.__tnResolveFieldRef("num_auth") + 1;
|
|
4954
|
+
}
|
|
4955
|
+
get_authorities_at(index) {
|
|
4956
|
+
const offset = 9;
|
|
4957
|
+
const slice = this.buffer.subarray(offset + index * 73, offset + (index + 1) * 73);
|
|
4958
|
+
return AuthorityRecord.from_array(slice);
|
|
4959
|
+
}
|
|
4960
|
+
get_authorities() {
|
|
4961
|
+
const len = this.get_authorities_length();
|
|
4962
|
+
const result = [];
|
|
4963
|
+
for (let i = 0; i < len; i++) {
|
|
4964
|
+
result.push(this.get_authorities_at(i));
|
|
4965
|
+
}
|
|
4966
|
+
return result;
|
|
4967
|
+
}
|
|
4968
|
+
set_authorities_at(index, value) {
|
|
4969
|
+
const offset = 9;
|
|
4970
|
+
const slice = this.buffer.subarray(offset + index * 73, offset + (index + 1) * 73);
|
|
4971
|
+
slice.set(value["buffer"]);
|
|
4972
|
+
}
|
|
4973
|
+
set_authorities(value) {
|
|
4974
|
+
const len = Math.min(this.get_authorities_length(), value.length);
|
|
4975
|
+
for (let i = 0; i < len; i++) {
|
|
4976
|
+
this.set_authorities_at(i, value[i]);
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
get authorities() {
|
|
4980
|
+
return this.get_authorities();
|
|
4981
|
+
}
|
|
4982
|
+
set authorities(value) {
|
|
4983
|
+
this.set_authorities(value);
|
|
4984
|
+
}
|
|
4985
|
+
static __tnFootprintInternal(__tnParams) {
|
|
4986
|
+
return __tnEvalFootprint3(__tn_ir_WalletAccount.root, { params: __tnParams });
|
|
4987
|
+
}
|
|
4988
|
+
static __tnValidateInternal(buffer, __tnParams) {
|
|
4989
|
+
return __tnValidateIrTree3(__tn_ir_WalletAccount, buffer, __tnParams);
|
|
4990
|
+
}
|
|
4991
|
+
static __tnInvokeFootprint(__tnParams) {
|
|
4992
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
4993
|
+
}
|
|
4994
|
+
static __tnInvokeValidate(buffer, __tnParams) {
|
|
4995
|
+
return this.__tnValidateInternal(buffer, __tnParams);
|
|
4996
|
+
}
|
|
4997
|
+
static footprintIr(authorities_num_auth) {
|
|
4998
|
+
const params = _WalletAccount.Params.fromValues({
|
|
4999
|
+
authorities_num_auth
|
|
5000
|
+
});
|
|
5001
|
+
return this.footprintIrFromParams(params);
|
|
5002
|
+
}
|
|
5003
|
+
static __tnPackParams(params) {
|
|
5004
|
+
const record = /* @__PURE__ */ Object.create(null);
|
|
5005
|
+
record["authorities.num_auth"] = params.authorities_num_auth;
|
|
5006
|
+
return record;
|
|
5007
|
+
}
|
|
5008
|
+
static footprintIrFromParams(params) {
|
|
5009
|
+
const __tnParams = this.__tnPackParams(params);
|
|
5010
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
5011
|
+
}
|
|
5012
|
+
static footprintFromParams(params) {
|
|
5013
|
+
const irResult = this.footprintIrFromParams(params);
|
|
5014
|
+
const maxSafe = __tnToBigInt3(Number.MAX_SAFE_INTEGER);
|
|
5015
|
+
if (__tnBigIntGreaterThan3(irResult, maxSafe)) throw new Error("footprint exceeds Number.MAX_SAFE_INTEGER for WalletAccount");
|
|
5016
|
+
return __tnBigIntToNumber3(irResult, "WalletAccount::footprintFromParams");
|
|
5017
|
+
}
|
|
5018
|
+
static footprintFromValues(input) {
|
|
5019
|
+
const params = _WalletAccount.params(input);
|
|
5020
|
+
return this.footprintFromParams(params);
|
|
5021
|
+
}
|
|
5022
|
+
static footprint(params) {
|
|
5023
|
+
return this.footprintFromParams(params);
|
|
5024
|
+
}
|
|
5025
|
+
static validate(buffer, opts) {
|
|
5026
|
+
if (!buffer || buffer.length === void 0) {
|
|
5027
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
5028
|
+
}
|
|
5029
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
5030
|
+
let params = opts?.params ?? null;
|
|
5031
|
+
if (!params) {
|
|
5032
|
+
const extracted = this.__tnExtractParams(view, buffer);
|
|
5033
|
+
if (!extracted) return { ok: false, code: "tn.param_extraction_failed" };
|
|
5034
|
+
params = extracted.params;
|
|
5035
|
+
}
|
|
5036
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
5037
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
5038
|
+
if (!irResult.ok) {
|
|
5039
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "WalletAccount::validate") : void 0, params };
|
|
5040
|
+
}
|
|
5041
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "WalletAccount::validate") : void 0;
|
|
5042
|
+
return { ok: true, consumed, params };
|
|
5043
|
+
}
|
|
5044
|
+
static from_array(buffer, opts) {
|
|
5045
|
+
if (!buffer || buffer.length === void 0) {
|
|
5046
|
+
return null;
|
|
5047
|
+
}
|
|
5048
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
5049
|
+
let params = opts?.params ?? null;
|
|
5050
|
+
if (!params) {
|
|
5051
|
+
const derived = this.__tnExtractParams(view, buffer);
|
|
5052
|
+
if (!derived) return null;
|
|
5053
|
+
params = derived.params;
|
|
5054
|
+
}
|
|
5055
|
+
const validation = this.validate(buffer, { params });
|
|
5056
|
+
if (!validation.ok) {
|
|
5057
|
+
return null;
|
|
5058
|
+
}
|
|
5059
|
+
const cached = validation.params ?? params;
|
|
5060
|
+
const state = new _WalletAccount(buffer, cached);
|
|
5061
|
+
return state;
|
|
4630
5062
|
}
|
|
4631
5063
|
};
|
|
5064
|
+
((WalletAccount2) => {
|
|
5065
|
+
WalletAccount2.ParamKeys = Object.freeze({
|
|
5066
|
+
authorities_num_auth: "authorities.num_auth"
|
|
5067
|
+
});
|
|
5068
|
+
WalletAccount2.Params = {
|
|
5069
|
+
fromValues(input) {
|
|
5070
|
+
return {
|
|
5071
|
+
authorities_num_auth: __tnToBigInt3(input.authorities_num_auth)
|
|
5072
|
+
};
|
|
5073
|
+
},
|
|
5074
|
+
fromBuilder(source) {
|
|
5075
|
+
if (source.dynamicParams) {
|
|
5076
|
+
return source.dynamicParams();
|
|
5077
|
+
}
|
|
5078
|
+
if (source.params) {
|
|
5079
|
+
return source.params;
|
|
5080
|
+
}
|
|
5081
|
+
return source;
|
|
5082
|
+
}
|
|
5083
|
+
};
|
|
5084
|
+
function params(input) {
|
|
5085
|
+
return WalletAccount2.Params.fromValues(input);
|
|
5086
|
+
}
|
|
5087
|
+
WalletAccount2.params = params;
|
|
5088
|
+
})(WalletAccount || (WalletAccount = {}));
|
|
4632
5089
|
__tnRegisterFootprint3("WalletAccount", (params) => WalletAccount.__tnInvokeFootprint(params));
|
|
4633
5090
|
__tnRegisterValidate3("WalletAccount", (buffer, params) => WalletAccount.__tnInvokeValidate(buffer, params));
|
|
4634
5091
|
__tnRegisterDynamicValidate3("WalletAccount", (buffer) => {
|
|
4635
5092
|
const result = WalletAccount.validate(buffer);
|
|
4636
|
-
|
|
5093
|
+
const params = result.params;
|
|
5094
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4637
5095
|
});
|
|
4638
5096
|
var __tn_ir_WalletCreatedEventData = {
|
|
4639
5097
|
typeName: "WalletCreatedEventData",
|
|
@@ -4759,7 +5217,8 @@ __tnRegisterFootprint3("WalletCreatedEventData", (params) => WalletCreatedEventD
|
|
|
4759
5217
|
__tnRegisterValidate3("WalletCreatedEventData", (buffer, params) => WalletCreatedEventData.__tnInvokeValidate(buffer, params));
|
|
4760
5218
|
__tnRegisterDynamicValidate3("WalletCreatedEventData", (buffer) => {
|
|
4761
5219
|
const result = WalletCreatedEventData.validate(buffer);
|
|
4762
|
-
|
|
5220
|
+
const params = result.params;
|
|
5221
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4763
5222
|
});
|
|
4764
5223
|
var __tn_ir_WalletTransferEventData = {
|
|
4765
5224
|
typeName: "WalletTransferEventData",
|
|
@@ -4904,7 +5363,8 @@ __tnRegisterFootprint3("WalletTransferEventData", (params) => WalletTransferEven
|
|
|
4904
5363
|
__tnRegisterValidate3("WalletTransferEventData", (buffer, params) => WalletTransferEventData.__tnInvokeValidate(buffer, params));
|
|
4905
5364
|
__tnRegisterDynamicValidate3("WalletTransferEventData", (buffer) => {
|
|
4906
5365
|
const result = WalletTransferEventData.validate(buffer);
|
|
4907
|
-
|
|
5366
|
+
const params = result.params;
|
|
5367
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4908
5368
|
});
|
|
4909
5369
|
var __tn_ir_WalletValidatedEventData = {
|
|
4910
5370
|
typeName: "WalletValidatedEventData",
|
|
@@ -5028,11 +5488,12 @@ __tnRegisterFootprint3("WalletValidatedEventData", (params) => WalletValidatedEv
|
|
|
5028
5488
|
__tnRegisterValidate3("WalletValidatedEventData", (buffer, params) => WalletValidatedEventData.__tnInvokeValidate(buffer, params));
|
|
5029
5489
|
__tnRegisterDynamicValidate3("WalletValidatedEventData", (buffer) => {
|
|
5030
5490
|
const result = WalletValidatedEventData.validate(buffer);
|
|
5031
|
-
|
|
5491
|
+
const params = result.params;
|
|
5492
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5032
5493
|
});
|
|
5033
5494
|
var __tn_ir_AddAuthorityArgs = {
|
|
5034
5495
|
typeName: "AddAuthorityArgs",
|
|
5035
|
-
root: { op: "const", value:
|
|
5496
|
+
root: { op: "const", value: 75n }
|
|
5036
5497
|
};
|
|
5037
5498
|
var AddAuthorityArgs = class _AddAuthorityArgs {
|
|
5038
5499
|
constructor(buffer) {
|
|
@@ -5064,21 +5525,21 @@ var AddAuthorityArgs = class _AddAuthorityArgs {
|
|
|
5064
5525
|
set wallet_account_idx(value) {
|
|
5065
5526
|
this.set_wallet_account_idx(value);
|
|
5066
5527
|
}
|
|
5067
|
-
|
|
5528
|
+
get_authority_record() {
|
|
5068
5529
|
const offset = 2;
|
|
5069
|
-
const slice = this.buffer.subarray(offset, offset +
|
|
5070
|
-
return
|
|
5530
|
+
const slice = this.buffer.subarray(offset, offset + 73);
|
|
5531
|
+
return AuthorityRecord.from_array(slice);
|
|
5071
5532
|
}
|
|
5072
|
-
|
|
5533
|
+
set_authority_record(value) {
|
|
5073
5534
|
const sourceBytes = value.buffer;
|
|
5074
5535
|
const offset = 2;
|
|
5075
5536
|
this.buffer.set(sourceBytes, offset);
|
|
5076
5537
|
}
|
|
5077
|
-
get
|
|
5078
|
-
return this.
|
|
5538
|
+
get authority_record() {
|
|
5539
|
+
return this.get_authority_record();
|
|
5079
5540
|
}
|
|
5080
|
-
set
|
|
5081
|
-
this.
|
|
5541
|
+
set authority_record(value) {
|
|
5542
|
+
this.set_authority_record(value);
|
|
5082
5543
|
}
|
|
5083
5544
|
static __tnFootprintInternal(__tnParams) {
|
|
5084
5545
|
return __tnEvalFootprint3(__tn_ir_AddAuthorityArgs.root, { params: __tnParams });
|
|
@@ -5104,8 +5565,8 @@ var AddAuthorityArgs = class _AddAuthorityArgs {
|
|
|
5104
5565
|
return __tnBigIntToNumber3(irResult, "AddAuthorityArgs::footprint");
|
|
5105
5566
|
}
|
|
5106
5567
|
static validate(buffer, _opts) {
|
|
5107
|
-
if (buffer.length <
|
|
5108
|
-
return { ok: true, consumed:
|
|
5568
|
+
if (buffer.length < 75) return { ok: false, code: "tn.buffer_too_small", consumed: 75 };
|
|
5569
|
+
return { ok: true, consumed: 75 };
|
|
5109
5570
|
}
|
|
5110
5571
|
static from_array(buffer) {
|
|
5111
5572
|
if (!buffer || buffer.length === void 0) {
|
|
@@ -5121,15 +5582,15 @@ var AddAuthorityArgs = class _AddAuthorityArgs {
|
|
|
5121
5582
|
};
|
|
5122
5583
|
var AddAuthorityArgsBuilder = class {
|
|
5123
5584
|
constructor() {
|
|
5124
|
-
this.buffer = new Uint8Array(
|
|
5585
|
+
this.buffer = new Uint8Array(75);
|
|
5125
5586
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
5126
5587
|
}
|
|
5127
5588
|
set_wallet_account_idx(value) {
|
|
5128
5589
|
this.view.setUint16(0, value, true);
|
|
5129
5590
|
return this;
|
|
5130
5591
|
}
|
|
5131
|
-
|
|
5132
|
-
if (value.length !==
|
|
5592
|
+
set_authority_record(value) {
|
|
5593
|
+
if (value.length !== 73) throw new Error("authority_record expects 73 bytes");
|
|
5133
5594
|
this.buffer.set(value, 2);
|
|
5134
5595
|
return this;
|
|
5135
5596
|
}
|
|
@@ -5151,7 +5612,8 @@ __tnRegisterFootprint3("AddAuthorityArgs", (params) => AddAuthorityArgs.__tnInvo
|
|
|
5151
5612
|
__tnRegisterValidate3("AddAuthorityArgs", (buffer, params) => AddAuthorityArgs.__tnInvokeValidate(buffer, params));
|
|
5152
5613
|
__tnRegisterDynamicValidate3("AddAuthorityArgs", (buffer) => {
|
|
5153
5614
|
const result = AddAuthorityArgs.validate(buffer);
|
|
5154
|
-
|
|
5615
|
+
const params = result.params;
|
|
5616
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5155
5617
|
});
|
|
5156
5618
|
var __tn_ir_CredentialLookup = {
|
|
5157
5619
|
typeName: "CredentialLookup",
|
|
@@ -5256,7 +5718,8 @@ __tnRegisterFootprint3("CredentialLookup", (params) => CredentialLookup.__tnInvo
|
|
|
5256
5718
|
__tnRegisterValidate3("CredentialLookup", (buffer, params) => CredentialLookup.__tnInvokeValidate(buffer, params));
|
|
5257
5719
|
__tnRegisterDynamicValidate3("CredentialLookup", (buffer) => {
|
|
5258
5720
|
const result = CredentialLookup.validate(buffer);
|
|
5259
|
-
|
|
5721
|
+
const params = result.params;
|
|
5722
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5260
5723
|
});
|
|
5261
5724
|
var __tn_ir_CredentialRegisteredEventData = {
|
|
5262
5725
|
typeName: "CredentialRegisteredEventData",
|
|
@@ -5382,7 +5845,8 @@ __tnRegisterFootprint3("CredentialRegisteredEventData", (params) => CredentialRe
|
|
|
5382
5845
|
__tnRegisterValidate3("CredentialRegisteredEventData", (buffer, params) => CredentialRegisteredEventData.__tnInvokeValidate(buffer, params));
|
|
5383
5846
|
__tnRegisterDynamicValidate3("CredentialRegisteredEventData", (buffer) => {
|
|
5384
5847
|
const result = CredentialRegisteredEventData.validate(buffer);
|
|
5385
|
-
|
|
5848
|
+
const params = result.params;
|
|
5849
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5386
5850
|
});
|
|
5387
5851
|
var __tn_ir_PasskeyEvent = {
|
|
5388
5852
|
typeName: "PasskeyEvent",
|
|
@@ -5737,30 +6201,93 @@ __tnRegisterFootprint3("PasskeyEvent", (params) => PasskeyEvent.__tnInvokeFootpr
|
|
|
5737
6201
|
__tnRegisterValidate3("PasskeyEvent", (buffer, params) => PasskeyEvent.__tnInvokeValidate(buffer, params));
|
|
5738
6202
|
__tnRegisterDynamicValidate3("PasskeyEvent", (buffer) => {
|
|
5739
6203
|
const result = PasskeyEvent.validate(buffer);
|
|
5740
|
-
|
|
6204
|
+
const params = result.params;
|
|
6205
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5741
6206
|
});
|
|
5742
6207
|
var __tn_ir_CreateArgs = {
|
|
5743
6208
|
typeName: "CreateArgs",
|
|
5744
|
-
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "add", left: { op: "align", alignment: 2, node: { op: "const", value: 2n } }, right: { op: "align", alignment: 1, node: { op: "const", value:
|
|
6209
|
+
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "add", left: { op: "align", alignment: 2, node: { op: "const", value: 2n } }, right: { op: "align", alignment: 1, node: { op: "const", value: 73n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 1, node: { op: "call", typeName: "StateProof", args: [{ name: "proof_body.hdr.type_slot", source: "proof_body.hdr.type_slot" }, { name: "proof_body.payload_size", source: "proof_body.payload_size" }] } } } }
|
|
5745
6210
|
};
|
|
5746
6211
|
var CreateArgs = class _CreateArgs {
|
|
5747
|
-
constructor(buffer) {
|
|
6212
|
+
constructor(buffer, params) {
|
|
5748
6213
|
this.buffer = buffer;
|
|
5749
6214
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6215
|
+
if (params) {
|
|
6216
|
+
this.__tnParams = params;
|
|
6217
|
+
} else {
|
|
6218
|
+
const derived = _CreateArgs.__tnExtractParams(this.view, buffer);
|
|
6219
|
+
if (!derived) {
|
|
6220
|
+
throw new Error("CreateArgs: failed to derive dynamic parameters");
|
|
6221
|
+
}
|
|
6222
|
+
this.__tnParams = derived.params;
|
|
6223
|
+
}
|
|
5750
6224
|
}
|
|
5751
6225
|
static __tnCreateView(buffer, opts) {
|
|
5752
6226
|
if (!buffer || buffer.length === void 0) throw new Error("CreateArgs.__tnCreateView requires a Uint8Array");
|
|
5753
|
-
|
|
6227
|
+
let params = opts?.params ?? null;
|
|
6228
|
+
if (!params) {
|
|
6229
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6230
|
+
const derived = _CreateArgs.__tnExtractParams(view, buffer);
|
|
6231
|
+
if (!derived) throw new Error("CreateArgs.__tnCreateView: failed to derive params");
|
|
6232
|
+
params = derived.params;
|
|
6233
|
+
}
|
|
6234
|
+
const instance = new _CreateArgs(new Uint8Array(buffer), params);
|
|
6235
|
+
return instance;
|
|
6236
|
+
}
|
|
6237
|
+
dynamicParams() {
|
|
6238
|
+
return this.__tnParams;
|
|
5754
6239
|
}
|
|
5755
6240
|
static builder() {
|
|
5756
6241
|
return new CreateArgsBuilder();
|
|
5757
6242
|
}
|
|
5758
6243
|
static fromBuilder(builder) {
|
|
5759
6244
|
const buffer = builder.build();
|
|
5760
|
-
|
|
6245
|
+
const params = builder.dynamicParams();
|
|
6246
|
+
return _CreateArgs.from_array(buffer, { params });
|
|
5761
6247
|
}
|
|
5762
|
-
|
|
5763
|
-
const
|
|
6248
|
+
static __tnComputeSequentialLayout(view, buffer) {
|
|
6249
|
+
const __tnLength = buffer.length;
|
|
6250
|
+
let __tnParamSeq_proof_body_hdr_type_slot = null;
|
|
6251
|
+
let __tnParamSeq_proof_body_payload_size = null;
|
|
6252
|
+
let __tnCursorMutable = 0;
|
|
6253
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
6254
|
+
view.getUint16(__tnCursorMutable, true);
|
|
6255
|
+
__tnCursorMutable += 2;
|
|
6256
|
+
if (__tnCursorMutable + 65 > __tnLength) return null;
|
|
6257
|
+
__tnCursorMutable += 65;
|
|
6258
|
+
if (__tnCursorMutable + 32 > __tnLength) return null;
|
|
6259
|
+
__tnCursorMutable += 32;
|
|
6260
|
+
const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate3("StateProof", buffer.subarray(__tnCursorMutable));
|
|
6261
|
+
if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === void 0) return null;
|
|
6262
|
+
const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
|
|
6263
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === void 0) return null;
|
|
6264
|
+
__tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
|
|
6265
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === void 0) return null;
|
|
6266
|
+
__tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
|
|
6267
|
+
__tnCursorMutable += __tnBigIntToNumber3(__tnTyperefResult_state_proof.consumed, "CreateArgs::state_proof");
|
|
6268
|
+
const params = /* @__PURE__ */ Object.create(null);
|
|
6269
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
|
|
6270
|
+
params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot;
|
|
6271
|
+
if (__tnParamSeq_proof_body_payload_size === null) return null;
|
|
6272
|
+
params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size;
|
|
6273
|
+
return { params, offsets: null, derived: null };
|
|
6274
|
+
}
|
|
6275
|
+
static __tnExtractParams(view, buffer) {
|
|
6276
|
+
const __tnLayout = _CreateArgs.__tnComputeSequentialLayout(view, buffer);
|
|
6277
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
6278
|
+
const __tnSeqParams = __tnLayout.params;
|
|
6279
|
+
const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
|
|
6280
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === void 0) return null;
|
|
6281
|
+
const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
|
|
6282
|
+
if (__tnParamSeq_proof_body_payload_size === void 0) return null;
|
|
6283
|
+
const __tnExtractedParams = _CreateArgs.Params.fromValues({
|
|
6284
|
+
proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot,
|
|
6285
|
+
proof_body_payload_size: __tnParamSeq_proof_body_payload_size
|
|
6286
|
+
});
|
|
6287
|
+
return { params: __tnExtractedParams, derived: null };
|
|
6288
|
+
}
|
|
6289
|
+
get_wallet_account_idx() {
|
|
6290
|
+
const offset = 0;
|
|
5764
6291
|
return this.view.getUint16(offset, true);
|
|
5765
6292
|
}
|
|
5766
6293
|
set_wallet_account_idx(value) {
|
|
@@ -5773,30 +6300,30 @@ var CreateArgs = class _CreateArgs {
|
|
|
5773
6300
|
set wallet_account_idx(value) {
|
|
5774
6301
|
this.set_wallet_account_idx(value);
|
|
5775
6302
|
}
|
|
5776
|
-
|
|
6303
|
+
get_authority_record() {
|
|
5777
6304
|
const offset = 2;
|
|
5778
|
-
const slice = this.buffer.subarray(offset, offset +
|
|
5779
|
-
return
|
|
6305
|
+
const slice = this.buffer.subarray(offset, offset + 73);
|
|
6306
|
+
return AuthorityRecord.from_array(slice);
|
|
5780
6307
|
}
|
|
5781
|
-
|
|
6308
|
+
set_authority_record(value) {
|
|
5782
6309
|
const sourceBytes = value.buffer;
|
|
5783
6310
|
const offset = 2;
|
|
5784
6311
|
this.buffer.set(sourceBytes, offset);
|
|
5785
6312
|
}
|
|
5786
|
-
get
|
|
5787
|
-
return this.
|
|
6313
|
+
get authority_record() {
|
|
6314
|
+
return this.get_authority_record();
|
|
5788
6315
|
}
|
|
5789
|
-
set
|
|
5790
|
-
this.
|
|
6316
|
+
set authority_record(value) {
|
|
6317
|
+
this.set_authority_record(value);
|
|
5791
6318
|
}
|
|
5792
6319
|
get_seed() {
|
|
5793
|
-
const offset =
|
|
6320
|
+
const offset = 75;
|
|
5794
6321
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
5795
6322
|
return Seed32.from_array(slice);
|
|
5796
6323
|
}
|
|
5797
6324
|
set_seed(value) {
|
|
5798
6325
|
const sourceBytes = value.buffer;
|
|
5799
|
-
const offset =
|
|
6326
|
+
const offset = 75;
|
|
5800
6327
|
this.buffer.set(sourceBytes, offset);
|
|
5801
6328
|
}
|
|
5802
6329
|
get seed() {
|
|
@@ -5806,7 +6333,7 @@ var CreateArgs = class _CreateArgs {
|
|
|
5806
6333
|
this.set_seed(value);
|
|
5807
6334
|
}
|
|
5808
6335
|
get_state_proof() {
|
|
5809
|
-
const offset =
|
|
6336
|
+
const offset = 107;
|
|
5810
6337
|
const tail = this.buffer.subarray(offset);
|
|
5811
6338
|
const validation = StateProof.validate(tail);
|
|
5812
6339
|
if (!validation.ok || validation.consumed === void 0) {
|
|
@@ -5819,7 +6346,7 @@ var CreateArgs = class _CreateArgs {
|
|
|
5819
6346
|
}
|
|
5820
6347
|
set_state_proof(value) {
|
|
5821
6348
|
const sourceBytes = value.buffer;
|
|
5822
|
-
const offset =
|
|
6349
|
+
const offset = 107;
|
|
5823
6350
|
this.buffer.set(sourceBytes, offset);
|
|
5824
6351
|
}
|
|
5825
6352
|
get state_proof() {
|
|
@@ -5840,146 +6367,294 @@ var CreateArgs = class _CreateArgs {
|
|
|
5840
6367
|
static __tnInvokeValidate(buffer, __tnParams) {
|
|
5841
6368
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
5842
6369
|
}
|
|
5843
|
-
static footprintIr() {
|
|
5844
|
-
|
|
6370
|
+
static footprintIr(proof_body_hdr_type_slot, proof_body_payload_size) {
|
|
6371
|
+
const params = _CreateArgs.Params.fromValues({
|
|
6372
|
+
proof_body_hdr_type_slot,
|
|
6373
|
+
proof_body_payload_size
|
|
6374
|
+
});
|
|
6375
|
+
return this.footprintIrFromParams(params);
|
|
5845
6376
|
}
|
|
5846
|
-
static
|
|
5847
|
-
const
|
|
6377
|
+
static __tnPackParams(params) {
|
|
6378
|
+
const record = /* @__PURE__ */ Object.create(null);
|
|
6379
|
+
record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
|
|
6380
|
+
record["proof_body.payload_size"] = params.proof_body_payload_size;
|
|
6381
|
+
return record;
|
|
6382
|
+
}
|
|
6383
|
+
static footprintIrFromParams(params) {
|
|
6384
|
+
const __tnParams = this.__tnPackParams(params);
|
|
6385
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
6386
|
+
}
|
|
6387
|
+
static footprintFromParams(params) {
|
|
6388
|
+
const irResult = this.footprintIrFromParams(params);
|
|
5848
6389
|
const maxSafe = __tnToBigInt3(Number.MAX_SAFE_INTEGER);
|
|
5849
|
-
if (__tnBigIntGreaterThan3(irResult, maxSafe))
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
6390
|
+
if (__tnBigIntGreaterThan3(irResult, maxSafe)) throw new Error("footprint exceeds Number.MAX_SAFE_INTEGER for CreateArgs");
|
|
6391
|
+
return __tnBigIntToNumber3(irResult, "CreateArgs::footprintFromParams");
|
|
6392
|
+
}
|
|
6393
|
+
static footprintFromValues(input) {
|
|
6394
|
+
const params = _CreateArgs.params(input);
|
|
6395
|
+
return this.footprintFromParams(params);
|
|
5853
6396
|
}
|
|
5854
|
-
static
|
|
5855
|
-
|
|
5856
|
-
return { ok: true, consumed: _buffer.length };
|
|
6397
|
+
static footprint(params) {
|
|
6398
|
+
return this.footprintFromParams(params);
|
|
5857
6399
|
}
|
|
5858
|
-
static
|
|
6400
|
+
static validate(buffer, opts) {
|
|
6401
|
+
if (!buffer || buffer.length === void 0) {
|
|
6402
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
6403
|
+
}
|
|
6404
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6405
|
+
let params = opts?.params ?? null;
|
|
6406
|
+
if (!params) {
|
|
6407
|
+
return { ok: false, code: "tn.param_extraction_failed" };
|
|
6408
|
+
}
|
|
6409
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
6410
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
6411
|
+
if (!irResult.ok) {
|
|
6412
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "CreateArgs::validate") : void 0, params };
|
|
6413
|
+
}
|
|
6414
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "CreateArgs::validate") : void 0;
|
|
6415
|
+
return { ok: true, consumed, params };
|
|
6416
|
+
}
|
|
6417
|
+
static from_array(buffer, opts) {
|
|
5859
6418
|
if (!buffer || buffer.length === void 0) {
|
|
5860
6419
|
return null;
|
|
5861
6420
|
}
|
|
5862
6421
|
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
5863
|
-
|
|
6422
|
+
let params = opts?.params ?? null;
|
|
6423
|
+
if (!params) {
|
|
6424
|
+
__tnLogWarn3("CreateArgs::from_array requires params when IR extraction is unavailable");
|
|
6425
|
+
return null;
|
|
6426
|
+
}
|
|
6427
|
+
const validation = this.validate(buffer, { params });
|
|
5864
6428
|
if (!validation.ok) {
|
|
5865
6429
|
return null;
|
|
5866
6430
|
}
|
|
5867
|
-
|
|
6431
|
+
const cached = validation.params ?? params;
|
|
6432
|
+
const state = new _CreateArgs(buffer, cached);
|
|
6433
|
+
return state;
|
|
5868
6434
|
}
|
|
5869
6435
|
};
|
|
6436
|
+
((CreateArgs2) => {
|
|
6437
|
+
CreateArgs2.ParamKeys = Object.freeze({
|
|
6438
|
+
proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
|
|
6439
|
+
proof_body_payload_size: "proof_body.payload_size"
|
|
6440
|
+
});
|
|
6441
|
+
CreateArgs2.Params = {
|
|
6442
|
+
fromValues(input) {
|
|
6443
|
+
return {
|
|
6444
|
+
proof_body_hdr_type_slot: __tnToBigInt3(input.proof_body_hdr_type_slot),
|
|
6445
|
+
proof_body_payload_size: __tnToBigInt3(input.proof_body_payload_size)
|
|
6446
|
+
};
|
|
6447
|
+
},
|
|
6448
|
+
fromBuilder(source) {
|
|
6449
|
+
if (source.dynamicParams) {
|
|
6450
|
+
return source.dynamicParams();
|
|
6451
|
+
}
|
|
6452
|
+
if (source.params) {
|
|
6453
|
+
return source.params;
|
|
6454
|
+
}
|
|
6455
|
+
return source;
|
|
6456
|
+
}
|
|
6457
|
+
};
|
|
6458
|
+
function params(input) {
|
|
6459
|
+
return CreateArgs2.Params.fromValues(input);
|
|
6460
|
+
}
|
|
6461
|
+
CreateArgs2.params = params;
|
|
6462
|
+
})(CreateArgs || (CreateArgs = {}));
|
|
5870
6463
|
var CreateArgsBuilder = class {
|
|
5871
6464
|
constructor() {
|
|
6465
|
+
this.__tnCachedParams = null;
|
|
6466
|
+
this.__tnLastBuffer = null;
|
|
6467
|
+
this.__tnLastParams = null;
|
|
5872
6468
|
this.__tnTail_state_proof = null;
|
|
5873
|
-
this.
|
|
6469
|
+
this.__tnTailParams_state_proof = null;
|
|
6470
|
+
this.buffer = new Uint8Array(107);
|
|
5874
6471
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
5875
6472
|
}
|
|
5876
6473
|
__tnInvalidate() {
|
|
6474
|
+
this.__tnCachedParams = null;
|
|
6475
|
+
this.__tnLastBuffer = null;
|
|
6476
|
+
this.__tnLastParams = null;
|
|
5877
6477
|
}
|
|
5878
6478
|
set_wallet_account_idx(value) {
|
|
5879
6479
|
this.view.setUint16(0, value, true);
|
|
5880
6480
|
this.__tnInvalidate();
|
|
5881
6481
|
return this;
|
|
5882
6482
|
}
|
|
5883
|
-
|
|
5884
|
-
if (value.length !==
|
|
6483
|
+
set_authority_record(value) {
|
|
6484
|
+
if (value.length !== 73) throw new Error("authority_record expects 73 bytes");
|
|
5885
6485
|
this.buffer.set(value, 2);
|
|
5886
6486
|
this.__tnInvalidate();
|
|
5887
6487
|
return this;
|
|
5888
6488
|
}
|
|
5889
6489
|
set_seed(value) {
|
|
5890
6490
|
if (value.length !== 32) throw new Error("seed expects 32 bytes");
|
|
5891
|
-
this.buffer.set(value,
|
|
6491
|
+
this.buffer.set(value, 75);
|
|
5892
6492
|
this.__tnInvalidate();
|
|
5893
6493
|
return this;
|
|
5894
6494
|
}
|
|
5895
6495
|
set_state_proof(value) {
|
|
5896
6496
|
const bytes = __tnResolveStructFieldInput(value, "CreateArgsBuilder::state_proof");
|
|
6497
|
+
const validation = __tnInvokeDynamicValidate3("StateProof", bytes);
|
|
6498
|
+
if (!validation.ok || validation.consumed === void 0) throw new Error("CreateArgsBuilder: field 'state_proof' failed validation");
|
|
6499
|
+
if (__tnBigIntToNumber3(validation.consumed, "CreateArgsBuilder::state_proof") !== bytes.length) throw new Error("CreateArgsBuilder: field 'state_proof' validation did not consume the full buffer");
|
|
5897
6500
|
this.__tnTail_state_proof = bytes;
|
|
6501
|
+
this.__tnTailParams_state_proof = validation.params ?? null;
|
|
5898
6502
|
this.__tnInvalidate();
|
|
5899
6503
|
return this;
|
|
5900
6504
|
}
|
|
5901
6505
|
build() {
|
|
5902
|
-
const
|
|
5903
|
-
const size =
|
|
6506
|
+
const params = this.__tnComputeParams();
|
|
6507
|
+
const size = CreateArgs.footprintFromParams(params);
|
|
5904
6508
|
const buffer = new Uint8Array(size);
|
|
5905
|
-
this.__tnWriteInto(buffer
|
|
5906
|
-
this.__tnValidateOrThrow(buffer);
|
|
6509
|
+
this.__tnWriteInto(buffer);
|
|
6510
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
5907
6511
|
return buffer;
|
|
5908
6512
|
}
|
|
5909
6513
|
buildInto(target, offset = 0) {
|
|
5910
|
-
const
|
|
5911
|
-
const size =
|
|
6514
|
+
const params = this.__tnComputeParams();
|
|
6515
|
+
const size = CreateArgs.footprintFromParams(params);
|
|
5912
6516
|
if (target.length - offset < size) throw new Error("CreateArgsBuilder: target buffer too small");
|
|
5913
6517
|
const slice = target.subarray(offset, offset + size);
|
|
5914
|
-
this.__tnWriteInto(slice
|
|
5915
|
-
this.__tnValidateOrThrow(slice);
|
|
6518
|
+
this.__tnWriteInto(slice);
|
|
6519
|
+
this.__tnValidateOrThrow(slice, params);
|
|
5916
6520
|
return target;
|
|
5917
6521
|
}
|
|
5918
6522
|
finish() {
|
|
5919
6523
|
const buffer = this.build();
|
|
5920
|
-
const
|
|
6524
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
6525
|
+
const view = CreateArgs.from_array(buffer, { params });
|
|
5921
6526
|
if (!view) throw new Error("CreateArgsBuilder: failed to finalize view");
|
|
5922
6527
|
return view;
|
|
5923
6528
|
}
|
|
5924
6529
|
finishView() {
|
|
5925
6530
|
return this.finish();
|
|
5926
6531
|
}
|
|
5927
|
-
|
|
5928
|
-
return
|
|
5929
|
-
(() => {
|
|
5930
|
-
const bytes = this.__tnTail_state_proof;
|
|
5931
|
-
if (!bytes) throw new Error("CreateArgsBuilder: field 'state_proof' must be set before build()");
|
|
5932
|
-
return bytes;
|
|
5933
|
-
})()
|
|
5934
|
-
];
|
|
6532
|
+
dynamicParams() {
|
|
6533
|
+
return this.__tnComputeParams();
|
|
5935
6534
|
}
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
6535
|
+
__tnComputeParams() {
|
|
6536
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
6537
|
+
const params = CreateArgs.Params.fromValues({
|
|
6538
|
+
proof_body_hdr_type_slot: (() => {
|
|
6539
|
+
const params2 = this.__tnTailParams_state_proof;
|
|
6540
|
+
if (!params2 || params2["proof_body_hdr_type_slot"] === void 0) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before computing params");
|
|
6541
|
+
return params2["proof_body_hdr_type_slot"];
|
|
6542
|
+
})(),
|
|
6543
|
+
proof_body_payload_size: (() => {
|
|
6544
|
+
const params2 = this.__tnTailParams_state_proof;
|
|
6545
|
+
if (!params2 || params2["proof_body_payload_size"] === void 0) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before computing params");
|
|
6546
|
+
return params2["proof_body_payload_size"];
|
|
6547
|
+
})()
|
|
6548
|
+
});
|
|
6549
|
+
this.__tnCachedParams = params;
|
|
6550
|
+
return params;
|
|
5942
6551
|
}
|
|
5943
|
-
__tnWriteInto(target
|
|
6552
|
+
__tnWriteInto(target) {
|
|
5944
6553
|
target.set(this.buffer, 0);
|
|
5945
6554
|
let cursor = this.buffer.length;
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
6555
|
+
const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
|
|
6556
|
+
if (!__tnLocal_state_proof_bytes) throw new Error("CreateArgsBuilder: field 'state_proof' must be written before build");
|
|
6557
|
+
target.set(__tnLocal_state_proof_bytes, cursor);
|
|
6558
|
+
cursor += __tnLocal_state_proof_bytes.length;
|
|
5950
6559
|
}
|
|
5951
|
-
__tnValidateOrThrow(buffer) {
|
|
5952
|
-
const result = CreateArgs.validate(buffer);
|
|
6560
|
+
__tnValidateOrThrow(buffer, params) {
|
|
6561
|
+
const result = CreateArgs.validate(buffer, { params });
|
|
5953
6562
|
if (!result.ok) {
|
|
5954
|
-
throw new Error(
|
|
6563
|
+
throw new Error(`${CreateArgs}Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
5955
6564
|
}
|
|
6565
|
+
this.__tnLastParams = result.params ?? params;
|
|
6566
|
+
this.__tnLastBuffer = buffer;
|
|
5956
6567
|
}
|
|
5957
6568
|
};
|
|
5958
6569
|
__tnRegisterFootprint3("CreateArgs", (params) => CreateArgs.__tnInvokeFootprint(params));
|
|
5959
6570
|
__tnRegisterValidate3("CreateArgs", (buffer, params) => CreateArgs.__tnInvokeValidate(buffer, params));
|
|
5960
6571
|
__tnRegisterDynamicValidate3("CreateArgs", (buffer) => {
|
|
5961
6572
|
const result = CreateArgs.validate(buffer);
|
|
5962
|
-
|
|
6573
|
+
const params = result.params;
|
|
6574
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
5963
6575
|
});
|
|
5964
6576
|
var __tn_ir_RegisterCredentialArgs = {
|
|
5965
6577
|
typeName: "RegisterCredentialArgs",
|
|
5966
6578
|
root: { op: "align", alignment: 1, node: { op: "add", left: { op: "add", left: { op: "add", left: { op: "align", alignment: 2, node: { op: "const", value: 2n } }, right: { op: "align", alignment: 2, node: { op: "const", value: 2n } } }, right: { op: "align", alignment: 1, node: { op: "const", value: 32n } } }, right: { op: "align", alignment: 1, node: { op: "call", typeName: "StateProof", args: [{ name: "proof_body.hdr.type_slot", source: "proof_body.hdr.type_slot" }, { name: "proof_body.payload_size", source: "proof_body.payload_size" }] } } } }
|
|
5967
6579
|
};
|
|
5968
6580
|
var RegisterCredentialArgs = class _RegisterCredentialArgs {
|
|
5969
|
-
constructor(buffer) {
|
|
6581
|
+
constructor(buffer, params) {
|
|
5970
6582
|
this.buffer = buffer;
|
|
5971
6583
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6584
|
+
if (params) {
|
|
6585
|
+
this.__tnParams = params;
|
|
6586
|
+
} else {
|
|
6587
|
+
const derived = _RegisterCredentialArgs.__tnExtractParams(this.view, buffer);
|
|
6588
|
+
if (!derived) {
|
|
6589
|
+
throw new Error("RegisterCredentialArgs: failed to derive dynamic parameters");
|
|
6590
|
+
}
|
|
6591
|
+
this.__tnParams = derived.params;
|
|
6592
|
+
}
|
|
5972
6593
|
}
|
|
5973
6594
|
static __tnCreateView(buffer, opts) {
|
|
5974
6595
|
if (!buffer || buffer.length === void 0) throw new Error("RegisterCredentialArgs.__tnCreateView requires a Uint8Array");
|
|
5975
|
-
|
|
6596
|
+
let params = opts?.params ?? null;
|
|
6597
|
+
if (!params) {
|
|
6598
|
+
const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6599
|
+
const derived = _RegisterCredentialArgs.__tnExtractParams(view, buffer);
|
|
6600
|
+
if (!derived) throw new Error("RegisterCredentialArgs.__tnCreateView: failed to derive params");
|
|
6601
|
+
params = derived.params;
|
|
6602
|
+
}
|
|
6603
|
+
const instance = new _RegisterCredentialArgs(new Uint8Array(buffer), params);
|
|
6604
|
+
return instance;
|
|
6605
|
+
}
|
|
6606
|
+
dynamicParams() {
|
|
6607
|
+
return this.__tnParams;
|
|
5976
6608
|
}
|
|
5977
6609
|
static builder() {
|
|
5978
6610
|
return new RegisterCredentialArgsBuilder();
|
|
5979
6611
|
}
|
|
5980
6612
|
static fromBuilder(builder) {
|
|
5981
6613
|
const buffer = builder.build();
|
|
5982
|
-
|
|
6614
|
+
const params = builder.dynamicParams();
|
|
6615
|
+
return _RegisterCredentialArgs.from_array(buffer, { params });
|
|
6616
|
+
}
|
|
6617
|
+
static __tnComputeSequentialLayout(view, buffer) {
|
|
6618
|
+
const __tnLength = buffer.length;
|
|
6619
|
+
let __tnParamSeq_proof_body_hdr_type_slot = null;
|
|
6620
|
+
let __tnParamSeq_proof_body_payload_size = null;
|
|
6621
|
+
let __tnCursorMutable = 0;
|
|
6622
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
6623
|
+
view.getUint16(__tnCursorMutable, true);
|
|
6624
|
+
__tnCursorMutable += 2;
|
|
6625
|
+
if (__tnCursorMutable + 2 > __tnLength) return null;
|
|
6626
|
+
view.getUint16(__tnCursorMutable, true);
|
|
6627
|
+
__tnCursorMutable += 2;
|
|
6628
|
+
if (__tnCursorMutable + 32 > __tnLength) return null;
|
|
6629
|
+
__tnCursorMutable += 32;
|
|
6630
|
+
const __tnTyperefResult_state_proof = __tnInvokeDynamicValidate3("StateProof", buffer.subarray(__tnCursorMutable));
|
|
6631
|
+
if (!__tnTyperefResult_state_proof.ok || __tnTyperefResult_state_proof.consumed === void 0) return null;
|
|
6632
|
+
const __tnTyperefParams_state_proof = __tnTyperefResult_state_proof.params ?? null;
|
|
6633
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_hdr_type_slot"] === void 0) return null;
|
|
6634
|
+
__tnParamSeq_proof_body_hdr_type_slot = __tnTyperefParams_state_proof["proof_body_hdr_type_slot"];
|
|
6635
|
+
if (!__tnTyperefParams_state_proof || __tnTyperefParams_state_proof["proof_body_payload_size"] === void 0) return null;
|
|
6636
|
+
__tnParamSeq_proof_body_payload_size = __tnTyperefParams_state_proof["proof_body_payload_size"];
|
|
6637
|
+
__tnCursorMutable += __tnBigIntToNumber3(__tnTyperefResult_state_proof.consumed, "RegisterCredentialArgs::state_proof");
|
|
6638
|
+
const params = /* @__PURE__ */ Object.create(null);
|
|
6639
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === null) return null;
|
|
6640
|
+
params["proof_body_hdr_type_slot"] = __tnParamSeq_proof_body_hdr_type_slot;
|
|
6641
|
+
if (__tnParamSeq_proof_body_payload_size === null) return null;
|
|
6642
|
+
params["proof_body_payload_size"] = __tnParamSeq_proof_body_payload_size;
|
|
6643
|
+
return { params, offsets: null, derived: null };
|
|
6644
|
+
}
|
|
6645
|
+
static __tnExtractParams(view, buffer) {
|
|
6646
|
+
const __tnLayout = _RegisterCredentialArgs.__tnComputeSequentialLayout(view, buffer);
|
|
6647
|
+
if (!__tnLayout || !__tnLayout.params) return null;
|
|
6648
|
+
const __tnSeqParams = __tnLayout.params;
|
|
6649
|
+
const __tnParamSeq_proof_body_hdr_type_slot = __tnSeqParams["proof_body_hdr_type_slot"];
|
|
6650
|
+
if (__tnParamSeq_proof_body_hdr_type_slot === void 0) return null;
|
|
6651
|
+
const __tnParamSeq_proof_body_payload_size = __tnSeqParams["proof_body_payload_size"];
|
|
6652
|
+
if (__tnParamSeq_proof_body_payload_size === void 0) return null;
|
|
6653
|
+
const __tnExtractedParams = _RegisterCredentialArgs.Params.fromValues({
|
|
6654
|
+
proof_body_hdr_type_slot: __tnParamSeq_proof_body_hdr_type_slot,
|
|
6655
|
+
proof_body_payload_size: __tnParamSeq_proof_body_payload_size
|
|
6656
|
+
});
|
|
6657
|
+
return { params: __tnExtractedParams, derived: null };
|
|
5983
6658
|
}
|
|
5984
6659
|
get_wallet_account_idx() {
|
|
5985
6660
|
const offset = 0;
|
|
@@ -6060,40 +6735,113 @@ var RegisterCredentialArgs = class _RegisterCredentialArgs {
|
|
|
6060
6735
|
static __tnInvokeValidate(buffer, __tnParams) {
|
|
6061
6736
|
return this.__tnValidateInternal(buffer, __tnParams);
|
|
6062
6737
|
}
|
|
6063
|
-
static footprintIr() {
|
|
6064
|
-
|
|
6738
|
+
static footprintIr(proof_body_hdr_type_slot, proof_body_payload_size) {
|
|
6739
|
+
const params = _RegisterCredentialArgs.Params.fromValues({
|
|
6740
|
+
proof_body_hdr_type_slot,
|
|
6741
|
+
proof_body_payload_size
|
|
6742
|
+
});
|
|
6743
|
+
return this.footprintIrFromParams(params);
|
|
6065
6744
|
}
|
|
6066
|
-
static
|
|
6067
|
-
const
|
|
6745
|
+
static __tnPackParams(params) {
|
|
6746
|
+
const record = /* @__PURE__ */ Object.create(null);
|
|
6747
|
+
record["proof_body.hdr.type_slot"] = params.proof_body_hdr_type_slot;
|
|
6748
|
+
record["proof_body.payload_size"] = params.proof_body_payload_size;
|
|
6749
|
+
return record;
|
|
6750
|
+
}
|
|
6751
|
+
static footprintIrFromParams(params) {
|
|
6752
|
+
const __tnParams = this.__tnPackParams(params);
|
|
6753
|
+
return this.__tnFootprintInternal(__tnParams);
|
|
6754
|
+
}
|
|
6755
|
+
static footprintFromParams(params) {
|
|
6756
|
+
const irResult = this.footprintIrFromParams(params);
|
|
6068
6757
|
const maxSafe = __tnToBigInt3(Number.MAX_SAFE_INTEGER);
|
|
6069
|
-
if (__tnBigIntGreaterThan3(irResult, maxSafe))
|
|
6070
|
-
|
|
6071
|
-
}
|
|
6072
|
-
return __tnBigIntToNumber3(irResult, "RegisterCredentialArgs::footprint");
|
|
6758
|
+
if (__tnBigIntGreaterThan3(irResult, maxSafe)) throw new Error("footprint exceeds Number.MAX_SAFE_INTEGER for RegisterCredentialArgs");
|
|
6759
|
+
return __tnBigIntToNumber3(irResult, "RegisterCredentialArgs::footprintFromParams");
|
|
6073
6760
|
}
|
|
6074
|
-
static
|
|
6075
|
-
|
|
6076
|
-
return
|
|
6761
|
+
static footprintFromValues(input) {
|
|
6762
|
+
const params = _RegisterCredentialArgs.params(input);
|
|
6763
|
+
return this.footprintFromParams(params);
|
|
6077
6764
|
}
|
|
6078
|
-
static
|
|
6765
|
+
static footprint(params) {
|
|
6766
|
+
return this.footprintFromParams(params);
|
|
6767
|
+
}
|
|
6768
|
+
static validate(buffer, opts) {
|
|
6769
|
+
if (!buffer || buffer.length === void 0) {
|
|
6770
|
+
return { ok: false, code: "tn.invalid_buffer" };
|
|
6771
|
+
}
|
|
6772
|
+
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6773
|
+
let params = opts?.params ?? null;
|
|
6774
|
+
if (!params) {
|
|
6775
|
+
return { ok: false, code: "tn.param_extraction_failed" };
|
|
6776
|
+
}
|
|
6777
|
+
const __tnParamsRec = this.__tnPackParams(params);
|
|
6778
|
+
const irResult = this.__tnValidateInternal(buffer, __tnParamsRec);
|
|
6779
|
+
if (!irResult.ok) {
|
|
6780
|
+
return { ok: false, code: irResult.code, consumed: irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "RegisterCredentialArgs::validate") : void 0, params };
|
|
6781
|
+
}
|
|
6782
|
+
const consumed = irResult.consumed ? __tnBigIntToNumber3(irResult.consumed, "RegisterCredentialArgs::validate") : void 0;
|
|
6783
|
+
return { ok: true, consumed, params };
|
|
6784
|
+
}
|
|
6785
|
+
static from_array(buffer, opts) {
|
|
6079
6786
|
if (!buffer || buffer.length === void 0) {
|
|
6080
6787
|
return null;
|
|
6081
6788
|
}
|
|
6082
6789
|
new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
6083
|
-
|
|
6790
|
+
let params = opts?.params ?? null;
|
|
6791
|
+
if (!params) {
|
|
6792
|
+
__tnLogWarn3("RegisterCredentialArgs::from_array requires params when IR extraction is unavailable");
|
|
6793
|
+
return null;
|
|
6794
|
+
}
|
|
6795
|
+
const validation = this.validate(buffer, { params });
|
|
6084
6796
|
if (!validation.ok) {
|
|
6085
6797
|
return null;
|
|
6086
6798
|
}
|
|
6087
|
-
|
|
6799
|
+
const cached = validation.params ?? params;
|
|
6800
|
+
const state = new _RegisterCredentialArgs(buffer, cached);
|
|
6801
|
+
return state;
|
|
6088
6802
|
}
|
|
6089
6803
|
};
|
|
6804
|
+
((RegisterCredentialArgs2) => {
|
|
6805
|
+
RegisterCredentialArgs2.ParamKeys = Object.freeze({
|
|
6806
|
+
proof_body_hdr_type_slot: "proof_body.hdr.type_slot",
|
|
6807
|
+
proof_body_payload_size: "proof_body.payload_size"
|
|
6808
|
+
});
|
|
6809
|
+
RegisterCredentialArgs2.Params = {
|
|
6810
|
+
fromValues(input) {
|
|
6811
|
+
return {
|
|
6812
|
+
proof_body_hdr_type_slot: __tnToBigInt3(input.proof_body_hdr_type_slot),
|
|
6813
|
+
proof_body_payload_size: __tnToBigInt3(input.proof_body_payload_size)
|
|
6814
|
+
};
|
|
6815
|
+
},
|
|
6816
|
+
fromBuilder(source) {
|
|
6817
|
+
if (source.dynamicParams) {
|
|
6818
|
+
return source.dynamicParams();
|
|
6819
|
+
}
|
|
6820
|
+
if (source.params) {
|
|
6821
|
+
return source.params;
|
|
6822
|
+
}
|
|
6823
|
+
return source;
|
|
6824
|
+
}
|
|
6825
|
+
};
|
|
6826
|
+
function params(input) {
|
|
6827
|
+
return RegisterCredentialArgs2.Params.fromValues(input);
|
|
6828
|
+
}
|
|
6829
|
+
RegisterCredentialArgs2.params = params;
|
|
6830
|
+
})(RegisterCredentialArgs || (RegisterCredentialArgs = {}));
|
|
6090
6831
|
var RegisterCredentialArgsBuilder = class {
|
|
6091
6832
|
constructor() {
|
|
6833
|
+
this.__tnCachedParams = null;
|
|
6834
|
+
this.__tnLastBuffer = null;
|
|
6835
|
+
this.__tnLastParams = null;
|
|
6092
6836
|
this.__tnTail_state_proof = null;
|
|
6837
|
+
this.__tnTailParams_state_proof = null;
|
|
6093
6838
|
this.buffer = new Uint8Array(36);
|
|
6094
6839
|
this.view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
6095
6840
|
}
|
|
6096
6841
|
__tnInvalidate() {
|
|
6842
|
+
this.__tnCachedParams = null;
|
|
6843
|
+
this.__tnLastBuffer = null;
|
|
6844
|
+
this.__tnLastParams = null;
|
|
6097
6845
|
}
|
|
6098
6846
|
set_wallet_account_idx(value) {
|
|
6099
6847
|
this.view.setUint16(0, value, true);
|
|
@@ -6113,72 +6861,84 @@ var RegisterCredentialArgsBuilder = class {
|
|
|
6113
6861
|
}
|
|
6114
6862
|
set_state_proof(value) {
|
|
6115
6863
|
const bytes = __tnResolveStructFieldInput(value, "RegisterCredentialArgsBuilder::state_proof");
|
|
6864
|
+
const validation = __tnInvokeDynamicValidate3("StateProof", bytes);
|
|
6865
|
+
if (!validation.ok || validation.consumed === void 0) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' failed validation");
|
|
6866
|
+
if (__tnBigIntToNumber3(validation.consumed, "RegisterCredentialArgsBuilder::state_proof") !== bytes.length) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' validation did not consume the full buffer");
|
|
6116
6867
|
this.__tnTail_state_proof = bytes;
|
|
6868
|
+
this.__tnTailParams_state_proof = validation.params ?? null;
|
|
6117
6869
|
this.__tnInvalidate();
|
|
6118
6870
|
return this;
|
|
6119
6871
|
}
|
|
6120
6872
|
build() {
|
|
6121
|
-
const
|
|
6122
|
-
const size =
|
|
6873
|
+
const params = this.__tnComputeParams();
|
|
6874
|
+
const size = RegisterCredentialArgs.footprintFromParams(params);
|
|
6123
6875
|
const buffer = new Uint8Array(size);
|
|
6124
|
-
this.__tnWriteInto(buffer
|
|
6125
|
-
this.__tnValidateOrThrow(buffer);
|
|
6876
|
+
this.__tnWriteInto(buffer);
|
|
6877
|
+
this.__tnValidateOrThrow(buffer, params);
|
|
6126
6878
|
return buffer;
|
|
6127
6879
|
}
|
|
6128
6880
|
buildInto(target, offset = 0) {
|
|
6129
|
-
const
|
|
6130
|
-
const size =
|
|
6881
|
+
const params = this.__tnComputeParams();
|
|
6882
|
+
const size = RegisterCredentialArgs.footprintFromParams(params);
|
|
6131
6883
|
if (target.length - offset < size) throw new Error("RegisterCredentialArgsBuilder: target buffer too small");
|
|
6132
6884
|
const slice = target.subarray(offset, offset + size);
|
|
6133
|
-
this.__tnWriteInto(slice
|
|
6134
|
-
this.__tnValidateOrThrow(slice);
|
|
6885
|
+
this.__tnWriteInto(slice);
|
|
6886
|
+
this.__tnValidateOrThrow(slice, params);
|
|
6135
6887
|
return target;
|
|
6136
6888
|
}
|
|
6137
6889
|
finish() {
|
|
6138
6890
|
const buffer = this.build();
|
|
6139
|
-
const
|
|
6891
|
+
const params = this.__tnLastParams ?? this.__tnComputeParams();
|
|
6892
|
+
const view = RegisterCredentialArgs.from_array(buffer, { params });
|
|
6140
6893
|
if (!view) throw new Error("RegisterCredentialArgsBuilder: failed to finalize view");
|
|
6141
6894
|
return view;
|
|
6142
6895
|
}
|
|
6143
6896
|
finishView() {
|
|
6144
6897
|
return this.finish();
|
|
6145
6898
|
}
|
|
6146
|
-
|
|
6147
|
-
return
|
|
6148
|
-
(() => {
|
|
6149
|
-
const bytes = this.__tnTail_state_proof;
|
|
6150
|
-
if (!bytes) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be set before build()");
|
|
6151
|
-
return bytes;
|
|
6152
|
-
})()
|
|
6153
|
-
];
|
|
6899
|
+
dynamicParams() {
|
|
6900
|
+
return this.__tnComputeParams();
|
|
6154
6901
|
}
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6902
|
+
__tnComputeParams() {
|
|
6903
|
+
if (this.__tnCachedParams) return this.__tnCachedParams;
|
|
6904
|
+
const params = RegisterCredentialArgs.Params.fromValues({
|
|
6905
|
+
proof_body_hdr_type_slot: (() => {
|
|
6906
|
+
const params2 = this.__tnTailParams_state_proof;
|
|
6907
|
+
if (!params2 || params2["proof_body_hdr_type_slot"] === void 0) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before computing params");
|
|
6908
|
+
return params2["proof_body_hdr_type_slot"];
|
|
6909
|
+
})(),
|
|
6910
|
+
proof_body_payload_size: (() => {
|
|
6911
|
+
const params2 = this.__tnTailParams_state_proof;
|
|
6912
|
+
if (!params2 || params2["proof_body_payload_size"] === void 0) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before computing params");
|
|
6913
|
+
return params2["proof_body_payload_size"];
|
|
6914
|
+
})()
|
|
6915
|
+
});
|
|
6916
|
+
this.__tnCachedParams = params;
|
|
6917
|
+
return params;
|
|
6161
6918
|
}
|
|
6162
|
-
__tnWriteInto(target
|
|
6919
|
+
__tnWriteInto(target) {
|
|
6163
6920
|
target.set(this.buffer, 0);
|
|
6164
6921
|
let cursor = this.buffer.length;
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6922
|
+
const __tnLocal_state_proof_bytes = this.__tnTail_state_proof;
|
|
6923
|
+
if (!__tnLocal_state_proof_bytes) throw new Error("RegisterCredentialArgsBuilder: field 'state_proof' must be written before build");
|
|
6924
|
+
target.set(__tnLocal_state_proof_bytes, cursor);
|
|
6925
|
+
cursor += __tnLocal_state_proof_bytes.length;
|
|
6169
6926
|
}
|
|
6170
|
-
__tnValidateOrThrow(buffer) {
|
|
6171
|
-
const result = RegisterCredentialArgs.validate(buffer);
|
|
6927
|
+
__tnValidateOrThrow(buffer, params) {
|
|
6928
|
+
const result = RegisterCredentialArgs.validate(buffer, { params });
|
|
6172
6929
|
if (!result.ok) {
|
|
6173
|
-
throw new Error(
|
|
6930
|
+
throw new Error(`${RegisterCredentialArgs}Builder: builder produced invalid buffer (code=${result.code ?? "unknown"})`);
|
|
6174
6931
|
}
|
|
6932
|
+
this.__tnLastParams = result.params ?? params;
|
|
6933
|
+
this.__tnLastBuffer = buffer;
|
|
6175
6934
|
}
|
|
6176
6935
|
};
|
|
6177
6936
|
__tnRegisterFootprint3("RegisterCredentialArgs", (params) => RegisterCredentialArgs.__tnInvokeFootprint(params));
|
|
6178
6937
|
__tnRegisterValidate3("RegisterCredentialArgs", (buffer, params) => RegisterCredentialArgs.__tnInvokeValidate(buffer, params));
|
|
6179
6938
|
__tnRegisterDynamicValidate3("RegisterCredentialArgs", (buffer) => {
|
|
6180
6939
|
const result = RegisterCredentialArgs.validate(buffer);
|
|
6181
|
-
|
|
6940
|
+
const params = result.params;
|
|
6941
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
6182
6942
|
});
|
|
6183
6943
|
var __tn_ir_PasskeyInstruction = {
|
|
6184
6944
|
typeName: "PasskeyInstruction",
|
|
@@ -6439,7 +7199,7 @@ _PasskeyInstruction.payloadVariantDescriptors = Object.freeze([
|
|
|
6439
7199
|
tag: 1,
|
|
6440
7200
|
payloadSize: null,
|
|
6441
7201
|
payloadType: "PasskeyInstruction::payload::validate",
|
|
6442
|
-
createPayloadBuilder: () =>
|
|
7202
|
+
createPayloadBuilder: () => __tnMaybeCallBuilder(ValidateArgs)
|
|
6443
7203
|
},
|
|
6444
7204
|
{
|
|
6445
7205
|
name: "transfer",
|
|
@@ -6451,7 +7211,7 @@ _PasskeyInstruction.payloadVariantDescriptors = Object.freeze([
|
|
|
6451
7211
|
{
|
|
6452
7212
|
name: "add_authority",
|
|
6453
7213
|
tag: 4,
|
|
6454
|
-
payloadSize:
|
|
7214
|
+
payloadSize: 75,
|
|
6455
7215
|
payloadType: "PasskeyInstruction::payload::add_authority",
|
|
6456
7216
|
createPayloadBuilder: () => __tnMaybeCallBuilder(AddAuthorityArgs)
|
|
6457
7217
|
},
|
|
@@ -6606,35 +7366,108 @@ __tnRegisterFootprint3("PasskeyInstruction", (params) => PasskeyInstruction.__tn
|
|
|
6606
7366
|
__tnRegisterValidate3("PasskeyInstruction", (buffer, params) => PasskeyInstruction.__tnInvokeValidate(buffer, params));
|
|
6607
7367
|
__tnRegisterDynamicValidate3("PasskeyInstruction", (buffer) => {
|
|
6608
7368
|
const result = PasskeyInstruction.validate(buffer);
|
|
6609
|
-
|
|
7369
|
+
const params = result.params;
|
|
7370
|
+
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
6610
7371
|
});
|
|
6611
7372
|
|
|
7373
|
+
// src/passkey-manager/constants.ts
|
|
7374
|
+
var PASSKEY_MANAGER_PROGRAM_ADDRESS = "tabsq39mzj3DZlutXOGG6VtfMj8fUvI0HIOXfZm7TLLY6N";
|
|
7375
|
+
var INSTRUCTION_CREATE = 0;
|
|
7376
|
+
var INSTRUCTION_VALIDATE = 1;
|
|
7377
|
+
var INSTRUCTION_TRANSFER = 2;
|
|
7378
|
+
var INSTRUCTION_ADD_AUTHORITY = 4;
|
|
7379
|
+
var INSTRUCTION_REMOVE_AUTHORITY = 5;
|
|
7380
|
+
var INSTRUCTION_REGISTER_CREDENTIAL = 6;
|
|
7381
|
+
var AUTHORITY_TAG_PASSKEY = 1;
|
|
7382
|
+
var AUTHORITY_TAG_PUBKEY = 2;
|
|
7383
|
+
var AUTHORITY_BYTES = Authority.footprint();
|
|
7384
|
+
var AUTHORITY_RECORD_BYTES = AuthorityRecord.footprint();
|
|
7385
|
+
var LONG_LIVED_AUTHORITY_EXPIRY_SECONDS = 0xffffffffffffffffn;
|
|
7386
|
+
|
|
6612
7387
|
// src/passkey-manager/instructions/create.ts
|
|
7388
|
+
var AUTHORITY_DATA_BYTES = AUTHORITY_BYTES - 1;
|
|
7389
|
+
var PUBKEY_BYTES = AUTHORITY_DATA_BYTES / 2;
|
|
7390
|
+
var U64_MAX = 0xffffffffffffffffn;
|
|
6613
7391
|
function buildAuthority(authority) {
|
|
6614
|
-
const data = new Array(
|
|
7392
|
+
const data = new Array(AUTHORITY_DATA_BYTES).fill(0);
|
|
6615
7393
|
if (authority.tag === 1) {
|
|
6616
|
-
if (authority.pubkeyX.length !==
|
|
6617
|
-
if (authority.pubkeyY.length !==
|
|
6618
|
-
for (let i = 0; i <
|
|
6619
|
-
for (let i = 0; i <
|
|
7394
|
+
if (authority.pubkeyX.length !== PUBKEY_BYTES) throw new Error("pubkeyX must be 32 bytes");
|
|
7395
|
+
if (authority.pubkeyY.length !== PUBKEY_BYTES) throw new Error("pubkeyY must be 32 bytes");
|
|
7396
|
+
for (let i = 0; i < PUBKEY_BYTES; i++) data[i] = authority.pubkeyX[i];
|
|
7397
|
+
for (let i = 0; i < PUBKEY_BYTES; i++) data[PUBKEY_BYTES + i] = authority.pubkeyY[i];
|
|
6620
7398
|
} else if (authority.tag === 2) {
|
|
6621
|
-
if (authority.pubkey.length !==
|
|
6622
|
-
for (let i = 0; i <
|
|
7399
|
+
if (authority.pubkey.length !== PUBKEY_BYTES) throw new Error("pubkey must be 32 bytes");
|
|
7400
|
+
for (let i = 0; i < PUBKEY_BYTES; i++) data[i] = authority.pubkey[i];
|
|
6623
7401
|
} else {
|
|
6624
7402
|
throw new Error("Invalid authority tag");
|
|
6625
7403
|
}
|
|
6626
7404
|
return new AuthorityBuilder().set_tag(authority.tag).set_data(data).build();
|
|
6627
7405
|
}
|
|
7406
|
+
function copyGeneratedBuffer(view, label) {
|
|
7407
|
+
const buffer = view.buffer;
|
|
7408
|
+
if (!buffer) {
|
|
7409
|
+
throw new Error(`${label} did not expose a generated buffer`);
|
|
7410
|
+
}
|
|
7411
|
+
return buffer.slice();
|
|
7412
|
+
}
|
|
7413
|
+
function assertU64(value, label) {
|
|
7414
|
+
if (value < 0n || value > U64_MAX) {
|
|
7415
|
+
throw new Error(`${label} must fit in u64`);
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7418
|
+
function createAuthorityRecord(authority, expiresAtBlockTimeSeconds = LONG_LIVED_AUTHORITY_EXPIRY_SECONDS) {
|
|
7419
|
+
return { authority, expiresAtBlockTimeSeconds };
|
|
7420
|
+
}
|
|
7421
|
+
function createSessionAuthorityRecord(params) {
|
|
7422
|
+
return createAuthorityRecord(
|
|
7423
|
+
{ tag: 2, pubkey: params.pubkey },
|
|
7424
|
+
params.expiresAtBlockTimeSeconds
|
|
7425
|
+
);
|
|
7426
|
+
}
|
|
7427
|
+
function buildAuthorityRecord(record) {
|
|
7428
|
+
assertU64(record.expiresAtBlockTimeSeconds, "expiresAtBlockTimeSeconds");
|
|
7429
|
+
const authority = Authority.from_array(buildAuthority(record.authority));
|
|
7430
|
+
if (!authority) {
|
|
7431
|
+
throw new Error("Failed to build authority");
|
|
7432
|
+
}
|
|
7433
|
+
const authorityRecord = AuthorityRecord.__tnCreateView(
|
|
7434
|
+
new Uint8Array(AUTHORITY_RECORD_BYTES)
|
|
7435
|
+
);
|
|
7436
|
+
authorityRecord.set_authority(authority);
|
|
7437
|
+
authorityRecord.set_expires_at_block_time_seconds(
|
|
7438
|
+
record.expiresAtBlockTimeSeconds
|
|
7439
|
+
);
|
|
7440
|
+
return copyGeneratedBuffer(authorityRecord, "AuthorityRecord");
|
|
7441
|
+
}
|
|
6628
7442
|
function encodeCreateInstruction(params) {
|
|
6629
|
-
const { walletAccountIdx,
|
|
7443
|
+
const { walletAccountIdx, authorityRecord, seed, stateProof } = params;
|
|
6630
7444
|
if (seed.length !== 32) throw new Error("seed must be 32 bytes");
|
|
6631
7445
|
if (walletAccountIdx < 0 || walletAccountIdx > 65535) {
|
|
6632
7446
|
throw new Error("walletAccountIdx must be 0-65535");
|
|
6633
7447
|
}
|
|
6634
|
-
const
|
|
6635
|
-
const argsPayload = new CreateArgsBuilder().set_wallet_account_idx(walletAccountIdx).
|
|
7448
|
+
const authorityRecordBytes = buildAuthorityRecord(authorityRecord);
|
|
7449
|
+
const argsPayload = new CreateArgsBuilder().set_wallet_account_idx(walletAccountIdx).set_authority_record(authorityRecordBytes).set_seed(seed).set_state_proof(stateProof).build();
|
|
6636
7450
|
return new PasskeyInstructionBuilder().payload().select("create").writePayload(argsPayload).finish().build();
|
|
6637
7451
|
}
|
|
7452
|
+
function writeU16LE(target, offset, value) {
|
|
7453
|
+
target[offset] = value & 255;
|
|
7454
|
+
target[offset + 1] = value >> 8 & 255;
|
|
7455
|
+
}
|
|
7456
|
+
function encodeLegacyCreateInstruction(params) {
|
|
7457
|
+
const { walletAccountIdx, authorityRecord, seed, stateProof } = params;
|
|
7458
|
+
if (seed.length !== 32) throw new Error("seed must be 32 bytes");
|
|
7459
|
+
if (walletAccountIdx < 0 || walletAccountIdx > 65535) {
|
|
7460
|
+
throw new Error("walletAccountIdx must be 0-65535");
|
|
7461
|
+
}
|
|
7462
|
+
const authorityBytes = buildAuthority(authorityRecord.authority);
|
|
7463
|
+
const output = new Uint8Array(1 + 2 + authorityBytes.length + seed.length + stateProof.length);
|
|
7464
|
+
output[0] = INSTRUCTION_CREATE;
|
|
7465
|
+
writeU16LE(output, 1, walletAccountIdx);
|
|
7466
|
+
output.set(authorityBytes, 3);
|
|
7467
|
+
output.set(seed, 3 + authorityBytes.length);
|
|
7468
|
+
output.set(stateProof, 3 + authorityBytes.length + seed.length);
|
|
7469
|
+
return output;
|
|
7470
|
+
}
|
|
6638
7471
|
|
|
6639
7472
|
// src/passkey-manager/target-instruction.ts
|
|
6640
7473
|
function buildTargetInstructionBytes({
|
|
@@ -6659,14 +7492,6 @@ function buildTargetInstructionBytes({
|
|
|
6659
7492
|
}
|
|
6660
7493
|
|
|
6661
7494
|
// src/passkey-manager/instructions/validate.ts
|
|
6662
|
-
var U8_SIZE = Uint8Array.BYTES_PER_ELEMENT;
|
|
6663
|
-
var U16_SIZE = Uint16Array.BYTES_PER_ELEMENT;
|
|
6664
|
-
var P256_COORDINATE_SIZE = 32;
|
|
6665
|
-
var VALIDATE_FIXED_PREFIX_SIZE = U16_SIZE + U8_SIZE + P256_COORDINATE_SIZE + P256_COORDINATE_SIZE + U16_SIZE + U16_SIZE;
|
|
6666
|
-
function writeU16LE(target, offset, value) {
|
|
6667
|
-
target[offset] = value & 255;
|
|
6668
|
-
target[offset + 1] = value >> 8 & 255;
|
|
6669
|
-
}
|
|
6670
7495
|
function encodeValidateInstruction(params) {
|
|
6671
7496
|
const {
|
|
6672
7497
|
walletAccountIdx,
|
|
@@ -6690,28 +7515,10 @@ function encodeValidateInstruction(params) {
|
|
|
6690
7515
|
throw new Error("clientDataJSON length must be 0-65535");
|
|
6691
7516
|
}
|
|
6692
7517
|
const targetInstructionBytes = buildTargetInstructionBytes(targetInstruction);
|
|
6693
|
-
const
|
|
6694
|
-
|
|
6695
|
-
);
|
|
6696
|
-
|
|
6697
|
-
writeU16LE(argsPayload, offset, walletAccountIdx);
|
|
6698
|
-
offset += 2;
|
|
6699
|
-
argsPayload[offset] = authIdx;
|
|
6700
|
-
offset += 1;
|
|
6701
|
-
argsPayload.set(signatureR, offset);
|
|
6702
|
-
offset += signatureR.length;
|
|
6703
|
-
argsPayload.set(signatureS, offset);
|
|
6704
|
-
offset += signatureS.length;
|
|
6705
|
-
writeU16LE(argsPayload, offset, authenticatorData.length);
|
|
6706
|
-
offset += 2;
|
|
6707
|
-
writeU16LE(argsPayload, offset, clientDataJSON.length);
|
|
6708
|
-
offset += 2;
|
|
6709
|
-
argsPayload.set(authenticatorData, offset);
|
|
6710
|
-
offset += authenticatorData.length;
|
|
6711
|
-
argsPayload.set(clientDataJSON, offset);
|
|
6712
|
-
offset += clientDataJSON.length;
|
|
6713
|
-
argsPayload.set(targetInstructionBytes, offset);
|
|
6714
|
-
return new PasskeyInstructionBuilder().payload().select("validate").writePayload(argsPayload).finish().build();
|
|
7518
|
+
const argsBuilder = new ValidateArgsBuilder().set_wallet_account_idx(walletAccountIdx).set_auth_idx(authIdx).set_signature_r(signatureR).set_signature_s(signatureS).set_target_instruction(targetInstructionBytes);
|
|
7519
|
+
argsBuilder.authenticator_data().write(authenticatorData).finish();
|
|
7520
|
+
argsBuilder.client_data().write(clientDataJSON).finish();
|
|
7521
|
+
return new PasskeyInstructionBuilder().payload().select("validate").writePayload(argsBuilder).finish().build();
|
|
6715
7522
|
}
|
|
6716
7523
|
|
|
6717
7524
|
// src/passkey-manager/instructions/transfer.ts
|
|
@@ -6728,16 +7535,39 @@ function encodeTransferInstruction(params) {
|
|
|
6728
7535
|
return new PasskeyInstructionBuilder().payload().select("transfer").writePayload(argsPayload).finish().build();
|
|
6729
7536
|
}
|
|
6730
7537
|
|
|
7538
|
+
// src/passkey-manager/instructions/invoke.ts
|
|
7539
|
+
function encodeInvokeInstruction(_programPubkey, _instruction) {
|
|
7540
|
+
throw new Error(
|
|
7541
|
+
"encodeInvokeInstruction is from the legacy passkey-manager ABI. Migrate this flow to encodeValidateInstruction({ targetInstruction }) against the upgraded passkey manager."
|
|
7542
|
+
);
|
|
7543
|
+
}
|
|
7544
|
+
|
|
6731
7545
|
// src/passkey-manager/instructions/add-authority.ts
|
|
6732
7546
|
function encodeAddAuthorityInstruction(params) {
|
|
6733
7547
|
const { walletAccountIdx } = params;
|
|
6734
7548
|
if (walletAccountIdx < 0 || walletAccountIdx > 65535) {
|
|
6735
7549
|
throw new Error("walletAccountIdx must be 0-65535");
|
|
6736
7550
|
}
|
|
6737
|
-
const
|
|
6738
|
-
const argsPayload = new AddAuthorityArgsBuilder().set_wallet_account_idx(walletAccountIdx).
|
|
7551
|
+
const authorityRecordBytes = buildAuthorityRecord(params.authorityRecord);
|
|
7552
|
+
const argsPayload = new AddAuthorityArgsBuilder().set_wallet_account_idx(walletAccountIdx).set_authority_record(authorityRecordBytes).build();
|
|
6739
7553
|
return new PasskeyInstructionBuilder().payload().select("add_authority").writePayload(argsPayload).finish().build();
|
|
6740
7554
|
}
|
|
7555
|
+
function writeU16LE2(target, offset, value) {
|
|
7556
|
+
target[offset] = value & 255;
|
|
7557
|
+
target[offset + 1] = value >> 8 & 255;
|
|
7558
|
+
}
|
|
7559
|
+
function encodeLegacyAddAuthorityInstruction(params) {
|
|
7560
|
+
const { walletAccountIdx } = params;
|
|
7561
|
+
if (walletAccountIdx < 0 || walletAccountIdx > 65535) {
|
|
7562
|
+
throw new Error("walletAccountIdx must be 0-65535");
|
|
7563
|
+
}
|
|
7564
|
+
const authorityBytes = buildAuthority(params.authorityRecord.authority);
|
|
7565
|
+
const output = new Uint8Array(1 + 2 + authorityBytes.length);
|
|
7566
|
+
output[0] = INSTRUCTION_ADD_AUTHORITY;
|
|
7567
|
+
writeU16LE2(output, 1, walletAccountIdx);
|
|
7568
|
+
output.set(authorityBytes, 3);
|
|
7569
|
+
return output;
|
|
7570
|
+
}
|
|
6741
7571
|
|
|
6742
7572
|
// src/passkey-manager/instructions/remove-authority.ts
|
|
6743
7573
|
function encodeRemoveAuthorityInstruction(params) {
|
|
@@ -6764,6 +7594,21 @@ function encodeRegisterCredentialInstruction(params) {
|
|
|
6764
7594
|
return new PasskeyInstructionBuilder().payload().select("register_credential").writePayload(argsPayload).finish().build();
|
|
6765
7595
|
}
|
|
6766
7596
|
|
|
7597
|
+
// src/passkey-manager/instructions/shared.ts
|
|
7598
|
+
function concatenateInstructions(instructions) {
|
|
7599
|
+
const totalLength = instructions.reduce(
|
|
7600
|
+
(sum, instruction) => sum + instruction.length,
|
|
7601
|
+
0
|
|
7602
|
+
);
|
|
7603
|
+
const result = new Uint8Array(totalLength);
|
|
7604
|
+
let offset = 0;
|
|
7605
|
+
for (const instruction of instructions) {
|
|
7606
|
+
result.set(instruction, offset);
|
|
7607
|
+
offset += instruction.length;
|
|
7608
|
+
}
|
|
7609
|
+
return result;
|
|
7610
|
+
}
|
|
7611
|
+
|
|
6767
7612
|
// src/passkey-manager/challenge.ts
|
|
6768
7613
|
var VALIDATE_CHALLENGE_DOMAIN = "thru.passkey.validate";
|
|
6769
7614
|
function writeU64LE(target, offset, value) {
|
|
@@ -6978,50 +7823,79 @@ function buildPasskeyReadWriteAccounts(userAccounts, feePayerPublicKey, programA
|
|
|
6978
7823
|
};
|
|
6979
7824
|
return { readWriteAddresses, findAccountIndex };
|
|
6980
7825
|
}
|
|
7826
|
+
var LEGACY_WALLET_HEADER_BYTES = 9;
|
|
7827
|
+
var LEGACY_AUTHORITY_BYTES = 65;
|
|
7828
|
+
var AUTHORITY_DATA_BYTES2 = 64;
|
|
6981
7829
|
function parseWalletNonce(data) {
|
|
6982
7830
|
const account = WalletAccount.from_array(data);
|
|
6983
|
-
if (!account) return 0n;
|
|
7831
|
+
if (!account) return parseLegacyWalletNonce(data) ?? 0n;
|
|
6984
7832
|
return account.get_nonce();
|
|
6985
7833
|
}
|
|
6986
7834
|
async function fetchWalletNonce(sdk, walletAddress) {
|
|
6987
7835
|
const account = await sdk.accounts.get(walletAddress);
|
|
6988
7836
|
const data = account.data?.data;
|
|
6989
7837
|
if (!data) return 0n;
|
|
6990
|
-
|
|
6991
|
-
if (!parsed) return 0n;
|
|
6992
|
-
return parsed.get_nonce();
|
|
6993
|
-
}
|
|
6994
|
-
var AUTHORITY_HEADER_BYTES = 9;
|
|
6995
|
-
var AUTHORITY_ENTRY_BYTES = 65;
|
|
6996
|
-
function readU64LE(data, offset) {
|
|
6997
|
-
if (offset + 8 > data.length) {
|
|
6998
|
-
throw new Error("Out of bounds");
|
|
6999
|
-
}
|
|
7000
|
-
let value = 0n;
|
|
7001
|
-
for (let i = 0; i < 8; i++) {
|
|
7002
|
-
value |= BigInt(data[offset + i]) << 8n * BigInt(i);
|
|
7003
|
-
}
|
|
7004
|
-
return value;
|
|
7838
|
+
return parseWalletNonce(data);
|
|
7005
7839
|
}
|
|
7006
7840
|
function parseWalletAuthorities(data) {
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
const nonce = readU64LE(data, 1);
|
|
7012
|
-
const count = numAuth + 1;
|
|
7013
|
-
const required = AUTHORITY_HEADER_BYTES + count * AUTHORITY_ENTRY_BYTES;
|
|
7014
|
-
if (data.length < required) {
|
|
7841
|
+
const account = WalletAccount.from_array(data);
|
|
7842
|
+
if (!account) {
|
|
7843
|
+
const legacy = parseLegacyWalletAuthorities(data);
|
|
7844
|
+
if (legacy) return legacy;
|
|
7015
7845
|
throw new Error("Wallet data truncated");
|
|
7016
7846
|
}
|
|
7017
7847
|
const authorities = [];
|
|
7018
|
-
|
|
7019
|
-
const
|
|
7848
|
+
account.get_authorities().forEach((record, idx) => {
|
|
7849
|
+
const authority = record.get_authority();
|
|
7850
|
+
const tag = authority.get_tag();
|
|
7851
|
+
const payload = Uint8Array.from(authority.get_data());
|
|
7852
|
+
const expiresAtBlockTimeSeconds = record.get_expires_at_block_time_seconds();
|
|
7853
|
+
if (tag === 1) {
|
|
7854
|
+
authorities.push({
|
|
7855
|
+
idx,
|
|
7856
|
+
expiresAtBlockTimeSeconds,
|
|
7857
|
+
kind: "passkey",
|
|
7858
|
+
x: payload.slice(0, 32),
|
|
7859
|
+
y: payload.slice(32, 64)
|
|
7860
|
+
});
|
|
7861
|
+
return;
|
|
7862
|
+
}
|
|
7863
|
+
if (tag === 2) {
|
|
7864
|
+
authorities.push({
|
|
7865
|
+
idx,
|
|
7866
|
+
expiresAtBlockTimeSeconds,
|
|
7867
|
+
kind: "pubkey",
|
|
7868
|
+
pubkey: payload.slice(0, 32)
|
|
7869
|
+
});
|
|
7870
|
+
return;
|
|
7871
|
+
}
|
|
7872
|
+
authorities.push({ idx, expiresAtBlockTimeSeconds, kind: "unknown", tag, data: payload });
|
|
7873
|
+
});
|
|
7874
|
+
return { nonce: account.get_nonce(), authorities, layout: "authorityRecord" };
|
|
7875
|
+
}
|
|
7876
|
+
function parseLegacyWalletNonce(data) {
|
|
7877
|
+
if (data.length < LEGACY_WALLET_HEADER_BYTES) return null;
|
|
7878
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
7879
|
+
return view.getBigUint64(1, true);
|
|
7880
|
+
}
|
|
7881
|
+
function parseLegacyWalletAuthorities(data) {
|
|
7882
|
+
if (data.length < LEGACY_WALLET_HEADER_BYTES) return null;
|
|
7883
|
+
const numAuth = data[0];
|
|
7884
|
+
const authorityCount = numAuth + 1;
|
|
7885
|
+
const requiredLength = LEGACY_WALLET_HEADER_BYTES + authorityCount * LEGACY_AUTHORITY_BYTES;
|
|
7886
|
+
if (data.length < requiredLength) return null;
|
|
7887
|
+
const nonce = parseLegacyWalletNonce(data);
|
|
7888
|
+
if (nonce === null) return null;
|
|
7889
|
+
const authorities = [];
|
|
7890
|
+
for (let idx = 0; idx < authorityCount; idx += 1) {
|
|
7891
|
+
const offset = LEGACY_WALLET_HEADER_BYTES + idx * LEGACY_AUTHORITY_BYTES;
|
|
7020
7892
|
const tag = data[offset];
|
|
7021
|
-
const payload = data.slice(offset + 1, offset +
|
|
7893
|
+
const payload = data.slice(offset + 1, offset + 1 + AUTHORITY_DATA_BYTES2);
|
|
7894
|
+
const expiresAtBlockTimeSeconds = LONG_LIVED_AUTHORITY_EXPIRY_SECONDS;
|
|
7022
7895
|
if (tag === 1) {
|
|
7023
7896
|
authorities.push({
|
|
7024
7897
|
idx,
|
|
7898
|
+
expiresAtBlockTimeSeconds,
|
|
7025
7899
|
kind: "passkey",
|
|
7026
7900
|
x: payload.slice(0, 32),
|
|
7027
7901
|
y: payload.slice(32, 64)
|
|
@@ -7029,12 +7903,17 @@ function parseWalletAuthorities(data) {
|
|
|
7029
7903
|
continue;
|
|
7030
7904
|
}
|
|
7031
7905
|
if (tag === 2) {
|
|
7032
|
-
authorities.push({
|
|
7906
|
+
authorities.push({
|
|
7907
|
+
idx,
|
|
7908
|
+
expiresAtBlockTimeSeconds,
|
|
7909
|
+
kind: "pubkey",
|
|
7910
|
+
pubkey: payload.slice(0, 32)
|
|
7911
|
+
});
|
|
7033
7912
|
continue;
|
|
7034
7913
|
}
|
|
7035
|
-
authorities.push({ idx, kind: "unknown", tag, data: payload });
|
|
7914
|
+
authorities.push({ idx, expiresAtBlockTimeSeconds, kind: "unknown", tag, data: payload });
|
|
7036
7915
|
}
|
|
7037
|
-
return { nonce, authorities };
|
|
7916
|
+
return { nonce, authorities, layout: "legacyAuthority" };
|
|
7038
7917
|
}
|
|
7039
7918
|
function formatAuthorityPubkey(pubkey) {
|
|
7040
7919
|
return helpers.encodeAddress(pubkey);
|
|
@@ -7185,6 +8064,8 @@ Object.defineProperty(exports, "encodeAddress", {
|
|
|
7185
8064
|
enumerable: true,
|
|
7186
8065
|
get: function () { return helpers.encodeAddress; }
|
|
7187
8066
|
});
|
|
8067
|
+
exports.AUTHORITY_BYTES = AUTHORITY_BYTES;
|
|
8068
|
+
exports.AUTHORITY_RECORD_BYTES = AUTHORITY_RECORD_BYTES;
|
|
7188
8069
|
exports.AUTHORITY_TAG_PASSKEY = AUTHORITY_TAG_PASSKEY;
|
|
7189
8070
|
exports.AUTHORITY_TAG_PUBKEY = AUTHORITY_TAG_PUBKEY;
|
|
7190
8071
|
exports.FEE_PAYER_ADDRESS = FEE_PAYER_ADDRESS;
|
|
@@ -7194,6 +8075,7 @@ exports.INSTRUCTION_REGISTER_CREDENTIAL = INSTRUCTION_REGISTER_CREDENTIAL;
|
|
|
7194
8075
|
exports.INSTRUCTION_REMOVE_AUTHORITY = INSTRUCTION_REMOVE_AUTHORITY;
|
|
7195
8076
|
exports.INSTRUCTION_TRANSFER = INSTRUCTION_TRANSFER;
|
|
7196
8077
|
exports.INSTRUCTION_VALIDATE = INSTRUCTION_VALIDATE;
|
|
8078
|
+
exports.LONG_LIVED_AUTHORITY_EXPIRY_SECONDS = LONG_LIVED_AUTHORITY_EXPIRY_SECONDS;
|
|
7197
8079
|
exports.P256_HALF_N = P256_HALF_N;
|
|
7198
8080
|
exports.P256_N = P256_N;
|
|
7199
8081
|
exports.PASSKEY_MANAGER_PROGRAM_ADDRESS = PASSKEY_MANAGER_PROGRAM_ADDRESS;
|
|
@@ -7203,6 +8085,8 @@ exports.base64UrlToArrayBuffer = base64UrlToArrayBuffer;
|
|
|
7203
8085
|
exports.base64UrlToBytes = base64UrlToBytes;
|
|
7204
8086
|
exports.bigIntToBytesBE = bigIntToBytesBE;
|
|
7205
8087
|
exports.buildAccountContext = buildAccountContext;
|
|
8088
|
+
exports.buildAuthority = buildAuthority;
|
|
8089
|
+
exports.buildAuthorityRecord = buildAuthorityRecord;
|
|
7206
8090
|
exports.buildPasskeyReadWriteAccounts = buildPasskeyReadWriteAccounts;
|
|
7207
8091
|
exports.bytesEqual = bytesEqual;
|
|
7208
8092
|
exports.bytesToBase64 = bytesToBase64;
|
|
@@ -7210,13 +8094,19 @@ exports.bytesToBase64Url = bytesToBase64Url;
|
|
|
7210
8094
|
exports.bytesToBigIntBE = bytesToBigIntBE;
|
|
7211
8095
|
exports.bytesToHex = bytesToHex;
|
|
7212
8096
|
exports.compareBytes = compareBytes;
|
|
8097
|
+
exports.concatenateInstructions = concatenateInstructions;
|
|
8098
|
+
exports.createAuthorityRecord = createAuthorityRecord;
|
|
7213
8099
|
exports.createCredentialLookupSeed = createCredentialLookupSeed;
|
|
8100
|
+
exports.createSessionAuthorityRecord = createSessionAuthorityRecord;
|
|
7214
8101
|
exports.createValidateChallenge = createValidateChallenge;
|
|
7215
8102
|
exports.createWalletSeed = createWalletSeed;
|
|
7216
8103
|
exports.deriveCredentialLookupAddress = deriveCredentialLookupAddress;
|
|
7217
8104
|
exports.deriveWalletAddress = deriveWalletAddress;
|
|
7218
8105
|
exports.encodeAddAuthorityInstruction = encodeAddAuthorityInstruction;
|
|
7219
8106
|
exports.encodeCreateInstruction = encodeCreateInstruction;
|
|
8107
|
+
exports.encodeInvokeInstruction = encodeInvokeInstruction;
|
|
8108
|
+
exports.encodeLegacyAddAuthorityInstruction = encodeLegacyAddAuthorityInstruction;
|
|
8109
|
+
exports.encodeLegacyCreateInstruction = encodeLegacyCreateInstruction;
|
|
7220
8110
|
exports.encodeRegisterCredentialInstruction = encodeRegisterCredentialInstruction;
|
|
7221
8111
|
exports.encodeRemoveAuthorityInstruction = encodeRemoveAuthorityInstruction;
|
|
7222
8112
|
exports.encodeTransferInstruction = encodeTransferInstruction;
|