@alephium/web3 0.36.1 → 0.38.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/dist/alephium-web3.min.js +1 -1
- package/dist/alephium-web3.min.js.map +1 -1
- package/dist/src/api/api-alephium.d.ts +6 -1
- package/dist/src/api/api-alephium.js +1 -1
- package/dist/src/api/types.d.ts +1 -1
- package/dist/src/codec/array-codec.d.ts +17 -0
- package/dist/src/codec/array-codec.js +59 -0
- package/dist/src/codec/asset-output-codec.d.ts +27 -0
- package/dist/src/codec/asset-output-codec.js +135 -0
- package/dist/src/codec/bigint-codec.d.ts +5 -0
- package/dist/src/codec/bigint-codec.js +86 -0
- package/dist/src/codec/bytestring-codec.d.ts +16 -0
- package/dist/src/codec/bytestring-codec.js +50 -0
- package/dist/src/codec/codec.d.ts +8 -0
- package/dist/src/codec/codec.js +9 -0
- package/dist/src/codec/compact-int-codec.d.ts +51 -0
- package/dist/src/codec/compact-int-codec.js +300 -0
- package/dist/src/codec/contract-codec.d.ts +23 -0
- package/dist/src/codec/contract-codec.js +81 -0
- package/dist/src/codec/contract-output-codec.d.ts +21 -0
- package/dist/src/codec/contract-output-codec.js +82 -0
- package/dist/src/codec/contract-output-ref-codec.d.ts +15 -0
- package/dist/src/codec/contract-output-ref-codec.js +38 -0
- package/dist/src/codec/either-codec.d.ts +17 -0
- package/dist/src/codec/either-codec.js +67 -0
- package/dist/src/codec/hash.d.ts +4 -0
- package/dist/src/codec/hash.js +23 -0
- package/dist/src/codec/index.d.ts +23 -0
- package/dist/src/codec/index.js +69 -0
- package/dist/src/codec/input-codec.d.ts +22 -0
- package/dist/src/codec/input-codec.js +71 -0
- package/dist/src/codec/instr-codec.d.ts +230 -0
- package/dist/src/codec/instr-codec.js +471 -0
- package/dist/src/codec/lockup-script-codec.d.ts +28 -0
- package/dist/src/codec/lockup-script-codec.js +80 -0
- package/dist/src/codec/long-codec.d.ts +9 -0
- package/dist/src/codec/long-codec.js +56 -0
- package/dist/src/codec/method-codec.d.ts +31 -0
- package/dist/src/codec/method-codec.js +78 -0
- package/dist/src/codec/option-codec.d.ts +15 -0
- package/dist/src/codec/option-codec.js +55 -0
- package/dist/src/codec/output-codec.d.ts +7 -0
- package/dist/src/codec/output-codec.js +26 -0
- package/dist/src/codec/script-codec.d.ts +16 -0
- package/dist/src/codec/script-codec.js +41 -0
- package/dist/src/codec/signature-codec.d.ts +14 -0
- package/dist/src/codec/signature-codec.js +19 -0
- package/dist/src/codec/signed-int-codec.d.ts +9 -0
- package/dist/src/codec/signed-int-codec.js +39 -0
- package/dist/src/codec/token-codec.d.ts +16 -0
- package/dist/src/codec/token-codec.js +46 -0
- package/dist/src/codec/transaction-codec.d.ts +27 -0
- package/dist/src/codec/transaction-codec.js +128 -0
- package/dist/src/codec/unlock-script-codec.d.ts +40 -0
- package/dist/src/codec/unlock-script-codec.js +170 -0
- package/dist/src/codec/unsigned-tx-codec.d.ts +30 -0
- package/dist/src/codec/unsigned-tx-codec.js +103 -0
- package/dist/src/contract/contract.d.ts +14 -8
- package/dist/src/contract/contract.js +205 -22
- package/dist/src/contract/ralph.d.ts +16 -0
- package/dist/src/contract/ralph.js +127 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -1
- package/package.json +5 -4
- package/src/api/api-alephium.ts +7 -1
- package/src/api/types.ts +1 -1
- package/src/codec/array-codec.ts +63 -0
- package/src/codec/asset-output-codec.ts +149 -0
- package/src/codec/bigint-codec.ts +92 -0
- package/src/codec/bytestring-codec.ts +56 -0
- package/src/codec/codec.ts +31 -0
- package/src/codec/compact-int-codec.ts +316 -0
- package/src/codec/contract-codec.ts +95 -0
- package/src/codec/contract-output-codec.ts +95 -0
- package/src/codec/contract-output-ref-codec.ts +42 -0
- package/src/codec/either-codec.ts +74 -0
- package/src/codec/hash.ts +35 -0
- package/src/codec/index.ts +41 -0
- package/src/codec/input-codec.ts +81 -0
- package/src/codec/instr-codec.ts +479 -0
- package/src/codec/lockup-script-codec.ts +99 -0
- package/src/codec/long-codec.ts +59 -0
- package/src/codec/method-codec.ts +97 -0
- package/src/codec/option-codec.ts +60 -0
- package/src/codec/output-codec.ts +26 -0
- package/src/codec/script-codec.ts +45 -0
- package/src/codec/signature-codec.ts +40 -0
- package/src/codec/signed-int-codec.ts +37 -0
- package/src/codec/token-codec.ts +51 -0
- package/src/codec/transaction-codec.ts +147 -0
- package/src/codec/unlock-script-codec.ts +194 -0
- package/src/codec/unsigned-tx-codec.ts +124 -0
- package/src/contract/contract.ts +299 -23
- package/src/contract/ralph.ts +140 -2
- package/src/index.ts +1 -1
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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 = exports.BoolToByteVec = exports.BoolNeq = exports.BoolEq = exports.BoolOr = exports.BoolAnd = exports.BoolNot = exports.Pop = exports.StoreLocal = exports.LoadLocal = exports.AddressConst = exports.ByteConst = 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 = void 0;
|
|
4
|
+
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 = 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.U256SHR = exports.U256SHL = exports.U256Xor = exports.U256BitOr = exports.U256BitAnd = exports.U256ModMul = exports.U256ModSub = exports.U256ModAdd = exports.U256Ge = exports.U256Gt = exports.U256Le = void 0;
|
|
5
|
+
exports.TransferAlphToSelf = exports.TransferAlphFromSelf = exports.TransferAlph = exports.IsPaying = exports.TokenRemaining = exports.AlphRemaining = exports.ApproveToken = exports.ApproveAlph = exports.StoreMutField = exports.LoadMutField = exports.BoolToString = exports.I256ToString = exports.U256ToString = exports.AddModN = exports.MulModN = exports.GetSegragatedSignature = exports.VerifyBIP340Schnorr = exports.U256ModExp = 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 = void 0;
|
|
6
|
+
exports.instrsCodec = exports.instrCodec = exports.InstrCodec = 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 = exports.CopyCreateSubContractWithToken = exports.CopyCreateSubContract = exports.CreateSubContractWithToken = exports.CreateSubContract = exports.LockApprovedAssets = exports.BurnToken = exports.CopyCreateContractWithToken = exports.MigrateWithFields = exports.MigrateSimple = exports.ContractInitialCodeHash = exports.ContractInitialStateHash = exports.CallerCodeHash = exports.CallerInitialStateHash = exports.IsCallerFromTxScript = exports.CallerAddress = exports.CallerContractId = exports.SelfAddress = exports.SelfContractId = exports.DestroySelf = exports.CopyCreateContract = exports.CreateContractWithToken = exports.CreateContract = exports.TransferTokenToSelf = exports.TransferTokenFromSelf = exports.TransferToken = void 0;
|
|
7
|
+
/*
|
|
8
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
9
|
+
This file is part of the alephium project.
|
|
10
|
+
|
|
11
|
+
The library is free software: you can redistribute it and/or modify
|
|
12
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
13
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
14
|
+
(at your option) any later version.
|
|
15
|
+
|
|
16
|
+
The library is distributed in the hope that it will be useful,
|
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19
|
+
GNU Lesser General Public License for more details.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
22
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
23
|
+
*/
|
|
24
|
+
const buffer_1 = require("buffer/");
|
|
25
|
+
const binary_parser_1 = require("binary-parser");
|
|
26
|
+
const array_codec_1 = require("./array-codec");
|
|
27
|
+
const compact_int_codec_1 = require("./compact-int-codec");
|
|
28
|
+
const bytestring_codec_1 = require("./bytestring-codec");
|
|
29
|
+
const lockup_script_codec_1 = require("./lockup-script-codec");
|
|
30
|
+
const byteStringArrayCodec = new array_codec_1.ArrayCodec(bytestring_codec_1.byteStringCodec);
|
|
31
|
+
const CallLocal = (index) => ({ code: 0x00, value: { index } });
|
|
32
|
+
exports.CallLocal = CallLocal;
|
|
33
|
+
const CallExternal = (index) => ({ code: 0x01, value: { index } });
|
|
34
|
+
exports.CallExternal = CallExternal;
|
|
35
|
+
exports.Return = { code: 0x02, value: {} };
|
|
36
|
+
exports.ConstTrue = { code: 0x03, value: {} };
|
|
37
|
+
exports.ConstFalse = { code: 0x04, value: {} };
|
|
38
|
+
exports.I256Const0 = { code: 0x05, value: {} };
|
|
39
|
+
exports.I256Const1 = { code: 0x06, value: {} };
|
|
40
|
+
exports.I256Const2 = { code: 0x07, value: {} };
|
|
41
|
+
exports.I256Const3 = { code: 0x08, value: {} };
|
|
42
|
+
exports.I256Const4 = { code: 0x09, value: {} };
|
|
43
|
+
exports.I256Const5 = { code: 0x0a, value: {} };
|
|
44
|
+
exports.I256ConstN1 = { code: 0x0b, value: {} };
|
|
45
|
+
exports.U256Const0 = { code: 0x0c, value: {} };
|
|
46
|
+
exports.U256Const1 = { code: 0x0d, value: {} };
|
|
47
|
+
exports.U256Const2 = { code: 0x0e, value: {} };
|
|
48
|
+
exports.U256Const3 = { code: 0x0f, value: {} };
|
|
49
|
+
exports.U256Const4 = { code: 0x10, value: {} };
|
|
50
|
+
exports.U256Const5 = { code: 0x11, value: {} };
|
|
51
|
+
const I256Const = (value) => ({ code: 0x12, value: { value } });
|
|
52
|
+
exports.I256Const = I256Const;
|
|
53
|
+
const U256Const = (value) => ({ code: 0x13, value: { value } });
|
|
54
|
+
exports.U256Const = U256Const;
|
|
55
|
+
const ByteConst = (value) => ({ code: 0x14, value: { value } });
|
|
56
|
+
exports.ByteConst = ByteConst;
|
|
57
|
+
const AddressConst = (value) => ({ code: 0x15, value: { value } });
|
|
58
|
+
exports.AddressConst = AddressConst;
|
|
59
|
+
const LoadLocal = (index) => ({ code: 0x16, value: { index } });
|
|
60
|
+
exports.LoadLocal = LoadLocal;
|
|
61
|
+
const StoreLocal = (index) => ({ code: 0x17, value: { index } });
|
|
62
|
+
exports.StoreLocal = StoreLocal;
|
|
63
|
+
exports.Pop = { code: 0x18, value: {} };
|
|
64
|
+
exports.BoolNot = { code: 0x19, value: {} };
|
|
65
|
+
exports.BoolAnd = { code: 0x1a, value: {} };
|
|
66
|
+
exports.BoolOr = { code: 0x1b, value: {} };
|
|
67
|
+
exports.BoolEq = { code: 0x1c, value: {} };
|
|
68
|
+
exports.BoolNeq = { code: 0x1d, value: {} };
|
|
69
|
+
exports.BoolToByteVec = { code: 0x1e, value: {} };
|
|
70
|
+
exports.I256Add = { code: 0x1f, value: {} };
|
|
71
|
+
exports.I256Sub = { code: 0x20, value: {} };
|
|
72
|
+
exports.I256Mul = { code: 0x21, value: {} };
|
|
73
|
+
exports.I256Div = { code: 0x22, value: {} };
|
|
74
|
+
exports.I256Mod = { code: 0x23, value: {} };
|
|
75
|
+
exports.I256Eq = { code: 0x24, value: {} };
|
|
76
|
+
exports.I256Neq = { code: 0x25, value: {} };
|
|
77
|
+
exports.I256Lt = { code: 0x26, value: {} };
|
|
78
|
+
exports.I256Le = { code: 0x27, value: {} };
|
|
79
|
+
exports.I256Gt = { code: 0x28, value: {} };
|
|
80
|
+
exports.I256Ge = { code: 0x29, value: {} };
|
|
81
|
+
exports.U256Add = { code: 0x2a, value: {} };
|
|
82
|
+
exports.U256Sub = { code: 0x2b, value: {} };
|
|
83
|
+
exports.U256Mul = { code: 0x2c, value: {} };
|
|
84
|
+
exports.U256Div = { code: 0x2d, value: {} };
|
|
85
|
+
exports.U256Mod = { code: 0x2e, value: {} };
|
|
86
|
+
exports.U256Eq = { code: 0x2f, value: {} };
|
|
87
|
+
exports.U256Neq = { code: 0x30, value: {} };
|
|
88
|
+
exports.U256Lt = { code: 0x31, value: {} };
|
|
89
|
+
exports.U256Le = { code: 0x32, value: {} };
|
|
90
|
+
exports.U256Gt = { code: 0x33, value: {} };
|
|
91
|
+
exports.U256Ge = { code: 0x34, value: {} };
|
|
92
|
+
exports.U256ModAdd = { code: 0x35, value: {} };
|
|
93
|
+
exports.U256ModSub = { code: 0x36, value: {} };
|
|
94
|
+
exports.U256ModMul = { code: 0x37, value: {} };
|
|
95
|
+
exports.U256BitAnd = { code: 0x38, value: {} };
|
|
96
|
+
exports.U256BitOr = { code: 0x39, value: {} };
|
|
97
|
+
exports.U256Xor = { code: 0x3a, value: {} };
|
|
98
|
+
exports.U256SHL = { code: 0x3b, value: {} };
|
|
99
|
+
exports.U256SHR = { code: 0x3c, value: {} };
|
|
100
|
+
exports.I256ToU256 = { code: 0x3d, value: {} };
|
|
101
|
+
exports.I256ToByteVec = { code: 0x3e, value: {} };
|
|
102
|
+
exports.U256ToI256 = { code: 0x3f, value: {} };
|
|
103
|
+
exports.U256ToByteVec = { code: 0x40, value: {} };
|
|
104
|
+
exports.ByteVecEq = { code: 0x41, value: {} };
|
|
105
|
+
exports.ByteVecNeq = { code: 0x42, value: {} };
|
|
106
|
+
exports.ByteVecSize = { code: 0x43, value: {} };
|
|
107
|
+
exports.ByteVecConcat = { code: 0x44, value: {} };
|
|
108
|
+
exports.AddressEq = { code: 0x45, value: {} };
|
|
109
|
+
exports.AddressNeq = { code: 0x46, value: {} };
|
|
110
|
+
exports.AddressToByteVec = { code: 0x47, value: {} };
|
|
111
|
+
exports.IsAssetAddress = { code: 0x48, value: {} };
|
|
112
|
+
exports.IsContractAddress = { code: 0x49, value: {} };
|
|
113
|
+
const Jump = (value) => ({ code: 0x4a, value });
|
|
114
|
+
exports.Jump = Jump;
|
|
115
|
+
const IfTrue = (value) => ({ code: 0x4b, value });
|
|
116
|
+
exports.IfTrue = IfTrue;
|
|
117
|
+
const IfFalse = (value) => ({ code: 0x4c, value: { value } });
|
|
118
|
+
exports.IfFalse = IfFalse;
|
|
119
|
+
exports.Assert = { code: 0x4d, value: {} };
|
|
120
|
+
exports.Blake2b = { code: 0x4e, value: {} };
|
|
121
|
+
exports.Keccak256 = { code: 0x4f, value: {} };
|
|
122
|
+
exports.Sha256 = { code: 0x50, value: {} };
|
|
123
|
+
exports.Sha3 = { code: 0x51, value: {} };
|
|
124
|
+
exports.VerifyTxSignature = { code: 0x52, value: {} };
|
|
125
|
+
exports.VerifySecP256K1 = { code: 0x53, value: {} };
|
|
126
|
+
exports.VerifyED25519 = { code: 0x54, value: {} };
|
|
127
|
+
exports.NetworkId = { code: 0x55, value: {} };
|
|
128
|
+
exports.BlockTimeStamp = { code: 0x56, value: {} };
|
|
129
|
+
exports.BlockTarget = { code: 0x57, value: {} };
|
|
130
|
+
exports.TxId = { code: 0x58, value: {} };
|
|
131
|
+
exports.TxInputAddressAt = { code: 0x59, value: {} };
|
|
132
|
+
exports.TxInputsSize = { code: 0x5a, value: {} };
|
|
133
|
+
exports.VerifyAbsoluteLocktime = { code: 0x5b, value: {} };
|
|
134
|
+
exports.VerifyRelativeLocktime = { code: 0x5c, value: {} };
|
|
135
|
+
exports.Log1 = { code: 0x5d, value: {} };
|
|
136
|
+
exports.Log2 = { code: 0x5e, value: {} };
|
|
137
|
+
exports.Log3 = { code: 0x5f, value: {} };
|
|
138
|
+
exports.Log4 = { code: 0x60, value: {} };
|
|
139
|
+
exports.Log5 = { code: 0x61, value: {} };
|
|
140
|
+
exports.ByteVecSlice = { code: 0x62, value: {} };
|
|
141
|
+
exports.ByteVecToAddress = { code: 0x63, value: {} };
|
|
142
|
+
exports.Encode = { code: 0x64, value: {} };
|
|
143
|
+
exports.Zeros = { code: 0x65, value: {} };
|
|
144
|
+
exports.U256To1Byte = { code: 0x66, value: {} };
|
|
145
|
+
exports.U256To2Byte = { code: 0x67, value: {} };
|
|
146
|
+
exports.U256To4Byte = { code: 0x68, value: {} };
|
|
147
|
+
exports.U256To8Byte = { code: 0x69, value: {} };
|
|
148
|
+
exports.U256To16Byte = { code: 0x6a, value: {} };
|
|
149
|
+
exports.U256To32Byte = { code: 0x6b, value: {} };
|
|
150
|
+
exports.U256From1Byte = { code: 0x6c, value: {} };
|
|
151
|
+
exports.U256From2Byte = { code: 0x6d, value: {} };
|
|
152
|
+
exports.U256From4Byte = { code: 0x6e, value: {} };
|
|
153
|
+
exports.U256From8Byte = { code: 0x6f, value: {} };
|
|
154
|
+
exports.U256From16Byte = { code: 0x70, value: {} };
|
|
155
|
+
exports.U256From32Byte = { code: 0x71, value: {} };
|
|
156
|
+
exports.EthEcRecover = { code: 0x72, value: {} };
|
|
157
|
+
exports.Log6 = { code: 0x73, value: {} };
|
|
158
|
+
exports.Log7 = { code: 0x74, value: {} };
|
|
159
|
+
exports.Log8 = { code: 0x75, value: {} };
|
|
160
|
+
exports.Log9 = { code: 0x76, value: {} };
|
|
161
|
+
exports.ContractIdToAddress = { code: 0x77, value: {} };
|
|
162
|
+
exports.LoadLocalByIndex = { code: 0x78, value: {} };
|
|
163
|
+
exports.StoreLocalByIndex = { code: 0x79, value: {} };
|
|
164
|
+
exports.Dup = { code: 0x7a, value: {} };
|
|
165
|
+
exports.AssertWithErrorCode = { code: 0x7b, value: {} };
|
|
166
|
+
exports.Swap = { code: 0x7c, value: {} };
|
|
167
|
+
exports.BlockHash = { code: 0x7d, value: {} };
|
|
168
|
+
const DEBUG = (stringParts) => ({ code: 0x7e, value: { stringParts } });
|
|
169
|
+
exports.DEBUG = DEBUG;
|
|
170
|
+
exports.TxGasPrice = { code: 0x7f, value: {} };
|
|
171
|
+
exports.TxGasAmount = { code: 0x80, value: {} };
|
|
172
|
+
exports.TxGasFee = { code: 0x81, value: {} };
|
|
173
|
+
exports.I256Exp = { code: 0x82, value: {} };
|
|
174
|
+
exports.U256Exp = { code: 0x83, value: {} };
|
|
175
|
+
exports.U256ModExp = { code: 0x84, value: {} };
|
|
176
|
+
exports.VerifyBIP340Schnorr = { code: 0x85, value: {} };
|
|
177
|
+
exports.GetSegragatedSignature = { code: 0x86, value: {} };
|
|
178
|
+
exports.MulModN = { code: 0x87, value: {} };
|
|
179
|
+
exports.AddModN = { code: 0x88, value: {} };
|
|
180
|
+
exports.U256ToString = { code: 0x89, value: {} };
|
|
181
|
+
exports.I256ToString = { code: 0x8a, value: {} };
|
|
182
|
+
exports.BoolToString = { code: 0x8b, value: {} };
|
|
183
|
+
const LoadMutField = (index) => ({ code: 0xa0, value: { index } });
|
|
184
|
+
exports.LoadMutField = LoadMutField;
|
|
185
|
+
const StoreMutField = (index) => ({ code: 0xa1, value: { index } });
|
|
186
|
+
exports.StoreMutField = StoreMutField;
|
|
187
|
+
exports.ApproveAlph = { code: 0xa2, value: {} };
|
|
188
|
+
exports.ApproveToken = { code: 0xa3, value: {} };
|
|
189
|
+
exports.AlphRemaining = { code: 0xa4, value: {} };
|
|
190
|
+
exports.TokenRemaining = { code: 0xa5, value: {} };
|
|
191
|
+
exports.IsPaying = { code: 0xa6, value: {} };
|
|
192
|
+
exports.TransferAlph = { code: 0xa7, value: {} };
|
|
193
|
+
exports.TransferAlphFromSelf = { code: 0xa8, value: {} };
|
|
194
|
+
exports.TransferAlphToSelf = { code: 0xa9, value: {} };
|
|
195
|
+
exports.TransferToken = { code: 0xaa, value: {} };
|
|
196
|
+
exports.TransferTokenFromSelf = { code: 0xab, value: {} };
|
|
197
|
+
exports.TransferTokenToSelf = { code: 0xac, value: {} };
|
|
198
|
+
exports.CreateContract = { code: 0xad, value: {} };
|
|
199
|
+
exports.CreateContractWithToken = { code: 0xae, value: {} };
|
|
200
|
+
exports.CopyCreateContract = { code: 0xaf, value: {} };
|
|
201
|
+
exports.DestroySelf = { code: 0xb0, value: {} };
|
|
202
|
+
exports.SelfContractId = { code: 0xb1, value: {} };
|
|
203
|
+
exports.SelfAddress = { code: 0xb2, value: {} };
|
|
204
|
+
exports.CallerContractId = { code: 0xb3, value: {} };
|
|
205
|
+
exports.CallerAddress = { code: 0xb4, value: {} };
|
|
206
|
+
exports.IsCallerFromTxScript = { code: 0xb5, value: {} };
|
|
207
|
+
exports.CallerInitialStateHash = { code: 0xb6, value: {} };
|
|
208
|
+
exports.CallerCodeHash = { code: 0xb7, value: {} };
|
|
209
|
+
exports.ContractInitialStateHash = { code: 0xb8, value: {} };
|
|
210
|
+
exports.ContractInitialCodeHash = { code: 0xb9, value: {} };
|
|
211
|
+
exports.MigrateSimple = { code: 0xba, value: {} };
|
|
212
|
+
exports.MigrateWithFields = { code: 0xbb, value: {} };
|
|
213
|
+
exports.CopyCreateContractWithToken = { code: 0xbc, value: {} };
|
|
214
|
+
exports.BurnToken = { code: 0xbd, value: {} };
|
|
215
|
+
exports.LockApprovedAssets = { code: 0xbe, value: {} };
|
|
216
|
+
exports.CreateSubContract = { code: 0xbf, value: {} };
|
|
217
|
+
exports.CreateSubContractWithToken = { code: 0xc0, value: {} };
|
|
218
|
+
exports.CopyCreateSubContract = { code: 0xc1, value: {} };
|
|
219
|
+
exports.CopyCreateSubContractWithToken = { code: 0xc2, value: {} };
|
|
220
|
+
exports.LoadMutFieldByIndex = { code: 0xc3, value: {} };
|
|
221
|
+
exports.StoreMutFieldByIndex = { code: 0xc4, value: {} };
|
|
222
|
+
exports.ContractExists = { code: 0xc5, value: {} };
|
|
223
|
+
exports.CreateContractAndTransferToken = { code: 0xc6, value: {} };
|
|
224
|
+
exports.CopyCreateContractAndTransferToken = { code: 0xc7, value: {} };
|
|
225
|
+
exports.CreateSubContractAndTransferToken = { code: 0xc8, value: {} };
|
|
226
|
+
exports.CopyCreateSubContractAndTransferToken = { code: 0xc9, value: {} };
|
|
227
|
+
exports.NullContractAddress = { code: 0xca, value: {} };
|
|
228
|
+
exports.SubContractId = { code: 0xcb, value: {} };
|
|
229
|
+
exports.SubContractIdOf = { code: 0xcc, value: {} };
|
|
230
|
+
exports.AlphTokenId = { code: 0xcd, value: {} };
|
|
231
|
+
const LoadImmField = (index) => ({ code: 0xce, value: { index } });
|
|
232
|
+
exports.LoadImmField = LoadImmField;
|
|
233
|
+
exports.LoadImmFieldByIndex = { code: 0xcf, value: {} };
|
|
234
|
+
exports.PayGasFee = { code: 0xd0, value: {} };
|
|
235
|
+
exports.MinimalContractDeposit = { code: 0xd1, value: {} };
|
|
236
|
+
const CreateMapEntry = (immFields, mutFields) => ({ code: 0xd2, value: { immFields, mutFields } });
|
|
237
|
+
exports.CreateMapEntry = CreateMapEntry;
|
|
238
|
+
class InstrCodec {
|
|
239
|
+
constructor() {
|
|
240
|
+
this.parser = binary_parser_1.Parser.start()
|
|
241
|
+
.uint8('code')
|
|
242
|
+
.choice('value', {
|
|
243
|
+
tag: 'code',
|
|
244
|
+
choices: {
|
|
245
|
+
0x00: binary_parser_1.Parser.start().uint8('index'),
|
|
246
|
+
0x01: binary_parser_1.Parser.start().uint8('index'),
|
|
247
|
+
[exports.Return.code]: binary_parser_1.Parser.start(),
|
|
248
|
+
[exports.ConstTrue.code]: binary_parser_1.Parser.start(),
|
|
249
|
+
[exports.ConstFalse.code]: binary_parser_1.Parser.start(),
|
|
250
|
+
[exports.I256Const0.code]: binary_parser_1.Parser.start(),
|
|
251
|
+
[exports.I256Const1.code]: binary_parser_1.Parser.start(),
|
|
252
|
+
[exports.I256Const2.code]: binary_parser_1.Parser.start(),
|
|
253
|
+
[exports.I256Const3.code]: binary_parser_1.Parser.start(),
|
|
254
|
+
[exports.I256Const4.code]: binary_parser_1.Parser.start(),
|
|
255
|
+
[exports.I256Const5.code]: binary_parser_1.Parser.start(),
|
|
256
|
+
[exports.I256ConstN1.code]: binary_parser_1.Parser.start(),
|
|
257
|
+
[exports.U256Const0.code]: binary_parser_1.Parser.start(),
|
|
258
|
+
[exports.U256Const1.code]: binary_parser_1.Parser.start(),
|
|
259
|
+
[exports.U256Const2.code]: binary_parser_1.Parser.start(),
|
|
260
|
+
[exports.U256Const3.code]: binary_parser_1.Parser.start(),
|
|
261
|
+
[exports.U256Const4.code]: binary_parser_1.Parser.start(),
|
|
262
|
+
[exports.U256Const5.code]: binary_parser_1.Parser.start(),
|
|
263
|
+
0x12: binary_parser_1.Parser.start().nest('value', { type: compact_int_codec_1.compactSignedIntCodec.parser }),
|
|
264
|
+
0x13: binary_parser_1.Parser.start().nest('value', { type: compact_int_codec_1.compactUnsignedIntCodec.parser }),
|
|
265
|
+
0x14: binary_parser_1.Parser.start().nest('value', { type: bytestring_codec_1.byteStringCodec.parser }),
|
|
266
|
+
0x15: binary_parser_1.Parser.start().nest('value', { type: lockup_script_codec_1.lockupScriptCodec.parser }),
|
|
267
|
+
0x16: binary_parser_1.Parser.start().uint8('index'),
|
|
268
|
+
0x17: binary_parser_1.Parser.start().uint8('index'),
|
|
269
|
+
[exports.Pop.code]: binary_parser_1.Parser.start(),
|
|
270
|
+
[exports.BoolNot.code]: binary_parser_1.Parser.start(),
|
|
271
|
+
[exports.BoolAnd.code]: binary_parser_1.Parser.start(),
|
|
272
|
+
[exports.BoolOr.code]: binary_parser_1.Parser.start(),
|
|
273
|
+
[exports.BoolEq.code]: binary_parser_1.Parser.start(),
|
|
274
|
+
[exports.BoolNeq.code]: binary_parser_1.Parser.start(),
|
|
275
|
+
[exports.BoolToByteVec.code]: binary_parser_1.Parser.start(),
|
|
276
|
+
[exports.I256Add.code]: binary_parser_1.Parser.start(),
|
|
277
|
+
[exports.I256Sub.code]: binary_parser_1.Parser.start(),
|
|
278
|
+
[exports.I256Mul.code]: binary_parser_1.Parser.start(),
|
|
279
|
+
[exports.I256Div.code]: binary_parser_1.Parser.start(),
|
|
280
|
+
[exports.I256Mod.code]: binary_parser_1.Parser.start(),
|
|
281
|
+
[exports.I256Eq.code]: binary_parser_1.Parser.start(),
|
|
282
|
+
[exports.I256Neq.code]: binary_parser_1.Parser.start(),
|
|
283
|
+
[exports.I256Lt.code]: binary_parser_1.Parser.start(),
|
|
284
|
+
[exports.I256Le.code]: binary_parser_1.Parser.start(),
|
|
285
|
+
[exports.I256Gt.code]: binary_parser_1.Parser.start(),
|
|
286
|
+
[exports.I256Ge.code]: binary_parser_1.Parser.start(),
|
|
287
|
+
[exports.U256Add.code]: binary_parser_1.Parser.start(),
|
|
288
|
+
[exports.U256Sub.code]: binary_parser_1.Parser.start(),
|
|
289
|
+
[exports.U256Mul.code]: binary_parser_1.Parser.start(),
|
|
290
|
+
[exports.U256Div.code]: binary_parser_1.Parser.start(),
|
|
291
|
+
[exports.U256Mod.code]: binary_parser_1.Parser.start(),
|
|
292
|
+
[exports.U256Eq.code]: binary_parser_1.Parser.start(),
|
|
293
|
+
[exports.U256Neq.code]: binary_parser_1.Parser.start(),
|
|
294
|
+
[exports.U256Lt.code]: binary_parser_1.Parser.start(),
|
|
295
|
+
[exports.U256Le.code]: binary_parser_1.Parser.start(),
|
|
296
|
+
[exports.U256Gt.code]: binary_parser_1.Parser.start(),
|
|
297
|
+
[exports.U256Ge.code]: binary_parser_1.Parser.start(),
|
|
298
|
+
[exports.U256ModAdd.code]: binary_parser_1.Parser.start(),
|
|
299
|
+
[exports.U256ModSub.code]: binary_parser_1.Parser.start(),
|
|
300
|
+
[exports.U256ModMul.code]: binary_parser_1.Parser.start(),
|
|
301
|
+
[exports.U256BitAnd.code]: binary_parser_1.Parser.start(),
|
|
302
|
+
[exports.U256BitOr.code]: binary_parser_1.Parser.start(),
|
|
303
|
+
[exports.U256Xor.code]: binary_parser_1.Parser.start(),
|
|
304
|
+
[exports.U256SHL.code]: binary_parser_1.Parser.start(),
|
|
305
|
+
[exports.U256SHR.code]: binary_parser_1.Parser.start(),
|
|
306
|
+
[exports.I256ToU256.code]: binary_parser_1.Parser.start(),
|
|
307
|
+
[exports.I256ToByteVec.code]: binary_parser_1.Parser.start(),
|
|
308
|
+
[exports.U256ToI256.code]: binary_parser_1.Parser.start(),
|
|
309
|
+
[exports.U256ToByteVec.code]: binary_parser_1.Parser.start(),
|
|
310
|
+
[exports.ByteVecEq.code]: binary_parser_1.Parser.start(),
|
|
311
|
+
[exports.ByteVecNeq.code]: binary_parser_1.Parser.start(),
|
|
312
|
+
[exports.ByteVecSize.code]: binary_parser_1.Parser.start(),
|
|
313
|
+
[exports.ByteVecConcat.code]: binary_parser_1.Parser.start(),
|
|
314
|
+
[exports.AddressEq.code]: binary_parser_1.Parser.start(),
|
|
315
|
+
[exports.AddressNeq.code]: binary_parser_1.Parser.start(),
|
|
316
|
+
[exports.AddressToByteVec.code]: binary_parser_1.Parser.start(),
|
|
317
|
+
[exports.IsAssetAddress.code]: binary_parser_1.Parser.start(),
|
|
318
|
+
[exports.IsContractAddress.code]: binary_parser_1.Parser.start(),
|
|
319
|
+
0x4a: binary_parser_1.Parser.start().nest('value', { type: compact_int_codec_1.compactUnsignedIntCodec.parser }),
|
|
320
|
+
0x4b: binary_parser_1.Parser.start().nest('value', { type: compact_int_codec_1.compactUnsignedIntCodec.parser }),
|
|
321
|
+
0x4c: binary_parser_1.Parser.start().nest('value', { type: compact_int_codec_1.compactUnsignedIntCodec.parser }),
|
|
322
|
+
[exports.Assert.code]: binary_parser_1.Parser.start(),
|
|
323
|
+
[exports.Blake2b.code]: binary_parser_1.Parser.start(),
|
|
324
|
+
[exports.Keccak256.code]: binary_parser_1.Parser.start(),
|
|
325
|
+
[exports.Sha256.code]: binary_parser_1.Parser.start(),
|
|
326
|
+
[exports.Sha3.code]: binary_parser_1.Parser.start(),
|
|
327
|
+
[exports.VerifyTxSignature.code]: binary_parser_1.Parser.start(),
|
|
328
|
+
[exports.VerifySecP256K1.code]: binary_parser_1.Parser.start(),
|
|
329
|
+
[exports.VerifyED25519.code]: binary_parser_1.Parser.start(),
|
|
330
|
+
[exports.NetworkId.code]: binary_parser_1.Parser.start(),
|
|
331
|
+
[exports.BlockTimeStamp.code]: binary_parser_1.Parser.start(),
|
|
332
|
+
[exports.BlockTarget.code]: binary_parser_1.Parser.start(),
|
|
333
|
+
[exports.TxId.code]: binary_parser_1.Parser.start(),
|
|
334
|
+
[exports.TxInputAddressAt.code]: binary_parser_1.Parser.start(),
|
|
335
|
+
[exports.TxInputsSize.code]: binary_parser_1.Parser.start(),
|
|
336
|
+
[exports.VerifyAbsoluteLocktime.code]: binary_parser_1.Parser.start(),
|
|
337
|
+
[exports.VerifyRelativeLocktime.code]: binary_parser_1.Parser.start(),
|
|
338
|
+
[exports.Log1.code]: binary_parser_1.Parser.start(),
|
|
339
|
+
[exports.Log2.code]: binary_parser_1.Parser.start(),
|
|
340
|
+
[exports.Log3.code]: binary_parser_1.Parser.start(),
|
|
341
|
+
[exports.Log4.code]: binary_parser_1.Parser.start(),
|
|
342
|
+
[exports.Log5.code]: binary_parser_1.Parser.start(),
|
|
343
|
+
[exports.ByteVecSlice.code]: binary_parser_1.Parser.start(),
|
|
344
|
+
[exports.ByteVecToAddress.code]: binary_parser_1.Parser.start(),
|
|
345
|
+
[exports.Encode.code]: binary_parser_1.Parser.start(),
|
|
346
|
+
[exports.Zeros.code]: binary_parser_1.Parser.start(),
|
|
347
|
+
[exports.U256To1Byte.code]: binary_parser_1.Parser.start(),
|
|
348
|
+
[exports.U256To2Byte.code]: binary_parser_1.Parser.start(),
|
|
349
|
+
[exports.U256To4Byte.code]: binary_parser_1.Parser.start(),
|
|
350
|
+
[exports.U256To8Byte.code]: binary_parser_1.Parser.start(),
|
|
351
|
+
[exports.U256To16Byte.code]: binary_parser_1.Parser.start(),
|
|
352
|
+
[exports.U256To32Byte.code]: binary_parser_1.Parser.start(),
|
|
353
|
+
[exports.U256From1Byte.code]: binary_parser_1.Parser.start(),
|
|
354
|
+
[exports.U256From2Byte.code]: binary_parser_1.Parser.start(),
|
|
355
|
+
[exports.U256From4Byte.code]: binary_parser_1.Parser.start(),
|
|
356
|
+
[exports.U256From8Byte.code]: binary_parser_1.Parser.start(),
|
|
357
|
+
[exports.U256From16Byte.code]: binary_parser_1.Parser.start(),
|
|
358
|
+
[exports.U256From32Byte.code]: binary_parser_1.Parser.start(),
|
|
359
|
+
[exports.EthEcRecover.code]: binary_parser_1.Parser.start(),
|
|
360
|
+
[exports.Log6.code]: binary_parser_1.Parser.start(),
|
|
361
|
+
[exports.Log7.code]: binary_parser_1.Parser.start(),
|
|
362
|
+
[exports.Log8.code]: binary_parser_1.Parser.start(),
|
|
363
|
+
[exports.Log9.code]: binary_parser_1.Parser.start(),
|
|
364
|
+
[exports.ContractIdToAddress.code]: binary_parser_1.Parser.start(),
|
|
365
|
+
[exports.LoadLocalByIndex.code]: binary_parser_1.Parser.start(),
|
|
366
|
+
[exports.StoreLocalByIndex.code]: binary_parser_1.Parser.start(),
|
|
367
|
+
[exports.Dup.code]: binary_parser_1.Parser.start(),
|
|
368
|
+
[exports.AssertWithErrorCode.code]: binary_parser_1.Parser.start(),
|
|
369
|
+
[exports.Swap.code]: binary_parser_1.Parser.start(),
|
|
370
|
+
[exports.BlockHash.code]: binary_parser_1.Parser.start(),
|
|
371
|
+
0x7e: binary_parser_1.Parser.start().nest('stringParts', { type: byteStringArrayCodec.parser }),
|
|
372
|
+
[exports.TxGasPrice.code]: binary_parser_1.Parser.start(),
|
|
373
|
+
[exports.TxGasAmount.code]: binary_parser_1.Parser.start(),
|
|
374
|
+
[exports.TxGasFee.code]: binary_parser_1.Parser.start(),
|
|
375
|
+
[exports.I256Exp.code]: binary_parser_1.Parser.start(),
|
|
376
|
+
[exports.U256Exp.code]: binary_parser_1.Parser.start(),
|
|
377
|
+
[exports.U256ModExp.code]: binary_parser_1.Parser.start(),
|
|
378
|
+
[exports.VerifyBIP340Schnorr.code]: binary_parser_1.Parser.start(),
|
|
379
|
+
[exports.GetSegragatedSignature.code]: binary_parser_1.Parser.start(),
|
|
380
|
+
[exports.MulModN.code]: binary_parser_1.Parser.start(),
|
|
381
|
+
[exports.AddModN.code]: binary_parser_1.Parser.start(),
|
|
382
|
+
[exports.U256ToString.code]: binary_parser_1.Parser.start(),
|
|
383
|
+
[exports.I256ToString.code]: binary_parser_1.Parser.start(),
|
|
384
|
+
[exports.BoolToString.code]: binary_parser_1.Parser.start(),
|
|
385
|
+
0xa0: binary_parser_1.Parser.start().uint8('index'),
|
|
386
|
+
0xa1: binary_parser_1.Parser.start().uint8('index'),
|
|
387
|
+
[exports.ApproveAlph.code]: binary_parser_1.Parser.start(),
|
|
388
|
+
[exports.ApproveToken.code]: binary_parser_1.Parser.start(),
|
|
389
|
+
[exports.AlphRemaining.code]: binary_parser_1.Parser.start(),
|
|
390
|
+
[exports.TokenRemaining.code]: binary_parser_1.Parser.start(),
|
|
391
|
+
[exports.IsPaying.code]: binary_parser_1.Parser.start(),
|
|
392
|
+
[exports.TransferAlph.code]: binary_parser_1.Parser.start(),
|
|
393
|
+
[exports.TransferAlphFromSelf.code]: binary_parser_1.Parser.start(),
|
|
394
|
+
[exports.TransferAlphToSelf.code]: binary_parser_1.Parser.start(),
|
|
395
|
+
[exports.TransferToken.code]: binary_parser_1.Parser.start(),
|
|
396
|
+
[exports.TransferTokenFromSelf.code]: binary_parser_1.Parser.start(),
|
|
397
|
+
[exports.TransferTokenToSelf.code]: binary_parser_1.Parser.start(),
|
|
398
|
+
[exports.CreateContract.code]: binary_parser_1.Parser.start(),
|
|
399
|
+
[exports.CreateContractWithToken.code]: binary_parser_1.Parser.start(),
|
|
400
|
+
[exports.CopyCreateContract.code]: binary_parser_1.Parser.start(),
|
|
401
|
+
[exports.DestroySelf.code]: binary_parser_1.Parser.start(),
|
|
402
|
+
[exports.SelfContractId.code]: binary_parser_1.Parser.start(),
|
|
403
|
+
[exports.SelfAddress.code]: binary_parser_1.Parser.start(),
|
|
404
|
+
[exports.CallerContractId.code]: binary_parser_1.Parser.start(),
|
|
405
|
+
[exports.CallerAddress.code]: binary_parser_1.Parser.start(),
|
|
406
|
+
[exports.IsCallerFromTxScript.code]: binary_parser_1.Parser.start(),
|
|
407
|
+
[exports.CallerInitialStateHash.code]: binary_parser_1.Parser.start(),
|
|
408
|
+
[exports.CallerCodeHash.code]: binary_parser_1.Parser.start(),
|
|
409
|
+
[exports.ContractInitialStateHash.code]: binary_parser_1.Parser.start(),
|
|
410
|
+
[exports.ContractInitialCodeHash.code]: binary_parser_1.Parser.start(),
|
|
411
|
+
[exports.MigrateSimple.code]: binary_parser_1.Parser.start(),
|
|
412
|
+
[exports.MigrateWithFields.code]: binary_parser_1.Parser.start(),
|
|
413
|
+
[exports.CopyCreateContractWithToken.code]: binary_parser_1.Parser.start(),
|
|
414
|
+
[exports.BurnToken.code]: binary_parser_1.Parser.start(),
|
|
415
|
+
[exports.LockApprovedAssets.code]: binary_parser_1.Parser.start(),
|
|
416
|
+
[exports.CreateSubContract.code]: binary_parser_1.Parser.start(),
|
|
417
|
+
[exports.CreateSubContractWithToken.code]: binary_parser_1.Parser.start(),
|
|
418
|
+
[exports.CopyCreateSubContract.code]: binary_parser_1.Parser.start(),
|
|
419
|
+
[exports.CopyCreateSubContractWithToken.code]: binary_parser_1.Parser.start(),
|
|
420
|
+
[exports.LoadMutFieldByIndex.code]: binary_parser_1.Parser.start(),
|
|
421
|
+
[exports.StoreMutFieldByIndex.code]: binary_parser_1.Parser.start(),
|
|
422
|
+
[exports.ContractExists.code]: binary_parser_1.Parser.start(),
|
|
423
|
+
[exports.CreateContractAndTransferToken.code]: binary_parser_1.Parser.start(),
|
|
424
|
+
[exports.CopyCreateContractAndTransferToken.code]: binary_parser_1.Parser.start(),
|
|
425
|
+
[exports.CreateSubContractAndTransferToken.code]: binary_parser_1.Parser.start(),
|
|
426
|
+
[exports.CopyCreateSubContractAndTransferToken.code]: binary_parser_1.Parser.start(),
|
|
427
|
+
[exports.NullContractAddress.code]: binary_parser_1.Parser.start(),
|
|
428
|
+
[exports.SubContractId.code]: binary_parser_1.Parser.start(),
|
|
429
|
+
[exports.SubContractIdOf.code]: binary_parser_1.Parser.start(),
|
|
430
|
+
[exports.AlphTokenId.code]: binary_parser_1.Parser.start(),
|
|
431
|
+
0xce: binary_parser_1.Parser.start().uint8('index'),
|
|
432
|
+
[exports.LoadImmFieldByIndex.code]: binary_parser_1.Parser.start(),
|
|
433
|
+
[exports.PayGasFee.code]: binary_parser_1.Parser.start(),
|
|
434
|
+
[exports.MinimalContractDeposit.code]: binary_parser_1.Parser.start(),
|
|
435
|
+
0xd2: binary_parser_1.Parser.start().uint8('immFields').uint8('mutFields')
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
encode(instr) {
|
|
440
|
+
const instrValue = instr.value;
|
|
441
|
+
const result = [instr.code];
|
|
442
|
+
const instrsWithIndex = [0x00, 0x01, 0x16, 0x17, 0xa0, 0xa1, 0xce];
|
|
443
|
+
const instrsWithCompactInt = [0x12, 0x13, 0x4a, 0x4b, 0x4c];
|
|
444
|
+
if (instr.code === 0x14) {
|
|
445
|
+
result.push(...bytestring_codec_1.byteStringCodec.encode(instrValue.value));
|
|
446
|
+
}
|
|
447
|
+
else if (instr.code === 0x15) {
|
|
448
|
+
result.push(...lockup_script_codec_1.lockupScriptCodec.encode(instrValue.value));
|
|
449
|
+
}
|
|
450
|
+
else if (instr.code === 0x7e) {
|
|
451
|
+
result.push(...byteStringArrayCodec.encode(instrValue.stringParts.value));
|
|
452
|
+
}
|
|
453
|
+
else if (instrsWithCompactInt.includes(instr.code)) {
|
|
454
|
+
result.push(...compact_int_codec_1.compactUnsignedIntCodec.encode(instrValue.value));
|
|
455
|
+
}
|
|
456
|
+
else if (instrsWithIndex.includes(instr.code)) {
|
|
457
|
+
result.push(instrValue.index);
|
|
458
|
+
}
|
|
459
|
+
else if (instr.code === 0xd2) {
|
|
460
|
+
const value = instrValue;
|
|
461
|
+
result.push(value.immFields, value.mutFields);
|
|
462
|
+
}
|
|
463
|
+
return buffer_1.Buffer.from(result);
|
|
464
|
+
}
|
|
465
|
+
decode(input) {
|
|
466
|
+
return this.parser.parse(input);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
exports.InstrCodec = InstrCodec;
|
|
470
|
+
exports.instrCodec = new InstrCodec();
|
|
471
|
+
exports.instrsCodec = new array_codec_1.ArrayCodec(exports.instrCodec);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Buffer } from 'buffer/';
|
|
2
|
+
import { Parser } from 'binary-parser';
|
|
3
|
+
import { DecodedCompactInt } from './compact-int-codec';
|
|
4
|
+
import { Codec } from './codec';
|
|
5
|
+
import { DecodedArray } from './array-codec';
|
|
6
|
+
export interface PublicKeyHash {
|
|
7
|
+
publicKeyHash: Buffer;
|
|
8
|
+
}
|
|
9
|
+
export interface MultiSig {
|
|
10
|
+
publicKeyHashes: DecodedArray<PublicKeyHash>;
|
|
11
|
+
m: DecodedCompactInt;
|
|
12
|
+
}
|
|
13
|
+
export interface P2SH {
|
|
14
|
+
scriptHash: Buffer;
|
|
15
|
+
}
|
|
16
|
+
export interface P2C {
|
|
17
|
+
contractId: Buffer;
|
|
18
|
+
}
|
|
19
|
+
export interface LockupScript {
|
|
20
|
+
scriptType: number;
|
|
21
|
+
script: PublicKeyHash | MultiSig | P2SH | P2C;
|
|
22
|
+
}
|
|
23
|
+
export declare class LockupScriptCodec implements Codec<LockupScript> {
|
|
24
|
+
parser: Parser;
|
|
25
|
+
encode(input: LockupScript): Buffer;
|
|
26
|
+
decode(input: Buffer): LockupScript;
|
|
27
|
+
}
|
|
28
|
+
export declare const lockupScriptCodec: LockupScriptCodec;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lockupScriptCodec = exports.LockupScriptCodec = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
6
|
+
This file is part of the alephium project.
|
|
7
|
+
|
|
8
|
+
The library is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
The library is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU Lesser General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
const buffer_1 = require("buffer/");
|
|
22
|
+
const binary_parser_1 = require("binary-parser");
|
|
23
|
+
const compact_int_codec_1 = require("./compact-int-codec");
|
|
24
|
+
const array_codec_1 = require("./array-codec");
|
|
25
|
+
class PublicKeyHashCodec {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.parser = binary_parser_1.Parser.start().buffer('publicKeyHash', { length: 32 });
|
|
28
|
+
}
|
|
29
|
+
encode(input) {
|
|
30
|
+
return input.publicKeyHash;
|
|
31
|
+
}
|
|
32
|
+
decode(input) {
|
|
33
|
+
return this.parser.parse(input);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const publicKeyHashCodec = new PublicKeyHashCodec();
|
|
37
|
+
const publicKeyHashesCodec = new array_codec_1.ArrayCodec(publicKeyHashCodec);
|
|
38
|
+
const multiSigParser = binary_parser_1.Parser.start()
|
|
39
|
+
.nest('publicKeyHashes', { type: publicKeyHashesCodec.parser })
|
|
40
|
+
.nest('m', { type: compact_int_codec_1.compactUnsignedIntCodec.parser });
|
|
41
|
+
class LockupScriptCodec {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.parser = binary_parser_1.Parser.start()
|
|
44
|
+
.uint8('scriptType')
|
|
45
|
+
.choice('script', {
|
|
46
|
+
tag: 'scriptType',
|
|
47
|
+
choices: {
|
|
48
|
+
0: publicKeyHashCodec.parser,
|
|
49
|
+
1: multiSigParser,
|
|
50
|
+
2: binary_parser_1.Parser.start().buffer('scriptHash', { length: 32 }),
|
|
51
|
+
3: binary_parser_1.Parser.start().buffer('contractId', { length: 32 })
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
encode(input) {
|
|
56
|
+
const result = [input.scriptType];
|
|
57
|
+
if (input.scriptType === 0) {
|
|
58
|
+
result.push(...input.script.publicKeyHash);
|
|
59
|
+
}
|
|
60
|
+
else if (input.scriptType === 1) {
|
|
61
|
+
result.push(...publicKeyHashesCodec.encode(input.script.publicKeyHashes.value));
|
|
62
|
+
result.push(...compact_int_codec_1.compactUnsignedIntCodec.encode(input.script.m));
|
|
63
|
+
}
|
|
64
|
+
else if (input.scriptType === 2) {
|
|
65
|
+
result.push(...input.script.scriptHash);
|
|
66
|
+
}
|
|
67
|
+
else if (input.scriptType === 3) {
|
|
68
|
+
result.push(...input.script.contractId);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(`Unsupported script type: ${input.scriptType}`);
|
|
72
|
+
}
|
|
73
|
+
return buffer_1.Buffer.from(result);
|
|
74
|
+
}
|
|
75
|
+
decode(input) {
|
|
76
|
+
return this.parser.parse(input);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.LockupScriptCodec = LockupScriptCodec;
|
|
80
|
+
exports.lockupScriptCodec = new LockupScriptCodec();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Buffer } from 'buffer/';
|
|
2
|
+
import { Parser } from 'binary-parser';
|
|
3
|
+
import { Codec } from './codec';
|
|
4
|
+
export declare class LongCodec implements Codec<bigint> {
|
|
5
|
+
parser: Parser;
|
|
6
|
+
encode(input: bigint): Buffer;
|
|
7
|
+
decode(bytes: Buffer): bigint;
|
|
8
|
+
}
|
|
9
|
+
export declare const longCodec: LongCodec;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.longCodec = exports.LongCodec = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2018 - 2022 The Alephium Authors
|
|
6
|
+
This file is part of the alephium project.
|
|
7
|
+
|
|
8
|
+
The library is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
The library is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU Lesser General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
const buffer_1 = require("buffer/");
|
|
22
|
+
const binary_parser_1 = require("binary-parser");
|
|
23
|
+
const codec_1 = require("./codec");
|
|
24
|
+
class LongCodec {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.parser = binary_parser_1.Parser.start().buffer('value', {
|
|
27
|
+
length: 8
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
encode(input) {
|
|
31
|
+
const byteArray = new Uint8Array(8);
|
|
32
|
+
(0, codec_1.assert)(byteArray.length <= 8, 'Length should be less than or equal to 8');
|
|
33
|
+
for (let index = 0; index < byteArray.length; index++) {
|
|
34
|
+
const byte = input & BigInt(0xff);
|
|
35
|
+
byteArray[byteArray.length - index - 1] = Number(byte);
|
|
36
|
+
input >>= BigInt(8);
|
|
37
|
+
}
|
|
38
|
+
return buffer_1.Buffer.from(byteArray);
|
|
39
|
+
}
|
|
40
|
+
decode(bytes) {
|
|
41
|
+
(0, codec_1.assert)(bytes.length == 8, 'Length should be 8');
|
|
42
|
+
let int64 = BigInt(0);
|
|
43
|
+
let pow = BigInt(1);
|
|
44
|
+
for (let i = bytes.length - 1; i >= 0; i--) {
|
|
45
|
+
int64 += BigInt(bytes[i]) * pow;
|
|
46
|
+
pow *= BigInt(256);
|
|
47
|
+
}
|
|
48
|
+
// Determine if the number is negative (check the sign bit of the first byte)
|
|
49
|
+
if (bytes[0] & 0x80) {
|
|
50
|
+
int64 -= BigInt(1) << BigInt(64);
|
|
51
|
+
}
|
|
52
|
+
return int64;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.LongCodec = LongCodec;
|
|
56
|
+
exports.longCodec = new LongCodec();
|