@alephium/web3 1.12.0-danube.1 → 2.0.0-beta.2

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.
@@ -5,7 +5,8 @@ export declare enum AddressType {
5
5
  P2MPKH = 1,
6
6
  P2SH = 2,
7
7
  P2C = 3,
8
- P2PK = 4
8
+ P2PK = 4,
9
+ P2HMPK = 5
9
10
  }
10
11
  export declare function validateAddress(address: string): void;
11
12
  export declare function isValidAddress(address: string): boolean;
@@ -14,7 +15,7 @@ export declare function isAssetAddress(address: string): boolean;
14
15
  export declare function isGrouplessAddress(address: string): boolean;
15
16
  export declare function isGrouplessAddressWithoutGroupIndex(address: string): boolean;
16
17
  export declare function isGrouplessAddressWithGroupIndex(address: string): boolean;
17
- export declare function defaultGroupOfGrouplessAddress(pubKey: Uint8Array): number;
18
+ export declare function defaultGroupOfGrouplessAddress(bytes: Uint8Array): number;
18
19
  export declare function isContractAddress(address: string): boolean;
19
20
  export declare function groupOfAddress(address: string): number;
20
21
  export declare function contractIdFromAddress(address: string): Uint8Array;
@@ -55,6 +55,7 @@ const codec_1 = require("../codec");
55
55
  const djb2_1 = __importDefault(require("../utils/djb2"));
56
56
  const error_1 = require("../error");
57
57
  const codec_2 = require("../codec/codec");
58
+ const public_key_like_codec_1 = require("../codec/public-key-like-codec");
58
59
  const secp256k1 = new elliptic_1.ec('secp256k1');
59
60
  const secp256r1 = new elliptic_1.ec('p256');
60
61
  const ed25519 = new elliptic_1.eddsa('ed25519');
@@ -66,6 +67,7 @@ var AddressType;
66
67
  AddressType[AddressType["P2SH"] = 2] = "P2SH";
67
68
  AddressType[AddressType["P2C"] = 3] = "P2C";
68
69
  AddressType[AddressType["P2PK"] = 4] = "P2PK";
70
+ AddressType[AddressType["P2HMPK"] = 5] = "P2HMPK";
69
71
  })(AddressType = exports.AddressType || (exports.AddressType = {}));
