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