@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.cjs
CHANGED
|
@@ -6745,7 +6745,10 @@ __export(tx_exports6, {
|
|
|
6745
6745
|
MsgExecuteProgramResponse: () => MsgExecuteProgramResponse,
|
|
6746
6746
|
MsgRegisterSVMPQCKey: () => MsgRegisterSVMPQCKey,
|
|
6747
6747
|
MsgRegisterSVMPQCKeyResponse: () => MsgRegisterSVMPQCKeyResponse,
|
|
6748
|
+
MsgUpdateParams: () => MsgUpdateParams,
|
|
6749
|
+
MsgUpdateParamsResponse: () => MsgUpdateParamsResponse,
|
|
6748
6750
|
SVMAuth: () => SVMAuth,
|
|
6751
|
+
SVMParams: () => SVMParams,
|
|
6749
6752
|
SvmAccountMeta: () => SvmAccountMeta,
|
|
6750
6753
|
protobufPackage: () => protobufPackage6
|
|
6751
6754
|
});
|
|
@@ -7482,6 +7485,292 @@ var MsgRegisterSVMPQCKeyResponse = {
|
|
|
7482
7485
|
return message;
|
|
7483
7486
|
}
|
|
7484
7487
|
};
|
|
7488
|
+
function createBaseSVMParams() {
|
|
7489
|
+
return {
|
|
7490
|
+
maxProgramSize: "0",
|
|
7491
|
+
maxAccountDataSize: "0",
|
|
7492
|
+
computeBudgetMax: "0",
|
|
7493
|
+
lamportsPerByte: "0",
|
|
7494
|
+
rentExemptionMulti: "",
|
|
7495
|
+
enabled: false,
|
|
7496
|
+
svmSlotOffset: "0",
|
|
7497
|
+
defaultSigScheme: 0,
|
|
7498
|
+
maxCpi: 0
|
|
7499
|
+
};
|
|
7500
|
+
}
|
|
7501
|
+
var SVMParams = {
|
|
7502
|
+
encode(message, writer = new wire.BinaryWriter()) {
|
|
7503
|
+
if (message.maxProgramSize !== "0") {
|
|
7504
|
+
writer.uint32(8).uint64(message.maxProgramSize);
|
|
7505
|
+
}
|
|
7506
|
+
if (message.maxAccountDataSize !== "0") {
|
|
7507
|
+
writer.uint32(16).uint64(message.maxAccountDataSize);
|
|
7508
|
+
}
|
|
7509
|
+
if (message.computeBudgetMax !== "0") {
|
|
7510
|
+
writer.uint32(24).uint64(message.computeBudgetMax);
|
|
7511
|
+
}
|
|
7512
|
+
if (message.lamportsPerByte !== "0") {
|
|
7513
|
+
writer.uint32(32).uint64(message.lamportsPerByte);
|
|
7514
|
+
}
|
|
7515
|
+
if (message.rentExemptionMulti !== "") {
|
|
7516
|
+
writer.uint32(42).string(message.rentExemptionMulti);
|
|
7517
|
+
}
|
|
7518
|
+
if (message.enabled !== false) {
|
|
7519
|
+
writer.uint32(48).bool(message.enabled);
|
|
7520
|
+
}
|
|
7521
|
+
if (message.svmSlotOffset !== "0") {
|
|
7522
|
+
writer.uint32(56).int64(message.svmSlotOffset);
|
|
7523
|
+
}
|
|
7524
|
+
if (message.defaultSigScheme !== 0) {
|
|
7525
|
+
writer.uint32(64).uint32(message.defaultSigScheme);
|
|
7526
|
+
}
|
|
7527
|
+
if (message.maxCpi !== 0) {
|
|
7528
|
+
writer.uint32(72).uint32(message.maxCpi);
|
|
7529
|
+
}
|
|
7530
|
+
return writer;
|
|
7531
|
+
},
|
|
7532
|
+
decode(input, length) {
|
|
7533
|
+
const reader = input instanceof wire.BinaryReader ? input : new wire.BinaryReader(input);
|
|
7534
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7535
|
+
const message = createBaseSVMParams();
|
|
7536
|
+
while (reader.pos < end) {
|
|
7537
|
+
const tag = reader.uint32();
|
|
7538
|
+
switch (tag >>> 3) {
|
|
7539
|
+
case 1: {
|
|
7540
|
+
if (tag !== 8) {
|
|
7541
|
+
break;
|
|
7542
|
+
}
|
|
7543
|
+
message.maxProgramSize = reader.uint64().toString();
|
|
7544
|
+
continue;
|
|
7545
|
+
}
|
|
7546
|
+
case 2: {
|
|
7547
|
+
if (tag !== 16) {
|
|
7548
|
+
break;
|
|
7549
|
+
}
|
|
7550
|
+
message.maxAccountDataSize = reader.uint64().toString();
|
|
7551
|
+
continue;
|
|
7552
|
+
}
|
|
7553
|
+
case 3: {
|
|
7554
|
+
if (tag !== 24) {
|
|
7555
|
+
break;
|
|
7556
|
+
}
|
|
7557
|
+
message.computeBudgetMax = reader.uint64().toString();
|
|
7558
|
+
continue;
|
|
7559
|
+
}
|
|
7560
|
+
case 4: {
|
|
7561
|
+
if (tag !== 32) {
|
|
7562
|
+
break;
|
|
7563
|
+
}
|
|
7564
|
+
message.lamportsPerByte = reader.uint64().toString();
|
|
7565
|
+
continue;
|
|
7566
|
+
}
|
|
7567
|
+
case 5: {
|
|
7568
|
+
if (tag !== 42) {
|
|
7569
|
+
break;
|
|
7570
|
+
}
|
|
7571
|
+
message.rentExemptionMulti = reader.string();
|
|
7572
|
+
continue;
|
|
7573
|
+
}
|
|
7574
|
+
case 6: {
|
|
7575
|
+
if (tag !== 48) {
|
|
7576
|
+
break;
|
|
7577
|
+
}
|
|
7578
|
+
message.enabled = reader.bool();
|
|
7579
|
+
continue;
|
|
7580
|
+
}
|
|
7581
|
+
case 7: {
|
|
7582
|
+
if (tag !== 56) {
|
|
7583
|
+
break;
|
|
7584
|
+
}
|
|
7585
|
+
message.svmSlotOffset = reader.int64().toString();
|
|
7586
|
+
continue;
|
|
7587
|
+
}
|
|
7588
|
+
case 8: {
|
|
7589
|
+
if (tag !== 64) {
|
|
7590
|
+
break;
|
|
7591
|
+
}
|
|
7592
|
+
message.defaultSigScheme = reader.uint32();
|
|
7593
|
+
continue;
|
|
7594
|
+
}
|
|
7595
|
+
case 9: {
|
|
7596
|
+
if (tag !== 72) {
|
|
7597
|
+
break;
|
|
7598
|
+
}
|
|
7599
|
+
message.maxCpi = reader.uint32();
|
|
7600
|
+
continue;
|
|
7601
|
+
}
|
|
7602
|
+
}
|
|
7603
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7604
|
+
break;
|
|
7605
|
+
}
|
|
7606
|
+
reader.skip(tag & 7);
|
|
7607
|
+
}
|
|
7608
|
+
return message;
|
|
7609
|
+
},
|
|
7610
|
+
fromJSON(object) {
|
|
7611
|
+
return {
|
|
7612
|
+
maxProgramSize: isSet7(object.maxProgramSize) ? globalThis.String(object.maxProgramSize) : isSet7(object.max_program_size) ? globalThis.String(object.max_program_size) : "0",
|
|
7613
|
+
maxAccountDataSize: isSet7(object.maxAccountDataSize) ? globalThis.String(object.maxAccountDataSize) : isSet7(object.max_account_data_size) ? globalThis.String(object.max_account_data_size) : "0",
|
|
7614
|
+
computeBudgetMax: isSet7(object.computeBudgetMax) ? globalThis.String(object.computeBudgetMax) : isSet7(object.compute_budget_max) ? globalThis.String(object.compute_budget_max) : "0",
|
|
7615
|
+
lamportsPerByte: isSet7(object.lamportsPerByte) ? globalThis.String(object.lamportsPerByte) : isSet7(object.lamports_per_byte) ? globalThis.String(object.lamports_per_byte) : "0",
|
|
7616
|
+
rentExemptionMulti: isSet7(object.rentExemptionMulti) ? globalThis.String(object.rentExemptionMulti) : isSet7(object.rent_exemption_multi) ? globalThis.String(object.rent_exemption_multi) : "",
|
|
7617
|
+
enabled: isSet7(object.enabled) ? globalThis.Boolean(object.enabled) : false,
|
|
7618
|
+
svmSlotOffset: isSet7(object.svmSlotOffset) ? globalThis.String(object.svmSlotOffset) : isSet7(object.svm_slot_offset) ? globalThis.String(object.svm_slot_offset) : "0",
|
|
7619
|
+
defaultSigScheme: isSet7(object.defaultSigScheme) ? globalThis.Number(object.defaultSigScheme) : isSet7(object.default_sig_scheme) ? globalThis.Number(object.default_sig_scheme) : 0,
|
|
7620
|
+
maxCpi: isSet7(object.maxCpi) ? globalThis.Number(object.maxCpi) : isSet7(object.max_cpi) ? globalThis.Number(object.max_cpi) : 0
|
|
7621
|
+
};
|
|
7622
|
+
},
|
|
7623
|
+
toJSON(message) {
|
|
7624
|
+
const obj = {};
|
|
7625
|
+
if (message.maxProgramSize !== "0") {
|
|
7626
|
+
obj.maxProgramSize = message.maxProgramSize;
|
|
7627
|
+
}
|
|
7628
|
+
if (message.maxAccountDataSize !== "0") {
|
|
7629
|
+
obj.maxAccountDataSize = message.maxAccountDataSize;
|
|
7630
|
+
}
|
|
7631
|
+
if (message.computeBudgetMax !== "0") {
|
|
7632
|
+
obj.computeBudgetMax = message.computeBudgetMax;
|
|
7633
|
+
}
|
|
7634
|
+
if (message.lamportsPerByte !== "0") {
|
|
7635
|
+
obj.lamportsPerByte = message.lamportsPerByte;
|
|
7636
|
+
}
|
|
7637
|
+
if (message.rentExemptionMulti !== "") {
|
|
7638
|
+
obj.rentExemptionMulti = message.rentExemptionMulti;
|
|
7639
|
+
}
|
|
7640
|
+
if (message.enabled !== false) {
|
|
7641
|
+
obj.enabled = message.enabled;
|
|
7642
|
+
}
|
|
7643
|
+
if (message.svmSlotOffset !== "0") {
|
|
7644
|
+
obj.svmSlotOffset = message.svmSlotOffset;
|
|
7645
|
+
}
|
|
7646
|
+
if (message.defaultSigScheme !== 0) {
|
|
7647
|
+
obj.defaultSigScheme = Math.round(message.defaultSigScheme);
|
|
7648
|
+
}
|
|
7649
|
+
if (message.maxCpi !== 0) {
|
|
7650
|
+
obj.maxCpi = Math.round(message.maxCpi);
|
|
7651
|
+
}
|
|
7652
|
+
return obj;
|
|
7653
|
+
},
|
|
7654
|
+
create(base) {
|
|
7655
|
+
return SVMParams.fromPartial(base ?? {});
|
|
7656
|
+
},
|
|
7657
|
+
fromPartial(object) {
|
|
7658
|
+
const message = createBaseSVMParams();
|
|
7659
|
+
message.maxProgramSize = object.maxProgramSize ?? "0";
|
|
7660
|
+
message.maxAccountDataSize = object.maxAccountDataSize ?? "0";
|
|
7661
|
+
message.computeBudgetMax = object.computeBudgetMax ?? "0";
|
|
7662
|
+
message.lamportsPerByte = object.lamportsPerByte ?? "0";
|
|
7663
|
+
message.rentExemptionMulti = object.rentExemptionMulti ?? "";
|
|
7664
|
+
message.enabled = object.enabled ?? false;
|
|
7665
|
+
message.svmSlotOffset = object.svmSlotOffset ?? "0";
|
|
7666
|
+
message.defaultSigScheme = object.defaultSigScheme ?? 0;
|
|
7667
|
+
message.maxCpi = object.maxCpi ?? 0;
|
|
7668
|
+
return message;
|
|
7669
|
+
}
|
|
7670
|
+
};
|
|
7671
|
+
function createBaseMsgUpdateParams() {
|
|
7672
|
+
return { authority: "", params: void 0 };
|
|
7673
|
+
}
|
|
7674
|
+
var MsgUpdateParams = {
|
|
7675
|
+
encode(message, writer = new wire.BinaryWriter()) {
|
|
7676
|
+
if (message.authority !== "") {
|
|
7677
|
+
writer.uint32(10).string(message.authority);
|
|
7678
|
+
}
|
|
7679
|
+
if (message.params !== void 0) {
|
|
7680
|
+
SVMParams.encode(message.params, writer.uint32(18).fork()).join();
|
|
7681
|
+
}
|
|
7682
|
+
return writer;
|
|
7683
|
+
},
|
|
7684
|
+
decode(input, length) {
|
|
7685
|
+
const reader = input instanceof wire.BinaryReader ? input : new wire.BinaryReader(input);
|
|
7686
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7687
|
+
const message = createBaseMsgUpdateParams();
|
|
7688
|
+
while (reader.pos < end) {
|
|
7689
|
+
const tag = reader.uint32();
|
|
7690
|
+
switch (tag >>> 3) {
|
|
7691
|
+
case 1: {
|
|
7692
|
+
if (tag !== 10) {
|
|
7693
|
+
break;
|
|
7694
|
+
}
|
|
7695
|
+
message.authority = reader.string();
|
|
7696
|
+
continue;
|
|
7697
|
+
}
|
|
7698
|
+
case 2: {
|
|
7699
|
+
if (tag !== 18) {
|
|
7700
|
+
break;
|
|
7701
|
+
}
|
|
7702
|
+
message.params = SVMParams.decode(reader, reader.uint32());
|
|
7703
|
+
continue;
|
|
7704
|
+
}
|
|
7705
|
+
}
|
|
7706
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7707
|
+
break;
|
|
7708
|
+
}
|
|
7709
|
+
reader.skip(tag & 7);
|
|
7710
|
+
}
|
|
7711
|
+
return message;
|
|
7712
|
+
},
|
|
7713
|
+
fromJSON(object) {
|
|
7714
|
+
return {
|
|
7715
|
+
authority: isSet7(object.authority) ? globalThis.String(object.authority) : "",
|
|
7716
|
+
params: isSet7(object.params) ? SVMParams.fromJSON(object.params) : void 0
|
|
7717
|
+
};
|
|
7718
|
+
},
|
|
7719
|
+
toJSON(message) {
|
|
7720
|
+
const obj = {};
|
|
7721
|
+
if (message.authority !== "") {
|
|
7722
|
+
obj.authority = message.authority;
|
|
7723
|
+
}
|
|
7724
|
+
if (message.params !== void 0) {
|
|
7725
|
+
obj.params = SVMParams.toJSON(message.params);
|
|
7726
|
+
}
|
|
7727
|
+
return obj;
|
|
7728
|
+
},
|
|
7729
|
+
create(base) {
|
|
7730
|
+
return MsgUpdateParams.fromPartial(base ?? {});
|
|
7731
|
+
},
|
|
7732
|
+
fromPartial(object) {
|
|
7733
|
+
const message = createBaseMsgUpdateParams();
|
|
7734
|
+
message.authority = object.authority ?? "";
|
|
7735
|
+
message.params = object.params !== void 0 && object.params !== null ? SVMParams.fromPartial(object.params) : void 0;
|
|
7736
|
+
return message;
|
|
7737
|
+
}
|
|
7738
|
+
};
|
|
7739
|
+
function createBaseMsgUpdateParamsResponse() {
|
|
7740
|
+
return {};
|
|
7741
|
+
}
|
|
7742
|
+
var MsgUpdateParamsResponse = {
|
|
7743
|
+
encode(_, writer = new wire.BinaryWriter()) {
|
|
7744
|
+
return writer;
|
|
7745
|
+
},
|
|
7746
|
+
decode(input, length) {
|
|
7747
|
+
const reader = input instanceof wire.BinaryReader ? input : new wire.BinaryReader(input);
|
|
7748
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
7749
|
+
const message = createBaseMsgUpdateParamsResponse();
|
|
7750
|
+
while (reader.pos < end) {
|
|
7751
|
+
const tag = reader.uint32();
|
|
7752
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
7753
|
+
break;
|
|
7754
|
+
}
|
|
7755
|
+
reader.skip(tag & 7);
|
|
7756
|
+
}
|
|
7757
|
+
return message;
|
|
7758
|
+
},
|
|
7759
|
+
fromJSON(_) {
|
|
7760
|
+
return {};
|
|
7761
|
+
},
|
|
7762
|
+
toJSON(_) {
|
|
7763
|
+
const obj = {};
|
|
7764
|
+
return obj;
|
|
7765
|
+
},
|
|
7766
|
+
create(base) {
|
|
7767
|
+
return MsgUpdateParamsResponse.fromPartial(base ?? {});
|
|
7768
|
+
},
|
|
7769
|
+
fromPartial(_) {
|
|
7770
|
+
const message = createBaseMsgUpdateParamsResponse();
|
|
7771
|
+
return message;
|
|
7772
|
+
}
|
|
7773
|
+
};
|
|
7485
7774
|
var MsgDefinition6 = {
|
|
7486
7775
|
name: "Msg",
|
|
7487
7776
|
fullName: "qorechain.svm.v1.Msg",
|
|
@@ -7517,6 +7806,14 @@ var MsgDefinition6 = {
|
|
|
7517
7806
|
responseType: MsgRegisterSVMPQCKeyResponse,
|
|
7518
7807
|
responseStream: false,
|
|
7519
7808
|
options: {}
|
|
7809
|
+
},
|
|
7810
|
+
updateParams: {
|
|
7811
|
+
name: "UpdateParams",
|
|
7812
|
+
requestType: MsgUpdateParams,
|
|
7813
|
+
requestStream: false,
|
|
7814
|
+
responseType: MsgUpdateParamsResponse,
|
|
7815
|
+
responseStream: false,
|
|
7816
|
+
options: {}
|
|
7520
7817
|
}
|
|
7521
7818
|
}
|
|
7522
7819
|
};
|
|
@@ -9851,7 +10148,15 @@ __export(tx_exports10, {
|
|
|
9851
10148
|
});
|
|
9852
10149
|
var protobufPackage10 = "qorechain.crossvm.v1";
|
|
9853
10150
|
function createBaseMsgCrossVMCall() {
|
|
9854
|
-
return {
|
|
10151
|
+
return {
|
|
10152
|
+
sender: "",
|
|
10153
|
+
sourceVm: "",
|
|
10154
|
+
targetVm: "",
|
|
10155
|
+
targetContract: "",
|
|
10156
|
+
payload: new Uint8Array(0),
|
|
10157
|
+
funds: [],
|
|
10158
|
+
async: false
|
|
10159
|
+
};
|
|
9855
10160
|
}
|
|
9856
10161
|
var MsgCrossVMCall = {
|
|
9857
10162
|
encode(message, writer = new wire.BinaryWriter()) {
|
|
@@ -9873,6 +10178,9 @@ var MsgCrossVMCall = {
|
|
|
9873
10178
|
for (const v of message.funds) {
|
|
9874
10179
|
Coin.encode(v, writer.uint32(50).fork()).join();
|
|
9875
10180
|
}
|
|
10181
|
+
if (message.async !== false) {
|
|
10182
|
+
writer.uint32(56).bool(message.async);
|
|
10183
|
+
}
|
|
9876
10184
|
return writer;
|
|
9877
10185
|
},
|
|
9878
10186
|
decode(input, length) {
|
|
@@ -9924,6 +10232,13 @@ var MsgCrossVMCall = {
|
|
|
9924
10232
|
message.funds.push(Coin.decode(reader, reader.uint32()));
|
|
9925
10233
|
continue;
|
|
9926
10234
|
}
|
|
10235
|
+
case 7: {
|
|
10236
|
+
if (tag !== 56) {
|
|
10237
|
+
break;
|
|
10238
|
+
}
|
|
10239
|
+
message.async = reader.bool();
|
|
10240
|
+
continue;
|
|
10241
|
+
}
|
|
9927
10242
|
}
|
|
9928
10243
|
if ((tag & 7) === 4 || tag === 0) {
|
|
9929
10244
|
break;
|
|
@@ -9939,7 +10254,8 @@ var MsgCrossVMCall = {
|
|
|
9939
10254
|
targetVm: isSet11(object.targetVm) ? globalThis.String(object.targetVm) : isSet11(object.target_vm) ? globalThis.String(object.target_vm) : "",
|
|
9940
10255
|
targetContract: isSet11(object.targetContract) ? globalThis.String(object.targetContract) : isSet11(object.target_contract) ? globalThis.String(object.target_contract) : "",
|
|
9941
10256
|
payload: isSet11(object.payload) ? bytesFromBase647(object.payload) : new Uint8Array(0),
|
|
9942
|
-
funds: globalThis.Array.isArray(object?.funds) ? object.funds.map((e) => Coin.fromJSON(e)) : []
|
|
10257
|
+
funds: globalThis.Array.isArray(object?.funds) ? object.funds.map((e) => Coin.fromJSON(e)) : [],
|
|
10258
|
+
async: isSet11(object.async) ? globalThis.Boolean(object.async) : false
|
|
9943
10259
|
};
|
|
9944
10260
|
},
|
|
9945
10261
|
toJSON(message) {
|
|
@@ -9962,6 +10278,9 @@ var MsgCrossVMCall = {
|
|
|
9962
10278
|
if (message.funds?.length) {
|
|
9963
10279
|
obj.funds = message.funds.map((e) => Coin.toJSON(e));
|
|
9964
10280
|
}
|
|
10281
|
+
if (message.async !== false) {
|
|
10282
|
+
obj.async = message.async;
|
|
10283
|
+
}
|
|
9965
10284
|
return obj;
|
|
9966
10285
|
},
|
|
9967
10286
|
create(base) {
|
|
@@ -9975,17 +10294,27 @@ var MsgCrossVMCall = {
|
|
|
9975
10294
|
message.targetContract = object.targetContract ?? "";
|
|
9976
10295
|
message.payload = object.payload ?? new Uint8Array(0);
|
|
9977
10296
|
message.funds = object.funds?.map((e) => Coin.fromPartial(e)) || [];
|
|
10297
|
+
message.async = object.async ?? false;
|
|
9978
10298
|
return message;
|
|
9979
10299
|
}
|
|
9980
10300
|
};
|
|
9981
10301
|
function createBaseMsgCrossVMCallResponse() {
|
|
9982
|
-
return { messageId: "" };
|
|
10302
|
+
return { messageId: "", executed: false, data: new Uint8Array(0), gasUsed: "0" };
|
|
9983
10303
|
}
|
|
9984
10304
|
var MsgCrossVMCallResponse = {
|
|
9985
10305
|
encode(message, writer = new wire.BinaryWriter()) {
|
|
9986
10306
|
if (message.messageId !== "") {
|
|
9987
10307
|
writer.uint32(10).string(message.messageId);
|
|
9988
10308
|
}
|
|
10309
|
+
if (message.executed !== false) {
|
|
10310
|
+
writer.uint32(16).bool(message.executed);
|
|
10311
|
+
}
|
|
10312
|
+
if (message.data.length !== 0) {
|
|
10313
|
+
writer.uint32(26).bytes(message.data);
|
|
10314
|
+
}
|
|
10315
|
+
if (message.gasUsed !== "0") {
|
|
10316
|
+
writer.uint32(32).uint64(message.gasUsed);
|
|
10317
|
+
}
|
|
9989
10318
|
return writer;
|
|
9990
10319
|
},
|
|
9991
10320
|
decode(input, length) {
|
|
@@ -10002,6 +10331,27 @@ var MsgCrossVMCallResponse = {
|
|
|
10002
10331
|
message.messageId = reader.string();
|
|
10003
10332
|
continue;
|
|
10004
10333
|
}
|
|
10334
|
+
case 2: {
|
|
10335
|
+
if (tag !== 16) {
|
|
10336
|
+
break;
|
|
10337
|
+
}
|
|
10338
|
+
message.executed = reader.bool();
|
|
10339
|
+
continue;
|
|
10340
|
+
}
|
|
10341
|
+
case 3: {
|
|
10342
|
+
if (tag !== 26) {
|
|
10343
|
+
break;
|
|
10344
|
+
}
|
|
10345
|
+
message.data = reader.bytes();
|
|
10346
|
+
continue;
|
|
10347
|
+
}
|
|
10348
|
+
case 4: {
|
|
10349
|
+
if (tag !== 32) {
|
|
10350
|
+
break;
|
|
10351
|
+
}
|
|
10352
|
+
message.gasUsed = reader.uint64().toString();
|
|
10353
|
+
continue;
|
|
10354
|
+
}
|
|
10005
10355
|
}
|
|
10006
10356
|
if ((tag & 7) === 4 || tag === 0) {
|
|
10007
10357
|
break;
|
|
@@ -10012,7 +10362,10 @@ var MsgCrossVMCallResponse = {
|
|
|
10012
10362
|
},
|
|
10013
10363
|
fromJSON(object) {
|
|
10014
10364
|
return {
|
|
10015
|
-
messageId: isSet11(object.messageId) ? globalThis.String(object.messageId) : isSet11(object.message_id) ? globalThis.String(object.message_id) : ""
|
|
10365
|
+
messageId: isSet11(object.messageId) ? globalThis.String(object.messageId) : isSet11(object.message_id) ? globalThis.String(object.message_id) : "",
|
|
10366
|
+
executed: isSet11(object.executed) ? globalThis.Boolean(object.executed) : false,
|
|
10367
|
+
data: isSet11(object.data) ? bytesFromBase647(object.data) : new Uint8Array(0),
|
|
10368
|
+
gasUsed: isSet11(object.gasUsed) ? globalThis.String(object.gasUsed) : isSet11(object.gas_used) ? globalThis.String(object.gas_used) : "0"
|
|
10016
10369
|
};
|
|
10017
10370
|
},
|
|
10018
10371
|
toJSON(message) {
|
|
@@ -10020,6 +10373,15 @@ var MsgCrossVMCallResponse = {
|
|
|
10020
10373
|
if (message.messageId !== "") {
|
|
10021
10374
|
obj.messageId = message.messageId;
|
|
10022
10375
|
}
|
|
10376
|
+
if (message.executed !== false) {
|
|
10377
|
+
obj.executed = message.executed;
|
|
10378
|
+
}
|
|
10379
|
+
if (message.data.length !== 0) {
|
|
10380
|
+
obj.data = base64FromBytes7(message.data);
|
|
10381
|
+
}
|
|
10382
|
+
if (message.gasUsed !== "0") {
|
|
10383
|
+
obj.gasUsed = message.gasUsed;
|
|
10384
|
+
}
|
|
10023
10385
|
return obj;
|
|
10024
10386
|
},
|
|
10025
10387
|
create(base) {
|
|
@@ -10028,6 +10390,9 @@ var MsgCrossVMCallResponse = {
|
|
|
10028
10390
|
fromPartial(object) {
|
|
10029
10391
|
const message = createBaseMsgCrossVMCallResponse();
|
|
10030
10392
|
message.messageId = object.messageId ?? "";
|
|
10393
|
+
message.executed = object.executed ?? false;
|
|
10394
|
+
message.data = object.data ?? new Uint8Array(0);
|
|
10395
|
+
message.gasUsed = object.gasUsed ?? "0";
|
|
10031
10396
|
return message;
|
|
10032
10397
|
}
|
|
10033
10398
|
};
|
|
@@ -10121,7 +10486,11 @@ var MsgDefinition10 = {
|
|
|
10121
10486
|
name: "Msg",
|
|
10122
10487
|
fullName: "qorechain.crossvm.v1.Msg",
|
|
10123
10488
|
methods: {
|
|
10124
|
-
/**
|
|
10489
|
+
/**
|
|
10490
|
+
* CrossVMCall invokes a contract on another VM. It executes within the
|
|
10491
|
+
* transaction and returns the callee's answer, unless async is set, in which
|
|
10492
|
+
* case it is queued for ProcessQueue to dispatch later.
|
|
10493
|
+
*/
|
|
10125
10494
|
crossVMCall: {
|
|
10126
10495
|
name: "CrossVMCall",
|
|
10127
10496
|
requestType: MsgCrossVMCall,
|
|
@@ -10745,6 +11114,7 @@ var qorechainRegistryTypes = [
|
|
|
10745
11114
|
["/qorechain.svm.v1.MsgCreateAccount", MsgCreateAccount],
|
|
10746
11115
|
["/qorechain.svm.v1.MsgExecuteProgram", MsgExecuteProgram],
|
|
10747
11116
|
["/qorechain.svm.v1.MsgRegisterSVMPQCKey", MsgRegisterSVMPQCKey],
|
|
11117
|
+
["/qorechain.svm.v1.MsgUpdateParams", MsgUpdateParams],
|
|
10748
11118
|
// lightnode
|
|
10749
11119
|
["/qorechain.lightnode.v1.MsgRegisterLightNode", MsgRegisterLightNode],
|
|
10750
11120
|
["/qorechain.lightnode.v1.MsgHeartbeat", MsgHeartbeat],
|
|
@@ -11092,7 +11462,12 @@ var TxClient = class _TxClient {
|
|
|
11092
11462
|
height: res.height,
|
|
11093
11463
|
gasUsed: res.gasUsed,
|
|
11094
11464
|
gasWanted: res.gasWanted,
|
|
11095
|
-
rawLog: res.rawLog
|
|
11465
|
+
rawLog: res.rawLog,
|
|
11466
|
+
// Carried through so callers can read typed attributes / decode the
|
|
11467
|
+
// per-message responses (e.g. MsgCrossVMCallResponse) without a
|
|
11468
|
+
// second round-trip.
|
|
11469
|
+
events: res.events,
|
|
11470
|
+
msgResponses: res.msgResponses
|
|
11096
11471
|
};
|
|
11097
11472
|
}
|
|
11098
11473
|
const hash = await this.client.signAndBroadcastSync(
|
|
@@ -11720,9 +12095,16 @@ function generatePqcKeypair(seed) {
|
|
|
11720
12095
|
return { publicKey: kp.publicKey, secretKey: kp.secretKey };
|
|
11721
12096
|
}
|
|
11722
12097
|
function pqcSign(secretKey, message, opts) {
|
|
12098
|
+
if (secretKey.length !== ML_DSA_87_SECRET_KEY_LENGTH) {
|
|
12099
|
+
throw new Error(
|
|
12100
|
+
`ML-DSA-87 secret key must be ${ML_DSA_87_SECRET_KEY_LENGTH} bytes, got ${secretKey.length}`
|
|
12101
|
+
);
|
|
12102
|
+
}
|
|
11723
12103
|
return pqc$1.mldsa87.sign(secretKey, message, opts);
|
|
11724
12104
|
}
|
|
11725
12105
|
function pqcVerify(publicKey, message, signature) {
|
|
12106
|
+
if (publicKey.length !== ML_DSA_87_PUBLIC_KEY_LENGTH) return false;
|
|
12107
|
+
if (signature.length !== ML_DSA_87_SIGNATURE_LENGTH) return false;
|
|
11726
12108
|
return pqc$1.mldsa87.verify(publicKey, message, signature);
|
|
11727
12109
|
}
|
|
11728
12110
|
function buildHybridSignatureExtension(args) {
|
|
@@ -11933,37 +12315,17 @@ function unifiedAccountFromSeed(seed32) {
|
|
|
11933
12315
|
pqc: pqc2
|
|
11934
12316
|
};
|
|
11935
12317
|
}
|
|
11936
|
-
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
|
|
11940
|
-
|
|
11941
|
-
|
|
11942
|
-
if (!pk) throw new Error("Phantom provider exposed no public key");
|
|
11943
|
-
if (pk instanceof Uint8Array) return pk;
|
|
11944
|
-
return pk.toBytes();
|
|
11945
|
-
}
|
|
11946
|
-
function signatureBytes(res) {
|
|
11947
|
-
return res instanceof Uint8Array ? res : res.signature;
|
|
12318
|
+
|
|
12319
|
+
// src/accounts/phantom.ts
|
|
12320
|
+
function unifiedAccountFromPhantomSignature(signatureBytes) {
|
|
12321
|
+
throw new Error(
|
|
12322
|
+
"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."
|
|
12323
|
+
);
|
|
11948
12324
|
}
|
|
11949
12325
|
async function connectPhantomUnified(opts = {}) {
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
throw new Error(
|
|
11953
|
-
"no Phantom provider found (window.solana); pass opts.provider"
|
|
11954
|
-
);
|
|
11955
|
-
}
|
|
11956
|
-
const conn = await provider.connect();
|
|
11957
|
-
const pk = pubkeyBytes(
|
|
11958
|
-
provider.publicKey ?? conn.publicKey
|
|
12326
|
+
throw new Error(
|
|
12327
|
+
"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."
|
|
11959
12328
|
);
|
|
11960
|
-
const message = `${PHANTOM_DERIVATION_DOMAIN}
|
|
11961
|
-
${base.base58.encode(pk)}`;
|
|
11962
|
-
const signed = await provider.signMessage(
|
|
11963
|
-
new TextEncoder().encode(message),
|
|
11964
|
-
"utf8"
|
|
11965
|
-
);
|
|
11966
|
-
return unifiedAccountFromPhantomSignature(signatureBytes(signed));
|
|
11967
12329
|
}
|
|
11968
12330
|
async function directSignerFromPrivateKey(privateKey, prefix) {
|
|
11969
12331
|
if (privateKey.length !== 32) {
|
|
@@ -12341,21 +12703,28 @@ function attachHybridExtension(body, ext, opts = {}) {
|
|
|
12341
12703
|
}
|
|
12342
12704
|
return next;
|
|
12343
12705
|
}
|
|
12706
|
+
|
|
12707
|
+
// src/tx/signbytes.ts
|
|
12708
|
+
var SIGN_BYTES_V2_UPGRADE = "v3.1.98";
|
|
12709
|
+
var LEGACY_SIGN_BYTES_CHAINS = [
|
|
12710
|
+
"qorechain-vladi",
|
|
12711
|
+
"qorechain-diana"
|
|
12712
|
+
];
|
|
12713
|
+
var HYBRID_SIGN_BYTES_V2_DOMAIN = "qorechain-pqc-hybrid-v2";
|
|
12714
|
+
var MIGRATION_SIGN_BYTES_V2_DOMAIN = "qorechain-key-migration-v2";
|
|
12715
|
+
var BRIDGE_ATTESTATION_V2_DOMAIN = "qorechain-bridge-attestation-v2";
|
|
12716
|
+
var utf8 = new TextEncoder();
|
|
12344
12717
|
function be32(n) {
|
|
12345
12718
|
const b = new Uint8Array(4);
|
|
12346
|
-
b
|
|
12347
|
-
b[1] = n >>> 16 & 255;
|
|
12348
|
-
b[2] = n >>> 8 & 255;
|
|
12349
|
-
b[3] = n & 255;
|
|
12719
|
+
new DataView(b.buffer).setUint32(0, n >>> 0, false);
|
|
12350
12720
|
return b;
|
|
12351
12721
|
}
|
|
12352
|
-
function
|
|
12353
|
-
const
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
return out;
|
|
12722
|
+
function be642(n) {
|
|
12723
|
+
const b = new Uint8Array(8);
|
|
12724
|
+
new DataView(b.buffer).setBigUint64(0, BigInt(n), false);
|
|
12725
|
+
return b;
|
|
12357
12726
|
}
|
|
12358
|
-
function
|
|
12727
|
+
function concat2(parts) {
|
|
12359
12728
|
let total = 0;
|
|
12360
12729
|
for (const p of parts) total += p.length;
|
|
12361
12730
|
const out = new Uint8Array(total);
|
|
@@ -12366,6 +12735,154 @@ function concatBytes(...parts) {
|
|
|
12366
12735
|
}
|
|
12367
12736
|
return out;
|
|
12368
12737
|
}
|
|
12738
|
+
function assertVersion(version) {
|
|
12739
|
+
if (version !== "v1" && version !== "v2") {
|
|
12740
|
+
throw new Error(`sign-bytes version must be "v1" or "v2", got ${JSON.stringify(version)}`);
|
|
12741
|
+
}
|
|
12742
|
+
}
|
|
12743
|
+
function hybridSignBytesV1(b0, authInfo) {
|
|
12744
|
+
return concat2([be32(b0.length), b0, be32(authInfo.length), authInfo]);
|
|
12745
|
+
}
|
|
12746
|
+
function hybridSignBytesV2(chainId, b0, authInfo) {
|
|
12747
|
+
const cid = utf8.encode(chainId);
|
|
12748
|
+
return concat2([
|
|
12749
|
+
utf8.encode(HYBRID_SIGN_BYTES_V2_DOMAIN),
|
|
12750
|
+
be642(cid.length),
|
|
12751
|
+
cid,
|
|
12752
|
+
be32(b0.length),
|
|
12753
|
+
b0,
|
|
12754
|
+
be32(authInfo.length),
|
|
12755
|
+
authInfo
|
|
12756
|
+
]);
|
|
12757
|
+
}
|
|
12758
|
+
function hybridSignBytes(version, chainId, b0, authInfo) {
|
|
12759
|
+
assertVersion(version);
|
|
12760
|
+
return version === "v2" ? hybridSignBytesV2(chainId, b0, authInfo) : hybridSignBytesV1(b0, authInfo);
|
|
12761
|
+
}
|
|
12762
|
+
function migrationSignBytesV1(input) {
|
|
12763
|
+
return utf8.encode(
|
|
12764
|
+
`qorechain-key-migration:chain=${input.chainId}:from=${input.fromAlgorithmId}:to=${input.toAlgorithmId}:account=${input.account}:height=${BigInt(input.height)}`
|
|
12765
|
+
);
|
|
12766
|
+
}
|
|
12767
|
+
function migrationSignBytesV2(input) {
|
|
12768
|
+
const cid = utf8.encode(input.chainId);
|
|
12769
|
+
const acct = utf8.encode(input.account);
|
|
12770
|
+
return concat2([
|
|
12771
|
+
utf8.encode(MIGRATION_SIGN_BYTES_V2_DOMAIN),
|
|
12772
|
+
be642(cid.length),
|
|
12773
|
+
cid,
|
|
12774
|
+
be642(acct.length),
|
|
12775
|
+
acct,
|
|
12776
|
+
be32(input.fromAlgorithmId),
|
|
12777
|
+
be32(input.toAlgorithmId),
|
|
12778
|
+
be642(input.height),
|
|
12779
|
+
be32(input.oldPublicKey.length),
|
|
12780
|
+
input.oldPublicKey,
|
|
12781
|
+
be32(input.newPublicKey.length),
|
|
12782
|
+
input.newPublicKey
|
|
12783
|
+
]);
|
|
12784
|
+
}
|
|
12785
|
+
function migrationSignBytes(version, input) {
|
|
12786
|
+
assertVersion(version);
|
|
12787
|
+
return version === "v2" ? migrationSignBytesV2(input) : migrationSignBytesV1(input);
|
|
12788
|
+
}
|
|
12789
|
+
function bridgeAttestationSignBytesV1(input) {
|
|
12790
|
+
return utf8.encode(
|
|
12791
|
+
[input.chain, input.eventType, input.operationId, input.txHash, input.amount, input.asset].join("|")
|
|
12792
|
+
);
|
|
12793
|
+
}
|
|
12794
|
+
function bridgeAttestationSignBytesV2(input) {
|
|
12795
|
+
const parts = [utf8.encode(BRIDGE_ATTESTATION_V2_DOMAIN)];
|
|
12796
|
+
for (const f of [
|
|
12797
|
+
input.chainId,
|
|
12798
|
+
input.chain,
|
|
12799
|
+
input.eventType,
|
|
12800
|
+
input.operationId,
|
|
12801
|
+
input.txHash,
|
|
12802
|
+
input.amount,
|
|
12803
|
+
input.asset
|
|
12804
|
+
]) {
|
|
12805
|
+
const b = utf8.encode(f);
|
|
12806
|
+
parts.push(be642(b.length), b);
|
|
12807
|
+
}
|
|
12808
|
+
return concat2(parts);
|
|
12809
|
+
}
|
|
12810
|
+
function bridgeAttestationSignBytes(version, input) {
|
|
12811
|
+
assertVersion(version);
|
|
12812
|
+
return version === "v2" ? bridgeAttestationSignBytesV2(input) : bridgeAttestationSignBytesV1(input);
|
|
12813
|
+
}
|
|
12814
|
+
function isLegacySignBytesChain(chainId) {
|
|
12815
|
+
return LEGACY_SIGN_BYTES_CHAINS.includes(chainId);
|
|
12816
|
+
}
|
|
12817
|
+
function signBytesVersionFor(chainId, v2AppliedHeight) {
|
|
12818
|
+
return BigInt(v2AppliedHeight) > 0n || !isLegacySignBytesChain(chainId) ? "v2" : "v1";
|
|
12819
|
+
}
|
|
12820
|
+
function parseAppliedHeight(body) {
|
|
12821
|
+
const h = body?.height;
|
|
12822
|
+
if (h === void 0 || h === null || h === "") return 0n;
|
|
12823
|
+
if (typeof h !== "string" && typeof h !== "number" && typeof h !== "bigint") {
|
|
12824
|
+
throw new Error(`unexpected applied_plan height ${JSON.stringify(h)}`);
|
|
12825
|
+
}
|
|
12826
|
+
return BigInt(h);
|
|
12827
|
+
}
|
|
12828
|
+
async function fetchSignBytesV2AppliedHeight(rest, fetchImpl = globalThis.fetch) {
|
|
12829
|
+
const url = `${rest.replace(/\/+$/, "")}/cosmos/upgrade/v1beta1/applied_plan/${SIGN_BYTES_V2_UPGRADE}`;
|
|
12830
|
+
const res = await fetchImpl(url);
|
|
12831
|
+
if (!res.ok) {
|
|
12832
|
+
throw new Error(`applied_plan query failed: HTTP ${res.status} from ${url}`);
|
|
12833
|
+
}
|
|
12834
|
+
return parseAppliedHeight(await res.json());
|
|
12835
|
+
}
|
|
12836
|
+
var cache = /* @__PURE__ */ new Map();
|
|
12837
|
+
function clearSignBytesCache() {
|
|
12838
|
+
cache.clear();
|
|
12839
|
+
}
|
|
12840
|
+
async function resolveSignBytesVersion(opts) {
|
|
12841
|
+
const requested = opts.signBytesVersion ?? "auto";
|
|
12842
|
+
if (requested === "v1" || requested === "v2") return requested;
|
|
12843
|
+
if (requested !== "auto") {
|
|
12844
|
+
throw new Error(`signBytesVersion must be "auto", "v1" or "v2", got ${JSON.stringify(requested)}`);
|
|
12845
|
+
}
|
|
12846
|
+
if (!isLegacySignBytesChain(opts.chainId)) return "v2";
|
|
12847
|
+
if (!opts.rest) {
|
|
12848
|
+
throw new Error(
|
|
12849
|
+
`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)`
|
|
12850
|
+
);
|
|
12851
|
+
}
|
|
12852
|
+
const key = `${opts.rest}\0${opts.chainId}`;
|
|
12853
|
+
const ttl = opts.ttlMs ?? 6e4;
|
|
12854
|
+
const hit = cache.get(key);
|
|
12855
|
+
if (!opts.forceRefresh && hit && Date.now() - hit.at < ttl) return hit.version;
|
|
12856
|
+
let height;
|
|
12857
|
+
try {
|
|
12858
|
+
height = await fetchSignBytesV2AppliedHeight(opts.rest, opts.fetch);
|
|
12859
|
+
} catch (e) {
|
|
12860
|
+
throw new Error(
|
|
12861
|
+
`cannot ask ${opts.rest} whether ${SIGN_BYTES_V2_UPGRADE} is applied (${e.message}); pass signBytesVersion "v1" or "v2"`
|
|
12862
|
+
);
|
|
12863
|
+
}
|
|
12864
|
+
const version = signBytesVersionFor(opts.chainId, height);
|
|
12865
|
+
cache.set(key, { version, at: Date.now() });
|
|
12866
|
+
return version;
|
|
12867
|
+
}
|
|
12868
|
+
var HYBRID_SIGN_BYTES_REJECTION_LOG = "hybrid PQC signature verification failed";
|
|
12869
|
+
function isHybridSignBytesRejection(x) {
|
|
12870
|
+
if (x === null || x === void 0) return false;
|
|
12871
|
+
const o = x;
|
|
12872
|
+
if (o.codespace === "pqc" && Number(o.code) === 21) return true;
|
|
12873
|
+
for (const t of [o.log, o.rawLog, o.message]) {
|
|
12874
|
+
if (typeof t === "string" && t.includes(HYBRID_SIGN_BYTES_REJECTION_LOG)) return true;
|
|
12875
|
+
}
|
|
12876
|
+
return false;
|
|
12877
|
+
}
|
|
12878
|
+
|
|
12879
|
+
// src/tx/hybrid-tx.ts
|
|
12880
|
+
function fromBase64(b64) {
|
|
12881
|
+
const binary = atob(b64);
|
|
12882
|
+
const out = new Uint8Array(binary.length);
|
|
12883
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
12884
|
+
return out;
|
|
12885
|
+
}
|
|
12369
12886
|
async function buildHybridTx(opts) {
|
|
12370
12887
|
const {
|
|
12371
12888
|
registry,
|
|
@@ -12401,12 +12918,14 @@ async function buildHybridTx(opts) {
|
|
|
12401
12918
|
fee.payer,
|
|
12402
12919
|
signing.SignMode.SIGN_MODE_DIRECT
|
|
12403
12920
|
);
|
|
12404
|
-
const
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12921
|
+
const signBytesVersion = await resolveSignBytesVersion({
|
|
12922
|
+
chainId,
|
|
12923
|
+
rest: opts.rest,
|
|
12924
|
+
signBytesVersion: opts.signBytesVersion,
|
|
12925
|
+
fetch: opts.fetch,
|
|
12926
|
+
forceRefresh: opts.forceRefreshSignBytesVersion
|
|
12927
|
+
});
|
|
12928
|
+
const pqcSignedMessage = hybridSignBytes(signBytesVersion, chainId, b0, authInfoBytes);
|
|
12410
12929
|
const pqcSignature = pqcSign(pqcKeypair.secretKey, pqcSignedMessage);
|
|
12411
12930
|
const ext = buildHybridSignatureExtension({
|
|
12412
12931
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12440,18 +12959,34 @@ async function buildHybridTx(opts) {
|
|
|
12440
12959
|
txRawBytes,
|
|
12441
12960
|
authInfoBytes,
|
|
12442
12961
|
pqcSignedMessage,
|
|
12443
|
-
pqcSignature
|
|
12962
|
+
pqcSignature,
|
|
12963
|
+
signBytesVersion
|
|
12444
12964
|
};
|
|
12445
12965
|
}
|
|
12446
12966
|
async function signAndBroadcastHybrid(opts) {
|
|
12967
|
+
const auto = (opts.signBytesVersion ?? "auto") === "auto";
|
|
12968
|
+
try {
|
|
12969
|
+
return await broadcastHybridOnce(opts, false);
|
|
12970
|
+
} catch (e) {
|
|
12971
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
12972
|
+
return broadcastHybridOnce(opts, true);
|
|
12973
|
+
}
|
|
12974
|
+
}
|
|
12975
|
+
async function broadcastHybridOnce(opts, forceRefresh) {
|
|
12447
12976
|
const { transport } = opts;
|
|
12448
12977
|
const mode = opts.mode ?? "commit";
|
|
12449
|
-
const built = await buildHybridTx(
|
|
12978
|
+
const built = await buildHybridTx({
|
|
12979
|
+
...opts,
|
|
12980
|
+
forceRefreshSignBytesVersion: forceRefresh || opts.forceRefreshSignBytesVersion
|
|
12981
|
+
});
|
|
12450
12982
|
if (mode === "commit") {
|
|
12451
12983
|
const res = await transport.broadcastTx(built.txRawBytes);
|
|
12452
12984
|
if (res.code !== 0) {
|
|
12453
|
-
throw
|
|
12454
|
-
|
|
12985
|
+
throw Object.assign(
|
|
12986
|
+
new Error(
|
|
12987
|
+
`hybrid transaction failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
12988
|
+
),
|
|
12989
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
12455
12990
|
);
|
|
12456
12991
|
}
|
|
12457
12992
|
return {
|
|
@@ -12475,24 +13010,11 @@ function fromHex(hex) {
|
|
|
12475
13010
|
}
|
|
12476
13011
|
return bytes;
|
|
12477
13012
|
}
|
|
12478
|
-
function
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
b[3] = n & 255;
|
|
12484
|
-
return b;
|
|
12485
|
-
}
|
|
12486
|
-
function concatBytes2(...parts) {
|
|
12487
|
-
let total = 0;
|
|
12488
|
-
for (const p of parts) total += p.length;
|
|
12489
|
-
const out = new Uint8Array(total);
|
|
12490
|
-
let off = 0;
|
|
12491
|
-
for (const p of parts) {
|
|
12492
|
-
out.set(p, off);
|
|
12493
|
-
off += p.length;
|
|
12494
|
-
}
|
|
12495
|
-
return out;
|
|
13013
|
+
function defaultSignBytesVersion(chainId) {
|
|
13014
|
+
if (!isLegacySignBytesChain(chainId)) return "v2";
|
|
13015
|
+
throw new Error(
|
|
13016
|
+
`signHybridEth on ${chainId} needs signBytesVersion: resolve it with resolveSignBytesVersion({ chainId, rest }) \u2014 the network switches from v1 to v2 at its own upgrade height`
|
|
13017
|
+
);
|
|
12496
13018
|
}
|
|
12497
13019
|
function encodeMessages(params) {
|
|
12498
13020
|
const enc3 = params.encodeMessage;
|
|
@@ -12578,12 +13100,8 @@ function signHybridEth(params) {
|
|
|
12578
13100
|
const b0 = tx$1.TxBody.encode(
|
|
12579
13101
|
tx$1.TxBody.fromPartial({ messages: encodedMessages, memo, timeoutHeight })
|
|
12580
13102
|
).finish();
|
|
12581
|
-
const
|
|
12582
|
-
|
|
12583
|
-
b0,
|
|
12584
|
-
be322(authInfoBytes.length),
|
|
12585
|
-
authInfoBytes
|
|
12586
|
-
);
|
|
13103
|
+
const version = params.signBytesVersion ?? defaultSignBytesVersion(params.chainId);
|
|
13104
|
+
const pqcSignedMessage = hybridSignBytes(version, params.chainId, b0, authInfoBytes);
|
|
12587
13105
|
const pqcSignature = pqcSign(params.account.pqc.secretKey, pqcSignedMessage);
|
|
12588
13106
|
const ext = buildHybridSignatureExtension({
|
|
12589
13107
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12632,6 +13150,22 @@ var EthNativeSigner = class {
|
|
|
12632
13150
|
};
|
|
12633
13151
|
this.registry = opts.registry ?? qorechainRegistry();
|
|
12634
13152
|
this.signMode = opts.signMode ?? "hybrid";
|
|
13153
|
+
this.signBytesVersion = opts.signBytesVersion ?? "auto";
|
|
13154
|
+
this.rest = opts.rest;
|
|
13155
|
+
this.fetchImpl = opts.fetch;
|
|
13156
|
+
}
|
|
13157
|
+
/**
|
|
13158
|
+
* The hybrid sign-bytes form for `chainId` under this signer's settings.
|
|
13159
|
+
* Pass `forceRefresh` to bypass the cached answer.
|
|
13160
|
+
*/
|
|
13161
|
+
resolveSignBytesVersion(chainId, forceRefresh = false) {
|
|
13162
|
+
return resolveSignBytesVersion({
|
|
13163
|
+
chainId,
|
|
13164
|
+
rest: this.rest,
|
|
13165
|
+
signBytesVersion: this.signBytesVersion,
|
|
13166
|
+
fetch: this.fetchImpl,
|
|
13167
|
+
forceRefresh
|
|
13168
|
+
});
|
|
12635
13169
|
}
|
|
12636
13170
|
/** Build and sign a `TxRaw` for the given messages. Does not broadcast. */
|
|
12637
13171
|
sign(params) {
|
|
@@ -12644,20 +13178,34 @@ var EthNativeSigner = class {
|
|
|
12644
13178
|
sequence: params.sequence,
|
|
12645
13179
|
memo: params.memo,
|
|
12646
13180
|
timeoutHeight: params.timeoutHeight,
|
|
12647
|
-
encodeMessage: this.encode
|
|
13181
|
+
encodeMessage: this.encode,
|
|
13182
|
+
signBytesVersion: params.signBytesVersion ?? (this.signBytesVersion === "auto" ? void 0 : this.signBytesVersion)
|
|
12648
13183
|
};
|
|
12649
13184
|
return this.signMode === "classical" ? signClassicalEth(signParams) : signHybridEth(signParams);
|
|
12650
13185
|
}
|
|
12651
13186
|
/** Sign and broadcast the given messages via `transport`. */
|
|
12652
13187
|
async signAndBroadcast(transport, params) {
|
|
12653
|
-
const
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
13188
|
+
const once = async (forceRefresh) => {
|
|
13189
|
+
const signBytesVersion = this.signMode === "hybrid" ? params.signBytesVersion ?? await this.resolveSignBytesVersion(params.chainId, forceRefresh) : void 0;
|
|
13190
|
+
const { txRawBytes } = this.sign({ ...params, signBytesVersion });
|
|
13191
|
+
const res = await transport.broadcastTx(txRawBytes);
|
|
13192
|
+
if (res.code !== 0) {
|
|
13193
|
+
throw Object.assign(
|
|
13194
|
+
new Error(
|
|
13195
|
+
`eth-native tx failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
13196
|
+
),
|
|
13197
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
13198
|
+
);
|
|
13199
|
+
}
|
|
13200
|
+
return res;
|
|
13201
|
+
};
|
|
13202
|
+
const auto = this.signMode === "hybrid" && params.signBytesVersion === void 0 && this.signBytesVersion === "auto";
|
|
13203
|
+
try {
|
|
13204
|
+
return await once(false);
|
|
13205
|
+
} catch (e) {
|
|
13206
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
13207
|
+
return once(true);
|
|
12659
13208
|
}
|
|
12660
|
-
return res;
|
|
12661
13209
|
}
|
|
12662
13210
|
/** Send `amount` to `toAddress` via a bank `MsgSend`, signed eth-native. */
|
|
12663
13211
|
bankSend(transport, toAddress, amount, params) {
|
|
@@ -12953,6 +13501,20 @@ var svm = {
|
|
|
12953
13501
|
registerSvmPqcKey: composer2(
|
|
12954
13502
|
"/qorechain.svm.v1.MsgRegisterSVMPQCKey",
|
|
12955
13503
|
MsgRegisterSVMPQCKey
|
|
13504
|
+
),
|
|
13505
|
+
/**
|
|
13506
|
+
* Replace the x/svm runtime parameters wholesale (chain v3.1.97).
|
|
13507
|
+
*
|
|
13508
|
+
* GOVERNANCE ONLY: `authority` must be the governance module account, so this
|
|
13509
|
+
* message is submitted inside a gov proposal, not signed by a user. It is what
|
|
13510
|
+
* makes enabling/disabling the SVM lane a proposal rather than a binary
|
|
13511
|
+
* release. `params` is replaced in full — send every field, not just the ones
|
|
13512
|
+
* you mean to change. `rentExemptionMulti` is a `LegacyDec` string (e.g.
|
|
13513
|
+
* `"2.000000000000000000"`).
|
|
13514
|
+
*/
|
|
13515
|
+
updateParams: composer2(
|
|
13516
|
+
"/qorechain.svm.v1.MsgUpdateParams",
|
|
13517
|
+
MsgUpdateParams
|
|
12956
13518
|
)
|
|
12957
13519
|
};
|
|
12958
13520
|
var lightnode = {
|
|
@@ -26291,6 +26853,30 @@ function extractMessageIds(result) {
|
|
|
26291
26853
|
}
|
|
26292
26854
|
return ids;
|
|
26293
26855
|
}
|
|
26856
|
+
var CROSSVM_CALL_RESPONSE_TYPE_URL = "/qorechain.crossvm.v1.MsgCrossVMCallResponse";
|
|
26857
|
+
function unknownOutcome() {
|
|
26858
|
+
return { executed: false, data: new Uint8Array(0), gasUsed: 0n };
|
|
26859
|
+
}
|
|
26860
|
+
function decodeCallOutcomes(result) {
|
|
26861
|
+
const responses = result.msgResponses;
|
|
26862
|
+
if (!Array.isArray(responses)) return [];
|
|
26863
|
+
const out = [];
|
|
26864
|
+
for (const r of responses) {
|
|
26865
|
+
if (r?.typeUrl !== CROSSVM_CALL_RESPONSE_TYPE_URL) continue;
|
|
26866
|
+
try {
|
|
26867
|
+
const decoded = MsgCrossVMCallResponse.decode(r.value);
|
|
26868
|
+
out.push({
|
|
26869
|
+
executed: decoded.executed,
|
|
26870
|
+
data: decoded.data,
|
|
26871
|
+
// uint64 is generated as a decimal string; surface it as a bigint.
|
|
26872
|
+
gasUsed: BigInt(decoded.gasUsed ?? 0)
|
|
26873
|
+
});
|
|
26874
|
+
} catch {
|
|
26875
|
+
out.push(unknownOutcome());
|
|
26876
|
+
}
|
|
26877
|
+
}
|
|
26878
|
+
return out;
|
|
26879
|
+
}
|
|
26294
26880
|
function createCrossVMClient(tx, opts = {}) {
|
|
26295
26881
|
const sender = tx.senderAddress;
|
|
26296
26882
|
const query = opts.query;
|
|
@@ -26301,7 +26887,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26301
26887
|
targetVm: o.targetVm,
|
|
26302
26888
|
targetContract: o.targetContract,
|
|
26303
26889
|
payload,
|
|
26304
|
-
funds: o.funds ?? []
|
|
26890
|
+
funds: o.funds ?? [],
|
|
26891
|
+
async: o.async ?? false
|
|
26305
26892
|
});
|
|
26306
26893
|
const buildCallSync = (o, payload) => buildFrom(o, payload);
|
|
26307
26894
|
const buildCall = (o) => {
|
|
@@ -26326,7 +26913,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26326
26913
|
{ autoFee: o.autoFee }
|
|
26327
26914
|
);
|
|
26328
26915
|
const [messageId = ""] = extractMessageIds(result);
|
|
26329
|
-
|
|
26916
|
+
const [outcome = unknownOutcome()] = decodeCallOutcomes(result);
|
|
26917
|
+
return { messageId, ...outcome, result };
|
|
26330
26918
|
};
|
|
26331
26919
|
const callAtomic = async (calls, w = {}) => {
|
|
26332
26920
|
if (calls.length === 0) {
|
|
@@ -26341,7 +26929,11 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26341
26929
|
w.memo ?? "",
|
|
26342
26930
|
{ autoFee: w.autoFee }
|
|
26343
26931
|
);
|
|
26344
|
-
return {
|
|
26932
|
+
return {
|
|
26933
|
+
messageIds: extractMessageIds(result),
|
|
26934
|
+
outcomes: decodeCallOutcomes(result),
|
|
26935
|
+
result
|
|
26936
|
+
};
|
|
26345
26937
|
};
|
|
26346
26938
|
const getMessage = (id) => {
|
|
26347
26939
|
requireGetMessageSource(query, qor);
|
|
@@ -26445,7 +27037,7 @@ async function migrateToHybrid(tx, opts) {
|
|
|
26445
27037
|
}
|
|
26446
27038
|
|
|
26447
27039
|
// src/index.ts
|
|
26448
|
-
var VERSION = "0.
|
|
27040
|
+
var VERSION = "0.8.0";
|
|
26449
27041
|
|
|
26450
27042
|
Object.defineProperty(exports, "AI_ANOMALY_CHECK_ADDRESS", {
|
|
26451
27043
|
enumerable: true,
|
|
@@ -26478,30 +27070,35 @@ Object.defineProperty(exports, "simulateWithRiskScore", {
|
|
|
26478
27070
|
exports.AlgorithmDilithium5 = AlgorithmDilithium5;
|
|
26479
27071
|
exports.AlgorithmMLKEM1024 = AlgorithmMLKEM1024;
|
|
26480
27072
|
exports.AlgorithmUnspecified = AlgorithmUnspecified;
|
|
27073
|
+
exports.BRIDGE_ATTESTATION_V2_DOMAIN = BRIDGE_ATTESTATION_V2_DOMAIN;
|
|
26481
27074
|
exports.CANONICAL_DERIVATION = CANONICAL_DERIVATION;
|
|
26482
27075
|
exports.DEFAULT_GAS_MULTIPLIER = DEFAULT_GAS_MULTIPLIER;
|
|
26483
27076
|
exports.DEFAULT_GAS_PRICE = DEFAULT_GAS_PRICE;
|
|
26484
27077
|
exports.ETHSECP256K1_PUBKEY_TYPE = ETHSECP256K1_PUBKEY_TYPE;
|
|
26485
27078
|
exports.EthNativeSigner = EthNativeSigner;
|
|
26486
27079
|
exports.GasPrice = GasPrice;
|
|
27080
|
+
exports.HYBRID_SIGN_BYTES_REJECTION_LOG = HYBRID_SIGN_BYTES_REJECTION_LOG;
|
|
27081
|
+
exports.HYBRID_SIGN_BYTES_V2_DOMAIN = HYBRID_SIGN_BYTES_V2_DOMAIN;
|
|
26487
27082
|
exports.HYBRID_SIG_TYPE_URL = HYBRID_SIG_TYPE_URL;
|
|
26488
27083
|
exports.HybridSigner = HybridSigner;
|
|
26489
27084
|
exports.JsonRpcClient = JsonRpcClient;
|
|
26490
27085
|
exports.JsonRpcError = JsonRpcError;
|
|
26491
27086
|
exports.LEGACY_DERIVATION = LEGACY_DERIVATION;
|
|
27087
|
+
exports.LEGACY_SIGN_BYTES_CHAINS = LEGACY_SIGN_BYTES_CHAINS;
|
|
27088
|
+
exports.MIGRATION_SIGN_BYTES_V2_DOMAIN = MIGRATION_SIGN_BYTES_V2_DOMAIN;
|
|
26492
27089
|
exports.ML_DSA_87_PUBLIC_KEY_LENGTH = ML_DSA_87_PUBLIC_KEY_LENGTH;
|
|
26493
27090
|
exports.ML_DSA_87_SECRET_KEY_LENGTH = ML_DSA_87_SECRET_KEY_LENGTH;
|
|
26494
27091
|
exports.ML_DSA_87_SEED_LENGTH = ML_DSA_87_SEED_LENGTH;
|
|
26495
27092
|
exports.ML_DSA_87_SIGNATURE_LENGTH = ML_DSA_87_SIGNATURE_LENGTH;
|
|
26496
27093
|
exports.MSG_SEND_TYPE_URL = MSG_SEND_TYPE_URL;
|
|
26497
27094
|
exports.NETWORKS = NETWORKS;
|
|
26498
|
-
exports.PHANTOM_DERIVATION_DOMAIN = PHANTOM_DERIVATION_DOMAIN;
|
|
26499
27095
|
exports.PQC_KEY_STATUS_PRECOMPILE_ADDRESS = PQC_KEY_STATUS_PRECOMPILE_ADDRESS;
|
|
26500
27096
|
exports.PqcSigner = PqcSigner;
|
|
26501
27097
|
exports.QorClient = QorClient;
|
|
26502
27098
|
exports.QoreHttpError = QoreHttpError;
|
|
26503
27099
|
exports.QoreTxError = QoreTxError;
|
|
26504
27100
|
exports.RestClient = RestClient;
|
|
27101
|
+
exports.SIGN_BYTES_V2_UPGRADE = SIGN_BYTES_V2_UPGRADE;
|
|
26505
27102
|
exports.STATIC_FALLBACK = STATIC_FALLBACK;
|
|
26506
27103
|
exports.TxClient = TxClient;
|
|
26507
27104
|
exports.VERSION = VERSION;
|
|
@@ -26517,6 +27114,9 @@ exports.bank = bank;
|
|
|
26517
27114
|
exports.be64 = be64;
|
|
26518
27115
|
exports.bech32ToHex = bech32ToHex;
|
|
26519
27116
|
exports.bridge = bridge;
|
|
27117
|
+
exports.bridgeAttestationSignBytes = bridgeAttestationSignBytes;
|
|
27118
|
+
exports.bridgeAttestationSignBytesV1 = bridgeAttestationSignBytesV1;
|
|
27119
|
+
exports.bridgeAttestationSignBytesV2 = bridgeAttestationSignBytesV2;
|
|
26520
27120
|
exports.broadcastAndWait = broadcastAndWait;
|
|
26521
27121
|
exports.buildAminoTypes = buildAminoTypes;
|
|
26522
27122
|
exports.buildEventsQuery = buildEventsQuery;
|
|
@@ -26532,6 +27132,7 @@ exports.buildUrl = buildUrl;
|
|
|
26532
27132
|
exports.bytesToBech32 = bytesToBech32;
|
|
26533
27133
|
exports.calculateFee = calculateFee;
|
|
26534
27134
|
exports.clearAdmin = clearAdmin;
|
|
27135
|
+
exports.clearSignBytesCache = clearSignBytesCache;
|
|
26535
27136
|
exports.connectCosmWasmSigner = connectCosmWasmSigner;
|
|
26536
27137
|
exports.connectPhantomUnified = connectPhantomUnified;
|
|
26537
27138
|
exports.connectQueryClients = connectQueryClients;
|
|
@@ -26564,6 +27165,7 @@ exports.explorerAddressUrl = explorerAddressUrl;
|
|
|
26564
27165
|
exports.explorerBlockUrl = explorerBlockUrl;
|
|
26565
27166
|
exports.explorerTxUrl = explorerTxUrl;
|
|
26566
27167
|
exports.feegrant = feegrant;
|
|
27168
|
+
exports.fetchSignBytesV2AppliedHeight = fetchSignBytesV2AppliedHeight;
|
|
26567
27169
|
exports.formatUnits = formatUnits;
|
|
26568
27170
|
exports.fromBase = fromBase;
|
|
26569
27171
|
exports.generateMnemonic = generateMnemonic;
|
|
@@ -26584,10 +27186,15 @@ exports.getPqcStatus = getPqcStatus;
|
|
|
26584
27186
|
exports.getTx = getTx;
|
|
26585
27187
|
exports.gov = gov;
|
|
26586
27188
|
exports.hexToBech32 = hexToBech32;
|
|
27189
|
+
exports.hybridSignBytes = hybridSignBytes;
|
|
27190
|
+
exports.hybridSignBytesV1 = hybridSignBytesV1;
|
|
27191
|
+
exports.hybridSignBytesV2 = hybridSignBytesV2;
|
|
26587
27192
|
exports.ibc = ibc;
|
|
26588
27193
|
exports.instantiate = instantiate;
|
|
26589
27194
|
exports.instantiate2 = instantiate2;
|
|
26590
27195
|
exports.isChecksumAddress = isChecksumAddress;
|
|
27196
|
+
exports.isHybridSignBytesRejection = isHybridSignBytesRejection;
|
|
27197
|
+
exports.isLegacySignBytesChain = isLegacySignBytesChain;
|
|
26591
27198
|
exports.isPqcRegistered = isPqcRegistered;
|
|
26592
27199
|
exports.isSignatureAlgorithm = isSignatureAlgorithm;
|
|
26593
27200
|
exports.isTxFailure = isTxFailure;
|
|
@@ -26604,6 +27211,9 @@ exports.listNetworks = listNetworks;
|
|
|
26604
27211
|
exports.migrate = migrate;
|
|
26605
27212
|
exports.migratePqcKey = migratePqcKey;
|
|
26606
27213
|
exports.migrateToHybrid = migrateToHybrid;
|
|
27214
|
+
exports.migrationSignBytes = migrationSignBytes;
|
|
27215
|
+
exports.migrationSignBytesV1 = migrationSignBytesV1;
|
|
27216
|
+
exports.migrationSignBytesV2 = migrationSignBytesV2;
|
|
26607
27217
|
exports.msg = msg;
|
|
26608
27218
|
exports.multilayer = multilayer;
|
|
26609
27219
|
exports.parseEthPubkeyAny = parseEthPubkeyAny;
|
|
@@ -26621,6 +27231,7 @@ exports.queryContractSmart = queryContractSmart;
|
|
|
26621
27231
|
exports.rdk = rdk;
|
|
26622
27232
|
exports.registerEthAuthenticatorMsg = registerEthAuthenticatorMsg;
|
|
26623
27233
|
exports.requestFaucet = requestFaucet;
|
|
27234
|
+
exports.resolveSignBytesVersion = resolveSignBytesVersion;
|
|
26624
27235
|
exports.revokeAuthenticatorMsg = revokeAuthenticatorMsg;
|
|
26625
27236
|
exports.ripemd160 = ripemd160;
|
|
26626
27237
|
exports.ripemd160Hex = ripemd160Hex;
|
|
@@ -26632,6 +27243,7 @@ exports.searchTxs = searchTxs;
|
|
|
26632
27243
|
exports.sha256 = sha256;
|
|
26633
27244
|
exports.sha256Hex = sha256Hex;
|
|
26634
27245
|
exports.signAndBroadcastHybrid = signAndBroadcastHybrid;
|
|
27246
|
+
exports.signBytesVersionFor = signBytesVersionFor;
|
|
26635
27247
|
exports.signClassicalEth = signClassicalEth;
|
|
26636
27248
|
exports.signHybridEth = signHybridEth;
|
|
26637
27249
|
exports.staking = staking;
|