@qorechain/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -13
- package/dist/index.cjs +703 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +438 -56
- package/dist/index.d.ts +438 -56
- package/dist/index.js +683 -91
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6743,7 +6743,10 @@ __export(tx_exports6, {
|
|
|
6743
6743
|
MsgExecuteProgramResponse: () => MsgExecuteProgramResponse,
|
|
6744
6744
|
MsgRegisterSVMPQCKey: () => MsgRegisterSVMPQCKey,
|
|
6745
6745
|
MsgRegisterSVMPQCKeyResponse: () => MsgRegisterSVMPQCKeyResponse,
|
|
6746
|
+
MsgUpdateParams: () => MsgUpdateParams,
|
|
6747
|
+
MsgUpdateParamsResponse: () => MsgUpdateParamsResponse,
|
|
6746
6748
|
SVMAuth: () => SVMAuth,
|
|
6749
|
+
SVMParams: () => SVMParams,
|
|
6747
6750
|
SvmAccountMeta: () => SvmAccountMeta,
|
|
6748
6751
|
protobufPackage: () => protobufPackage6
|
|
6749
6752
|
});
|
|
@@ -7480,6 +7483,292 @@ var MsgRegisterSVMPQCKeyResponse = {
|
|
|
7480
7483
|
return message;
|
|
7481
7484
|
}
|
|
7482
7485
|
};
|
|
7486
|
+
function createBaseSVMParams() {
|
|
7487
|
+
return {
|
|
7488
|
+
maxProgramSize: "0",
|
|
7489
|
+
maxAccountDataSize: "0",
|
|
7490
|
+
computeBudgetMax: "0",
|
|
7491
|
+
lamportsPerByte: "0",
|
|
7492
|
+
rentExemptionMulti: "",
|
|
7493
|
+
enabled: false,
|
|
7494
|
+
svmSlotOffset: "0",
|
|
7495
|
+
defaultSigScheme: 0,
|
|
7496
|
+
maxCpi: 0
|
|
7497
|
+
};
|
|
7498
|
+
}
|
|
7499
|
+
var SVMParams = {
|
|
7500
|
+
encode(message, writer = new BinaryWriter()) {
|
|
7501
|
+
if (message.maxProgramSize !== "0") {
|
|
7502
|
+
writer.uint32(8).uint64(message.maxProgramSize);
|
|
7503
|
+
}
|
|
7504
|
+
if (message.maxAccountDataSize !== "0") {
|
|
7505
|
+
writer.uint32(16).uint64(message.maxAccountDataSize);
|
|
7506
|
+
}
|
|
7507
|
+
if (message.computeBudgetMax !== "0") {
|
|
7508
|
+
writer.uint32(24).uint64(message.computeBudgetMax);
|
|
7509
|
+
}
|
|
7510
|
+
if (message.lamportsPerByte !== "0") {
|
|
7511
|
+
writer.uint32(32).uint64(message.lamportsPerByte);
|
|
7512
|
+
}
|
|
7513
|
+
if (message.rentExemptionMulti !== "") {
|
|
7514
|
+
writer.uint32(42).string(message.rentExemptionMulti);
|
|
7515
|
+
}
|
|
7516
|
+
if (message.enabled !== false) {
|
|
7517
|
+
writer.uint32(48).bool(message.enabled);
|
|
7518
|
+
}
|
|
7519
|
+
if (message.svmSlotOffset !== "0") {
|
|
7520
|
+
writer.uint32(56).int64(message.svmSlotOffset);
|
|
7521
|
+
}
|
|
7522
|
+
if (message.defaultSigScheme !== 0) {
|
|
7523
|
+
writer.uint32(64).uint32(message.defaultSigScheme);
|
|
7524
|
+
}
|
|
7525
|
+
if (message.maxCpi !== 0) {
|
|
7526
|
+
writer.uint32(72).uint32(message.maxCpi);
|
|
7527
|
+
}
|
|
7528
|
+
return writer;
|
|
7529
|
+
},
|
|
7530
|
+
decode(input, length) {
|
|
7531
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
7532
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7533
|
+
const message = createBaseSVMParams();
|
|
7534
|
+
while (reader.pos < end) {
|
|
7535
|
+
const tag = reader.uint32();
|
|
7536
|
+
switch (tag >>> 3) {
|
|
7537
|
+
case 1: {
|
|
7538
|
+
if (tag !== 8) {
|
|
7539
|
+
break;
|
|
7540
|
+
}
|
|
7541
|
+
message.maxProgramSize = reader.uint64().toString();
|
|
7542
|
+
continue;
|
|
7543
|
+
}
|
|
7544
|
+
case 2: {
|
|
7545
|
+
if (tag !== 16) {
|
|
7546
|
+
break;
|
|
7547
|
+
}
|
|
7548
|
+
message.maxAccountDataSize = reader.uint64().toString();
|
|
7549
|
+
continue;
|
|
7550
|
+
}
|
|
7551
|
+
case 3: {
|
|
7552
|
+
if (tag !== 24) {
|
|
7553
|
+
break;
|
|
7554
|
+
}
|
|
7555
|
+
message.computeBudgetMax = reader.uint64().toString();
|
|
7556
|
+
continue;
|
|
7557
|
+
}
|
|
7558
|
+
case 4: {
|
|
7559
|
+
if (tag !== 32) {
|
|
7560
|
+
break;
|
|
7561
|
+
}
|
|
7562
|
+
message.lamportsPerByte = reader.uint64().toString();
|
|
7563
|
+
continue;
|
|
7564
|
+
}
|
|
7565
|
+
case 5: {
|
|
7566
|
+
if (tag !== 42) {
|
|
7567
|
+
break;
|
|
7568
|
+
}
|
|
7569
|
+
message.rentExemptionMulti = reader.string();
|
|
7570
|
+
continue;
|
|
7571
|
+
}
|
|
7572
|
+
case 6: {
|
|
7573
|
+
if (tag !== 48) {
|
|
7574
|
+
break;
|
|
7575
|
+
}
|
|
7576
|
+
message.enabled = reader.bool();
|
|
7577
|
+
continue;
|
|
7578
|
+
}
|
|
7579
|
+
case 7: {
|
|
7580
|
+
if (tag !== 56) {
|
|
7581
|
+
break;
|
|
7582
|
+
}
|
|
7583
|
+
message.svmSlotOffset = reader.int64().toString();
|
|
7584
|
+
continue;
|
|
7585
|
+
}
|
|
7586
|
+
case 8: {
|
|
7587
|
+
if (tag !== 64) {
|
|
7588
|
+
break;
|
|
7589
|
+
}
|
|
7590
|
+
message.defaultSigScheme = reader.uint32();
|
|
7591
|
+
continue;
|
|
7592
|
+
}
|
|
7593
|
+
case 9: {
|
|
7594
|
+
if (tag !== 72) {
|
|
7595
|
+
break;
|
|
7596
|
+
}
|
|
7597
|
+
message.maxCpi = reader.uint32();
|
|
7598
|
+
continue;
|
|
7599
|
+
}
|
|
7600
|
+
}
|
|
7601
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7602
|
+
break;
|
|
7603
|
+
}
|
|
7604
|
+
reader.skip(tag & 7);
|
|
7605
|
+
}
|
|
7606
|
+
return message;
|
|
7607
|
+
},
|
|
7608
|
+
fromJSON(object) {
|
|
7609
|
+
return {
|
|
7610
|
+
maxProgramSize: isSet7(object.maxProgramSize) ? globalThis.String(object.maxProgramSize) : isSet7(object.max_program_size) ? globalThis.String(object.max_program_size) : "0",
|
|
7611
|
+
maxAccountDataSize: isSet7(object.maxAccountDataSize) ? globalThis.String(object.maxAccountDataSize) : isSet7(object.max_account_data_size) ? globalThis.String(object.max_account_data_size) : "0",
|
|
7612
|
+
computeBudgetMax: isSet7(object.computeBudgetMax) ? globalThis.String(object.computeBudgetMax) : isSet7(object.compute_budget_max) ? globalThis.String(object.compute_budget_max) : "0",
|
|
7613
|
+
lamportsPerByte: isSet7(object.lamportsPerByte) ? globalThis.String(object.lamportsPerByte) : isSet7(object.lamports_per_byte) ? globalThis.String(object.lamports_per_byte) : "0",
|
|
7614
|
+
rentExemptionMulti: isSet7(object.rentExemptionMulti) ? globalThis.String(object.rentExemptionMulti) : isSet7(object.rent_exemption_multi) ? globalThis.String(object.rent_exemption_multi) : "",
|
|
7615
|
+
enabled: isSet7(object.enabled) ? globalThis.Boolean(object.enabled) : false,
|
|
7616
|
+
svmSlotOffset: isSet7(object.svmSlotOffset) ? globalThis.String(object.svmSlotOffset) : isSet7(object.svm_slot_offset) ? globalThis.String(object.svm_slot_offset) : "0",
|
|
7617
|
+
defaultSigScheme: isSet7(object.defaultSigScheme) ? globalThis.Number(object.defaultSigScheme) : isSet7(object.default_sig_scheme) ? globalThis.Number(object.default_sig_scheme) : 0,
|
|
7618
|
+
maxCpi: isSet7(object.maxCpi) ? globalThis.Number(object.maxCpi) : isSet7(object.max_cpi) ? globalThis.Number(object.max_cpi) : 0
|
|
7619
|
+
};
|
|
7620
|
+
},
|
|
7621
|
+
toJSON(message) {
|
|
7622
|
+
const obj = {};
|
|
7623
|
+
if (message.maxProgramSize !== "0") {
|
|
7624
|
+
obj.maxProgramSize = message.maxProgramSize;
|
|
7625
|
+
}
|
|
7626
|
+
if (message.maxAccountDataSize !== "0") {
|
|
7627
|
+
obj.maxAccountDataSize = message.maxAccountDataSize;
|
|
7628
|
+
}
|
|
7629
|
+
if (message.computeBudgetMax !== "0") {
|
|
7630
|
+
obj.computeBudgetMax = message.computeBudgetMax;
|
|
7631
|
+
}
|
|
7632
|
+
if (message.lamportsPerByte !== "0") {
|
|
7633
|
+
obj.lamportsPerByte = message.lamportsPerByte;
|
|
7634
|
+
}
|
|
7635
|
+
if (message.rentExemptionMulti !== "") {
|
|
7636
|
+
obj.rentExemptionMulti = message.rentExemptionMulti;
|
|
7637
|
+
}
|
|
7638
|
+
if (message.enabled !== false) {
|
|
7639
|
+
obj.enabled = message.enabled;
|
|
7640
|
+
}
|
|
7641
|
+
if (message.svmSlotOffset !== "0") {
|
|
7642
|
+
obj.svmSlotOffset = message.svmSlotOffset;
|
|
7643
|
+
}
|
|
7644
|
+
if (message.defaultSigScheme !== 0) {
|
|
7645
|
+
obj.defaultSigScheme = Math.round(message.defaultSigScheme);
|
|
7646
|
+
}
|
|
7647
|
+
if (message.maxCpi !== 0) {
|
|
7648
|
+
obj.maxCpi = Math.round(message.maxCpi);
|
|
7649
|
+
}
|
|
7650
|
+
return obj;
|
|
7651
|
+
},
|
|
7652
|
+
create(base) {
|
|
7653
|
+
return SVMParams.fromPartial(base ?? {});
|
|
7654
|
+
},
|
|
7655
|
+
fromPartial(object) {
|
|
7656
|
+
const message = createBaseSVMParams();
|
|
7657
|
+
message.maxProgramSize = object.maxProgramSize ?? "0";
|
|
7658
|
+
message.maxAccountDataSize = object.maxAccountDataSize ?? "0";
|
|
7659
|
+
message.computeBudgetMax = object.computeBudgetMax ?? "0";
|
|
7660
|
+
message.lamportsPerByte = object.lamportsPerByte ?? "0";
|
|
7661
|
+
message.rentExemptionMulti = object.rentExemptionMulti ?? "";
|
|
7662
|
+
message.enabled = object.enabled ?? false;
|
|
7663
|
+
message.svmSlotOffset = object.svmSlotOffset ?? "0";
|
|
7664
|
+
message.defaultSigScheme = object.defaultSigScheme ?? 0;
|
|
7665
|
+
message.maxCpi = object.maxCpi ?? 0;
|
|
7666
|
+
return message;
|
|
7667
|
+
}
|
|
7668
|
+
};
|
|
7669
|
+
function createBaseMsgUpdateParams() {
|
|
7670
|
+
return { authority: "", params: void 0 };
|
|
7671
|
+
}
|
|
7672
|
+
var MsgUpdateParams = {
|
|
7673
|
+
encode(message, writer = new BinaryWriter()) {
|
|
7674
|
+
if (message.authority !== "") {
|
|
7675
|
+
writer.uint32(10).string(message.authority);
|
|
7676
|
+
}
|
|
7677
|
+
if (message.params !== void 0) {
|
|
7678
|
+
SVMParams.encode(message.params, writer.uint32(18).fork()).join();
|
|
7679
|
+
}
|
|
7680
|
+
return writer;
|
|
7681
|
+
},
|
|
7682
|
+
decode(input, length) {
|
|
7683
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
7684
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7685
|
+
const message = createBaseMsgUpdateParams();
|
|
7686
|
+
while (reader.pos < end) {
|
|
7687
|
+
const tag = reader.uint32();
|
|
7688
|
+
switch (tag >>> 3) {
|
|
7689
|
+
case 1: {
|
|
7690
|
+
if (tag !== 10) {
|
|
7691
|
+
break;
|
|
7692
|
+
}
|
|
7693
|
+
message.authority = reader.string();
|
|
7694
|
+
continue;
|
|
7695
|
+
}
|
|
7696
|
+
case 2: {
|
|
7697
|
+
if (tag !== 18) {
|
|
7698
|
+
break;
|
|
7699
|
+
}
|
|
7700
|
+
message.params = SVMParams.decode(reader, reader.uint32());
|
|
7701
|
+
continue;
|
|
7702
|
+
}
|
|
7703
|
+
}
|
|
7704
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7705
|
+
break;
|
|
7706
|
+
}
|
|
7707
|
+
reader.skip(tag & 7);
|
|
7708
|
+
}
|
|
7709
|
+
return message;
|
|
7710
|
+
},
|
|
7711
|
+
fromJSON(object) {
|
|
7712
|
+
return {
|
|
7713
|
+
authority: isSet7(object.authority) ? globalThis.String(object.authority) : "",
|
|
7714
|
+
params: isSet7(object.params) ? SVMParams.fromJSON(object.params) : void 0
|
|
7715
|
+
};
|
|
7716
|
+
},
|
|
7717
|
+
toJSON(message) {
|
|
7718
|
+
const obj = {};
|
|
7719
|
+
if (message.authority !== "") {
|
|
7720
|
+
obj.authority = message.authority;
|
|
7721
|
+
}
|
|
7722
|
+
if (message.params !== void 0) {
|
|
7723
|
+
obj.params = SVMParams.toJSON(message.params);
|
|
7724
|
+
}
|
|
7725
|
+
return obj;
|
|
7726
|
+
},
|
|
7727
|
+
create(base) {
|
|
7728
|
+
return MsgUpdateParams.fromPartial(base ?? {});
|
|
7729
|
+
},
|
|
7730
|
+
fromPartial(object) {
|
|
7731
|
+
const message = createBaseMsgUpdateParams();
|
|
7732
|
+
message.authority = object.authority ?? "";
|
|
7733
|
+
message.params = object.params !== void 0 && object.params !== null ? SVMParams.fromPartial(object.params) : void 0;
|
|
7734
|
+
return message;
|
|
7735
|
+
}
|
|
7736
|
+
};
|
|
7737
|
+
function createBaseMsgUpdateParamsResponse() {
|
|
7738
|
+
return {};
|
|
7739
|
+
}
|
|
7740
|
+
var MsgUpdateParamsResponse = {
|
|
7741
|
+
encode(_, writer = new BinaryWriter()) {
|
|
7742
|
+
return writer;
|
|
7743
|
+
},
|
|
7744
|
+
decode(input, length) {
|
|
7745
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
7746
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7747
|
+
const message = createBaseMsgUpdateParamsResponse();
|
|
7748
|
+
while (reader.pos < end) {
|
|
7749
|
+
const tag = reader.uint32();
|
|
7750
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7751
|
+
break;
|
|
7752
|
+
}
|
|
7753
|
+
reader.skip(tag & 7);
|
|
7754
|
+
}
|
|
7755
|
+
return message;
|
|
7756
|
+
},
|
|
7757
|
+
fromJSON(_) {
|
|
7758
|
+
return {};
|
|
7759
|
+
},
|
|
7760
|
+
toJSON(_) {
|
|
7761
|
+
const obj = {};
|
|
7762
|
+
return obj;
|
|
7763
|
+
},
|
|
7764
|
+
create(base) {
|
|
7765
|
+
return MsgUpdateParamsResponse.fromPartial(base ?? {});
|
|
7766
|
+
},
|
|
7767
|
+
fromPartial(_) {
|
|
7768
|
+
const message = createBaseMsgUpdateParamsResponse();
|
|
7769
|
+
return message;
|
|
7770
|
+
}
|
|
7771
|
+
};
|
|
7483
7772
|
var MsgDefinition6 = {
|
|
7484
7773
|
name: "Msg",
|
|
7485
7774
|
fullName: "qorechain.svm.v1.Msg",
|
|
@@ -7515,6 +7804,14 @@ var MsgDefinition6 = {
|
|
|
7515
7804
|
responseType: MsgRegisterSVMPQCKeyResponse,
|
|
7516
7805
|
responseStream: false,
|
|
7517
7806
|
options: {}
|
|
7807
|
+
},
|
|
7808
|
+
updateParams: {
|
|
7809
|
+
name: "UpdateParams",
|
|
7810
|
+
requestType: MsgUpdateParams,
|
|
7811
|
+
requestStream: false,
|
|
7812
|
+
responseType: MsgUpdateParamsResponse,
|
|
7813
|
+
responseStream: false,
|
|
7814
|
+
options: {}
|
|
7518
7815
|
}
|
|
7519
7816
|
}
|
|
7520
7817
|
};
|
|
@@ -9849,7 +10146,15 @@ __export(tx_exports10, {
|
|
|
9849
10146
|
});
|
|
9850
10147
|
var protobufPackage10 = "qorechain.crossvm.v1";
|
|
9851
10148
|
function createBaseMsgCrossVMCall() {
|
|
9852
|
-
return {
|
|
10149
|
+
return {
|
|
10150
|
+
sender: "",
|
|
10151
|
+
sourceVm: "",
|
|
10152
|
+
targetVm: "",
|
|
10153
|
+
targetContract: "",
|
|
10154
|
+
payload: new Uint8Array(0),
|
|
10155
|
+
funds: [],
|
|
10156
|
+
async: false
|
|
10157
|
+
};
|
|
9853
10158
|
}
|
|
9854
10159
|
var MsgCrossVMCall = {
|
|
9855
10160
|
encode(message, writer = new BinaryWriter()) {
|
|
@@ -9871,6 +10176,9 @@ var MsgCrossVMCall = {
|
|
|
9871
10176
|
for (const v of message.funds) {
|
|
9872
10177
|
Coin.encode(v, writer.uint32(50).fork()).join();
|
|
9873
10178
|
}
|
|
10179
|
+
if (message.async !== false) {
|
|
10180
|
+
writer.uint32(56).bool(message.async);
|
|
10181
|
+
}
|
|
9874
10182
|
return writer;
|
|
9875
10183
|
},
|
|
9876
10184
|
decode(input, length) {
|
|
@@ -9922,6 +10230,13 @@ var MsgCrossVMCall = {
|
|
|
9922
10230
|
message.funds.push(Coin.decode(reader, reader.uint32()));
|
|
9923
10231
|
continue;
|
|
9924
10232
|
}
|
|
10233
|
+
case 7: {
|
|
10234
|
+
if (tag !== 56) {
|
|
10235
|
+
break;
|
|
10236
|
+
}
|
|
10237
|
+
message.async = reader.bool();
|
|
10238
|
+
continue;
|
|
10239
|
+
}
|
|
9925
10240
|
}
|
|
9926
10241
|
if ((tag & 7) === 4 || tag === 0) {
|
|
9927
10242
|
break;
|
|
@@ -9937,7 +10252,8 @@ var MsgCrossVMCall = {
|
|
|
9937
10252
|
targetVm: isSet11(object.targetVm) ? globalThis.String(object.targetVm) : isSet11(object.target_vm) ? globalThis.String(object.target_vm) : "",
|
|
9938
10253
|
targetContract: isSet11(object.targetContract) ? globalThis.String(object.targetContract) : isSet11(object.target_contract) ? globalThis.String(object.target_contract) : "",
|
|
9939
10254
|
payload: isSet11(object.payload) ? bytesFromBase647(object.payload) : new Uint8Array(0),
|
|
9940
|
-
funds: globalThis.Array.isArray(object?.funds) ? object.funds.map((e) => Coin.fromJSON(e)) : []
|
|
10255
|
+
funds: globalThis.Array.isArray(object?.funds) ? object.funds.map((e) => Coin.fromJSON(e)) : [],
|
|
10256
|
+
async: isSet11(object.async) ? globalThis.Boolean(object.async) : false
|
|
9941
10257
|
};
|
|
9942
10258
|
},
|
|
9943
10259
|
toJSON(message) {
|
|
@@ -9960,6 +10276,9 @@ var MsgCrossVMCall = {
|
|
|
9960
10276
|
if (message.funds?.length) {
|
|
9961
10277
|
obj.funds = message.funds.map((e) => Coin.toJSON(e));
|
|
9962
10278
|
}
|
|
10279
|
+
if (message.async !== false) {
|
|
10280
|
+
obj.async = message.async;
|
|
10281
|
+
}
|
|
9963
10282
|
return obj;
|
|
9964
10283
|
},
|
|
9965
10284
|
create(base) {
|
|
@@ -9973,17 +10292,27 @@ var MsgCrossVMCall = {
|
|
|
9973
10292
|
message.targetContract = object.targetContract ?? "";
|
|
9974
10293
|
message.payload = object.payload ?? new Uint8Array(0);
|
|
9975
10294
|
message.funds = object.funds?.map((e) => Coin.fromPartial(e)) || [];
|
|
10295
|
+
message.async = object.async ?? false;
|
|
9976
10296
|
return message;
|
|
9977
10297
|
}
|
|
9978
10298
|
};
|
|
9979
10299
|
function createBaseMsgCrossVMCallResponse() {
|
|
9980
|
-
return { messageId: "" };
|
|
10300
|
+
return { messageId: "", executed: false, data: new Uint8Array(0), gasUsed: "0" };
|
|
9981
10301
|
}
|
|
9982
10302
|
var MsgCrossVMCallResponse = {
|
|
9983
10303
|
encode(message, writer = new BinaryWriter()) {
|
|
9984
10304
|
if (message.messageId !== "") {
|
|
9985
10305
|
writer.uint32(10).string(message.messageId);
|
|
9986
10306
|
}
|
|
10307
|
+
if (message.executed !== false) {
|
|
10308
|
+
writer.uint32(16).bool(message.executed);
|
|
10309
|
+
}
|
|
10310
|
+
if (message.data.length !== 0) {
|
|
10311
|
+
writer.uint32(26).bytes(message.data);
|
|
10312
|
+
}
|
|
10313
|
+
if (message.gasUsed !== "0") {
|
|
10314
|
+
writer.uint32(32).uint64(message.gasUsed);
|
|
10315
|
+
}
|
|
9987
10316
|
return writer;
|
|
9988
10317
|
},
|
|
9989
10318
|
decode(input, length) {
|
|
@@ -10000,6 +10329,27 @@ var MsgCrossVMCallResponse = {
|
|
|
10000
10329
|
message.messageId = reader.string();
|
|
10001
10330
|
continue;
|
|
10002
10331
|
}
|
|
10332
|
+
case 2: {
|
|
10333
|
+
if (tag !== 16) {
|
|
10334
|
+
break;
|
|
10335
|
+
}
|
|
10336
|
+
message.executed = reader.bool();
|
|
10337
|
+
continue;
|
|
10338
|
+
}
|
|
10339
|
+
case 3: {
|
|
10340
|
+
if (tag !== 26) {
|
|
10341
|
+
break;
|
|
10342
|
+
}
|
|
10343
|
+
message.data = reader.bytes();
|
|
10344
|
+
continue;
|
|
10345
|
+
}
|
|
10346
|
+
case 4: {
|
|
10347
|
+
if (tag !== 32) {
|
|
10348
|
+
break;
|
|
10349
|
+
}
|
|
10350
|
+
message.gasUsed = reader.uint64().toString();
|
|
10351
|
+
continue;
|
|
10352
|
+
}
|
|
10003
10353
|
}
|
|
10004
10354
|
if ((tag & 7) === 4 || tag === 0) {
|
|
10005
10355
|
break;
|
|
@@ -10010,7 +10360,10 @@ var MsgCrossVMCallResponse = {
|
|
|
10010
10360
|
},
|
|
10011
10361
|
fromJSON(object) {
|
|
10012
10362
|
return {
|
|
10013
|
-
messageId: isSet11(object.messageId) ? globalThis.String(object.messageId) : isSet11(object.message_id) ? globalThis.String(object.message_id) : ""
|
|
10363
|
+
messageId: isSet11(object.messageId) ? globalThis.String(object.messageId) : isSet11(object.message_id) ? globalThis.String(object.message_id) : "",
|
|
10364
|
+
executed: isSet11(object.executed) ? globalThis.Boolean(object.executed) : false,
|
|
10365
|
+
data: isSet11(object.data) ? bytesFromBase647(object.data) : new Uint8Array(0),
|
|
10366
|
+
gasUsed: isSet11(object.gasUsed) ? globalThis.String(object.gasUsed) : isSet11(object.gas_used) ? globalThis.String(object.gas_used) : "0"
|
|
10014
10367
|
};
|
|
10015
10368
|
},
|
|
10016
10369
|
toJSON(message) {
|
|
@@ -10018,6 +10371,15 @@ var MsgCrossVMCallResponse = {
|
|
|
10018
10371
|
if (message.messageId !== "") {
|
|
10019
10372
|
obj.messageId = message.messageId;
|
|
10020
10373
|
}
|
|
10374
|
+
if (message.executed !== false) {
|
|
10375
|
+
obj.executed = message.executed;
|
|
10376
|
+
}
|
|
10377
|
+
if (message.data.length !== 0) {
|
|
10378
|
+
obj.data = base64FromBytes7(message.data);
|
|
10379
|
+
}
|
|
10380
|
+
if (message.gasUsed !== "0") {
|
|
10381
|
+
obj.gasUsed = message.gasUsed;
|
|
10382
|
+
}
|
|
10021
10383
|
return obj;
|
|
10022
10384
|
},
|
|
10023
10385
|
create(base) {
|
|
@@ -10026,6 +10388,9 @@ var MsgCrossVMCallResponse = {
|
|
|
10026
10388
|
fromPartial(object) {
|
|
10027
10389
|
const message = createBaseMsgCrossVMCallResponse();
|
|
10028
10390
|
message.messageId = object.messageId ?? "";
|
|
10391
|
+
message.executed = object.executed ?? false;
|
|
10392
|
+
message.data = object.data ?? new Uint8Array(0);
|
|
10393
|
+
message.gasUsed = object.gasUsed ?? "0";
|
|
10029
10394
|
return message;
|
|
10030
10395
|
}
|
|
10031
10396
|
};
|
|
@@ -10119,7 +10484,11 @@ var MsgDefinition10 = {
|
|
|
10119
10484
|
name: "Msg",
|
|
10120
10485
|
fullName: "qorechain.crossvm.v1.Msg",
|
|
10121
10486
|
methods: {
|
|
10122
|
-
/**
|
|
10487
|
+
/**
|
|
10488
|
+
* CrossVMCall invokes a contract on another VM. It executes within the
|
|
10489
|
+
* transaction and returns the callee's answer, unless async is set, in which
|
|
10490
|
+
* case it is queued for ProcessQueue to dispatch later.
|
|
10491
|
+
*/
|
|
10123
10492
|
crossVMCall: {
|
|
10124
10493
|
name: "CrossVMCall",
|
|
10125
10494
|
requestType: MsgCrossVMCall,
|
|
@@ -10743,6 +11112,7 @@ var qorechainRegistryTypes = [
|
|
|
10743
11112
|
["/qorechain.svm.v1.MsgCreateAccount", MsgCreateAccount],
|
|
10744
11113
|
["/qorechain.svm.v1.MsgExecuteProgram", MsgExecuteProgram],
|
|
10745
11114
|
["/qorechain.svm.v1.MsgRegisterSVMPQCKey", MsgRegisterSVMPQCKey],
|
|
11115
|
+
["/qorechain.svm.v1.MsgUpdateParams", MsgUpdateParams],
|
|
10746
11116
|
// lightnode
|
|
10747
11117
|
["/qorechain.lightnode.v1.MsgRegisterLightNode", MsgRegisterLightNode],
|
|
10748
11118
|
["/qorechain.lightnode.v1.MsgHeartbeat", MsgHeartbeat],
|
|
@@ -11090,7 +11460,12 @@ var TxClient = class _TxClient {
|
|
|
11090
11460
|
height: res.height,
|
|
11091
11461
|
gasUsed: res.gasUsed,
|
|
11092
11462
|
gasWanted: res.gasWanted,
|
|
11093
|
-
rawLog: res.rawLog
|
|
11463
|
+
rawLog: res.rawLog,
|
|
11464
|
+
// Carried through so callers can read typed attributes / decode the
|
|
11465
|
+
// per-message responses (e.g. MsgCrossVMCallResponse) without a
|
|
11466
|
+
// second round-trip.
|
|
11467
|
+
events: res.events,
|
|
11468
|
+
msgResponses: res.msgResponses
|
|
11094
11469
|
};
|
|
11095
11470
|
}
|
|
11096
11471
|
const hash = await this.client.signAndBroadcastSync(
|
|
@@ -11718,9 +12093,16 @@ function generatePqcKeypair(seed) {
|
|
|
11718
12093
|
return { publicKey: kp.publicKey, secretKey: kp.secretKey };
|
|
11719
12094
|
}
|
|
11720
12095
|
function pqcSign(secretKey, message, opts) {
|
|
12096
|
+
if (secretKey.length !== ML_DSA_87_SECRET_KEY_LENGTH) {
|
|
12097
|
+
throw new Error(
|
|
12098
|
+
`ML-DSA-87 secret key must be ${ML_DSA_87_SECRET_KEY_LENGTH} bytes, got ${secretKey.length}`
|
|
12099
|
+
);
|
|
12100
|
+
}
|
|
11721
12101
|
return mldsa87.sign(secretKey, message, opts);
|
|
11722
12102
|
}
|
|
11723
12103
|
function pqcVerify(publicKey, message, signature) {
|
|
12104
|
+
if (publicKey.length !== ML_DSA_87_PUBLIC_KEY_LENGTH) return false;
|
|
12105
|
+
if (signature.length !== ML_DSA_87_SIGNATURE_LENGTH) return false;
|
|
11724
12106
|
return mldsa87.verify(publicKey, message, signature);
|
|
11725
12107
|
}
|
|
11726
12108
|
function buildHybridSignatureExtension(args) {
|
|
@@ -11931,37 +12313,17 @@ function unifiedAccountFromSeed(seed32) {
|
|
|
11931
12313
|
pqc: pqc2
|
|
11932
12314
|
};
|
|
11933
12315
|
}
|
|
11934
|
-
|
|
11935
|
-
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
if (!pk) throw new Error("Phantom provider exposed no public key");
|
|
11941
|
-
if (pk instanceof Uint8Array) return pk;
|
|
11942
|
-
return pk.toBytes();
|
|
11943
|
-
}
|
|
11944
|
-
function signatureBytes(res) {
|
|
11945
|
-
return res instanceof Uint8Array ? res : res.signature;
|
|
12316
|
+
|
|
12317
|
+
// src/accounts/phantom.ts
|
|
12318
|
+
function unifiedAccountFromPhantomSignature(signatureBytes) {
|
|
12319
|
+
throw new Error(
|
|
12320
|
+
"unifiedAccountFromPhantomSignature was removed in v0.8.0: deriving a spend key from a wallet signature is unsafe \u2014 the signature is a bearer secret that any page can request from the wallet, so whoever obtains it controls the account. Use the authenticator lanes instead: register the external key with MsgRegisterAuthenticator and spend via MsgExecuteCosmos / MsgExecuteEVM (see the Authenticators guide). Any account previously derived this way must be treated as exposed \u2014 move its funds."
|
|
12321
|
+
);
|
|
11946
12322
|
}
|
|
11947
12323
|
async function connectPhantomUnified(opts = {}) {
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
throw new Error(
|
|
11951
|
-
"no Phantom provider found (window.solana); pass opts.provider"
|
|
11952
|
-
);
|
|
11953
|
-
}
|
|
11954
|
-
const conn = await provider.connect();
|
|
11955
|
-
const pk = pubkeyBytes(
|
|
11956
|
-
provider.publicKey ?? conn.publicKey
|
|
12324
|
+
throw new Error(
|
|
12325
|
+
"connectPhantomUnified was removed in v0.8.0: deriving a spend key from a wallet signature is unsafe \u2014 the signature is a bearer secret that any page can request from the wallet, so whoever obtains it controls the account. Use the authenticator lanes instead: register the external key with MsgRegisterAuthenticator and spend via MsgExecuteCosmos / MsgExecuteEVM (see the Authenticators guide). Any account previously derived this way must be treated as exposed \u2014 move its funds."
|
|
11957
12326
|
);
|
|
11958
|
-
const message = `${PHANTOM_DERIVATION_DOMAIN}
|
|
11959
|
-
${base58.encode(pk)}`;
|
|
11960
|
-
const signed = await provider.signMessage(
|
|
11961
|
-
new TextEncoder().encode(message),
|
|
11962
|
-
"utf8"
|
|
11963
|
-
);
|
|
11964
|
-
return unifiedAccountFromPhantomSignature(signatureBytes(signed));
|
|
11965
12327
|
}
|
|
11966
12328
|
async function directSignerFromPrivateKey(privateKey, prefix) {
|
|
11967
12329
|
if (privateKey.length !== 32) {
|
|
@@ -12339,21 +12701,28 @@ function attachHybridExtension(body, ext, opts = {}) {
|
|
|
12339
12701
|
}
|
|
12340
12702
|
return next;
|
|
12341
12703
|
}
|
|
12704
|
+
|
|
12705
|
+
// src/tx/signbytes.ts
|
|
12706
|
+
var SIGN_BYTES_V2_UPGRADE = "v3.1.98";
|
|
12707
|
+
var LEGACY_SIGN_BYTES_CHAINS = [
|
|
12708
|
+
"qorechain-vladi",
|
|
12709
|
+
"qorechain-diana"
|
|
12710
|
+
];
|
|
12711
|
+
var HYBRID_SIGN_BYTES_V2_DOMAIN = "qorechain-pqc-hybrid-v2";
|
|
12712
|
+
var MIGRATION_SIGN_BYTES_V2_DOMAIN = "qorechain-key-migration-v2";
|
|
12713
|
+
var BRIDGE_ATTESTATION_V2_DOMAIN = "qorechain-bridge-attestation-v2";
|
|
12714
|
+
var utf8 = new TextEncoder();
|
|
12342
12715
|
function be32(n) {
|
|
12343
12716
|
const b = new Uint8Array(4);
|
|
12344
|
-
b
|
|
12345
|
-
b[1] = n >>> 16 & 255;
|
|
12346
|
-
b[2] = n >>> 8 & 255;
|
|
12347
|
-
b[3] = n & 255;
|
|
12717
|
+
new DataView(b.buffer).setUint32(0, n >>> 0, false);
|
|
12348
12718
|
return b;
|
|
12349
12719
|
}
|
|
12350
|
-
function
|
|
12351
|
-
const
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
return out;
|
|
12720
|
+
function be642(n) {
|
|
12721
|
+
const b = new Uint8Array(8);
|
|
12722
|
+
new DataView(b.buffer).setBigUint64(0, BigInt(n), false);
|
|
12723
|
+
return b;
|
|
12355
12724
|
}
|
|
12356
|
-
function
|
|
12725
|
+
function concat2(parts) {
|
|
12357
12726
|
let total = 0;
|
|
12358
12727
|
for (const p of parts) total += p.length;
|
|
12359
12728
|
const out = new Uint8Array(total);
|
|
@@ -12364,6 +12733,154 @@ function concatBytes(...parts) {
|
|
|
12364
12733
|
}
|
|
12365
12734
|
return out;
|
|
12366
12735
|
}
|
|
12736
|
+
function assertVersion(version) {
|
|
12737
|
+
if (version !== "v1" && version !== "v2") {
|
|
12738
|
+
throw new Error(`sign-bytes version must be "v1" or "v2", got ${JSON.stringify(version)}`);
|
|
12739
|
+
}
|
|
12740
|
+
}
|
|
12741
|
+
function hybridSignBytesV1(b0, authInfo) {
|
|
12742
|
+
return concat2([be32(b0.length), b0, be32(authInfo.length), authInfo]);
|
|
12743
|
+
}
|
|
12744
|
+
function hybridSignBytesV2(chainId, b0, authInfo) {
|
|
12745
|
+
const cid = utf8.encode(chainId);
|
|
12746
|
+
return concat2([
|
|
12747
|
+
utf8.encode(HYBRID_SIGN_BYTES_V2_DOMAIN),
|
|
12748
|
+
be642(cid.length),
|
|
12749
|
+
cid,
|
|
12750
|
+
be32(b0.length),
|
|
12751
|
+
b0,
|
|
12752
|
+
be32(authInfo.length),
|
|
12753
|
+
authInfo
|
|
12754
|
+
]);
|
|
12755
|
+
}
|
|
12756
|
+
function hybridSignBytes(version, chainId, b0, authInfo) {
|
|
12757
|
+
assertVersion(version);
|
|
12758
|
+
return version === "v2" ? hybridSignBytesV2(chainId, b0, authInfo) : hybridSignBytesV1(b0, authInfo);
|
|
12759
|
+
}
|
|
12760
|
+
function migrationSignBytesV1(input) {
|
|
12761
|
+
return utf8.encode(
|
|
12762
|
+
`qorechain-key-migration:chain=${input.chainId}:from=${input.fromAlgorithmId}:to=${input.toAlgorithmId}:account=${input.account}:height=${BigInt(input.height)}`
|
|
12763
|
+
);
|
|
12764
|
+
}
|
|
12765
|
+
function migrationSignBytesV2(input) {
|
|
12766
|
+
const cid = utf8.encode(input.chainId);
|
|
12767
|
+
const acct = utf8.encode(input.account);
|
|
12768
|
+
return concat2([
|
|
12769
|
+
utf8.encode(MIGRATION_SIGN_BYTES_V2_DOMAIN),
|
|
12770
|
+
be642(cid.length),
|
|
12771
|
+
cid,
|
|
12772
|
+
be642(acct.length),
|
|
12773
|
+
acct,
|
|
12774
|
+
be32(input.fromAlgorithmId),
|
|
12775
|
+
be32(input.toAlgorithmId),
|
|
12776
|
+
be642(input.height),
|
|
12777
|
+
be32(input.oldPublicKey.length),
|
|
12778
|
+
input.oldPublicKey,
|
|
12779
|
+
be32(input.newPublicKey.length),
|
|
12780
|
+
input.newPublicKey
|
|
12781
|
+
]);
|
|
12782
|
+
}
|
|
12783
|
+
function migrationSignBytes(version, input) {
|
|
12784
|
+
assertVersion(version);
|
|
12785
|
+
return version === "v2" ? migrationSignBytesV2(input) : migrationSignBytesV1(input);
|
|
12786
|
+
}
|
|
12787
|
+
function bridgeAttestationSignBytesV1(input) {
|
|
12788
|
+
return utf8.encode(
|
|
12789
|
+
[input.chain, input.eventType, input.operationId, input.txHash, input.amount, input.asset].join("|")
|
|
12790
|
+
);
|
|
12791
|
+
}
|
|
12792
|
+
function bridgeAttestationSignBytesV2(input) {
|
|
12793
|
+
const parts = [utf8.encode(BRIDGE_ATTESTATION_V2_DOMAIN)];
|
|
12794
|
+
for (const f of [
|
|
12795
|
+
input.chainId,
|
|
12796
|
+
input.chain,
|
|
12797
|
+
input.eventType,
|
|
12798
|
+
input.operationId,
|
|
12799
|
+
input.txHash,
|
|
12800
|
+
input.amount,
|
|
12801
|
+
input.asset
|
|
12802
|
+
]) {
|
|
12803
|
+
const b = utf8.encode(f);
|
|
12804
|
+
parts.push(be642(b.length), b);
|
|
12805
|
+
}
|
|
12806
|
+
return concat2(parts);
|
|
12807
|
+
}
|
|
12808
|
+
function bridgeAttestationSignBytes(version, input) {
|
|
12809
|
+
assertVersion(version);
|
|
12810
|
+
return version === "v2" ? bridgeAttestationSignBytesV2(input) : bridgeAttestationSignBytesV1(input);
|
|
12811
|
+
}
|
|
12812
|
+
function isLegacySignBytesChain(chainId) {
|
|
12813
|
+
return LEGACY_SIGN_BYTES_CHAINS.includes(chainId);
|
|
12814
|
+
}
|
|
12815
|
+
function signBytesVersionFor(chainId, v2AppliedHeight) {
|
|
12816
|
+
return BigInt(v2AppliedHeight) > 0n || !isLegacySignBytesChain(chainId) ? "v2" : "v1";
|
|
12817
|
+
}
|
|
12818
|
+
function parseAppliedHeight(body) {
|
|
12819
|
+
const h = body?.height;
|
|
12820
|
+
if (h === void 0 || h === null || h === "") return 0n;
|
|
12821
|
+
if (typeof h !== "string" && typeof h !== "number" && typeof h !== "bigint") {
|
|
12822
|
+
throw new Error(`unexpected applied_plan height ${JSON.stringify(h)}`);
|
|
12823
|
+
}
|
|
12824
|
+
return BigInt(h);
|
|
12825
|
+
}
|
|
12826
|
+
async function fetchSignBytesV2AppliedHeight(rest, fetchImpl = globalThis.fetch) {
|
|
12827
|
+
const url = `${rest.replace(/\/+$/, "")}/cosmos/upgrade/v1beta1/applied_plan/${SIGN_BYTES_V2_UPGRADE}`;
|
|
12828
|
+
const res = await fetchImpl(url);
|
|
12829
|
+
if (!res.ok) {
|
|
12830
|
+
throw new Error(`applied_plan query failed: HTTP ${res.status} from ${url}`);
|
|
12831
|
+
}
|
|
12832
|
+
return parseAppliedHeight(await res.json());
|
|
12833
|
+
}
|
|
12834
|
+
var cache = /* @__PURE__ */ new Map();
|
|
12835
|
+
function clearSignBytesCache() {
|
|
12836
|
+
cache.clear();
|
|
12837
|
+
}
|
|
12838
|
+
async function resolveSignBytesVersion(opts) {
|
|
12839
|
+
const requested = opts.signBytesVersion ?? "auto";
|
|
12840
|
+
if (requested === "v1" || requested === "v2") return requested;
|
|
12841
|
+
if (requested !== "auto") {
|
|
12842
|
+
throw new Error(`signBytesVersion must be "auto", "v1" or "v2", got ${JSON.stringify(requested)}`);
|
|
12843
|
+
}
|
|
12844
|
+
if (!isLegacySignBytesChain(opts.chainId)) return "v2";
|
|
12845
|
+
if (!opts.rest) {
|
|
12846
|
+
throw new Error(
|
|
12847
|
+
`cannot choose the hybrid sign-bytes form for ${opts.chainId} without its REST endpoint: pass rest, or signBytesVersion "v1" (before the ${SIGN_BYTES_V2_UPGRADE} upgrade) or "v2" (after)`
|
|
12848
|
+
);
|
|
12849
|
+
}
|
|
12850
|
+
const key = `${opts.rest}\0${opts.chainId}`;
|
|
12851
|
+
const ttl = opts.ttlMs ?? 6e4;
|
|
12852
|
+
const hit = cache.get(key);
|
|
12853
|
+
if (!opts.forceRefresh && hit && Date.now() - hit.at < ttl) return hit.version;
|
|
12854
|
+
let height;
|
|
12855
|
+
try {
|
|
12856
|
+
height = await fetchSignBytesV2AppliedHeight(opts.rest, opts.fetch);
|
|
12857
|
+
} catch (e) {
|
|
12858
|
+
throw new Error(
|
|
12859
|
+
`cannot ask ${opts.rest} whether ${SIGN_BYTES_V2_UPGRADE} is applied (${e.message}); pass signBytesVersion "v1" or "v2"`
|
|
12860
|
+
);
|
|
12861
|
+
}
|
|
12862
|
+
const version = signBytesVersionFor(opts.chainId, height);
|
|
12863
|
+
cache.set(key, { version, at: Date.now() });
|
|
12864
|
+
return version;
|
|
12865
|
+
}
|
|
12866
|
+
var HYBRID_SIGN_BYTES_REJECTION_LOG = "hybrid PQC signature verification failed";
|
|
12867
|
+
function isHybridSignBytesRejection(x) {
|
|
12868
|
+
if (x === null || x === void 0) return false;
|
|
12869
|
+
const o = x;
|
|
12870
|
+
if (o.codespace === "pqc" && Number(o.code) === 21) return true;
|
|
12871
|
+
for (const t of [o.log, o.rawLog, o.message]) {
|
|
12872
|
+
if (typeof t === "string" && t.includes(HYBRID_SIGN_BYTES_REJECTION_LOG)) return true;
|
|
12873
|
+
}
|
|
12874
|
+
return false;
|
|
12875
|
+
}
|
|
12876
|
+
|
|
12877
|
+
// src/tx/hybrid-tx.ts
|
|
12878
|
+
function fromBase64(b64) {
|
|
12879
|
+
const binary = atob(b64);
|
|
12880
|
+
const out = new Uint8Array(binary.length);
|
|
12881
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
12882
|
+
return out;
|
|
12883
|
+
}
|
|
12367
12884
|
async function buildHybridTx(opts) {
|
|
12368
12885
|
const {
|
|
12369
12886
|
registry,
|
|
@@ -12399,12 +12916,14 @@ async function buildHybridTx(opts) {
|
|
|
12399
12916
|
fee.payer,
|
|
12400
12917
|
SignMode.SIGN_MODE_DIRECT
|
|
12401
12918
|
);
|
|
12402
|
-
const
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12919
|
+
const signBytesVersion = await resolveSignBytesVersion({
|
|
12920
|
+
chainId,
|
|
12921
|
+
rest: opts.rest,
|
|
12922
|
+
signBytesVersion: opts.signBytesVersion,
|
|
12923
|
+
fetch: opts.fetch,
|
|
12924
|
+
forceRefresh: opts.forceRefreshSignBytesVersion
|
|
12925
|
+
});
|
|
12926
|
+
const pqcSignedMessage = hybridSignBytes(signBytesVersion, chainId, b0, authInfoBytes);
|
|
12408
12927
|
const pqcSignature = pqcSign(pqcKeypair.secretKey, pqcSignedMessage);
|
|
12409
12928
|
const ext = buildHybridSignatureExtension({
|
|
12410
12929
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12438,18 +12957,34 @@ async function buildHybridTx(opts) {
|
|
|
12438
12957
|
txRawBytes,
|
|
12439
12958
|
authInfoBytes,
|
|
12440
12959
|
pqcSignedMessage,
|
|
12441
|
-
pqcSignature
|
|
12960
|
+
pqcSignature,
|
|
12961
|
+
signBytesVersion
|
|
12442
12962
|
};
|
|
12443
12963
|
}
|
|
12444
12964
|
async function signAndBroadcastHybrid(opts) {
|
|
12965
|
+
const auto = (opts.signBytesVersion ?? "auto") === "auto";
|
|
12966
|
+
try {
|
|
12967
|
+
return await broadcastHybridOnce(opts, false);
|
|
12968
|
+
} catch (e) {
|
|
12969
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
12970
|
+
return broadcastHybridOnce(opts, true);
|
|
12971
|
+
}
|
|
12972
|
+
}
|
|
12973
|
+
async function broadcastHybridOnce(opts, forceRefresh) {
|
|
12445
12974
|
const { transport } = opts;
|
|
12446
12975
|
const mode = opts.mode ?? "commit";
|
|
12447
|
-
const built = await buildHybridTx(
|
|
12976
|
+
const built = await buildHybridTx({
|
|
12977
|
+
...opts,
|
|
12978
|
+
forceRefreshSignBytesVersion: forceRefresh || opts.forceRefreshSignBytesVersion
|
|
12979
|
+
});
|
|
12448
12980
|
if (mode === "commit") {
|
|
12449
12981
|
const res = await transport.broadcastTx(built.txRawBytes);
|
|
12450
12982
|
if (res.code !== 0) {
|
|
12451
|
-
throw
|
|
12452
|
-
|
|
12983
|
+
throw Object.assign(
|
|
12984
|
+
new Error(
|
|
12985
|
+
`hybrid transaction failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
12986
|
+
),
|
|
12987
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
12453
12988
|
);
|
|
12454
12989
|
}
|
|
12455
12990
|
return {
|
|
@@ -12473,24 +13008,11 @@ function fromHex(hex) {
|
|
|
12473
13008
|
}
|
|
12474
13009
|
return bytes;
|
|
12475
13010
|
}
|
|
12476
|
-
function
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
b[3] = n & 255;
|
|
12482
|
-
return b;
|
|
12483
|
-
}
|
|
12484
|
-
function concatBytes2(...parts) {
|
|
12485
|
-
let total = 0;
|
|
12486
|
-
for (const p of parts) total += p.length;
|
|
12487
|
-
const out = new Uint8Array(total);
|
|
12488
|
-
let off = 0;
|
|
12489
|
-
for (const p of parts) {
|
|
12490
|
-
out.set(p, off);
|
|
12491
|
-
off += p.length;
|
|
12492
|
-
}
|
|
12493
|
-
return out;
|
|
13011
|
+
function defaultSignBytesVersion(chainId) {
|
|
13012
|
+
if (!isLegacySignBytesChain(chainId)) return "v2";
|
|
13013
|
+
throw new Error(
|
|
13014
|
+
`signHybridEth on ${chainId} needs signBytesVersion: resolve it with resolveSignBytesVersion({ chainId, rest }) \u2014 the network switches from v1 to v2 at its own upgrade height`
|
|
13015
|
+
);
|
|
12494
13016
|
}
|
|
12495
13017
|
function encodeMessages(params) {
|
|
12496
13018
|
const enc3 = params.encodeMessage;
|
|
@@ -12576,12 +13098,8 @@ function signHybridEth(params) {
|
|
|
12576
13098
|
const b0 = TxBody.encode(
|
|
12577
13099
|
TxBody.fromPartial({ messages: encodedMessages, memo, timeoutHeight })
|
|
12578
13100
|
).finish();
|
|
12579
|
-
const
|
|
12580
|
-
|
|
12581
|
-
b0,
|
|
12582
|
-
be322(authInfoBytes.length),
|
|
12583
|
-
authInfoBytes
|
|
12584
|
-
);
|
|
13101
|
+
const version = params.signBytesVersion ?? defaultSignBytesVersion(params.chainId);
|
|
13102
|
+
const pqcSignedMessage = hybridSignBytes(version, params.chainId, b0, authInfoBytes);
|
|
12585
13103
|
const pqcSignature = pqcSign(params.account.pqc.secretKey, pqcSignedMessage);
|
|
12586
13104
|
const ext = buildHybridSignatureExtension({
|
|
12587
13105
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12630,6 +13148,22 @@ var EthNativeSigner = class {
|
|
|
12630
13148
|
};
|
|
12631
13149
|
this.registry = opts.registry ?? qorechainRegistry();
|
|
12632
13150
|
this.signMode = opts.signMode ?? "hybrid";
|
|
13151
|
+
this.signBytesVersion = opts.signBytesVersion ?? "auto";
|
|
13152
|
+
this.rest = opts.rest;
|
|
13153
|
+
this.fetchImpl = opts.fetch;
|
|
13154
|
+
}
|
|
13155
|
+
/**
|
|
13156
|
+
* The hybrid sign-bytes form for `chainId` under this signer's settings.
|
|
13157
|
+
* Pass `forceRefresh` to bypass the cached answer.
|
|
13158
|
+
*/
|
|
13159
|
+
resolveSignBytesVersion(chainId, forceRefresh = false) {
|
|
13160
|
+
return resolveSignBytesVersion({
|
|
13161
|
+
chainId,
|
|
13162
|
+
rest: this.rest,
|
|
13163
|
+
signBytesVersion: this.signBytesVersion,
|
|
13164
|
+
fetch: this.fetchImpl,
|
|
13165
|
+
forceRefresh
|
|
13166
|
+
});
|
|
12633
13167
|
}
|
|
12634
13168
|
/** Build and sign a `TxRaw` for the given messages. Does not broadcast. */
|
|
12635
13169
|
sign(params) {
|
|
@@ -12642,20 +13176,34 @@ var EthNativeSigner = class {
|
|
|
12642
13176
|
sequence: params.sequence,
|
|
12643
13177
|
memo: params.memo,
|
|
12644
13178
|
timeoutHeight: params.timeoutHeight,
|
|
12645
|
-
encodeMessage: this.encode
|
|
13179
|
+
encodeMessage: this.encode,
|
|
13180
|
+
signBytesVersion: params.signBytesVersion ?? (this.signBytesVersion === "auto" ? void 0 : this.signBytesVersion)
|
|
12646
13181
|
};
|
|
12647
13182
|
return this.signMode === "classical" ? signClassicalEth(signParams) : signHybridEth(signParams);
|
|
12648
13183
|
}
|
|
12649
13184
|
/** Sign and broadcast the given messages via `transport`. */
|
|
12650
13185
|
async signAndBroadcast(transport, params) {
|
|
12651
|
-
const
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
13186
|
+
const once = async (forceRefresh) => {
|
|
13187
|
+
const signBytesVersion = this.signMode === "hybrid" ? params.signBytesVersion ?? await this.resolveSignBytesVersion(params.chainId, forceRefresh) : void 0;
|
|
13188
|
+
const { txRawBytes } = this.sign({ ...params, signBytesVersion });
|
|
13189
|
+
const res = await transport.broadcastTx(txRawBytes);
|
|
13190
|
+
if (res.code !== 0) {
|
|
13191
|
+
throw Object.assign(
|
|
13192
|
+
new Error(
|
|
13193
|
+
`eth-native tx failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
13194
|
+
),
|
|
13195
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
13196
|
+
);
|
|
13197
|
+
}
|
|
13198
|
+
return res;
|
|
13199
|
+
};
|
|
13200
|
+
const auto = this.signMode === "hybrid" && params.signBytesVersion === void 0 && this.signBytesVersion === "auto";
|
|
13201
|
+
try {
|
|
13202
|
+
return await once(false);
|
|
13203
|
+
} catch (e) {
|
|
13204
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
13205
|
+
return once(true);
|
|
12657
13206
|
}
|
|
12658
|
-
return res;
|
|
12659
13207
|
}
|
|
12660
13208
|
/** Send `amount` to `toAddress` via a bank `MsgSend`, signed eth-native. */
|
|
12661
13209
|
bankSend(transport, toAddress, amount, params) {
|
|
@@ -12951,6 +13499,20 @@ var svm = {
|
|
|
12951
13499
|
registerSvmPqcKey: composer2(
|
|
12952
13500
|
"/qorechain.svm.v1.MsgRegisterSVMPQCKey",
|
|
12953
13501
|
MsgRegisterSVMPQCKey
|
|
13502
|
+
),
|
|
13503
|
+
/**
|
|
13504
|
+
* Replace the x/svm runtime parameters wholesale (chain v3.1.97).
|
|
13505
|
+
*
|
|
13506
|
+
* GOVERNANCE ONLY: `authority` must be the governance module account, so this
|
|
13507
|
+
* message is submitted inside a gov proposal, not signed by a user. It is what
|
|
13508
|
+
* makes enabling/disabling the SVM lane a proposal rather than a binary
|
|
13509
|
+
* release. `params` is replaced in full — send every field, not just the ones
|
|
13510
|
+
* you mean to change. `rentExemptionMulti` is a `LegacyDec` string (e.g.
|
|
13511
|
+
* `"2.000000000000000000"`).
|
|
13512
|
+
*/
|
|
13513
|
+
updateParams: composer2(
|
|
13514
|
+
"/qorechain.svm.v1.MsgUpdateParams",
|
|
13515
|
+
MsgUpdateParams
|
|
12954
13516
|
)
|
|
12955
13517
|
};
|
|
12956
13518
|
var lightnode = {
|
|
@@ -26289,6 +26851,30 @@ function extractMessageIds(result) {
|
|
|
26289
26851
|
}
|
|
26290
26852
|
return ids;
|
|
26291
26853
|
}
|
|
26854
|
+
var CROSSVM_CALL_RESPONSE_TYPE_URL = "/qorechain.crossvm.v1.MsgCrossVMCallResponse";
|
|
26855
|
+
function unknownOutcome() {
|
|
26856
|
+
return { executed: false, data: new Uint8Array(0), gasUsed: 0n };
|
|
26857
|
+
}
|
|
26858
|
+
function decodeCallOutcomes(result) {
|
|
26859
|
+
const responses = result.msgResponses;
|
|
26860
|
+
if (!Array.isArray(responses)) return [];
|
|
26861
|
+
const out = [];
|
|
26862
|
+
for (const r of responses) {
|
|
26863
|
+
if (r?.typeUrl !== CROSSVM_CALL_RESPONSE_TYPE_URL) continue;
|
|
26864
|
+
try {
|
|
26865
|
+
const decoded = MsgCrossVMCallResponse.decode(r.value);
|
|
26866
|
+
out.push({
|
|
26867
|
+
executed: decoded.executed,
|
|
26868
|
+
data: decoded.data,
|
|
26869
|
+
// uint64 is generated as a decimal string; surface it as a bigint.
|
|
26870
|
+
gasUsed: BigInt(decoded.gasUsed ?? 0)
|
|
26871
|
+
});
|
|
26872
|
+
} catch {
|
|
26873
|
+
out.push(unknownOutcome());
|
|
26874
|
+
}
|
|
26875
|
+
}
|
|
26876
|
+
return out;
|
|
26877
|
+
}
|
|
26292
26878
|
function createCrossVMClient(tx, opts = {}) {
|
|
26293
26879
|
const sender = tx.senderAddress;
|
|
26294
26880
|
const query = opts.query;
|
|
@@ -26299,7 +26885,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26299
26885
|
targetVm: o.targetVm,
|
|
26300
26886
|
targetContract: o.targetContract,
|
|
26301
26887
|
payload,
|
|
26302
|
-
funds: o.funds ?? []
|
|
26888
|
+
funds: o.funds ?? [],
|
|
26889
|
+
async: o.async ?? false
|
|
26303
26890
|
});
|
|
26304
26891
|
const buildCallSync = (o, payload) => buildFrom(o, payload);
|
|
26305
26892
|
const buildCall = (o) => {
|
|
@@ -26324,7 +26911,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26324
26911
|
{ autoFee: o.autoFee }
|
|
26325
26912
|
);
|
|
26326
26913
|
const [messageId = ""] = extractMessageIds(result);
|
|
26327
|
-
|
|
26914
|
+
const [outcome = unknownOutcome()] = decodeCallOutcomes(result);
|
|
26915
|
+
return { messageId, ...outcome, result };
|
|
26328
26916
|
};
|
|
26329
26917
|
const callAtomic = async (calls, w = {}) => {
|
|
26330
26918
|
if (calls.length === 0) {
|
|
@@ -26339,7 +26927,11 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26339
26927
|
w.memo ?? "",
|
|
26340
26928
|
{ autoFee: w.autoFee }
|
|
26341
26929
|
);
|
|
26342
|
-
return {
|
|
26930
|
+
return {
|
|
26931
|
+
messageIds: extractMessageIds(result),
|
|
26932
|
+
outcomes: decodeCallOutcomes(result),
|
|
26933
|
+
result
|
|
26934
|
+
};
|
|
26343
26935
|
};
|
|
26344
26936
|
const getMessage = (id) => {
|
|
26345
26937
|
requireGetMessageSource(query, qor);
|
|
@@ -26443,8 +27035,8 @@ async function migrateToHybrid(tx, opts) {
|
|
|
26443
27035
|
}
|
|
26444
27036
|
|
|
26445
27037
|
// src/index.ts
|
|
26446
|
-
var VERSION = "0.
|
|
27038
|
+
var VERSION = "0.8.0";
|
|
26447
27039
|
|
|
26448
|
-
export { AlgorithmDilithium5, AlgorithmMLKEM1024, AlgorithmUnspecified, CANONICAL_DERIVATION, DEFAULT_GAS_MULTIPLIER, DEFAULT_GAS_PRICE, ETHSECP256K1_PUBKEY_TYPE, EthNativeSigner, GasPrice, HYBRID_SIG_TYPE_URL, HybridSigner, JsonRpcClient, JsonRpcError, LEGACY_DERIVATION, ML_DSA_87_PUBLIC_KEY_LENGTH, ML_DSA_87_SECRET_KEY_LENGTH, ML_DSA_87_SEED_LENGTH, ML_DSA_87_SIGNATURE_LENGTH, MSG_SEND_TYPE_URL, NETWORKS,
|
|
27040
|
+
export { AlgorithmDilithium5, AlgorithmMLKEM1024, AlgorithmUnspecified, BRIDGE_ATTESTATION_V2_DOMAIN, CANONICAL_DERIVATION, DEFAULT_GAS_MULTIPLIER, DEFAULT_GAS_PRICE, ETHSECP256K1_PUBKEY_TYPE, EthNativeSigner, GasPrice, HYBRID_SIGN_BYTES_REJECTION_LOG, HYBRID_SIGN_BYTES_V2_DOMAIN, HYBRID_SIG_TYPE_URL, HybridSigner, JsonRpcClient, JsonRpcError, LEGACY_DERIVATION, LEGACY_SIGN_BYTES_CHAINS, MIGRATION_SIGN_BYTES_V2_DOMAIN, ML_DSA_87_PUBLIC_KEY_LENGTH, ML_DSA_87_SECRET_KEY_LENGTH, ML_DSA_87_SEED_LENGTH, ML_DSA_87_SIGNATURE_LENGTH, MSG_SEND_TYPE_URL, NETWORKS, PQC_KEY_STATUS_PRECOMPILE_ADDRESS, PqcSigner, QorClient, QoreHttpError, QoreTxError, RestClient, SIGN_BYTES_V2_UPGRADE, STATIC_FALLBACK, TxClient, VERSION, VM_TYPES, abstractaccount, accountAuthInfo, addressesFrom20, algorithmName, amm, attachHybridExtension, authz, bank, be64, bech32ToHex, bridge, bridgeAttestationSignBytes, bridgeAttestationSignBytesV1, bridgeAttestationSignBytesV2, broadcastAndWait, buildAminoTypes, buildEventsQuery, buildHybridSignatureExtension, buildHybridTx, buildMetaMaskExecuteCosmos, buildMetaMaskExecuteEvm, buildPhantomExecuteCosmos, buildPhantomExecuteEvm, buildRegisterPqcKeyMsg, buildTxQuery, buildUrl, bytesToBech32, calculateFee, clearAdmin, clearSignBytesCache, connectCosmWasmSigner, connectPhantomUnified, connectQueryClients, cosmosAuthSignBytes, createClient, createCosmWasmClient, createCrossVMClient, createMultilayerClient, createQueryClients, createRollupClient, createSubscriptionClient, crossvm, decodeTxError, deriveEvmAccount, deriveNativeAccount, derivePqcLegacy, deriveSvmAccount, deriveUnifiedAccount, directSignerFromPrivateKey, distribution, encodeHybridExtension, ensurePqcRegistered, estimateFee, evmAuthSignBytes, evmToQor, execute, executeCosmosMsg, executeEvmMsg, explorerAddressUrl, explorerBlockUrl, explorerTxUrl, feegrant, fetchSignBytesV2AppliedHeight, formatUnits, fromBase, generateMnemonic, generatePqcKeypair, getBlock, getCodeDetails, getCodes, getContractInfo, getContracts, getCosmosWallet, getCrossVmMessage, getCrossVmParams, getJson, getLatestBlock, getNetwork, getPendingCrossVmMessages, getPqcStatus, getTx, gov, hexToBech32, hybridSignBytes, hybridSignBytesV1, hybridSignBytesV2, ibc, instantiate, instantiate2, isChecksumAddress, isHybridSignBytesRejection, isLegacySignBytesChain, isPqcRegistered, isSignatureAlgorithm, isTxFailure, isValidBech32, isValidEvmAddress, isValidSvmAddress, joinUrl, keccak256, keccak256Hex, lengthPrefixed, license, lightnode, listNetworks, migrate, migratePqcKey, migrateToHybrid, migrationSignBytes, migrationSignBytesV1, migrationSignBytesV2, msg, multilayer, parseEthPubkeyAny, parseUnits, postJsonRpc, pqc as pqcMsg, pqcSign, pqcVerify, qorToEvm, qoreAddresses, qorechainRegistry, qorechainRegistryTypes, codegen_exports as qorechainTypes, queryContractSmart, rdk, registerEthAuthenticatorMsg, requestFaucet, resolveSignBytesVersion, revokeAuthenticatorMsg, ripemd160, ripemd160Hex, rlconsensus, rotatePqcKeyMsg, rotatePqcKeyMsgFromMnemonic, rotationSignBytes, searchTxs, sha256, sha256Hex, signAndBroadcastHybrid, signBytesVersionFor, signClassicalEth, signHybridEth, staking, subscribeNewBlocks, subscribeTx, suggestChainInfo, svm, toBase, toChecksumAddress, toHex, txErrorFrom, unifiedAccountFromPhantomSignature, unifiedAccountFromSeed, updateAdmin, uploadCode, validateMnemonic, waitForTx, withRetry2 as withRetry };
|
|
26449
27041
|
//# sourceMappingURL=index.js.map
|
|
26450
27042
|
//# sourceMappingURL=index.js.map
|