@qorechain/sdk 0.4.0 → 0.5.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/LICENSE +201 -0
- package/dist/index.cjs +254 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +359 -2
- package/dist/index.d.ts +359 -2
- package/dist/index.js +218 -2
- package/dist/index.js.map +1 -1
- package/package.json +26 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work, excluding
|
|
103
|
+
those notices that do not pertain to any part of the Derivative
|
|
104
|
+
Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one of
|
|
111
|
+
the following places: within a NOTICE text file distributed as
|
|
112
|
+
part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 QoreChain
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.cjs
CHANGED
|
@@ -18,6 +18,7 @@ var slip10_js = require('micro-key-producer/slip10.js');
|
|
|
18
18
|
var secp256k1 = require('@noble/curves/secp256k1');
|
|
19
19
|
var mlDsa_js = require('@noble/post-quantum/ml-dsa.js');
|
|
20
20
|
var utils = require('@noble/hashes/utils');
|
|
21
|
+
var evm = require('@qorechain/evm');
|
|
21
22
|
var tendermintRpc = require('@cosmjs/tendermint-rpc');
|
|
22
23
|
var any = require('cosmjs-types/google/protobuf/any');
|
|
23
24
|
var tx$1 = require('cosmjs-types/cosmos/tx/v1beta1/tx');
|
|
@@ -19599,9 +19600,252 @@ function createRollupClient(tx, opts = {}) {
|
|
|
19599
19600
|
};
|
|
19600
19601
|
}
|
|
19601
19602
|
|
|
19603
|
+
// src/helpers/crossvm.ts
|
|
19604
|
+
var VM_TYPES = ["evm", "cosmwasm", "svm"];
|
|
19605
|
+
var HEX_RE = /^0x[0-9a-fA-F]*$/;
|
|
19606
|
+
function rawToBytes(data) {
|
|
19607
|
+
if (typeof data !== "string") return data;
|
|
19608
|
+
if (!HEX_RE.test(data)) {
|
|
19609
|
+
throw new Error(
|
|
19610
|
+
`crossvm: invalid hex payload (expected 0x-prefixed hex, got "${data.slice(0, 12)}...")`
|
|
19611
|
+
);
|
|
19612
|
+
}
|
|
19613
|
+
const hex = data.slice(2);
|
|
19614
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
19615
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
19616
|
+
bytes[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
19617
|
+
}
|
|
19618
|
+
return bytes;
|
|
19619
|
+
}
|
|
19620
|
+
function cosmwasmToBytes(msg2) {
|
|
19621
|
+
return new TextEncoder().encode(JSON.stringify(msg2));
|
|
19622
|
+
}
|
|
19623
|
+
async function encodePayload(input) {
|
|
19624
|
+
if ("payload" in input) {
|
|
19625
|
+
return rawToBytes(input.payload);
|
|
19626
|
+
}
|
|
19627
|
+
if ("cosmwasm" in input) {
|
|
19628
|
+
return cosmwasmToBytes(input.cosmwasm);
|
|
19629
|
+
}
|
|
19630
|
+
if ("svm" in input) {
|
|
19631
|
+
return rawToBytes(input.svm.data);
|
|
19632
|
+
}
|
|
19633
|
+
const { encodeFunctionData } = await import('viem');
|
|
19634
|
+
const data = encodeFunctionData({
|
|
19635
|
+
// viem's Abi typing is structurally compatible; cast at the boundary.
|
|
19636
|
+
abi: input.evm.abi,
|
|
19637
|
+
functionName: input.evm.functionName,
|
|
19638
|
+
args: input.evm.args ?? []
|
|
19639
|
+
});
|
|
19640
|
+
return rawToBytes(data);
|
|
19641
|
+
}
|
|
19642
|
+
function requireGetMessageSource(query, qor) {
|
|
19643
|
+
if (!query && !qor) {
|
|
19644
|
+
throw new Error(
|
|
19645
|
+
"crossvm getMessage requires a query client or a qor client \u2014 pass { query } or { qor } to createCrossVMClient"
|
|
19646
|
+
);
|
|
19647
|
+
}
|
|
19648
|
+
}
|
|
19649
|
+
function extractMessageIds(result) {
|
|
19650
|
+
const events = result.events;
|
|
19651
|
+
const ids = [];
|
|
19652
|
+
if (Array.isArray(events)) {
|
|
19653
|
+
for (const ev of events) {
|
|
19654
|
+
const attrs = ev.attributes;
|
|
19655
|
+
if (!Array.isArray(attrs)) continue;
|
|
19656
|
+
for (const a of attrs) {
|
|
19657
|
+
const key = String(a.key ?? "");
|
|
19658
|
+
if (key === "message_id" || key === "messageId") {
|
|
19659
|
+
ids.push(String(a.value ?? ""));
|
|
19660
|
+
}
|
|
19661
|
+
}
|
|
19662
|
+
}
|
|
19663
|
+
}
|
|
19664
|
+
return ids;
|
|
19665
|
+
}
|
|
19666
|
+
function createCrossVMClient(tx, opts = {}) {
|
|
19667
|
+
const sender = tx.senderAddress;
|
|
19668
|
+
const query = opts.query;
|
|
19669
|
+
const qor = opts.qor;
|
|
19670
|
+
const buildFrom = (o, payload) => crossvm.crossVmCall({
|
|
19671
|
+
sender,
|
|
19672
|
+
sourceVm: o.sourceVm ?? "evm",
|
|
19673
|
+
targetVm: o.targetVm,
|
|
19674
|
+
targetContract: o.targetContract,
|
|
19675
|
+
payload,
|
|
19676
|
+
funds: o.funds ?? []
|
|
19677
|
+
});
|
|
19678
|
+
const buildCallSync = (o, payload) => buildFrom(o, payload);
|
|
19679
|
+
const buildCall = (o) => {
|
|
19680
|
+
if ("evm" in o) {
|
|
19681
|
+
throw new Error(
|
|
19682
|
+
"crossvm buildCall: EVM payloads are ABI-encoded asynchronously (viem). Use `call`/`callAtomic`, or pre-encode and pass `{ payload }`."
|
|
19683
|
+
);
|
|
19684
|
+
}
|
|
19685
|
+
let payload;
|
|
19686
|
+
if ("payload" in o) payload = rawToBytes(o.payload);
|
|
19687
|
+
else if ("cosmwasm" in o) payload = cosmwasmToBytes(o.cosmwasm);
|
|
19688
|
+
else payload = rawToBytes(o.svm.data);
|
|
19689
|
+
return buildCallSync(o, payload);
|
|
19690
|
+
};
|
|
19691
|
+
const call = async (o) => {
|
|
19692
|
+
const payload = await encodePayload(o);
|
|
19693
|
+
const message = buildFrom(o, payload);
|
|
19694
|
+
const result = await tx.signAndBroadcast(
|
|
19695
|
+
[message],
|
|
19696
|
+
o.fee ?? "auto",
|
|
19697
|
+
o.memo ?? "",
|
|
19698
|
+
{ autoFee: o.autoFee }
|
|
19699
|
+
);
|
|
19700
|
+
const [messageId = ""] = extractMessageIds(result);
|
|
19701
|
+
return { messageId, result };
|
|
19702
|
+
};
|
|
19703
|
+
const callAtomic = async (calls, w = {}) => {
|
|
19704
|
+
if (calls.length === 0) {
|
|
19705
|
+
throw new Error("crossvm callAtomic: provide at least one call");
|
|
19706
|
+
}
|
|
19707
|
+
const messages = await Promise.all(
|
|
19708
|
+
calls.map(async (o) => buildFrom(o, await encodePayload(o)))
|
|
19709
|
+
);
|
|
19710
|
+
const result = await tx.signAndBroadcast(
|
|
19711
|
+
messages,
|
|
19712
|
+
w.fee ?? "auto",
|
|
19713
|
+
w.memo ?? "",
|
|
19714
|
+
{ autoFee: w.autoFee }
|
|
19715
|
+
);
|
|
19716
|
+
return { messageIds: extractMessageIds(result), result };
|
|
19717
|
+
};
|
|
19718
|
+
const getMessage = (id) => {
|
|
19719
|
+
requireGetMessageSource(query, qor);
|
|
19720
|
+
if (query) return query.message({ id });
|
|
19721
|
+
return qor.getCrossVmMessage(id);
|
|
19722
|
+
};
|
|
19723
|
+
return { call, buildCall, callAtomic, getMessage };
|
|
19724
|
+
}
|
|
19725
|
+
|
|
19726
|
+
// src/helpers/pqc.ts
|
|
19727
|
+
var PQC_KEY_STATUS_PRECOMPILE_ADDRESS = "0x0000000000000000000000000000000000000A02";
|
|
19728
|
+
function resolveQor(source) {
|
|
19729
|
+
if ("qor" in source && source.qor) return source.qor;
|
|
19730
|
+
return source;
|
|
19731
|
+
}
|
|
19732
|
+
function asBool(v) {
|
|
19733
|
+
if (typeof v === "boolean") return v;
|
|
19734
|
+
if (typeof v === "number") return v !== 0;
|
|
19735
|
+
if (typeof v === "string") return v === "true" || v === "1";
|
|
19736
|
+
return false;
|
|
19737
|
+
}
|
|
19738
|
+
function asNumber(v) {
|
|
19739
|
+
if (typeof v === "number") return v;
|
|
19740
|
+
if (typeof v === "string" && v.trim() !== "" && !Number.isNaN(Number(v))) {
|
|
19741
|
+
return Number(v);
|
|
19742
|
+
}
|
|
19743
|
+
return void 0;
|
|
19744
|
+
}
|
|
19745
|
+
async function getPqcStatus(source, address) {
|
|
19746
|
+
const qor = resolveQor(source);
|
|
19747
|
+
const raw = await qor.getPqcKeyStatus(address);
|
|
19748
|
+
if (raw == null || typeof raw !== "object") {
|
|
19749
|
+
return { registered: false };
|
|
19750
|
+
}
|
|
19751
|
+
const registered = asBool(
|
|
19752
|
+
raw.registered ?? raw.isRegistered ?? raw.is_registered
|
|
19753
|
+
);
|
|
19754
|
+
const algorithmId = asNumber(raw.algorithmId ?? raw.algorithm_id);
|
|
19755
|
+
const pubkeyRaw = raw.pubkey ?? raw.publicKey ?? raw.public_key;
|
|
19756
|
+
const pubkey = typeof pubkeyRaw === "string" || pubkeyRaw instanceof Uint8Array ? pubkeyRaw : void 0;
|
|
19757
|
+
const status = { registered };
|
|
19758
|
+
if (algorithmId !== void 0) status.algorithmId = algorithmId;
|
|
19759
|
+
if (pubkey !== void 0) status.pubkey = pubkey;
|
|
19760
|
+
return status;
|
|
19761
|
+
}
|
|
19762
|
+
async function isPqcRegistered(source, address) {
|
|
19763
|
+
const status = await getPqcStatus(source, address);
|
|
19764
|
+
return status.registered;
|
|
19765
|
+
}
|
|
19766
|
+
function buildRegisterPqcKeyMsg(sender, opts) {
|
|
19767
|
+
return pqc.registerPqcKey({
|
|
19768
|
+
sender,
|
|
19769
|
+
dilithiumPubkey: opts.pqcKeypair.publicKey,
|
|
19770
|
+
ecdsaPubkey: opts.ecdsaPubkey ?? new Uint8Array(0),
|
|
19771
|
+
keyType: opts.keyType ?? "hybrid"
|
|
19772
|
+
});
|
|
19773
|
+
}
|
|
19774
|
+
async function ensurePqcRegistered(tx, opts) {
|
|
19775
|
+
const sender = tx.senderAddress;
|
|
19776
|
+
const status = opts.status ?? (opts.statusSource ? await getPqcStatus(opts.statusSource, sender) : void 0);
|
|
19777
|
+
if (status?.registered) {
|
|
19778
|
+
return { alreadyRegistered: true };
|
|
19779
|
+
}
|
|
19780
|
+
const message = buildRegisterPqcKeyMsg(sender, opts);
|
|
19781
|
+
const result = await tx.signAndBroadcast(
|
|
19782
|
+
[message],
|
|
19783
|
+
opts.fee ?? "auto",
|
|
19784
|
+
opts.memo ?? "",
|
|
19785
|
+
{ autoFee: opts.autoFee }
|
|
19786
|
+
);
|
|
19787
|
+
return {
|
|
19788
|
+
alreadyRegistered: false,
|
|
19789
|
+
txHash: result.transactionHash,
|
|
19790
|
+
result
|
|
19791
|
+
};
|
|
19792
|
+
}
|
|
19793
|
+
async function migratePqcKey(tx, opts) {
|
|
19794
|
+
const message = pqc.migratePqcKey({
|
|
19795
|
+
sender: tx.senderAddress,
|
|
19796
|
+
oldPublicKey: opts.oldPublicKey,
|
|
19797
|
+
newPublicKey: opts.newPublicKey,
|
|
19798
|
+
newAlgorithmId: opts.newAlgorithmId ?? AlgorithmDilithium5,
|
|
19799
|
+
oldSignature: opts.oldSignature,
|
|
19800
|
+
newSignature: opts.newSignature
|
|
19801
|
+
});
|
|
19802
|
+
return tx.signAndBroadcast([message], opts.fee ?? "auto", opts.memo ?? "", {
|
|
19803
|
+
autoFee: opts.autoFee
|
|
19804
|
+
});
|
|
19805
|
+
}
|
|
19806
|
+
async function migrateToHybrid(tx, opts) {
|
|
19807
|
+
const ensured = await ensurePqcRegistered(tx, opts);
|
|
19808
|
+
const pqcKeypair = opts.pqcKeypair;
|
|
19809
|
+
return {
|
|
19810
|
+
alreadyRegistered: ensured.alreadyRegistered,
|
|
19811
|
+
registrationTxHash: ensured.txHash,
|
|
19812
|
+
pqcKeypair,
|
|
19813
|
+
buildHybridTx: (o) => buildHybridTx({ ...o, pqcKeypair }),
|
|
19814
|
+
signAndBroadcastHybrid: (o) => signAndBroadcastHybrid({ ...o, pqcKeypair })
|
|
19815
|
+
};
|
|
19816
|
+
}
|
|
19817
|
+
|
|
19602
19818
|
// src/index.ts
|
|
19603
|
-
var VERSION = "0.
|
|
19819
|
+
var VERSION = "0.5.0";
|
|
19604
19820
|
|
|
19821
|
+
Object.defineProperty(exports, "AI_ANOMALY_CHECK_ADDRESS", {
|
|
19822
|
+
enumerable: true,
|
|
19823
|
+
get: function () { return evm.AI_ANOMALY_CHECK_ADDRESS; }
|
|
19824
|
+
});
|
|
19825
|
+
Object.defineProperty(exports, "AI_RISK_SCORE_ADDRESS", {
|
|
19826
|
+
enumerable: true,
|
|
19827
|
+
get: function () { return evm.AI_RISK_SCORE_ADDRESS; }
|
|
19828
|
+
});
|
|
19829
|
+
Object.defineProperty(exports, "RISK_LEVEL_UNSAFE_THRESHOLD", {
|
|
19830
|
+
enumerable: true,
|
|
19831
|
+
get: function () { return evm.RISK_LEVEL_UNSAFE_THRESHOLD; }
|
|
19832
|
+
});
|
|
19833
|
+
Object.defineProperty(exports, "ai", {
|
|
19834
|
+
enumerable: true,
|
|
19835
|
+
get: function () { return evm.ai; }
|
|
19836
|
+
});
|
|
19837
|
+
Object.defineProperty(exports, "aiAnomalyCheck", {
|
|
19838
|
+
enumerable: true,
|
|
19839
|
+
get: function () { return evm.aiAnomalyCheck; }
|
|
19840
|
+
});
|
|
19841
|
+
Object.defineProperty(exports, "aiRiskScore", {
|
|
19842
|
+
enumerable: true,
|
|
19843
|
+
get: function () { return evm.aiRiskScore; }
|
|
19844
|
+
});
|
|
19845
|
+
Object.defineProperty(exports, "simulateWithRiskScore", {
|
|
19846
|
+
enumerable: true,
|
|
19847
|
+
get: function () { return evm.simulateWithRiskScore; }
|
|
19848
|
+
});
|
|
19605
19849
|
exports.AlgorithmDilithium5 = AlgorithmDilithium5;
|
|
19606
19850
|
exports.AlgorithmMLKEM1024 = AlgorithmMLKEM1024;
|
|
19607
19851
|
exports.AlgorithmUnspecified = AlgorithmUnspecified;
|
|
@@ -19618,6 +19862,7 @@ exports.ML_DSA_87_SEED_LENGTH = ML_DSA_87_SEED_LENGTH;
|
|
|
19618
19862
|
exports.ML_DSA_87_SIGNATURE_LENGTH = ML_DSA_87_SIGNATURE_LENGTH;
|
|
19619
19863
|
exports.MSG_SEND_TYPE_URL = MSG_SEND_TYPE_URL;
|
|
19620
19864
|
exports.NETWORKS = NETWORKS;
|
|
19865
|
+
exports.PQC_KEY_STATUS_PRECOMPILE_ADDRESS = PQC_KEY_STATUS_PRECOMPILE_ADDRESS;
|
|
19621
19866
|
exports.PqcSigner = PqcSigner;
|
|
19622
19867
|
exports.QorClient = QorClient;
|
|
19623
19868
|
exports.QoreHttpError = QoreHttpError;
|
|
@@ -19626,6 +19871,7 @@ exports.RestClient = RestClient;
|
|
|
19626
19871
|
exports.STATIC_FALLBACK = STATIC_FALLBACK;
|
|
19627
19872
|
exports.TxClient = TxClient;
|
|
19628
19873
|
exports.VERSION = VERSION;
|
|
19874
|
+
exports.VM_TYPES = VM_TYPES;
|
|
19629
19875
|
exports.abstractaccount = abstractaccount;
|
|
19630
19876
|
exports.algorithmName = algorithmName;
|
|
19631
19877
|
exports.amm = amm;
|
|
@@ -19639,6 +19885,7 @@ exports.buildAminoTypes = buildAminoTypes;
|
|
|
19639
19885
|
exports.buildEventsQuery = buildEventsQuery;
|
|
19640
19886
|
exports.buildHybridSignatureExtension = buildHybridSignatureExtension;
|
|
19641
19887
|
exports.buildHybridTx = buildHybridTx;
|
|
19888
|
+
exports.buildRegisterPqcKeyMsg = buildRegisterPqcKeyMsg;
|
|
19642
19889
|
exports.buildTxQuery = buildTxQuery;
|
|
19643
19890
|
exports.buildUrl = buildUrl;
|
|
19644
19891
|
exports.bytesToBech32 = bytesToBech32;
|
|
@@ -19648,6 +19895,7 @@ exports.connectCosmWasmSigner = connectCosmWasmSigner;
|
|
|
19648
19895
|
exports.connectQueryClients = connectQueryClients;
|
|
19649
19896
|
exports.createClient = createClient;
|
|
19650
19897
|
exports.createCosmWasmClient = createCosmWasmClient;
|
|
19898
|
+
exports.createCrossVMClient = createCrossVMClient;
|
|
19651
19899
|
exports.createMultilayerClient = createMultilayerClient;
|
|
19652
19900
|
exports.createQueryClients = createQueryClients;
|
|
19653
19901
|
exports.createRollupClient = createRollupClient;
|
|
@@ -19660,6 +19908,7 @@ exports.deriveSvmAccount = deriveSvmAccount;
|
|
|
19660
19908
|
exports.directSignerFromPrivateKey = directSignerFromPrivateKey;
|
|
19661
19909
|
exports.distribution = distribution;
|
|
19662
19910
|
exports.encodeHybridExtension = encodeHybridExtension;
|
|
19911
|
+
exports.ensurePqcRegistered = ensurePqcRegistered;
|
|
19663
19912
|
exports.estimateFee = estimateFee;
|
|
19664
19913
|
exports.evmToQor = evmToQor;
|
|
19665
19914
|
exports.execute = execute;
|
|
@@ -19683,6 +19932,7 @@ exports.getJson = getJson;
|
|
|
19683
19932
|
exports.getLatestBlock = getLatestBlock;
|
|
19684
19933
|
exports.getNetwork = getNetwork;
|
|
19685
19934
|
exports.getPendingCrossVmMessages = getPendingCrossVmMessages;
|
|
19935
|
+
exports.getPqcStatus = getPqcStatus;
|
|
19686
19936
|
exports.getTx = getTx;
|
|
19687
19937
|
exports.gov = gov;
|
|
19688
19938
|
exports.hexToBech32 = hexToBech32;
|
|
@@ -19690,6 +19940,7 @@ exports.ibc = ibc;
|
|
|
19690
19940
|
exports.instantiate = instantiate;
|
|
19691
19941
|
exports.instantiate2 = instantiate2;
|
|
19692
19942
|
exports.isChecksumAddress = isChecksumAddress;
|
|
19943
|
+
exports.isPqcRegistered = isPqcRegistered;
|
|
19693
19944
|
exports.isSignatureAlgorithm = isSignatureAlgorithm;
|
|
19694
19945
|
exports.isTxFailure = isTxFailure;
|
|
19695
19946
|
exports.isValidBech32 = isValidBech32;
|
|
@@ -19702,6 +19953,8 @@ exports.license = license;
|
|
|
19702
19953
|
exports.lightnode = lightnode;
|
|
19703
19954
|
exports.listNetworks = listNetworks;
|
|
19704
19955
|
exports.migrate = migrate;
|
|
19956
|
+
exports.migratePqcKey = migratePqcKey;
|
|
19957
|
+
exports.migrateToHybrid = migrateToHybrid;
|
|
19705
19958
|
exports.msg = msg;
|
|
19706
19959
|
exports.multilayer = multilayer;
|
|
19707
19960
|
exports.parseUnits = parseUnits;
|