@qorechain/sdk 0.7.0 → 0.8.1
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 +68 -13
- package/dist/index.cjs +713 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +464 -56
- package/dist/index.d.ts +464 -56
- package/dist/index.js +691 -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
|
|
11957
|
-
);
|
|
11958
|
-
const message = `${PHANTOM_DERIVATION_DOMAIN}
|
|
11959
|
-
${base58.encode(pk)}`;
|
|
11960
|
-
const signed = await provider.signMessage(
|
|
11961
|
-
new TextEncoder().encode(message),
|
|
11962
|
-
"utf8"
|
|
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."
|
|
11963
12326
|
);
|
|
11964
|
-
return unifiedAccountFromPhantomSignature(signatureBytes(signed));
|
|
11965
12327
|
}
|
|
11966
12328
|
async function directSignerFromPrivateKey(privateKey, prefix) {
|
|
11967
12329
|
if (privateKey.length !== 32) {
|
|
@@ -12339,21 +12701,29 @@ 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.2.0";
|
|
12707
|
+
var SIGN_BYTES_V2_UPGRADES = ["v3.2.0", "v3.1.98"];
|
|
12708
|
+
var LEGACY_SIGN_BYTES_CHAINS = [
|
|
12709
|
+
"qorechain-vladi",
|
|
12710
|
+
"qorechain-diana"
|
|
12711
|
+
];
|
|
12712
|
+
var HYBRID_SIGN_BYTES_V2_DOMAIN = "qorechain-pqc-hybrid-v2";
|
|
12713
|
+
var MIGRATION_SIGN_BYTES_V2_DOMAIN = "qorechain-key-migration-v2";
|
|
12714
|
+
var BRIDGE_ATTESTATION_V2_DOMAIN = "qorechain-bridge-attestation-v2";
|
|
12715
|
+
var utf8 = new TextEncoder();
|
|
12342
12716
|
function be32(n) {
|
|
12343
12717
|
const b = new Uint8Array(4);
|
|
12344
|
-
b
|
|
12345
|
-
b[1] = n >>> 16 & 255;
|
|
12346
|
-
b[2] = n >>> 8 & 255;
|
|
12347
|
-
b[3] = n & 255;
|
|
12718
|
+
new DataView(b.buffer).setUint32(0, n >>> 0, false);
|
|
12348
12719
|
return b;
|
|
12349
12720
|
}
|
|
12350
|
-
function
|
|
12351
|
-
const
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
return out;
|
|
12721
|
+
function be642(n) {
|
|
12722
|
+
const b = new Uint8Array(8);
|
|
12723
|
+
new DataView(b.buffer).setBigUint64(0, BigInt(n), false);
|
|
12724
|
+
return b;
|
|
12355
12725
|
}
|
|
12356
|
-
function
|
|
12726
|
+
function concat2(parts) {
|
|
12357
12727
|
let total = 0;
|
|
12358
12728
|
for (const p of parts) total += p.length;
|
|
12359
12729
|
const out = new Uint8Array(total);
|
|
@@ -12364,6 +12734,161 @@ function concatBytes(...parts) {
|
|
|
12364
12734
|
}
|
|
12365
12735
|
return out;
|
|
12366
12736
|
}
|
|
12737
|
+
function assertVersion(version) {
|
|
12738
|
+
if (version !== "v1" && version !== "v2") {
|
|
12739
|
+
throw new Error(`sign-bytes version must be "v1" or "v2", got ${JSON.stringify(version)}`);
|
|
12740
|
+
}
|
|
12741
|
+
}
|
|
12742
|
+
function hybridSignBytesV1(b0, authInfo) {
|
|
12743
|
+
return concat2([be32(b0.length), b0, be32(authInfo.length), authInfo]);
|
|
12744
|
+
}
|
|
12745
|
+
function hybridSignBytesV2(chainId, b0, authInfo) {
|
|
12746
|
+
const cid = utf8.encode(chainId);
|
|
12747
|
+
return concat2([
|
|
12748
|
+
utf8.encode(HYBRID_SIGN_BYTES_V2_DOMAIN),
|
|
12749
|
+
be642(cid.length),
|
|
12750
|
+
cid,
|
|
12751
|
+
be32(b0.length),
|
|
12752
|
+
b0,
|
|
12753
|
+
be32(authInfo.length),
|
|
12754
|
+
authInfo
|
|
12755
|
+
]);
|
|
12756
|
+
}
|
|
12757
|
+
function hybridSignBytes(version, chainId, b0, authInfo) {
|
|
12758
|
+
assertVersion(version);
|
|
12759
|
+
return version === "v2" ? hybridSignBytesV2(chainId, b0, authInfo) : hybridSignBytesV1(b0, authInfo);
|
|
12760
|
+
}
|
|
12761
|
+
function migrationSignBytesV1(input) {
|
|
12762
|
+
return utf8.encode(
|
|
12763
|
+
`qorechain-key-migration:chain=${input.chainId}:from=${input.fromAlgorithmId}:to=${input.toAlgorithmId}:account=${input.account}:height=${BigInt(input.height)}`
|
|
12764
|
+
);
|
|
12765
|
+
}
|
|
12766
|
+
function migrationSignBytesV2(input) {
|
|
12767
|
+
const cid = utf8.encode(input.chainId);
|
|
12768
|
+
const acct = utf8.encode(input.account);
|
|
12769
|
+
return concat2([
|
|
12770
|
+
utf8.encode(MIGRATION_SIGN_BYTES_V2_DOMAIN),
|
|
12771
|
+
be642(cid.length),
|
|
12772
|
+
cid,
|
|
12773
|
+
be642(acct.length),
|
|
12774
|
+
acct,
|
|
12775
|
+
be32(input.fromAlgorithmId),
|
|
12776
|
+
be32(input.toAlgorithmId),
|
|
12777
|
+
be642(input.height),
|
|
12778
|
+
be32(input.oldPublicKey.length),
|
|
12779
|
+
input.oldPublicKey,
|
|
12780
|
+
be32(input.newPublicKey.length),
|
|
12781
|
+
input.newPublicKey
|
|
12782
|
+
]);
|
|
12783
|
+
}
|
|
12784
|
+
function migrationSignBytes(version, input) {
|
|
12785
|
+
assertVersion(version);
|
|
12786
|
+
return version === "v2" ? migrationSignBytesV2(input) : migrationSignBytesV1(input);
|
|
12787
|
+
}
|
|
12788
|
+
function bridgeAttestationSignBytesV1(input) {
|
|
12789
|
+
return utf8.encode(
|
|
12790
|
+
[input.chain, input.eventType, input.operationId, input.txHash, input.amount, input.asset].join("|")
|
|
12791
|
+
);
|
|
12792
|
+
}
|
|
12793
|
+
function bridgeAttestationSignBytesV2(input) {
|
|
12794
|
+
const parts = [utf8.encode(BRIDGE_ATTESTATION_V2_DOMAIN)];
|
|
12795
|
+
for (const f of [
|
|
12796
|
+
input.chainId,
|
|
12797
|
+
input.chain,
|
|
12798
|
+
input.eventType,
|
|
12799
|
+
input.operationId,
|
|
12800
|
+
input.txHash,
|
|
12801
|
+
input.amount,
|
|
12802
|
+
input.asset
|
|
12803
|
+
]) {
|
|
12804
|
+
const b = utf8.encode(f);
|
|
12805
|
+
parts.push(be642(b.length), b);
|
|
12806
|
+
}
|
|
12807
|
+
return concat2(parts);
|
|
12808
|
+
}
|
|
12809
|
+
function bridgeAttestationSignBytes(version, input) {
|
|
12810
|
+
assertVersion(version);
|
|
12811
|
+
return version === "v2" ? bridgeAttestationSignBytesV2(input) : bridgeAttestationSignBytesV1(input);
|
|
12812
|
+
}
|
|
12813
|
+
function isLegacySignBytesChain(chainId) {
|
|
12814
|
+
return LEGACY_SIGN_BYTES_CHAINS.includes(chainId);
|
|
12815
|
+
}
|
|
12816
|
+
function signBytesVersionFor(chainId, v2AppliedHeight) {
|
|
12817
|
+
return BigInt(v2AppliedHeight) > 0n || !isLegacySignBytesChain(chainId) ? "v2" : "v1";
|
|
12818
|
+
}
|
|
12819
|
+
function parseAppliedHeight(body) {
|
|
12820
|
+
const h = body?.height;
|
|
12821
|
+
if (h === void 0 || h === null || h === "") return 0n;
|
|
12822
|
+
if (typeof h !== "string" && typeof h !== "number" && typeof h !== "bigint") {
|
|
12823
|
+
throw new Error(`unexpected applied_plan height ${JSON.stringify(h)}`);
|
|
12824
|
+
}
|
|
12825
|
+
return BigInt(h);
|
|
12826
|
+
}
|
|
12827
|
+
async function fetchSignBytesV2AppliedHeight(rest, fetchImpl = globalThis.fetch, upgradeName = SIGN_BYTES_V2_UPGRADE) {
|
|
12828
|
+
const url = `${rest.replace(/\/+$/, "")}/cosmos/upgrade/v1beta1/applied_plan/${upgradeName}`;
|
|
12829
|
+
const res = await fetchImpl(url);
|
|
12830
|
+
if (!res.ok) {
|
|
12831
|
+
throw new Error(`applied_plan query failed: HTTP ${res.status} from ${url}`);
|
|
12832
|
+
}
|
|
12833
|
+
return parseAppliedHeight(await res.json());
|
|
12834
|
+
}
|
|
12835
|
+
async function fetchSignBytesV2AppliedHeightAny(rest, fetchImpl = globalThis.fetch) {
|
|
12836
|
+
for (const name of SIGN_BYTES_V2_UPGRADES) {
|
|
12837
|
+
const height = await fetchSignBytesV2AppliedHeight(rest, fetchImpl, name);
|
|
12838
|
+
if (height > 0n) return height;
|
|
12839
|
+
}
|
|
12840
|
+
return 0n;
|
|
12841
|
+
}
|
|
12842
|
+
var cache = /* @__PURE__ */ new Map();
|
|
12843
|
+
function clearSignBytesCache() {
|
|
12844
|
+
cache.clear();
|
|
12845
|
+
}
|
|
12846
|
+
async function resolveSignBytesVersion(opts) {
|
|
12847
|
+
const requested = opts.signBytesVersion ?? "auto";
|
|
12848
|
+
if (requested === "v1" || requested === "v2") return requested;
|
|
12849
|
+
if (requested !== "auto") {
|
|
12850
|
+
throw new Error(`signBytesVersion must be "auto", "v1" or "v2", got ${JSON.stringify(requested)}`);
|
|
12851
|
+
}
|
|
12852
|
+
if (!isLegacySignBytesChain(opts.chainId)) return "v2";
|
|
12853
|
+
if (!opts.rest) {
|
|
12854
|
+
throw new Error(
|
|
12855
|
+
`cannot choose the hybrid sign-bytes form for ${opts.chainId} without its REST endpoint: pass rest, or signBytesVersion "v1" (before the ${SIGN_BYTES_V2_UPGRADES.join(" / ")} upgrade) or "v2" (after)`
|
|
12856
|
+
);
|
|
12857
|
+
}
|
|
12858
|
+
const key = `${opts.rest}\0${opts.chainId}`;
|
|
12859
|
+
const ttl = opts.ttlMs ?? 6e4;
|
|
12860
|
+
const hit = cache.get(key);
|
|
12861
|
+
if (!opts.forceRefresh && hit && Date.now() - hit.at < ttl) return hit.version;
|
|
12862
|
+
let height;
|
|
12863
|
+
try {
|
|
12864
|
+
height = await fetchSignBytesV2AppliedHeightAny(opts.rest, opts.fetch);
|
|
12865
|
+
} catch (e) {
|
|
12866
|
+
throw new Error(
|
|
12867
|
+
`cannot ask ${opts.rest} whether any of ${SIGN_BYTES_V2_UPGRADES.join(", ")} is applied (${e.message}); pass signBytesVersion "v1" or "v2"`
|
|
12868
|
+
);
|
|
12869
|
+
}
|
|
12870
|
+
const version = signBytesVersionFor(opts.chainId, height);
|
|
12871
|
+
cache.set(key, { version, at: Date.now() });
|
|
12872
|
+
return version;
|
|
12873
|
+
}
|
|
12874
|
+
var HYBRID_SIGN_BYTES_REJECTION_LOG = "hybrid PQC signature verification failed";
|
|
12875
|
+
function isHybridSignBytesRejection(x) {
|
|
12876
|
+
if (x === null || x === void 0) return false;
|
|
12877
|
+
const o = x;
|
|
12878
|
+
if (o.codespace === "pqc" && Number(o.code) === 21) return true;
|
|
12879
|
+
for (const t of [o.log, o.rawLog, o.message]) {
|
|
12880
|
+
if (typeof t === "string" && t.includes(HYBRID_SIGN_BYTES_REJECTION_LOG)) return true;
|
|
12881
|
+
}
|
|
12882
|
+
return false;
|
|
12883
|
+
}
|
|
12884
|
+
|
|
12885
|
+
// src/tx/hybrid-tx.ts
|
|
12886
|
+
function fromBase64(b64) {
|
|
12887
|
+
const binary = atob(b64);
|
|
12888
|
+
const out = new Uint8Array(binary.length);
|
|
12889
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
12890
|
+
return out;
|
|
12891
|
+
}
|
|
12367
12892
|
async function buildHybridTx(opts) {
|
|
12368
12893
|
const {
|
|
12369
12894
|
registry,
|
|
@@ -12399,12 +12924,14 @@ async function buildHybridTx(opts) {
|
|
|
12399
12924
|
fee.payer,
|
|
12400
12925
|
SignMode.SIGN_MODE_DIRECT
|
|
12401
12926
|
);
|
|
12402
|
-
const
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12406
|
-
|
|
12407
|
-
|
|
12927
|
+
const signBytesVersion = await resolveSignBytesVersion({
|
|
12928
|
+
chainId,
|
|
12929
|
+
rest: opts.rest,
|
|
12930
|
+
signBytesVersion: opts.signBytesVersion,
|
|
12931
|
+
fetch: opts.fetch,
|
|
12932
|
+
forceRefresh: opts.forceRefreshSignBytesVersion
|
|
12933
|
+
});
|
|
12934
|
+
const pqcSignedMessage = hybridSignBytes(signBytesVersion, chainId, b0, authInfoBytes);
|
|
12408
12935
|
const pqcSignature = pqcSign(pqcKeypair.secretKey, pqcSignedMessage);
|
|
12409
12936
|
const ext = buildHybridSignatureExtension({
|
|
12410
12937
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12438,18 +12965,34 @@ async function buildHybridTx(opts) {
|
|
|
12438
12965
|
txRawBytes,
|
|
12439
12966
|
authInfoBytes,
|
|
12440
12967
|
pqcSignedMessage,
|
|
12441
|
-
pqcSignature
|
|
12968
|
+
pqcSignature,
|
|
12969
|
+
signBytesVersion
|
|
12442
12970
|
};
|
|
12443
12971
|
}
|
|
12444
12972
|
async function signAndBroadcastHybrid(opts) {
|
|
12973
|
+
const auto = (opts.signBytesVersion ?? "auto") === "auto";
|
|
12974
|
+
try {
|
|
12975
|
+
return await broadcastHybridOnce(opts, false);
|
|
12976
|
+
} catch (e) {
|
|
12977
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
12978
|
+
return broadcastHybridOnce(opts, true);
|
|
12979
|
+
}
|
|
12980
|
+
}
|
|
12981
|
+
async function broadcastHybridOnce(opts, forceRefresh) {
|
|
12445
12982
|
const { transport } = opts;
|
|
12446
12983
|
const mode = opts.mode ?? "commit";
|
|
12447
|
-
const built = await buildHybridTx(
|
|
12984
|
+
const built = await buildHybridTx({
|
|
12985
|
+
...opts,
|
|
12986
|
+
forceRefreshSignBytesVersion: forceRefresh || opts.forceRefreshSignBytesVersion
|
|
12987
|
+
});
|
|
12448
12988
|
if (mode === "commit") {
|
|
12449
12989
|
const res = await transport.broadcastTx(built.txRawBytes);
|
|
12450
12990
|
if (res.code !== 0) {
|
|
12451
|
-
throw
|
|
12452
|
-
|
|
12991
|
+
throw Object.assign(
|
|
12992
|
+
new Error(
|
|
12993
|
+
`hybrid transaction failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
12994
|
+
),
|
|
12995
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
12453
12996
|
);
|
|
12454
12997
|
}
|
|
12455
12998
|
return {
|
|
@@ -12473,24 +13016,11 @@ function fromHex(hex) {
|
|
|
12473
13016
|
}
|
|
12474
13017
|
return bytes;
|
|
12475
13018
|
}
|
|
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;
|
|
13019
|
+
function defaultSignBytesVersion(chainId) {
|
|
13020
|
+
if (!isLegacySignBytesChain(chainId)) return "v2";
|
|
13021
|
+
throw new Error(
|
|
13022
|
+
`signHybridEth on ${chainId} needs signBytesVersion: resolve it with resolveSignBytesVersion({ chainId, rest }) \u2014 the network switches from v1 to v2 at its own upgrade height`
|
|
13023
|
+
);
|
|
12494
13024
|
}
|
|
12495
13025
|
function encodeMessages(params) {
|
|
12496
13026
|
const enc3 = params.encodeMessage;
|
|
@@ -12576,12 +13106,8 @@ function signHybridEth(params) {
|
|
|
12576
13106
|
const b0 = TxBody.encode(
|
|
12577
13107
|
TxBody.fromPartial({ messages: encodedMessages, memo, timeoutHeight })
|
|
12578
13108
|
).finish();
|
|
12579
|
-
const
|
|
12580
|
-
|
|
12581
|
-
b0,
|
|
12582
|
-
be322(authInfoBytes.length),
|
|
12583
|
-
authInfoBytes
|
|
12584
|
-
);
|
|
13109
|
+
const version = params.signBytesVersion ?? defaultSignBytesVersion(params.chainId);
|
|
13110
|
+
const pqcSignedMessage = hybridSignBytes(version, params.chainId, b0, authInfoBytes);
|
|
12585
13111
|
const pqcSignature = pqcSign(params.account.pqc.secretKey, pqcSignedMessage);
|
|
12586
13112
|
const ext = buildHybridSignatureExtension({
|
|
12587
13113
|
algorithmId: AlgorithmDilithium5,
|
|
@@ -12630,6 +13156,22 @@ var EthNativeSigner = class {
|
|
|
12630
13156
|
};
|
|
12631
13157
|
this.registry = opts.registry ?? qorechainRegistry();
|
|
12632
13158
|
this.signMode = opts.signMode ?? "hybrid";
|
|
13159
|
+
this.signBytesVersion = opts.signBytesVersion ?? "auto";
|
|
13160
|
+
this.rest = opts.rest;
|
|
13161
|
+
this.fetchImpl = opts.fetch;
|
|
13162
|
+
}
|
|
13163
|
+
/**
|
|
13164
|
+
* The hybrid sign-bytes form for `chainId` under this signer's settings.
|
|
13165
|
+
* Pass `forceRefresh` to bypass the cached answer.
|
|
13166
|
+
*/
|
|
13167
|
+
resolveSignBytesVersion(chainId, forceRefresh = false) {
|
|
13168
|
+
return resolveSignBytesVersion({
|
|
13169
|
+
chainId,
|
|
13170
|
+
rest: this.rest,
|
|
13171
|
+
signBytesVersion: this.signBytesVersion,
|
|
13172
|
+
fetch: this.fetchImpl,
|
|
13173
|
+
forceRefresh
|
|
13174
|
+
});
|
|
12633
13175
|
}
|
|
12634
13176
|
/** Build and sign a `TxRaw` for the given messages. Does not broadcast. */
|
|
12635
13177
|
sign(params) {
|
|
@@ -12642,20 +13184,34 @@ var EthNativeSigner = class {
|
|
|
12642
13184
|
sequence: params.sequence,
|
|
12643
13185
|
memo: params.memo,
|
|
12644
13186
|
timeoutHeight: params.timeoutHeight,
|
|
12645
|
-
encodeMessage: this.encode
|
|
13187
|
+
encodeMessage: this.encode,
|
|
13188
|
+
signBytesVersion: params.signBytesVersion ?? (this.signBytesVersion === "auto" ? void 0 : this.signBytesVersion)
|
|
12646
13189
|
};
|
|
12647
13190
|
return this.signMode === "classical" ? signClassicalEth(signParams) : signHybridEth(signParams);
|
|
12648
13191
|
}
|
|
12649
13192
|
/** Sign and broadcast the given messages via `transport`. */
|
|
12650
13193
|
async signAndBroadcast(transport, params) {
|
|
12651
|
-
const
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
13194
|
+
const once = async (forceRefresh) => {
|
|
13195
|
+
const signBytesVersion = this.signMode === "hybrid" ? params.signBytesVersion ?? await this.resolveSignBytesVersion(params.chainId, forceRefresh) : void 0;
|
|
13196
|
+
const { txRawBytes } = this.sign({ ...params, signBytesVersion });
|
|
13197
|
+
const res = await transport.broadcastTx(txRawBytes);
|
|
13198
|
+
if (res.code !== 0) {
|
|
13199
|
+
throw Object.assign(
|
|
13200
|
+
new Error(
|
|
13201
|
+
`eth-native tx failed with code ${res.code}: ${res.rawLog ?? "(no log)"} (hash ${res.transactionHash})`
|
|
13202
|
+
),
|
|
13203
|
+
{ code: res.code, rawLog: res.rawLog, transactionHash: res.transactionHash }
|
|
13204
|
+
);
|
|
13205
|
+
}
|
|
13206
|
+
return res;
|
|
13207
|
+
};
|
|
13208
|
+
const auto = this.signMode === "hybrid" && params.signBytesVersion === void 0 && this.signBytesVersion === "auto";
|
|
13209
|
+
try {
|
|
13210
|
+
return await once(false);
|
|
13211
|
+
} catch (e) {
|
|
13212
|
+
if (!auto || !isHybridSignBytesRejection(e)) throw e;
|
|
13213
|
+
return once(true);
|
|
12657
13214
|
}
|
|
12658
|
-
return res;
|
|
12659
13215
|
}
|
|
12660
13216
|
/** Send `amount` to `toAddress` via a bank `MsgSend`, signed eth-native. */
|
|
12661
13217
|
bankSend(transport, toAddress, amount, params) {
|
|
@@ -12951,6 +13507,20 @@ var svm = {
|
|
|
12951
13507
|
registerSvmPqcKey: composer2(
|
|
12952
13508
|
"/qorechain.svm.v1.MsgRegisterSVMPQCKey",
|
|
12953
13509
|
MsgRegisterSVMPQCKey
|
|
13510
|
+
),
|
|
13511
|
+
/**
|
|
13512
|
+
* Replace the x/svm runtime parameters wholesale (chain v3.1.97).
|
|
13513
|
+
*
|
|
13514
|
+
* GOVERNANCE ONLY: `authority` must be the governance module account, so this
|
|
13515
|
+
* message is submitted inside a gov proposal, not signed by a user. It is what
|
|
13516
|
+
* makes enabling/disabling the SVM lane a proposal rather than a binary
|
|
13517
|
+
* release. `params` is replaced in full — send every field, not just the ones
|
|
13518
|
+
* you mean to change. `rentExemptionMulti` is a `LegacyDec` string (e.g.
|
|
13519
|
+
* `"2.000000000000000000"`).
|
|
13520
|
+
*/
|
|
13521
|
+
updateParams: composer2(
|
|
13522
|
+
"/qorechain.svm.v1.MsgUpdateParams",
|
|
13523
|
+
MsgUpdateParams
|
|
12954
13524
|
)
|
|
12955
13525
|
};
|
|
12956
13526
|
var lightnode = {
|
|
@@ -26289,6 +26859,30 @@ function extractMessageIds(result) {
|
|
|
26289
26859
|
}
|
|
26290
26860
|
return ids;
|
|
26291
26861
|
}
|
|
26862
|
+
var CROSSVM_CALL_RESPONSE_TYPE_URL = "/qorechain.crossvm.v1.MsgCrossVMCallResponse";
|
|
26863
|
+
function unknownOutcome() {
|
|
26864
|
+
return { executed: false, data: new Uint8Array(0), gasUsed: 0n };
|
|
26865
|
+
}
|
|
26866
|
+
function decodeCallOutcomes(result) {
|
|
26867
|
+
const responses = result.msgResponses;
|
|
26868
|
+
if (!Array.isArray(responses)) return [];
|
|
26869
|
+
const out = [];
|
|
26870
|
+
for (const r of responses) {
|
|
26871
|
+
if (r?.typeUrl !== CROSSVM_CALL_RESPONSE_TYPE_URL) continue;
|
|
26872
|
+
try {
|
|
26873
|
+
const decoded = MsgCrossVMCallResponse.decode(r.value);
|
|
26874
|
+
out.push({
|
|
26875
|
+
executed: decoded.executed,
|
|
26876
|
+
data: decoded.data,
|
|
26877
|
+
// uint64 is generated as a decimal string; surface it as a bigint.
|
|
26878
|
+
gasUsed: BigInt(decoded.gasUsed ?? 0)
|
|
26879
|
+
});
|
|
26880
|
+
} catch {
|
|
26881
|
+
out.push(unknownOutcome());
|
|
26882
|
+
}
|
|
26883
|
+
}
|
|
26884
|
+
return out;
|
|
26885
|
+
}
|
|
26292
26886
|
function createCrossVMClient(tx, opts = {}) {
|
|
26293
26887
|
const sender = tx.senderAddress;
|
|
26294
26888
|
const query = opts.query;
|
|
@@ -26299,7 +26893,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26299
26893
|
targetVm: o.targetVm,
|
|
26300
26894
|
targetContract: o.targetContract,
|
|
26301
26895
|
payload,
|
|
26302
|
-
funds: o.funds ?? []
|
|
26896
|
+
funds: o.funds ?? [],
|
|
26897
|
+
async: o.async ?? false
|
|
26303
26898
|
});
|
|
26304
26899
|
const buildCallSync = (o, payload) => buildFrom(o, payload);
|
|
26305
26900
|
const buildCall = (o) => {
|
|
@@ -26324,7 +26919,8 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26324
26919
|
{ autoFee: o.autoFee }
|
|
26325
26920
|
);
|
|
26326
26921
|
const [messageId = ""] = extractMessageIds(result);
|
|
26327
|
-
|
|
26922
|
+
const [outcome = unknownOutcome()] = decodeCallOutcomes(result);
|
|
26923
|
+
return { messageId, ...outcome, result };
|
|
26328
26924
|
};
|
|
26329
26925
|
const callAtomic = async (calls, w = {}) => {
|
|
26330
26926
|
if (calls.length === 0) {
|
|
@@ -26339,7 +26935,11 @@ function createCrossVMClient(tx, opts = {}) {
|
|
|
26339
26935
|
w.memo ?? "",
|
|
26340
26936
|
{ autoFee: w.autoFee }
|
|
26341
26937
|
);
|
|
26342
|
-
return {
|
|
26938
|
+
return {
|
|
26939
|
+
messageIds: extractMessageIds(result),
|
|
26940
|
+
outcomes: decodeCallOutcomes(result),
|
|
26941
|
+
result
|
|
26942
|
+
};
|
|
26343
26943
|
};
|
|
26344
26944
|
const getMessage = (id) => {
|
|
26345
26945
|
requireGetMessageSource(query, qor);
|
|
@@ -26443,8 +27043,8 @@ async function migrateToHybrid(tx, opts) {
|
|
|
26443
27043
|
}
|
|
26444
27044
|
|
|
26445
27045
|
// src/index.ts
|
|
26446
|
-
var VERSION = "0.
|
|
27046
|
+
var VERSION = "0.8.0";
|
|
26447
27047
|
|
|
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,
|
|
27048
|
+
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, SIGN_BYTES_V2_UPGRADES, 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, fetchSignBytesV2AppliedHeightAny, 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
27049
|
//# sourceMappingURL=index.js.map
|
|
26450
27050
|
//# sourceMappingURL=index.js.map
|