@alephium/web3 0.41.0 → 0.43.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/{utils → address}/address.js +15 -19
- package/dist/src/address/index.d.ts +1 -0
- package/dist/src/address/index.js +34 -0
- package/dist/src/api/node-provider.js +10 -9
- package/dist/src/api/types.js +1 -1
- package/dist/src/codec/array-codec.d.ts +2 -3
- package/dist/src/codec/array-codec.js +1 -2
- package/dist/src/codec/asset-output-codec.d.ts +3 -4
- package/dist/src/codec/asset-output-codec.js +10 -12
- package/dist/src/codec/bigint-codec.d.ts +2 -3
- package/dist/src/codec/bigint-codec.js +2 -3
- package/dist/src/codec/bytestring-codec.d.ts +5 -6
- package/dist/src/codec/bytestring-codec.js +5 -5
- package/dist/src/codec/codec.d.ts +2 -3
- package/dist/src/codec/compact-int-codec.d.ts +12 -13
- package/dist/src/codec/compact-int-codec.js +22 -22
- package/dist/src/codec/contract-codec.d.ts +5 -6
- package/dist/src/codec/contract-codec.js +24 -24
- package/dist/src/codec/contract-output-codec.d.ts +2 -3
- package/dist/src/codec/contract-output-codec.js +8 -10
- package/dist/src/codec/contract-output-ref-codec.d.ts +3 -4
- package/dist/src/codec/contract-output-ref-codec.js +2 -2
- package/dist/src/codec/either-codec.d.ts +2 -3
- package/dist/src/codec/either-codec.js +1 -2
- package/dist/src/codec/hash.d.ts +2 -3
- package/dist/src/codec/hash.js +17 -0
- package/dist/src/codec/input-codec.d.ts +3 -4
- package/dist/src/codec/input-codec.js +6 -6
- package/dist/src/codec/instr-codec.d.ts +2 -3
- package/dist/src/codec/instr-codec.js +1 -2
- package/dist/src/codec/lockup-script-codec.d.ts +5 -6
- package/dist/src/codec/lockup-script-codec.js +1 -2
- package/dist/src/codec/long-codec.d.ts +2 -3
- package/dist/src/codec/long-codec.js +1 -2
- package/dist/src/codec/method-codec.d.ts +2 -3
- package/dist/src/codec/method-codec.js +1 -2
- package/dist/src/codec/option-codec.d.ts +3 -4
- package/dist/src/codec/option-codec.js +2 -3
- package/dist/src/codec/script-codec.d.ts +4 -5
- package/dist/src/codec/script-codec.js +1 -3
- package/dist/src/codec/signature-codec.d.ts +3 -4
- package/dist/src/codec/signature-codec.js +17 -0
- package/dist/src/codec/signed-int-codec.d.ts +2 -3
- package/dist/src/codec/signed-int-codec.js +1 -2
- package/dist/src/codec/token-codec.d.ts +3 -4
- package/dist/src/codec/token-codec.js +3 -3
- package/dist/src/codec/transaction-codec.d.ts +4 -5
- package/dist/src/codec/transaction-codec.js +12 -13
- package/dist/src/codec/unlock-script-codec.d.ts +5 -6
- package/dist/src/codec/unlock-script-codec.js +14 -15
- package/dist/src/codec/unsigned-tx-codec.d.ts +4 -5
- package/dist/src/codec/unsigned-tx-codec.js +4 -5
- package/dist/src/contract/contract.d.ts +8 -95
- package/dist/src/contract/contract.js +31 -564
- package/dist/src/contract/ralph.d.ts +1 -1
- package/dist/src/contract/ralph.js +9 -10
- package/dist/src/{utils → exchange}/exchange.js +5 -5
- package/dist/src/exchange/index.d.ts +1 -0
- package/dist/src/exchange/index.js +25 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/signer/signer.js +4 -5
- package/dist/src/signer/tx-builder.js +3 -3
- package/dist/src/transaction/index.d.ts +1 -0
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/utils.d.ts +2 -0
- package/dist/src/transaction/utils.js +34 -0
- package/dist/src/utils/index.d.ts +0 -2
- package/dist/src/utils/index.js +0 -7
- package/dist/src/utils/sign.js +1 -1
- package/dist/src/utils/utils.d.ts +1 -0
- package/dist/src/utils/utils.js +30 -11
- package/dist/src/utils/webcrypto.js +3 -4
- package/package.json +1 -2
- package/src/{utils → address}/address.ts +15 -19
- package/src/address/index.ts +19 -0
- package/src/api/node-provider.ts +2 -9
- package/src/api/types.ts +2 -2
- package/src/codec/array-codec.ts +3 -4
- package/src/codec/asset-output-codec.ts +16 -18
- package/src/codec/bigint-codec.ts +4 -5
- package/src/codec/bytestring-codec.ts +8 -8
- package/src/codec/codec.ts +2 -3
- package/src/codec/compact-int-codec.ts +36 -37
- package/src/codec/contract-codec.ts +28 -27
- package/src/codec/contract-output-codec.ts +11 -13
- package/src/codec/contract-output-ref-codec.ts +5 -5
- package/src/codec/either-codec.ts +3 -4
- package/src/codec/hash.ts +2 -3
- package/src/codec/input-codec.ts +10 -10
- package/src/codec/instr-codec.ts +3 -4
- package/src/codec/lockup-script-codec.ts +8 -9
- package/src/codec/long-codec.ts +3 -4
- package/src/codec/method-codec.ts +3 -4
- package/src/codec/option-codec.ts +4 -5
- package/src/codec/script-codec.ts +5 -7
- package/src/codec/signature-codec.ts +3 -4
- package/src/codec/signed-int-codec.ts +3 -4
- package/src/codec/token-codec.ts +6 -6
- package/src/codec/transaction-codec.ts +17 -18
- package/src/codec/unlock-script-codec.ts +26 -27
- package/src/codec/unsigned-tx-codec.ts +10 -11
- package/src/contract/contract.ts +18 -790
- package/src/contract/ralph.ts +10 -11
- package/src/{utils → exchange}/exchange.ts +3 -11
- package/src/exchange/index.ts +19 -0
- package/src/index.ts +2 -0
- package/src/signer/signer.ts +2 -3
- package/src/signer/tx-builder.ts +2 -2
- package/src/transaction/index.ts +1 -0
- package/src/transaction/utils.ts +38 -0
- package/src/utils/index.ts +0 -2
- package/src/utils/sign.ts +1 -1
- package/src/utils/utils.ts +29 -10
- package/src/utils/webcrypto.ts +3 -4
- package/webpack.config.js +1 -6
- package/dist/src/utils/error.d.ts +0 -15
- package/dist/src/utils/error.js +0 -66
- package/src/utils/error.ts +0 -77
- /package/dist/src/{utils → address}/address.d.ts +0 -0
- /package/dist/src/{utils → exchange}/exchange.d.ts +0 -0
|
@@ -18,10 +18,10 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.tokensCodec = exports.tokenCodec = exports.TokenCodec = void 0;
|
|
21
|
-
const buffer_1 = require("buffer/");
|
|
22
21
|
const binary_parser_1 = require("binary-parser");
|
|
23
22
|
const compact_int_codec_1 = require("./compact-int-codec");
|
|
24
23
|
const array_codec_1 = require("./array-codec");
|
|
24
|
+
const utils_1 = require("../utils");
|
|
25
25
|
class TokenCodec {
|
|
26
26
|
constructor() {
|
|
27
27
|
this.parser = binary_parser_1.Parser.start()
|
|
@@ -34,8 +34,8 @@ class TokenCodec {
|
|
|
34
34
|
}
|
|
35
35
|
encode(input) {
|
|
36
36
|
const tokenId = input.tokenId;
|
|
37
|
-
const amount =
|
|
38
|
-
return
|
|
37
|
+
const amount = compact_int_codec_1.compactUnsignedIntCodec.encode(input.amount);
|
|
38
|
+
return (0, utils_1.concatBytes)([tokenId, amount]);
|
|
39
39
|
}
|
|
40
40
|
decode(input) {
|
|
41
41
|
return this.parser.parse(input);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Buffer } from 'buffer/';
|
|
2
1
|
import { Parser } from 'binary-parser';
|
|
3
2
|
import { DecodedArray } from './array-codec';
|
|
4
3
|
import { UnsignedTx } from './unsigned-tx-codec';
|
|
@@ -17,10 +16,10 @@ export interface Transaction {
|
|
|
17
16
|
}
|
|
18
17
|
export declare class TransactionCodec implements Codec<Transaction> {
|
|
19
18
|
parser: Parser;
|
|
20
|
-
encode(decodedTx: Transaction):
|
|
21
|
-
decode(input:
|
|
22
|
-
encodeApiTransaction(input: ApiTransaction):
|
|
23
|
-
decodeApiTransaction(input:
|
|
19
|
+
encode(decodedTx: Transaction): Uint8Array;
|
|
20
|
+
decode(input: Uint8Array): Transaction;
|
|
21
|
+
encodeApiTransaction(input: ApiTransaction): Uint8Array;
|
|
22
|
+
decodeApiTransaction(input: Uint8Array): ApiTransaction;
|
|
24
23
|
static toApiTransaction(transaction: Transaction): ApiTransaction;
|
|
25
24
|
static fromApiTransaction(tx: ApiTransaction): Transaction;
|
|
26
25
|
}
|
|
@@ -18,7 +18,6 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.transactionCodec = exports.TransactionCodec = void 0;
|
|
21
|
-
const buffer_1 = require("buffer/");
|
|
22
21
|
const binary_parser_1 = require("binary-parser");
|
|
23
22
|
const unsigned_tx_codec_1 = require("./unsigned-tx-codec");
|
|
24
23
|
const signature_codec_1 = require("./signature-codec");
|
|
@@ -48,13 +47,13 @@ class TransactionCodec {
|
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
encode(decodedTx) {
|
|
51
|
-
return
|
|
50
|
+
return (0, utils_1.concatBytes)([
|
|
52
51
|
unsigned_tx_codec_1.unsignedTxCodec.encode(decodedTx.unsigned),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
new Uint8Array([decodedTx.scriptExecutionOk]),
|
|
53
|
+
contract_output_ref_codec_1.contractOutputRefsCodec.encode(decodedTx.contractInputs.value),
|
|
54
|
+
output_codec_1.outputsCodec.encode(decodedTx.generatedOutputs.value),
|
|
55
|
+
signature_codec_1.signaturesCodec.encode(decodedTx.inputSignatures.value),
|
|
56
|
+
signature_codec_1.signaturesCodec.encode(decodedTx.scriptSignatures.value)
|
|
58
57
|
]);
|
|
59
58
|
}
|
|
60
59
|
decode(input) {
|
|
@@ -74,7 +73,7 @@ class TransactionCodec {
|
|
|
74
73
|
const scriptExecutionOk = !!transaction.scriptExecutionOk;
|
|
75
74
|
const contractInputs = transaction.contractInputs.value.map((contractInput) => {
|
|
76
75
|
const hint = contractInput.hint;
|
|
77
|
-
const key = contractInput.key
|
|
76
|
+
const key = (0, utils_1.binToHex)(contractInput.key);
|
|
78
77
|
return { hint, key };
|
|
79
78
|
});
|
|
80
79
|
const txIdBytes = (0, utils_1.hexToBinUnsafe)(txId);
|
|
@@ -87,15 +86,15 @@ class TransactionCodec {
|
|
|
87
86
|
return contract_output_codec_1.ContractOutputCodec.convertToApiContractOutput(txIdBytes, output.value, index);
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
|
-
const inputSignatures = transaction.inputSignatures.value.map((signature) => signature.value
|
|
91
|
-
const scriptSignatures = transaction.scriptSignatures.value.map((signature) => signature.value
|
|
89
|
+
const inputSignatures = transaction.inputSignatures.value.map((signature) => (0, utils_1.binToHex)(signature.value));
|
|
90
|
+
const scriptSignatures = transaction.scriptSignatures.value.map((signature) => (0, utils_1.binToHex)(signature.value));
|
|
92
91
|
return { unsigned, scriptExecutionOk, contractInputs, generatedOutputs, inputSignatures, scriptSignatures };
|
|
93
92
|
}
|
|
94
93
|
static fromApiTransaction(tx) {
|
|
95
94
|
const unsigned = unsigned_tx_codec_1.UnsignedTxCodec.fromApiUnsignedTx(tx.unsigned);
|
|
96
95
|
const scriptExecutionOk = tx.scriptExecutionOk ? 1 : 0;
|
|
97
96
|
const contractInputs = tx.contractInputs.map((contractInput) => {
|
|
98
|
-
return { hint: contractInput.hint, key:
|
|
97
|
+
return { hint: contractInput.hint, key: (0, utils_1.hexToBinUnsafe)(contractInput.key) };
|
|
99
98
|
});
|
|
100
99
|
const generatedOutputs = tx.generatedOutputs.map((output) => {
|
|
101
100
|
if (output.type === 'AssetOutput') {
|
|
@@ -109,10 +108,10 @@ class TransactionCodec {
|
|
|
109
108
|
}
|
|
110
109
|
});
|
|
111
110
|
const inputSignatures = tx.inputSignatures.map((signature) => {
|
|
112
|
-
return { value:
|
|
111
|
+
return { value: (0, utils_1.hexToBinUnsafe)(signature) };
|
|
113
112
|
});
|
|
114
113
|
const scriptSignatures = tx.scriptSignatures.map((signature) => {
|
|
115
|
-
return { value:
|
|
114
|
+
return { value: (0, utils_1.hexToBinUnsafe)(signature) };
|
|
116
115
|
});
|
|
117
116
|
return {
|
|
118
117
|
unsigned,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Buffer } from 'buffer/';
|
|
2
1
|
import { Parser } from 'binary-parser';
|
|
3
2
|
import { DecodedArray } from './array-codec';
|
|
4
3
|
import { DecodedCompactInt } from './compact-int-codec';
|
|
@@ -7,7 +6,7 @@ import { DecodedScript } from './script-codec';
|
|
|
7
6
|
import { ByteString } from './bytestring-codec';
|
|
8
7
|
import { LockupScript } from './lockup-script-codec';
|
|
9
8
|
export interface P2PKH {
|
|
10
|
-
publicKey:
|
|
9
|
+
publicKey: Uint8Array;
|
|
11
10
|
}
|
|
12
11
|
export interface P2MPKH {
|
|
13
12
|
publicKeys: DecodedArray<{
|
|
@@ -25,8 +24,8 @@ export interface P2SH {
|
|
|
25
24
|
}
|
|
26
25
|
export declare class P2SHCodec implements Codec<P2SH> {
|
|
27
26
|
parser: Parser;
|
|
28
|
-
encode(input: P2SH):
|
|
29
|
-
decode(input:
|
|
27
|
+
encode(input: P2SH): Uint8Array;
|
|
28
|
+
decode(input: Uint8Array): P2SH;
|
|
30
29
|
}
|
|
31
30
|
export interface UnlockScript {
|
|
32
31
|
scriptType: number;
|
|
@@ -34,7 +33,7 @@ export interface UnlockScript {
|
|
|
34
33
|
}
|
|
35
34
|
export declare class UnlockScriptCodec implements Codec<UnlockScript> {
|
|
36
35
|
parser: Parser;
|
|
37
|
-
encode(input: UnlockScript):
|
|
38
|
-
decode(input:
|
|
36
|
+
encode(input: UnlockScript): Uint8Array;
|
|
37
|
+
decode(input: Uint8Array): UnlockScript;
|
|
39
38
|
}
|
|
40
39
|
export declare const unlockScriptCodec: UnlockScriptCodec;
|
|
@@ -18,13 +18,13 @@ GNU Lesser General Public License for more details.
|
|
|
18
18
|
You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
const buffer_1 = require("buffer/");
|
|
22
21
|
const binary_parser_1 = require("binary-parser");
|
|
23
22
|
const array_codec_1 = require("./array-codec");
|
|
24
23
|
const compact_int_codec_1 = require("./compact-int-codec");
|
|
25
24
|
const script_codec_1 = require("./script-codec");
|
|
26
25
|
const bytestring_codec_1 = require("./bytestring-codec");
|
|
27
26
|
const lockup_script_codec_1 = require("./lockup-script-codec");
|
|
27
|
+
const utils_1 = require("../utils");
|
|
28
28
|
class P2PKHCodec {
|
|
29
29
|
constructor() {
|
|
30
30
|
this.parser = binary_parser_1.Parser.start().buffer('publicKey', { length: 33 });
|
|
@@ -46,10 +46,10 @@ class P2MPKHCodec {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
encode(input) {
|
|
49
|
-
return
|
|
50
|
-
|
|
49
|
+
return (0, utils_1.concatBytes)([
|
|
50
|
+
compact_int_codec_1.compactUnsignedIntCodec.encode(input.publicKeys.length),
|
|
51
51
|
...input.publicKeys.value.map((v) => {
|
|
52
|
-
return
|
|
52
|
+
return (0, utils_1.concatBytes)([v.publicKey.publicKey, compact_int_codec_1.compactUnsignedIntCodec.encode(v.index)]);
|
|
53
53
|
})
|
|
54
54
|
]);
|
|
55
55
|
}
|
|
@@ -77,23 +77,23 @@ class ValCodec {
|
|
|
77
77
|
const valType = input.type;
|
|
78
78
|
if (valType === 0x00) {
|
|
79
79
|
// Boolean
|
|
80
|
-
return
|
|
80
|
+
return new Uint8Array([valType, input.val]);
|
|
81
81
|
}
|
|
82
82
|
else if (valType === 0x01) {
|
|
83
83
|
// I256
|
|
84
|
-
return
|
|
84
|
+
return new Uint8Array([valType, ...compact_int_codec_1.compactUnsignedIntCodec.encode(input.val)]);
|
|
85
85
|
}
|
|
86
86
|
else if (valType === 0x02) {
|
|
87
87
|
// U256
|
|
88
|
-
return
|
|
88
|
+
return new Uint8Array([valType, ...compact_int_codec_1.compactUnsignedIntCodec.encode(input.val)]);
|
|
89
89
|
}
|
|
90
90
|
else if (valType === 0x03) {
|
|
91
91
|
// ByteVec
|
|
92
|
-
return
|
|
92
|
+
return new Uint8Array([valType, ...bytestring_codec_1.byteStringCodec.encode(input.val)]);
|
|
93
93
|
}
|
|
94
94
|
else if (valType === 0x04) {
|
|
95
95
|
// Address
|
|
96
|
-
return
|
|
96
|
+
return new Uint8Array([valType, ...lockup_script_codec_1.lockupScriptCodec.encode(input.val)]);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
99
|
throw new Error(`ValCodec: unsupported val type: ${valType}`);
|
|
@@ -116,7 +116,7 @@ class P2SHCodec {
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
encode(input) {
|
|
119
|
-
return
|
|
119
|
+
return (0, utils_1.concatBytes)([script_codec_1.scriptCodec.encode(input.script), valsCodec.encode(input.params.value)]);
|
|
120
120
|
}
|
|
121
121
|
decode(input) {
|
|
122
122
|
return this.parser.parse(input);
|
|
@@ -141,22 +141,21 @@ class UnlockScriptCodec {
|
|
|
141
141
|
encode(input) {
|
|
142
142
|
const scriptType = input.scriptType;
|
|
143
143
|
const inputUnLockScript = input.script;
|
|
144
|
-
const inputUnLockScriptType = buffer_1.Buffer.from([scriptType]);
|
|
145
144
|
if (scriptType === 0) {
|
|
146
145
|
// P2PKH
|
|
147
|
-
return
|
|
146
|
+
return new Uint8Array([scriptType, ...p2pkhCodec.encode(inputUnLockScript)]);
|
|
148
147
|
}
|
|
149
148
|
else if (scriptType === 1) {
|
|
150
149
|
// P2MPKH
|
|
151
|
-
return
|
|
150
|
+
return new Uint8Array([scriptType, ...p2mpkhCodec.encode(inputUnLockScript)]);
|
|
152
151
|
}
|
|
153
152
|
else if (scriptType === 2) {
|
|
154
153
|
// P2SH
|
|
155
|
-
return
|
|
154
|
+
return new Uint8Array([scriptType, ...p2shCodec.encode(inputUnLockScript)]);
|
|
156
155
|
}
|
|
157
156
|
else if (scriptType === 3) {
|
|
158
157
|
// SameAsPrevious
|
|
159
|
-
return
|
|
158
|
+
return new Uint8Array([scriptType]);
|
|
160
159
|
}
|
|
161
160
|
else {
|
|
162
161
|
throw new Error(`TODO: encode unlock script: ${scriptType}`);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Buffer } from 'buffer/';
|
|
2
1
|
import { Parser } from 'binary-parser';
|
|
3
2
|
import { UnsignedTx as ApiUnsignedTx } from '../api/api-alephium';
|
|
4
3
|
import { DecodedScript } from './script-codec';
|
|
@@ -19,10 +18,10 @@ export interface UnsignedTx {
|
|
|
19
18
|
}
|
|
20
19
|
export declare class UnsignedTxCodec implements Codec<UnsignedTx> {
|
|
21
20
|
parser: Parser;
|
|
22
|
-
encode(decodedUnsignedTx: UnsignedTx):
|
|
23
|
-
decode(input:
|
|
24
|
-
encodeApiUnsignedTx(input: ApiUnsignedTx):
|
|
25
|
-
decodeApiUnsignedTx(input:
|
|
21
|
+
encode(decodedUnsignedTx: UnsignedTx): Uint8Array;
|
|
22
|
+
decode(input: Uint8Array): UnsignedTx;
|
|
23
|
+
encodeApiUnsignedTx(input: ApiUnsignedTx): Uint8Array;
|
|
24
|
+
decodeApiUnsignedTx(input: Uint8Array): ApiUnsignedTx;
|
|
26
25
|
static txId(unsignedTx: UnsignedTx): string;
|
|
27
26
|
static toApiUnsignedTx(unsigned: UnsignedTx): ApiUnsignedTx;
|
|
28
27
|
static fromApiUnsignedTx(unsignedTx: ApiUnsignedTx): UnsignedTx;
|
|
@@ -18,7 +18,6 @@ GNU Lesser General Public License for more details.
|
|
|
18
18
|
You should have received a copy of the GNU Lesser General Public License
|
|
19
19
|
along with the library. If not, see <http://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
|
-
const buffer_1 = require("buffer/");
|
|
22
21
|
const binary_parser_1 = require("binary-parser");
|
|
23
22
|
const utils_1 = require("../utils");
|
|
24
23
|
const script_codec_1 = require("./script-codec");
|
|
@@ -48,8 +47,8 @@ class UnsignedTxCodec {
|
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
encode(decodedUnsignedTx) {
|
|
51
|
-
return
|
|
52
|
-
|
|
50
|
+
return (0, utils_1.concatBytes)([
|
|
51
|
+
new Uint8Array([decodedUnsignedTx.version, decodedUnsignedTx.networkId]),
|
|
53
52
|
script_codec_1.statefulScriptCodecOpt.encode(decodedUnsignedTx.statefulScript),
|
|
54
53
|
compact_int_codec_1.compactSignedIntCodec.encode(decodedUnsignedTx.gasAmount),
|
|
55
54
|
compact_int_codec_1.compactUnsignedIntCodec.encode(decodedUnsignedTx.gasPrice),
|
|
@@ -82,7 +81,7 @@ class UnsignedTxCodec {
|
|
|
82
81
|
const fixedOutputs = asset_output_codec_1.AssetOutputCodec.toFixedAssetOutputs(txIdBytes, unsigned.fixedOutputs.value);
|
|
83
82
|
let scriptOpt = undefined;
|
|
84
83
|
if (unsigned.statefulScript.option === 1) {
|
|
85
|
-
scriptOpt = script_codec_1.scriptCodec.encode(unsigned.statefulScript.value)
|
|
84
|
+
scriptOpt = (0, utils_1.binToHex)(script_codec_1.scriptCodec.encode(unsigned.statefulScript.value));
|
|
86
85
|
}
|
|
87
86
|
return { txId, version, networkId, gasAmount, scriptOpt, gasPrice, inputs, fixedOutputs };
|
|
88
87
|
}
|
|
@@ -95,7 +94,7 @@ class UnsignedTxCodec {
|
|
|
95
94
|
const inputs = input_codec_1.inputsCodec.fromArray(inputsValue);
|
|
96
95
|
const fixedOutputsValue = asset_output_codec_1.AssetOutputCodec.fromFixedAssetOutputs(unsignedTx.fixedOutputs);
|
|
97
96
|
const fixedOutputs = asset_output_codec_1.assetOutputsCodec.fromArray(fixedOutputsValue);
|
|
98
|
-
const statefulScript = script_codec_1.statefulScriptCodecOpt.
|
|
97
|
+
const statefulScript = script_codec_1.statefulScriptCodecOpt.fromBytes(unsignedTx.scriptOpt ? (0, utils_1.hexToBinUnsafe)(unsignedTx.scriptOpt) : undefined);
|
|
99
98
|
return { version, networkId, gasAmount, gasPrice, inputs, fixedOutputs, statefulScript };
|
|
100
99
|
}
|
|
101
100
|
}
|
|
@@ -12,60 +12,11 @@ export type Arguments = NamedVals;
|
|
|
12
12
|
export type Constant = node.Constant;
|
|
13
13
|
export type Enum = node.Enum;
|
|
14
14
|
export declare const StdIdFieldName = "__stdInterfaceId";
|
|
15
|
-
declare enum SourceKind {
|
|
16
|
-
Contract = 0,
|
|
17
|
-
Script = 1,
|
|
18
|
-
AbstractContract = 2,
|
|
19
|
-
Interface = 3,
|
|
20
|
-
Struct = 4
|
|
21
|
-
}
|
|
22
15
|
export type CompilerOptions = node.CompilerOptions & {
|
|
23
16
|
errorOnWarnings: boolean;
|
|
24
17
|
};
|
|
25
18
|
export declare const DEFAULT_NODE_COMPILER_OPTIONS: node.CompilerOptions;
|
|
26
19
|
export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
|
|
27
|
-
declare class TypedMatcher<T extends SourceKind> {
|
|
28
|
-
matcher: RegExp;
|
|
29
|
-
type: T;
|
|
30
|
-
constructor(pattern: string, type: T);
|
|
31
|
-
}
|
|
32
|
-
declare class SourceInfo {
|
|
33
|
-
type: SourceKind;
|
|
34
|
-
name: string;
|
|
35
|
-
contractRelativePath: string;
|
|
36
|
-
sourceCode: string;
|
|
37
|
-
sourceCodeHash: string;
|
|
38
|
-
isExternal: boolean;
|
|
39
|
-
getArtifactPath(artifactsRootDir: string): string;
|
|
40
|
-
constructor(type: SourceKind, name: string, sourceCode: string, sourceCodeHash: string, contractRelativePath: string, isExternal: boolean);
|
|
41
|
-
static from(type: SourceKind, name: string, sourceCode: string, contractRelativePath: string, isExternal: boolean): Promise<SourceInfo>;
|
|
42
|
-
}
|
|
43
|
-
declare class Compiled<T extends Artifact> {
|
|
44
|
-
sourceInfo: SourceInfo;
|
|
45
|
-
artifact: T;
|
|
46
|
-
warnings: string[];
|
|
47
|
-
constructor(sourceInfo: SourceInfo, artifact: T, warnings: string[]);
|
|
48
|
-
}
|
|
49
|
-
type CodeInfo = {
|
|
50
|
-
sourceFile: string;
|
|
51
|
-
sourceCodeHash: string;
|
|
52
|
-
bytecodeDebugPatch: string;
|
|
53
|
-
codeHashDebug: string;
|
|
54
|
-
warnings: string[];
|
|
55
|
-
};
|
|
56
|
-
export declare class ProjectArtifact {
|
|
57
|
-
static readonly artifactFileName = ".project.json";
|
|
58
|
-
fullNodeVersion: string;
|
|
59
|
-
compilerOptionsUsed: node.CompilerOptions;
|
|
60
|
-
infos: Map<string, CodeInfo>;
|
|
61
|
-
static checkCompilerOptionsParameter(compilerOptions: node.CompilerOptions): void;
|
|
62
|
-
constructor(fullNodeVersion: string, compilerOptionsUsed: node.CompilerOptions, infos: Map<string, CodeInfo>);
|
|
63
|
-
static isCodeChanged(current: ProjectArtifact, previous: ProjectArtifact): boolean;
|
|
64
|
-
saveToFile(rootPath: string): Promise<void>;
|
|
65
|
-
getChangedSources(sourceInfos: SourceInfo[]): SourceInfo[];
|
|
66
|
-
needToReCompile(compilerOptions: node.CompilerOptions, fullNodeVersion: string): boolean;
|
|
67
|
-
static from(rootPath: string): Promise<ProjectArtifact | undefined>;
|
|
68
|
-
}
|
|
69
20
|
export declare class Struct {
|
|
70
21
|
name: string;
|
|
71
22
|
fieldNames: string[];
|
|
@@ -76,43 +27,6 @@ export declare class Struct {
|
|
|
76
27
|
static fromStructSig(sig: node.StructSig): Struct;
|
|
77
28
|
toJson(): any;
|
|
78
29
|
}
|
|
79
|
-
export declare class Project {
|
|
80
|
-
sourceInfos: SourceInfo[];
|
|
81
|
-
contracts: Map<string, Compiled<Contract>>;
|
|
82
|
-
scripts: Map<string, Compiled<Script>>;
|
|
83
|
-
structs: Struct[];
|
|
84
|
-
projectArtifact: ProjectArtifact;
|
|
85
|
-
readonly contractsRootDir: string;
|
|
86
|
-
readonly artifactsRootDir: string;
|
|
87
|
-
static currentProject: Project;
|
|
88
|
-
static readonly importRegex: RegExp;
|
|
89
|
-
static readonly abstractContractMatcher: TypedMatcher<SourceKind>;
|
|
90
|
-
static readonly contractMatcher: TypedMatcher<SourceKind.Contract>;
|
|
91
|
-
static readonly interfaceMatcher: TypedMatcher<SourceKind.Interface>;
|
|
92
|
-
static readonly scriptMatcher: TypedMatcher<SourceKind.Script>;
|
|
93
|
-
static readonly structMatcher: TypedMatcher<SourceKind.Struct>;
|
|
94
|
-
static readonly matchers: TypedMatcher<SourceKind>[];
|
|
95
|
-
static buildProjectArtifact(fullNodeVersion: string, sourceInfos: SourceInfo[], contracts: Map<string, Compiled<Contract>>, scripts: Map<string, Compiled<Script>>, compilerOptions: node.CompilerOptions): ProjectArtifact;
|
|
96
|
-
private constructor();
|
|
97
|
-
static checkCompilerWarnings(warnings: string[], errorOnWarnings: boolean): void;
|
|
98
|
-
static contract(name: string): Contract;
|
|
99
|
-
static script(name: string): Script;
|
|
100
|
-
private static loadStructs;
|
|
101
|
-
private saveStructsToFile;
|
|
102
|
-
private saveArtifactsToFile;
|
|
103
|
-
private saveProjectArtifact;
|
|
104
|
-
contractByCodeHash(codeHash: string): Contract;
|
|
105
|
-
private static getCompileResult;
|
|
106
|
-
private static compile;
|
|
107
|
-
private static loadArtifacts;
|
|
108
|
-
private static getImportSourcePath;
|
|
109
|
-
private static handleImports;
|
|
110
|
-
private static loadSourceFile;
|
|
111
|
-
private static loadSourceFiles;
|
|
112
|
-
static readonly DEFAULT_CONTRACTS_DIR = "contracts";
|
|
113
|
-
static readonly DEFAULT_ARTIFACTS_DIR = "artifacts";
|
|
114
|
-
static build(compilerOptionsPartial?: Partial<CompilerOptions>, projectRootDir?: string, contractsRootDir?: string, artifactsRootDir?: string, defaultFullNodeVersion?: string | undefined, skipSaveArtifacts?: boolean): Promise<void>;
|
|
115
|
-
}
|
|
116
30
|
export declare abstract class Artifact {
|
|
117
31
|
readonly version: string;
|
|
118
32
|
readonly name: string;
|
|
@@ -153,18 +67,18 @@ export declare class Contract extends Artifact {
|
|
|
153
67
|
toApiContractStates(states?: ContractState[]): node.ContractState[] | undefined;
|
|
154
68
|
toApiTestContractParams(funcName: string, params: TestContractParams): node.TestContract;
|
|
155
69
|
fromApiContractState(state: node.ContractState): ContractState<Fields>;
|
|
156
|
-
static fromApiContractState(state: node.ContractState, getContractByCodeHash
|
|
70
|
+
static fromApiContractState(state: node.ContractState, getContractByCodeHash: (codeHash: string) => Contract): ContractState;
|
|
157
71
|
static ContractCreatedEventIndex: number;
|
|
158
72
|
static ContractCreatedEvent: EventSig;
|
|
159
73
|
static ContractDestroyedEventIndex: number;
|
|
160
74
|
static ContractDestroyedEvent: EventSig;
|
|
161
|
-
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined, txId: string, getContractByCodeHash
|
|
162
|
-
fromApiTestContractResult(methodName: string, result: node.TestContractResult, txId: string): TestContractResult<unknown>;
|
|
75
|
+
static fromApiEvent(event: node.ContractEventByTxId, codeHash: string | undefined, txId: string, getContractByCodeHash: (codeHash: string) => Contract): ContractEvent;
|
|
76
|
+
fromApiTestContractResult(methodName: string, result: node.TestContractResult, txId: string, getContractByCodeHash: (codeHash: string) => Contract): TestContractResult<unknown>;
|
|
163
77
|
txParamsForDeployment<P extends Fields>(signer: SignerProvider, params: DeployContractParams<P>): Promise<SignDeployContractTxParams>;
|
|
164
78
|
buildByteCodeToDeploy(initialFields: Fields, isDevnet: boolean): string;
|
|
165
|
-
static fromApiEvents(events: node.ContractEventByTxId[], addressToCodeHash: Map<string, string>, txId: string, getContractByCodeHash
|
|
79
|
+
static fromApiEvents(events: node.ContractEventByTxId[], addressToCodeHash: Map<string, string>, txId: string, getContractByCodeHash: (codeHash: string) => Contract): ContractEvent[];
|
|
166
80
|
toApiCallContract<T extends Arguments>(params: CallContractParams<T>, groupIndex: number, contractAddress: string, methodIndex: number): node.CallContract;
|
|
167
|
-
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash
|
|
81
|
+
fromApiCallContractResult(result: node.CallContractResult, txId: string, methodIndex: number, getContractByCodeHash: (codeHash: string) => Contract): CallContractResult<unknown>;
|
|
168
82
|
}
|
|
169
83
|
export declare class Script extends Artifact {
|
|
170
84
|
readonly bytecodeTemplate: string;
|
|
@@ -324,7 +238,7 @@ export declare function subscribeEventsFromContract<T extends Fields, M extends
|
|
|
324
238
|
export declare function addStdIdToFields<F extends Fields>(contract: Contract, fields: F): F | (F & {
|
|
325
239
|
__stdInterfaceId: HexString;
|
|
326
240
|
});
|
|
327
|
-
export declare function testMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R, M extends Record<string, Map<Val, Val>> = Record<string, Map<Val, Val>>>(factory: ContractFactory<I, F>, methodName: string, params: Optional<TestContractParams<F, A, M>, 'testArgs' | 'initialFields'
|
|
241
|
+
export declare function testMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R, M extends Record<string, Map<Val, Val>> = Record<string, Map<Val, Val>>>(factory: ContractFactory<I, F>, methodName: string, params: Optional<TestContractParams<F, A, M>, 'testArgs' | 'initialFields'>, getContractByCodeHash: (codeHash: string) => Contract): Promise<TestContractResult<R, M>>;
|
|
328
242
|
export declare class RalphMap<K extends Val, V extends Val> {
|
|
329
243
|
private readonly parentContract;
|
|
330
244
|
private readonly parentContractId;
|
|
@@ -352,9 +266,8 @@ export declare function subscribeContractDestroyedEvent(options: EventSubscribeO
|
|
|
352
266
|
export declare function decodeEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, event: node.ContractEvent, targetEventIndex: number): M;
|
|
353
267
|
export declare function subscribeContractEvent<F extends Fields, M extends ContractEvent<F>>(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<M>, eventName: string, fromCount?: number): EventSubscription;
|
|
354
268
|
export declare function subscribeContractEvents(contract: Contract, instance: ContractInstance, options: EventSubscribeOptions<ContractEvent<any>>, fromCount?: number): EventSubscription;
|
|
355
|
-
export declare function callMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R>(contract: ContractFactory<I, F>, instance: ContractInstance, methodName: string, params: Optional<CallContractParams<A>, 'args'>, getContractByCodeHash
|
|
356
|
-
export declare function multicallMethods<I extends ContractInstance, F extends Fields>(contract: ContractFactory<I, F>, instance: ContractInstance, calls: Record<string, Optional<CallContractParams<any>, 'args'>>, getContractByCodeHash
|
|
269
|
+
export declare function callMethod<I extends ContractInstance, F extends Fields, A extends Arguments, R>(contract: ContractFactory<I, F>, instance: ContractInstance, methodName: string, params: Optional<CallContractParams<A>, 'args'>, getContractByCodeHash: (codeHash: string) => Contract): Promise<CallContractResult<R>>;
|
|
270
|
+
export declare function multicallMethods<I extends ContractInstance, F extends Fields>(contract: ContractFactory<I, F>, instance: ContractInstance, calls: Record<string, Optional<CallContractParams<any>, 'args'>>, getContractByCodeHash: (codeHash: string) => Contract): Promise<Record<string, CallContractResult<any>>>;
|
|
357
271
|
export declare function getContractEventsCurrentCount(contractAddress: Address): Promise<number>;
|
|
358
272
|
export declare const getContractIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
359
273
|
export declare const getTokenIdFromUnsignedTx: (nodeProvider: NodeProvider, unsignedTx: string) => Promise<HexString>;
|
|
360
|
-
export {};
|