70
72
  function validateAddress(address) {
71
73
  decodeAndValidateAddress(address);
@@ -110,36 +112,23 @@ function decodeAndValidateAddress(address) {
110
112
  if (decoded.length === 33)
111
113
  return decoded;
112
114
  }
113
- else if (isGrouplessAddressWithGroup(decoded)) {
114
- // [type, keyType, ...publicKey, ...checkSum, ...groupByte]
115
- const publicKeyToIndex = decoded.length - 1 - 4;
116
- const publicKeyLikeBytes = decoded.slice(1, publicKeyToIndex);
117
- const checksum = (0, utils_1.binToHex)(decoded.slice(publicKeyToIndex, publicKeyToIndex + 4));
118
- const expectedChecksum = (0, utils_1.binToHex)(codec_1.intAs4BytesCodec.encode((0, djb2_1.default)(publicKeyLikeBytes)));
119
- if (checksum !== expectedChecksum) {
120
- throw new Error(`Invalid checksum for P2PK address: ${address}`);
121
- }
122
- const group = codec_2.byteCodec.decode(decoded.slice(decoded.length - 1, decoded.length));
123
- validateGroupIndex(group);
115
+ else if (addressType === AddressType.P2PK) {
116
+ const p2pk = lockup_script_codec_1.lockupScriptCodec.decode(decoded).value;
117
+ validateGroupIndex(p2pk.group);
118
+ return decoded;
119
+ }
120
+ else if (addressType === AddressType.P2HMPK) {
121
+ const p2hmpk = lockup_script_codec_1.lockupScriptCodec.decode(decoded).value;
122
+ validateGroupIndex(p2hmpk.group);
124
123
  return decoded;
125
124
  }
126
125
  throw new Error(`Invalid address: ${address}`);
127
126
  }
128
- function isGrouplessAddressWithoutGroup(decoded) {
129
- // An ED25519 public key is 32 bytes; other public keys are 33 bytes.
130
- // Format: AddressType(1 byte) + KeyType(1 byte) + PublicKey(32/33 bytes) + Checksum(4 bytes)
131
- return decoded[0] === AddressType.P2PK && (decoded.length === 38 || decoded.length === 39);
132
- }
133
- function isGrouplessAddressWithGroup(decoded) {
134
- // An ED25519 public key is 32 bytes; other public keys are 33 bytes.
135
- // Format: AddressType(1 byte) + KeyType(1 byte) + PublicKey(32/33 bytes) + Checksum(4 bytes) + GroupIndex(1 byte)
136
- return decoded[0] === AddressType.P2PK && (decoded.length === 39 || decoded.length === 40);
137
- }
138
127
  function addressToBytes(address) {
139
128
  if (hasExplicitGroupIndex(address)) {
140
129
  const groupIndex = parseGroupIndex(address[address.length - 1]);
141
130
  const decoded = (0, bs58_1.base58ToBytes)(address.slice(0, address.length - 2));
142
- if (isGrouplessAddressWithoutGroup(decoded)) {
131
+ if (decoded.length > 0 && isGrouplessType(decoded[0])) {
143
132
  const groupByte = codec_2.byteCodec.encode(groupIndex);
144
133
  return new Uint8Array([...decoded, ...groupByte]);
145
134
  }
@@ -147,7 +136,7 @@ function addressToBytes(address) {
147
136
  }
148
137
  else {
149
138
  const decoded = (0, bs58_1.base58ToBytes)(address);
150
- if (isGrouplessAddressWithoutGroup(decoded)) {
139
+ if (decoded.length > 0 && isGrouplessType(decoded[0])) {
151
140
  const group = defaultGroupOfGrouplessAddress(decoded.slice(2, decoded.length - 4));
152
141
  const groupByte = codec_2.byteCodec.encode(group);
153
142
  return new Uint8Array([...decoded, ...groupByte]);
@@ -161,12 +150,15 @@ function isAssetAddress(address) {
161
150
  return (addressType === AddressType.P2PKH ||
162
151
  addressType === AddressType.P2MPKH ||
163
152
  addressType === AddressType.P2SH ||
164
- addressType === AddressType.P2PK);
153
+ addressType === AddressType.P2PK ||
154
+ addressType === AddressType.P2HMPK);
165
155
  }
166
156
  exports.isAssetAddress = isAssetAddress;
157
+ function isGrouplessType(type) {
158
+ return type === AddressType.P2PK || type === AddressType.P2HMPK;
159
+ }
167
160
  function isGrouplessAddress(address) {
168
- const addressType = decodeAndValidateAddress(address)[0];
169
- return addressType === AddressType.P2PK;
161
+ return isGrouplessType(decodeAndValidateAddress(address)[0]);
170
162
  }
171
163
  exports.isGrouplessAddress = isGrouplessAddress;
172
164
  function isGrouplessAddressWithoutGroupIndex(address) {
@@ -177,8 +169,8 @@ function isGrouplessAddressWithGroupIndex(address) {
177
169
  return hasExplicitGroupIndex(address) && isGrouplessAddress(address);
178
170
  }
179
171
  exports.isGrouplessAddressWithGroupIndex = isGrouplessAddressWithGroupIndex;
180
- function defaultGroupOfGrouplessAddress(pubKey) {
181
- return pubKey[pubKey.length - 1] & 0xff % constants_1.TOTAL_NUMBER_OF_GROUPS;
172
+ function defaultGroupOfGrouplessAddress(bytes) {
173
+ return (bytes[bytes.length - 1] & 0xff) % constants_1.TOTAL_NUMBER_OF_GROUPS;
182
174
  }
183
175
  exports.defaultGroupOfGrouplessAddress = defaultGroupOfGrouplessAddress;
184
176
  function isContractAddress(address) {
@@ -190,17 +182,17 @@ function groupOfAddress(address) {
190
182
  const decoded = decodeAndValidateAddress(address);
191
183
  const addressType = decoded[0];
192
184
  const addressBody = decoded.slice(1);
193
- if (addressType == AddressType.P2PKH) {
185
+ if (addressType === AddressType.P2PKH) {
194
186
  return groupOfP2pkhAddress(addressBody);
195
187
  }
196
- else if (addressType == AddressType.P2MPKH) {
188
+ else if (addressType === AddressType.P2MPKH) {
197
189
  return groupOfP2mpkhAddress(addressBody);
198
190
  }
199
- else if (addressType == AddressType.P2SH) {
191
+ else if (addressType === AddressType.P2SH) {
200
192
  return groupOfP2shAddress(addressBody);
201
193
  }
202
- else if (addressType == AddressType.P2PK) {
203
- return groupOfP2pkAddress(addressBody);
194
+ else if (isGrouplessType(addressType)) {
195
+ return groupOfGrouplessAddress(addressBody);
204
196
  }
205
197
  else {
206
198
  // Contract Address
@@ -217,8 +209,8 @@ function groupOfP2pkhAddress(address) {
217
209
  function groupOfP2mpkhAddress(address) {
218
210
  return groupFromBytes(address.slice(1, 33));
219
211
  }
220
- function groupOfP2pkAddress(address) {
221
- return codec_2.byteCodec.decode(address.slice(38, 39)) % constants_1.TOTAL_NUMBER_OF_GROUPS;
212
+ function groupOfGrouplessAddress(address) {
213
+ return address[address.length - 1] % constants_1.TOTAL_NUMBER_OF_GROUPS;
222
214
  }
223
215
  // Pay to script hash address
224
216
  function groupOfP2shAddress(address) {
@@ -266,10 +258,16 @@ function publicKeyFromPrivateKey(privateKey, _keyType) {
266
258
  }
267
259
  exports.publicKeyFromPrivateKey = publicKeyFromPrivateKey;
268
260
  function p2pkAddressFromPublicKey(publicKey, keyType) {
269
- const keyTypeByte = keyType === 'gl-secp256k1' ? 0x00 : keyType === 'gl-secp256r1' ? 0x01 : keyType === 'gl-ed25519' ? 0x02 : 0x03;
270
- const publicKeyBytes = new Uint8Array([keyTypeByte, ...(0, utils_1.hexToBinUnsafe)(publicKey)]);
271
- const checksum = codec_1.intAs4BytesCodec.encode((0, djb2_1.default)(publicKeyBytes));
272
- const bytes = new Uint8Array([AddressType.P2PK, ...publicKeyBytes, ...checksum]);
261
+ const rawBytes = (0, utils_1.hexToBinUnsafe)(publicKey);
262
+ const publicKeyLike = keyType === 'gl-secp256k1'
263
+ ? { kind: 'SecP256K1', value: rawBytes }
264
+ : keyType === 'gl-secp256r1'
265
+ ? { kind: 'SecP256R1', value: rawBytes }
266
+ : keyType === 'gl-ed25519'
267
+ ? { kind: 'ED25519', value: rawBytes }
268
+ : { kind: 'WebAuthn', value: rawBytes };
269
+ const publicKeyBytes = public_key_like_codec_1.safePublicKeyLikeCodec.encode(publicKeyLike);
270
+ const bytes = new Uint8Array([AddressType.P2PK, ...publicKeyBytes]);
273
271
  return bs58_1.default.encode(bytes);
274
272
  }
275
273
  function addressFromPublicKey(publicKey, _keyType) {
@@ -340,7 +338,7 @@ function groupOfLockupScript(lockupScript) {
340
338
  else if (lockupScript.kind === 'P2SH') {
341
339
  return groupFromBytes(lockupScript.value);
342
340
  }
343
- else if (lockupScript.kind === 'P2PK') {
341
+ else if (lockupScript.kind === 'P2PK' || lockupScript.kind === 'P2HMPK') {
344
342
  return lockupScript.value.group % constants_1.TOTAL_NUMBER_OF_GROUPS;
345
343
  }
346
344
  else {
@@ -372,7 +370,7 @@ function addressWithoutExplicitGroupIndex(address) {
372
370
  }
373
371
  exports.addressWithoutExplicitGroupIndex = addressWithoutExplicitGroupIndex;
374
372
  function addressFromLockupScript(lockupScript) {
375
- if (lockupScript.kind === 'P2PK') {
373
+ if (lockupScript.kind === 'P2PK' || lockupScript.kind === 'P2HMPK') {
376
374
  const groupByte = lockup_script_codec_1.lockupScriptCodec.encode(lockupScript).slice(-1);
377
375
  const address = bs58_1.default.encode(lockup_script_codec_1.lockupScriptCodec.encode(lockupScript).slice(0, -1));
378
376
  return `${address}:${groupByte}`;
@@ -255,21 +255,51 @@ export interface BuildExecuteScriptTx {
255
255
  export type BuildExecuteScriptTxResult = BuildGrouplessExecuteScriptTxResult | BuildSimpleExecuteScriptTxResult;
256
256
  /** BuildGrouplessDeployContractTxResult */
257
257
  export interface BuildGrouplessDeployContractTxResult {
258
+ /** @format int32 */
259
+ fromGroup: number;
260
+ /** @format int32 */
261
+ toGroup: number;
262
+ unsignedTx: string;
263
+ /** @format gas */
264
+ gasAmount: number;
265
+ /** @format uint256 */
266
+ gasPrice: string;
267
+ /** @format 32-byte-hash */
268
+ txId: string;
269
+ /** @format address */
270
+ contractAddress: string;
258
271
  transferTxs: BuildSimpleTransferTxResult[];
259
- deployContractTx: BuildSimpleDeployContractTxResult;
260
- type: string;
261
272
  }
262
273
  /** BuildGrouplessExecuteScriptTxResult */
263
274
  export interface BuildGrouplessExecuteScriptTxResult {
275
+ /** @format int32 */
276
+ fromGroup: number;
277
+ /** @format int32 */
278
+ toGroup: number;
279
+ unsignedTx: string;
280
+ /** @format gas */
281
+ gasAmount: number;
282
+ /** @format uint256 */
283
+ gasPrice: string;
284
+ /** @format 32-byte-hash */
285
+ txId: string;
286
+ simulationResult: SimulationResult;
264
287
  transferTxs: BuildSimpleTransferTxResult[];
265
- executeScriptTx: BuildSimpleExecuteScriptTxResult;
266
- type: string;
267
288
  }
268
289
  /** BuildGrouplessTransferTxResult */
269
290
  export interface BuildGrouplessTransferTxResult {
291
+ unsignedTx: string;
292
+ /** @format gas */
293
+ gasAmount: number;
294
+ /** @format uint256 */
295
+ gasPrice: string;
296
+ /** @format 32-byte-hash */
297
+ txId: string;
298
+ /** @format int32 */
299
+ fromGroup: number;
300
+ /** @format int32 */
301
+ toGroup: number;
270
302
  transferTxs: BuildSimpleTransferTxResult[];
271
- transferTx: BuildSimpleTransferTxResult;
272
- type: string;
273
303
  }
274
304
  /** BuildInfo */
275
305
  export interface BuildInfo {
@@ -289,17 +319,24 @@ export interface BuildMultisig {
289
319
  /** @format address */
290
320
  fromAddress: string;
291
321
  fromPublicKeys: string[];
322
+ fromPublicKeyTypes?: string[];
323
+ fromPublicKeyIndexes?: number[];
292
324
  destinations: Destination[];
293
325
  /** @format gas */
294
326
  gas?: number;
295
327
  /** @format uint256 */
296
328
  gasPrice?: string;
329
+ /** @format group-index */
330
+ group?: number;
331
+ multiSigType?: MultiSigType;
297
332
  }
298
333
  /** BuildMultisigAddress */
299
334
  export interface BuildMultisigAddress {
300
335
  keys: string[];
336
+ keyTypes?: string[];
301
337
  /** @format int32 */
302
338
  mrequired: number;
339
+ multiSigType?: MultiSigType;
303
340
  }
304
341
  /** BuildMultisigAddressResult */
305
342
  export interface BuildMultisigAddressResult {
@@ -321,7 +358,6 @@ export interface BuildSimpleDeployContractTxResult {
321
358
  txId: string;
322
359
  /** @format address */
323
360
  contractAddress: string;
324
- type: string;
325
361
  }
326
362
  /** BuildSimpleExecuteScriptTxResult */
327
363
  export interface BuildSimpleExecuteScriptTxResult {
@@ -337,7 +373,6 @@ export interface BuildSimpleExecuteScriptTxResult {
337
373
  /** @format 32-byte-hash */
338
374
  txId: string;
339
375
  simulationResult: SimulationResult;
340
- type: string;
341
376
  }
342
377
  /** BuildSimpleTransferTxResult */
343
378
  export interface BuildSimpleTransferTxResult {
@@ -352,12 +387,13 @@ export interface BuildSimpleTransferTxResult {
352
387
  fromGroup: number;
353
388
  /** @format int32 */
354
389
  toGroup: number;
355
- type: string;
356
390
  }
357
391
  /** BuildSweepAddressTransactions */
358
392
  export interface BuildSweepAddressTransactions {
359
- /** @format public-key */
393
+ /** @format hex-string */
360
394
  fromPublicKey: string;
395
+ /** @format hex-string */
396
+ fromPublicKeyType?: string;
361
397
  /** @format address */
362
398
  toAddress: string;
363
399
  /** @format uint256 */
@@ -372,6 +408,8 @@ export interface BuildSweepAddressTransactions {
372
408
  targetBlockHash?: string;
373
409
  /** @format int32 */
374
410
  utxosLimit?: number;
411
+ /** @format group-index */
412
+ group?: number;
375
413
  }
376
414
  /** BuildSweepAddressTransactionsResult */
377
415
  export interface BuildSweepAddressTransactionsResult {
@@ -386,6 +424,8 @@ export interface BuildSweepMultisig {
386
424
  /** @format address */
387
425
  fromAddress: string;
388
426
  fromPublicKeys: string[];
427
+ fromPublicKeyTypes?: string[];
428
+ fromPublicKeyIndexes?: number[];
389
429
  /** @format address */
390
430
  toAddress: string;
391
431
  /** @format uint256 */
@@ -400,6 +440,9 @@ export interface BuildSweepMultisig {
400
440
  utxosLimit?: number;
401
441
  /** @format block-hash */
402
442
  targetBlockHash?: string;
443
+ /** @format group-index */
444
+ group?: number;
445
+ multiSigType?: MultiSigType;
403
446
  }
404
447
  /** BuildTransferTx */
405
448
  export interface BuildTransferTx {
@@ -551,6 +594,7 @@ export interface CompilerOptions {
551
594
  ignoreCheckExternalCallerWarnings?: boolean;
552
595
  ignoreUnusedFunctionReturnWarnings?: boolean;
553
596
  skipAbstractContractCheck?: boolean;
597
+ skipTests?: boolean;
554
598
  }
555
599
  /** Confirmed */
556
600
  export interface Confirmed {
@@ -805,6 +849,8 @@ export interface MinerAddressesInfo {
805
849
  }
806
850
  /** MisbehaviorAction */
807
851
  export type MisbehaviorAction = Ban | Unban;
852
+ /** MultiSigType */
853
+ export type MultiSigType = P2HMPK | P2MPKH;
808
854
  /** MultipleCallContract */
809
855
  export interface MultipleCallContract {
810
856
  calls: CallContract[];
@@ -843,6 +889,14 @@ export interface OutputRef {
843
889
  /** @format 32-byte-hash */
844
890
  key: string;
845
891
  }
892
+ /** P2HMPK */
893
+ export interface P2HMPK {
894
+ type: string;
895
+ }
896
+ /** P2MPKH */
897
+ export interface P2MPKH {
898
+ type: string;
899
+ }
846
900
  /** PeerAddress */
847
901
  export interface PeerAddress {
848
902
  /** @format inet-address */
@@ -1115,6 +1169,7 @@ export interface TestContract {
1115
1169
  args?: Val[];
1116
1170
  existingContracts?: ContractState[];
1117
1171
  inputAssets?: TestInputAsset[];
1172
+ /** @format uint256 */
1118
1173
  dustAmount?: string;
1119
1174
  }
1120
1175
  /** TestContractResult */
@@ -1376,7 +1431,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
1376
1431
  }
1377
1432
  /**
1378
1433
  * @title Alephium API
1379
- * @version 3.12.2
1434
+ * @version 3.15.1
1380
1435
  * @baseUrl ../
1381
1436
  */
1382
1437
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -2212,7 +2267,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2212
2267
  * @summary Build a multisig unsigned transaction
2213
2268
  * @request POST:/multisig/build
2214
2269
  */
2215
- postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<BuildSimpleTransferTxResult>;
2270
+ postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<BuildSimpleTransferTxResult | BuildGrouplessTransferTxResult>;
2216
2271
  /**
2217
2272
  * No description
2218
2273
  *
@@ -151,7 +151,7 @@ class HttpClient {
151
151
  exports.HttpClient = HttpClient;
152
152
  /**
153
153
  * @title Alephium API
154
- * @version 3.12.2
154
+ * @version 3.15.1
155
155
  * @baseUrl ../
156
156
  */
157
157
  class Api extends HttpClient {
@@ -0,0 +1,8 @@
1
+ import { Reader } from './reader';
2
+ import { Codec } from './codec';
3
+ export declare class Checksum<T> extends Codec<T> {
4
+ private rawCodec;
5
+ constructor(rawCodec: Codec<T>);
6
+ encode(value: T): Uint8Array;
7
+ _decode(input: Reader): T;
8
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /*
3
+ Copyright 2018 - 2022 The Alephium Authors
4
+ This file is part of the alephium project.
5
+
6
+ The library is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Lesser General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ The library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public License
17
+ along with the library. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.Checksum = void 0;
24
+ const utils_1 = require("../utils");
25
+ const djb2_1 = __importDefault(require("../utils/djb2"));
26
+ const int_as_4bytes_codec_1 = require("./int-as-4bytes-codec");
27
+ const codec_1 = require("./codec");
28
+ class Checksum extends codec_1.Codec {
29
+ constructor(rawCodec) {
30
+ super();
31
+ this.rawCodec = rawCodec;
32
+ }
33
+ encode(value) {
34
+ const rawEncoded = this.rawCodec.encode(value);
35
+ const checksum = int_as_4bytes_codec_1.intAs4BytesCodec.encode((0, djb2_1.default)(rawEncoded));
36
+ return (0, utils_1.concatBytes)([rawEncoded, checksum]);
37
+ }
38
+ _decode(input) {
39
+ const fromIndex = input.getIndex();
40
+ const rawDecoded = this.rawCodec._decode(input);
41
+ const toIndex = input.getIndex();
42
+ const checksum = int_as_4bytes_codec_1.intAs4BytesCodec._decode(input);
43
+ const expected = (0, djb2_1.default)(input.getBytes(fromIndex, toIndex));
44
+ if (expected != checksum) {
45
+ throw new Error(`Invalid checksum: expected ${expected}, but got ${checksum}`);
46
+ }
47
+ return rawDecoded;
48
+ }
49
+ }
50
+ exports.Checksum = Checksum;
@@ -444,6 +444,16 @@ export type Instr = {
444
444
  } | {
445
445
  name: 'GetSegregatedWebAuthnSignature';
446
446
  code: 0x8e;
447
+ } | {
448
+ name: 'DevInstr';
449
+ code: 0x8f;
450
+ instr: number;
451
+ } | {
452
+ name: 'I256RoundInfinityDiv';
453
+ code: 0x90;
454
+ } | {
455
+ name: 'U256RoundInfinityDiv';
456
+ code: 0x91;
447
457
  } | {
448
458
  name: 'LoadMutField';
449
459
  code: 0xa0;
@@ -629,6 +639,7 @@ export declare const JumpCode = 74;
629
639
  export declare const IfTrueCode = 75;
630
640
  export declare const IfFalseCode = 76;
631
641
  export declare const DEBUGCode = 126;
642
+ export declare const DevInstrCode = 143;
632
643
  export declare const LoadMutFieldCode = 160;
633
644
  export declare const StoreMutFieldCode = 161;
634
645
  export declare const LoadImmFieldCode = 206;
@@ -778,6 +789,9 @@ export declare const BoolToString: Instr;
778
789
  export declare const GroupOfAddress: Instr;
779
790
  export declare const VerifySignature: Instr;
780
791
  export declare const GetSegregatedWebAuthnSignature: Instr;
792
+ export declare const DevInstr: (instr: number) => Instr;
793
+ export declare const I256RoundInfinityDiv: Instr;
794
+ export declare const U256RoundInfinityDiv: Instr;
781
795
  export declare const LoadMutField: (index: number) => Instr;
782
796
  export declare const StoreMutField: (index: number) => Instr;
783
797
  export declare const ApproveAlph: Instr;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.I256Add = exports.BoolToByteVec = exports.BoolNeq = exports.BoolEq = exports.BoolOr = exports.BoolAnd = exports.BoolNot = exports.Pop = exports.StoreLocal = exports.LoadLocal = exports.AddressConst = exports.BytesConst = exports.U256Const = exports.I256Const = exports.U256Const5 = exports.U256Const4 = exports.U256Const3 = exports.U256Const2 = exports.U256Const1 = exports.U256Const0 = exports.I256ConstN1 = exports.I256Const5 = exports.I256Const4 = exports.I256Const3 = exports.I256Const2 = exports.I256Const1 = exports.I256Const0 = exports.ConstFalse = exports.ConstTrue = exports.Return = exports.CallExternal = exports.CallLocal = exports.CallExternalBySelectorCode = exports.MethodSelectorCode = exports.CreateMapEntryCode = exports.LoadImmFieldCode = exports.StoreMutFieldCode = exports.LoadMutFieldCode = exports.DEBUGCode = exports.IfFalseCode = exports.IfTrueCode = exports.JumpCode = exports.StoreLocalCode = exports.LoadLocalCode = exports.AddressConstCode = exports.BytesConstCode = exports.U256ConstCode = exports.I256ConstCode = exports.CallExternalCode = exports.CallLocalCode = void 0;
4
- exports.Sha3 = exports.Sha256 = exports.Keccak256 = exports.Blake2b = exports.Assert = exports.IfFalse = exports.IfTrue = exports.Jump = exports.IsContractAddress = exports.IsAssetAddress = exports.AddressToByteVec = exports.AddressNeq = exports.AddressEq = exports.ByteVecConcat = exports.ByteVecSize = exports.ByteVecNeq = exports.ByteVecEq = exports.U256ToByteVec = exports.U256ToI256 = exports.I256ToByteVec = exports.I256ToU256 = exports.NumericSHR = exports.NumericSHL = exports.NumericXor = exports.NumericBitOr = exports.NumericBitAnd = exports.U256ModMul = exports.U256ModSub = exports.U256ModAdd = exports.U256Ge = exports.U256Gt = exports.U256Le = exports.U256Lt = exports.U256Neq = exports.U256Eq = exports.U256Mod = exports.U256Div = exports.U256Mul = exports.U256Sub = exports.U256Add = exports.I256Ge = exports.I256Gt = exports.I256Le = exports.I256Lt = exports.I256Neq = exports.I256Eq = exports.I256Mod = exports.I256Div = exports.I256Mul = exports.I256Sub = void 0;
5
- exports.U256Exp = exports.I256Exp = exports.TxGasFee = exports.TxGasAmount = exports.TxGasPrice = exports.DEBUG = exports.BlockHash = exports.Swap = exports.AssertWithErrorCode = exports.Dup = exports.StoreLocalByIndex = exports.LoadLocalByIndex = exports.ContractIdToAddress = exports.Log9 = exports.Log8 = exports.Log7 = exports.Log6 = exports.EthEcRecover = exports.U256From32Byte = exports.U256From16Byte = exports.U256From8Byte = exports.U256From4Byte = exports.U256From2Byte = exports.U256From1Byte = exports.U256To32Byte = exports.U256To16Byte = exports.U256To8Byte = exports.U256To4Byte = exports.U256To2Byte = exports.U256To1Byte = exports.Zeros = exports.Encode = exports.ByteVecToAddress = exports.ByteVecSlice = exports.Log5 = exports.Log4 = exports.Log3 = exports.Log2 = exports.Log1 = exports.VerifyRelativeLocktime = exports.VerifyAbsoluteLocktime = exports.TxInputsSize = exports.TxInputAddressAt = exports.TxId = exports.BlockTarget = exports.BlockTimeStamp = exports.NetworkId = exports.VerifyED25519 = exports.VerifySecP256K1 = exports.VerifyTxSignature = void 0;
6
- exports.CreateContractAndTransferToken = exports.ContractExists = exports.StoreMutFieldByIndex = exports.LoadMutFieldByIndex = exports.CopyCreateSubContractWithToken = exports.CopyCreateSubContract = exports.CreateSubContractWithToken = exports.CreateSubContract = exports.LockApprovedAssets = exports.BurnToken = exports.CopyCreateContractWithToken = exports.MigrateWithFields = exports.MigrateSimple = exports.ContractCodeHash = exports.ContractInitialStateHash = exports.CallerCodeHash = exports.CallerInitialStateHash = exports.IsCalledFromTxScript = exports.CallerAddress = exports.CallerContractId = exports.SelfAddress = exports.SelfContractId = exports.DestroySelf = exports.CopyCreateContract = exports.CreateContractWithToken = exports.CreateContract = exports.TransferTokenToSelf = exports.TransferTokenFromSelf = exports.TransferToken = exports.TransferAlphToSelf = exports.TransferAlphFromSelf = exports.TransferAlph = exports.IsPaying = exports.TokenRemaining = exports.AlphRemaining = exports.ApproveToken = exports.ApproveAlph = exports.StoreMutField = exports.LoadMutField = exports.GetSegregatedWebAuthnSignature = exports.VerifySignature = exports.GroupOfAddress = exports.BoolToString = exports.I256ToString = exports.U256ToString = exports.AddModN = exports.MulModN = exports.GetSegregatedSignature = exports.VerifyBIP340Schnorr = exports.U256ModExp = void 0;
7
- exports.toI256 = exports.toU256 = exports.instrsCodec = exports.instrCodec = exports.InstrCodec = exports.ExternalCallerAddress = exports.ExternalCallerContractId = exports.CallExternalBySelector = exports.MethodSelector = exports.CreateMapEntry = exports.MinimalContractDeposit = exports.PayGasFee = exports.LoadImmFieldByIndex = exports.LoadImmField = exports.ALPHTokenId = exports.SubContractIdOf = exports.SubContractId = exports.NullContractAddress = exports.CopyCreateSubContractAndTransferToken = exports.CreateSubContractAndTransferToken = exports.CopyCreateContractAndTransferToken = void 0;
3
+ exports.BoolToByteVec = exports.BoolNeq = exports.BoolEq = exports.BoolOr = exports.BoolAnd = exports.BoolNot = exports.Pop = exports.StoreLocal = exports.LoadLocal = exports.AddressConst = exports.BytesConst = exports.U256Const = exports.I256Const = exports.U256Const5 = exports.U256Const4 = exports.U256Const3 = exports.U256Const2 = exports.U256Const1 = exports.U256Const0 = exports.I256ConstN1 = exports.I256Const5 = exports.I256Const4 = exports.I256Const3 = exports.I256Const2 = exports.I256Const1 = exports.I256Const0 = exports.ConstFalse = exports.ConstTrue = exports.Return = exports.CallExternal = exports.CallLocal = exports.CallExternalBySelectorCode = exports.MethodSelectorCode = exports.CreateMapEntryCode = exports.LoadImmFieldCode = exports.StoreMutFieldCode = exports.LoadMutFieldCode = exports.DevInstrCode = exports.DEBUGCode = exports.IfFalseCode = exports.IfTrueCode = exports.JumpCode = exports.StoreLocalCode = exports.LoadLocalCode = exports.AddressConstCode = exports.BytesConstCode = exports.U256ConstCode = exports.I256ConstCode = exports.CallExternalCode = exports.CallLocalCode = void 0;
4
+ exports.Sha256 = exports.Keccak256 = exports.Blake2b = exports.Assert = exports.IfFalse = exports.IfTrue = exports.Jump = exports.IsContractAddress = exports.IsAssetAddress = exports.AddressToByteVec = exports.AddressNeq = exports.AddressEq = exports.ByteVecConcat = exports.ByteVecSize = exports.ByteVecNeq = exports.ByteVecEq = exports.U256ToByteVec = exports.U256ToI256 = exports.I256ToByteVec = exports.I256ToU256 = exports.NumericSHR = exports.NumericSHL = exports.NumericXor = exports.NumericBitOr = exports.NumericBitAnd = exports.U256ModMul = exports.U256ModSub = exports.U256ModAdd = exports.U256Ge = exports.U256Gt = exports.U256Le = exports.U256Lt = exports.U256Neq = exports.U256Eq = exports.U256Mod = exports.U256Div = exports.U256Mul = exports.U256Sub = exports.U256Add = exports.I256Ge = exports.I256Gt = exports.I256Le = exports.I256Lt = exports.I256Neq = exports.I256Eq = exports.I256Mod = exports.I256Div = exports.I256Mul = exports.I256Sub = exports.I256Add = void 0;
5
+ exports.I256Exp = exports.TxGasFee = exports.TxGasAmount = exports.TxGasPrice = exports.DEBUG = exports.BlockHash = exports.Swap = exports.AssertWithErrorCode = exports.Dup = exports.StoreLocalByIndex = exports.LoadLocalByIndex = exports.ContractIdToAddress = exports.Log9 = exports.Log8 = exports.Log7 = exports.Log6 = exports.EthEcRecover = exports.U256From32Byte = exports.U256From16Byte = exports.U256From8Byte = exports.U256From4Byte = exports.U256From2Byte = exports.U256From1Byte = exports.U256To32Byte = exports.U256To16Byte = exports.U256To8Byte = exports.U256To4Byte = exports.U256To2Byte = exports.U256To1Byte = exports.Zeros = exports.Encode = exports.ByteVecToAddress = exports.ByteVecSlice = exports.Log5 = exports.Log4 = exports.Log3 = exports.Log2 = exports.Log1 = exports.VerifyRelativeLocktime = exports.VerifyAbsoluteLocktime = exports.TxInputsSize = exports.TxInputAddressAt = exports.TxId = exports.BlockTarget = exports.BlockTimeStamp = exports.NetworkId = exports.VerifyED25519 = exports.VerifySecP256K1 = exports.VerifyTxSignature = exports.Sha3 = void 0;
6
+ exports.CopyCreateSubContractWithToken = exports.CopyCreateSubContract = exports.CreateSubContractWithToken = exports.CreateSubContract = exports.LockApprovedAssets = exports.BurnToken = exports.CopyCreateContractWithToken = exports.MigrateWithFields = exports.MigrateSimple = exports.ContractCodeHash = exports.ContractInitialStateHash = exports.CallerCodeHash = exports.CallerInitialStateHash = exports.IsCalledFromTxScript = exports.CallerAddress = exports.CallerContractId = exports.SelfAddress = exports.SelfContractId = exports.DestroySelf = exports.CopyCreateContract = exports.CreateContractWithToken = exports.CreateContract = exports.TransferTokenToSelf = exports.TransferTokenFromSelf = exports.TransferToken = exports.TransferAlphToSelf = exports.TransferAlphFromSelf = exports.TransferAlph = exports.IsPaying = exports.TokenRemaining = exports.AlphRemaining = exports.ApproveToken = exports.ApproveAlph = exports.StoreMutField = exports.LoadMutField = exports.U256RoundInfinityDiv = exports.I256RoundInfinityDiv = exports.DevInstr = exports.GetSegregatedWebAuthnSignature = exports.VerifySignature = exports.GroupOfAddress = exports.BoolToString = exports.I256ToString = exports.U256ToString = exports.AddModN = exports.MulModN = exports.GetSegregatedSignature = exports.VerifyBIP340Schnorr = exports.U256ModExp = exports.U256Exp = void 0;
7
+ exports.toI256 = exports.toU256 = exports.instrsCodec = exports.instrCodec = exports.InstrCodec = exports.ExternalCallerAddress = exports.ExternalCallerContractId = exports.CallExternalBySelector = exports.MethodSelector = exports.CreateMapEntry = exports.MinimalContractDeposit = exports.PayGasFee = exports.LoadImmFieldByIndex = exports.LoadImmField = exports.ALPHTokenId = exports.SubContractIdOf = exports.SubContractId = exports.NullContractAddress = exports.CopyCreateSubContractAndTransferToken = exports.CreateSubContractAndTransferToken = exports.CopyCreateContractAndTransferToken = exports.CreateContractAndTransferToken = exports.ContractExists = exports.StoreMutFieldByIndex = exports.LoadMutFieldByIndex = void 0;
8
8
  /*
9
9
  Copyright 2018 - 2022 The Alephium Authors
10
10
  This file is part of the alephium project.
@@ -41,6 +41,7 @@ exports.JumpCode = 0x4a;
41
41
  exports.IfTrueCode = 0x4b;
42
42
  exports.IfFalseCode = 0x4c;
43
43
  exports.DEBUGCode = 0x7e;
44
+ exports.DevInstrCode = 0x8f;
44
45
  exports.LoadMutFieldCode = 0xa0;
45
46
  exports.StoreMutFieldCode = 0xa1;
46
47
  exports.LoadImmFieldCode = 0xce;
@@ -226,6 +227,12 @@ exports.BoolToString = { name: 'BoolToString', code: 0x8b };
226
227
  exports.GroupOfAddress = { name: 'GroupOfAddress', code: 0x8c };
227
228
  exports.VerifySignature = { name: 'VerifySignature', code: 0x8d };
228
229
  exports.GetSegregatedWebAuthnSignature = { name: 'GetSegregatedWebAuthnSignature', code: 0x8e };
230
+ const DevInstr = (instr) => {
231
+ return { name: 'DevInstr', code: 0x8f, instr };
232
+ };
233
+ exports.DevInstr = DevInstr;
234
+ exports.I256RoundInfinityDiv = { name: 'I256RoundInfinityDiv', code: 0x90 };
235
+ exports.U256RoundInfinityDiv = { name: 'U256RoundInfinityDiv', code: 0x91 };
229
236
  const LoadMutField = (index) => {
230
237
  return { name: 'LoadMutField', code: 0xa0, index };
231
238
  };
@@ -591,6 +598,12 @@ class InstrCodec extends codec_1.Codec {
591
598
  return new Uint8Array([0x8d]);
592
599
  case 'GetSegregatedWebAuthnSignature':
593
600
  return new Uint8Array([0x8e]);
601
+ case 'DevInstr':
602
+ return new Uint8Array([0x8f, ...codec_1.byteCodec.encode(instr.instr)]);
603
+ case 'I256RoundInfinityDiv':
604
+ return new Uint8Array([0x90]);
605
+ case 'U256RoundInfinityDiv':
606
+ return new Uint8Array([0x91]);
594
607
  case 'LoadMutField':
595
608
  return new Uint8Array([0xa0, ...codec_1.byteCodec.encode(instr.index)]);
596
609
  case 'StoreMutField':
@@ -992,6 +1005,12 @@ class InstrCodec extends codec_1.Codec {
992
1005
  return exports.VerifySignature;
993
1006
  case 0x8e:
994
1007
  return exports.GetSegregatedWebAuthnSignature;
1008
+ case 0x8f:
1009
+ return (0, exports.DevInstr)(codec_1.byteCodec._decode(input));
1010
+ case 0x90:
1011
+ return exports.I256RoundInfinityDiv;
1012
+ case 0x91:
1013
+ return exports.U256RoundInfinityDiv;
995
1014
  case 0xa0:
996
1015
  return (0, exports.LoadMutField)(codec_1.byteCodec._decode(input));
997
1016
  case 0xa1:
@@ -1,19 +1,25 @@
1
- import { EnumCodec, FixedSizeCodec } from './codec';
1
+ import { EnumCodec } from './codec';
2
+ import { PublicKeyLike } from './public-key-like-codec';
3
+ import { Checksum } from './checksum-codec';
2
4
  export type PublicKeyHash = Uint8Array;
3
5
  export type P2PKH = Uint8Array;
4
6
  export type P2SH = Uint8Array;
5
7
  export type P2C = Uint8Array;
6
- export declare const p2cCodec: FixedSizeCodec;
8
+ export type P2HMPKHash = Uint8Array;
9
+ export declare const p2cCodec: import("./codec").FixedSizeCodec;
7
10
  export interface P2MPKH {
8
11
  publicKeyHashes: PublicKeyHash[];
9
12
  m: number;
10
13
  }
11
- export interface P2PC {
12
- type: number;
13
- publicKey: Uint8Array;
14
- checkSum: Uint8Array;
14
+ export interface P2PK {
15
+ publicKeyLike: PublicKeyLike;
15
16
  group: number;
16
17
  }
18
+ export interface P2HMPK {
19
+ hash: P2HMPKHash;
20
+ group: number;
21
+ }
22
+ export declare const safeP2HMPKHashCodec: Checksum<Uint8Array>;
17
23
  export type LockupScript = {
18
24
  kind: 'P2PKH';
19
25
  value: P2PKH;
@@ -28,6 +34,9 @@ export type LockupScript = {
28
34
  value: P2C;
29
35
  } | {
30
36
  kind: 'P2PK';
31
- value: P2PC;
37
+ value: P2PK;
38
+ } | {
39
+ kind: 'P2HMPK';
40
+ value: P2HMPK;
32
41
  };
33
42
  export declare const lockupScriptCodec: EnumCodec<LockupScript>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lockupScriptCodec = exports.p2cCodec = void 0;
3
+ exports.lockupScriptCodec = exports.safeP2HMPKHashCodec = exports.p2cCodec = void 0;
4
4
  /*
5
5
  Copyright 2018 - 2022 The Alephium Authors
6
6
  This file is part of the alephium project.
@@ -21,15 +21,20 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
21
21
  const compact_int_codec_1 = require("./compact-int-codec");
22
22
  const codec_1 = require("./codec");
23
23
  const array_codec_1 = require("./array-codec");
24
+ const public_key_like_codec_1 = require("./public-key-like-codec");
25
+ const checksum_codec_1 = require("./checksum-codec");
24
26
  exports.p2cCodec = codec_1.byte32Codec;
25
27
  const p2mpkhCodec = new codec_1.ObjectCodec({
26
28
  publicKeyHashes: new array_codec_1.ArrayCodec(codec_1.byte32Codec),
27
29
  m: compact_int_codec_1.i32Codec
28
30
  });
29
31
  const p2pkCodec = new codec_1.ObjectCodec({
30
- type: codec_1.byteCodec,
31
- publicKey: new codec_1.FixedSizeCodec(33),
32
- checkSum: new codec_1.FixedSizeCodec(4),
32
+ publicKeyLike: public_key_like_codec_1.safePublicKeyLikeCodec,
33
+ group: codec_1.byteCodec
34
+ });
35
+ exports.safeP2HMPKHashCodec = new checksum_codec_1.Checksum(codec_1.byte32Codec);
36
+ const p2hmpkCodec = new codec_1.ObjectCodec({
37
+ hash: exports.safeP2HMPKHashCodec,
33
38
  group: codec_1.byteCodec
34
39
  });
35
40
  exports.lockupScriptCodec = new codec_1.EnumCodec('lockup script', {
@@ -37,5 +42,6 @@ exports.lockupScriptCodec = new codec_1.EnumCodec('lockup script', {
37
42
  P2MPKH: p2mpkhCodec,
38
43
  P2SH: codec_1.byte32Codec,
39
44
  P2C: codec_1.byte32Codec,
40
- P2PK: p2pkCodec
45
+ P2PK: p2pkCodec,
46
+ P2HMPK: p2hmpkCodec
41
47
  });