@alephium/web3 1.12.0-beta.0 → 1.12.0-danube.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/address/address.d.ts +1 -0
- package/dist/src/address/address.js +25 -23
- package/dist/src/api/api-alephium.d.ts +78 -124
- package/dist/src/api/api-alephium.js +0 -50
- package/dist/src/api/node-provider.d.ts +0 -2
- package/dist/src/api/node-provider.js +0 -1
- package/dist/src/contract/contract.d.ts +11 -6
- package/dist/src/contract/contract.js +35 -21
- package/dist/src/contract/deployment.d.ts +2 -0
- package/dist/src/signer/signer.d.ts +13 -13
- package/dist/src/signer/signer.js +84 -9
- package/dist/src/signer/tx-builder.d.ts +4 -10
- package/dist/src/signer/tx-builder.js +41 -67
- package/dist/src/signer/types.d.ts +14 -27
- package/dist/src/signer/types.js +0 -3
- package/dist/src/utils/sign.js +2 -2
- package/package.json +1 -1
- package/src/address/address.ts +25 -25
- package/src/api/api-alephium.ts +92 -172
- package/src/api/node-provider.ts +0 -3
- package/src/contract/contract.ts +45 -29
- package/src/contract/deployment.ts +2 -0
- package/src/signer/signer.ts +118 -24
- package/src/signer/tx-builder.ts +60 -99
- package/src/signer/types.ts +31 -39
- package/src/utils/sign.ts +2 -2
|
@@ -31,4 +31,5 @@ export declare function groupOfLockupScript(lockupScript: LockupScript): number;
|
|
|
31
31
|
export declare function groupFromBytes(bytes: Uint8Array): number;
|
|
32
32
|
export declare function groupFromHint(hint: number): number;
|
|
33
33
|
export declare function hasExplicitGroupIndex(address: string): boolean;
|
|
34
|
+
export declare function addressWithoutExplicitGroupIndex(address: string): string;
|
|
34
35
|
export declare function addressFromLockupScript(lockupScript: LockupScript): string;
|
|
@@ -43,7 +43,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
43
43
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
exports.addressFromLockupScript = exports.hasExplicitGroupIndex = exports.groupFromHint = exports.groupFromBytes = exports.groupOfLockupScript = exports.subContractId = exports.contractIdFromTx = exports.addressFromTokenId = exports.addressFromContractId = exports.addressFromScript = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isContractAddress = exports.defaultGroupOfGrouplessAddress = exports.isGrouplessAddressWithGroupIndex = exports.isGrouplessAddressWithoutGroupIndex = exports.isGrouplessAddress = exports.isAssetAddress = exports.addressToBytes = exports.isValidAddress = exports.validateAddress = exports.AddressType = void 0;
|
|
46
|
+
exports.addressFromLockupScript = exports.addressWithoutExplicitGroupIndex = exports.hasExplicitGroupIndex = exports.groupFromHint = exports.groupFromBytes = exports.groupOfLockupScript = exports.subContractId = exports.contractIdFromTx = exports.addressFromTokenId = exports.addressFromContractId = exports.addressFromScript = exports.addressFromPublicKey = exports.publicKeyFromPrivateKey = exports.groupOfPrivateKey = exports.tokenIdFromAddress = exports.contractIdFromAddress = exports.groupOfAddress = exports.isContractAddress = exports.defaultGroupOfGrouplessAddress = exports.isGrouplessAddressWithGroupIndex = exports.isGrouplessAddressWithoutGroupIndex = exports.isGrouplessAddress = exports.isAssetAddress = exports.addressToBytes = exports.isValidAddress = exports.validateAddress = exports.AddressType = void 0;
|
|
47
47
|
const elliptic_1 = require("elliptic");
|
|
48
48
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
49
49
|
const constants_1 = require("../constants");
|
|
@@ -108,32 +108,27 @@ function decodeAndValidateAddress(address) {
|
|
|
108
108
|
if (decoded.length === 33)
|
|
109
109
|
return decoded;
|
|
110
110
|
}
|
|
111
|
-
else if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
else if (addressType === AddressType.P2PK) {
|
|
112
|
+
if (decoded.length === 40) {
|
|
113
|
+
// [type, keyType, ...publicKey, ...checkSum, ...groupByte]
|
|
114
|
+
const publicKeyLikeBytes = decoded.slice(1, 35);
|
|
115
|
+
const checksum = (0, utils_1.binToHex)(decoded.slice(35, 39));
|
|
116
|
+
const expectedChecksum = (0, utils_1.binToHex)(codec_1.intAs4BytesCodec.encode((0, djb2_1.default)(publicKeyLikeBytes)));
|
|
117
|
+
if (checksum !== expectedChecksum) {
|
|
118
|
+
throw new Error(`Invalid checksum for P2PK address: ${address}`);
|
|
119
|
+
}
|
|
120
|
+
const group = codec_2.byteCodec.decode(decoded.slice(39, 40));
|
|
121
|
+
validateGroupIndex(group);
|
|
122
|
+
return decoded;
|
|
119
123
|
}
|
|
120
|
-
const group = codec_2.byteCodec.decode(decoded.slice(decoded.length - 1, decoded.length));
|
|
121
|
-
validateGroupIndex(group);
|
|
122
|
-
return decoded;
|
|
123
124
|
}
|
|
124
125
|
throw new Error(`Invalid address: ${address}`);
|
|
125
126
|
}
|
|
126
|
-
function isGrouplessAddressWithoutGroup(decoded) {
|
|
127
|
-
return decoded[0] === AddressType.P2PK && (decoded.length === 38 || decoded.length === 39);
|
|
128
|
-
}
|
|
129
|
-
function isGrouplessAddressWithGroup(decoded) {
|
|
130
|
-
return decoded[0] === AddressType.P2PK && (decoded.length === 39 || decoded.length === 40);
|
|
131
|
-
}
|
|
132
127
|
function addressToBytes(address) {
|
|
133
128
|
if (hasExplicitGroupIndex(address)) {
|
|
134
129
|
const groupIndex = parseGroupIndex(address[address.length - 1]);
|
|
135
130
|
const decoded = (0, bs58_1.base58ToBytes)(address.slice(0, address.length - 2));
|
|
136
|
-
if (
|
|
131
|
+
if (decoded[0] === 0x04 && decoded.length === 39) {
|
|
137
132
|
const groupByte = codec_2.byteCodec.encode(groupIndex);
|
|
138
133
|
return new Uint8Array([...decoded, ...groupByte]);
|
|
139
134
|
}
|
|
@@ -141,8 +136,8 @@ function addressToBytes(address) {
|
|
|
141
136
|
}
|
|
142
137
|
else {
|
|
143
138
|
const decoded = (0, bs58_1.base58ToBytes)(address);
|
|
144
|
-
if (
|
|
145
|
-
const group = defaultGroupOfGrouplessAddress(decoded.slice(2,
|
|
139
|
+
if (decoded[0] === 0x04 && decoded.length === 39) {
|
|
140
|
+
const group = defaultGroupOfGrouplessAddress(decoded.slice(2, 35));
|
|
146
141
|
const groupByte = codec_2.byteCodec.encode(group);
|
|
147
142
|
return new Uint8Array([...decoded, ...groupByte]);
|
|
148
143
|
}
|
|
@@ -245,7 +240,7 @@ function groupOfPrivateKey(privateKey, keyType) {
|
|
|
245
240
|
exports.groupOfPrivateKey = groupOfPrivateKey;
|
|
246
241
|
function publicKeyFromPrivateKey(privateKey, _keyType) {
|
|
247
242
|
const keyType = _keyType ?? 'default';
|
|
248
|
-
if (keyType === 'default' || keyType === '
|
|
243
|
+
if (keyType === 'default' || keyType === 'gl-secp256k1') {
|
|
249
244
|
const key = ec.keyFromPrivate(privateKey);
|
|
250
245
|
return key.getPublic(true, 'hex');
|
|
251
246
|
}
|
|
@@ -261,7 +256,7 @@ function addressFromPublicKey(publicKey, _keyType) {
|
|
|
261
256
|
const bytes = new Uint8Array([AddressType.P2PKH, ...hash]);
|
|
262
257
|
return bs58_1.default.encode(bytes);
|
|
263
258
|
}
|
|
264
|
-
else if (keyType === '
|
|
259
|
+
else if (keyType === 'gl-secp256k1') {
|
|
265
260
|
const publicKeyBytes = new Uint8Array([0x00, ...(0, utils_1.hexToBinUnsafe)(publicKey)]);
|
|
266
261
|
const hashBytes = codec_1.intAs4BytesCodec.encode((0, djb2_1.default)(publicKeyBytes));
|
|
267
262
|
const bytes = new Uint8Array([0x04, ...publicKeyBytes, ...hashBytes]);
|
|
@@ -348,6 +343,13 @@ function hasExplicitGroupIndex(address) {
|
|
|
348
343
|
return address.length > 2 && address[address.length - 2] === ':';
|
|
349
344
|
}
|
|
350
345
|
exports.hasExplicitGroupIndex = hasExplicitGroupIndex;
|
|
346
|
+
function addressWithoutExplicitGroupIndex(address) {
|
|
347
|
+
if (hasExplicitGroupIndex(address)) {
|
|
348
|
+
return address.slice(0, address.length - 2);
|
|
349
|
+
}
|
|
350
|
+
return address;
|
|
351
|
+
}
|
|
352
|
+
exports.addressWithoutExplicitGroupIndex = addressWithoutExplicitGroupIndex;
|
|
351
353
|
function addressFromLockupScript(lockupScript) {
|
|
352
354
|
if (lockupScript.kind === 'P2PK') {
|
|
353
355
|
const groupByte = lockup_script_codec_1.lockupScriptCodec.encode(lockupScript).slice(-1);
|
|
@@ -176,7 +176,7 @@ export interface BuildChainedDeployContractTx {
|
|
|
176
176
|
}
|
|
177
177
|
/** BuildChainedDeployContractTxResult */
|
|
178
178
|
export interface BuildChainedDeployContractTxResult {
|
|
179
|
-
value:
|
|
179
|
+
value: BuildSimpleDeployContractTxResult;
|
|
180
180
|
type: string;
|
|
181
181
|
}
|
|
182
182
|
/** BuildChainedExecuteScriptTx */
|
|
@@ -186,7 +186,7 @@ export interface BuildChainedExecuteScriptTx {
|
|
|
186
186
|
}
|
|
187
187
|
/** BuildChainedExecuteScriptTxResult */
|
|
188
188
|
export interface BuildChainedExecuteScriptTxResult {
|
|
189
|
-
value:
|
|
189
|
+
value: BuildSimpleExecuteScriptTxResult;
|
|
190
190
|
type: string;
|
|
191
191
|
}
|
|
192
192
|
/** BuildChainedTransferTx */
|
|
@@ -196,7 +196,7 @@ export interface BuildChainedTransferTx {
|
|
|
196
196
|
}
|
|
197
197
|
/** BuildChainedTransferTxResult */
|
|
198
198
|
export interface BuildChainedTransferTxResult {
|
|
199
|
-
value:
|
|
199
|
+
value: BuildSimpleTransferTxResult;
|
|
200
200
|
type: string;
|
|
201
201
|
}
|
|
202
202
|
/** BuildChainedTx */
|
|
@@ -222,25 +222,13 @@ export interface BuildDeployContractTx {
|
|
|
222
222
|
gasAmount?: number;
|
|
223
223
|
/** @format uint256 */
|
|
224
224
|
gasPrice?: string;
|
|
225
|
+
/** @format group-index */
|
|
226
|
+
group?: number;
|
|
225
227
|
/** @format block-hash */
|
|
226
228
|
targetBlockHash?: string;
|
|
227
229
|
}
|
|
228
230
|
/** BuildDeployContractTxResult */
|
|
229
|
-
export
|
|
230
|
-
/** @format int32 */
|
|
231
|
-
fromGroup: number;
|
|
232
|
-
/** @format int32 */
|
|
233
|
-
toGroup: number;
|
|
234
|
-
unsignedTx: string;
|
|
235
|
-
/** @format gas */
|
|
236
|
-
gasAmount: number;
|
|
237
|
-
/** @format uint256 */
|
|
238
|
-
gasPrice: string;
|
|
239
|
-
/** @format 32-byte-hash */
|
|
240
|
-
txId: string;
|
|
241
|
-
/** @format address */
|
|
242
|
-
contractAddress: string;
|
|
243
|
-
}
|
|
231
|
+
export type BuildDeployContractTxResult = BuildGrouplessDeployContractTxResult | BuildSimpleDeployContractTxResult;
|
|
244
232
|
/** BuildExecuteScriptTx */
|
|
245
233
|
export interface BuildExecuteScriptTx {
|
|
246
234
|
/** @format hex-string */
|
|
@@ -258,74 +246,30 @@ export interface BuildExecuteScriptTx {
|
|
|
258
246
|
gasPrice?: string;
|
|
259
247
|
/** @format block-hash */
|
|
260
248
|
targetBlockHash?: string;
|
|
249
|
+
/** @format group-index */
|
|
250
|
+
group?: number;
|
|
261
251
|
/** @format double */
|
|
262
252
|
gasEstimationMultiplier?: number;
|
|
263
253
|
}
|
|
264
254
|
/** BuildExecuteScriptTxResult */
|
|
265
|
-
export
|
|
266
|
-
/** @format int32 */
|
|
267
|
-
fromGroup: number;
|
|
268
|
-
/** @format int32 */
|
|
269
|
-
toGroup: number;
|
|
270
|
-
unsignedTx: string;
|
|
271
|
-
/** @format gas */
|
|
272
|
-
gasAmount: number;
|
|
273
|
-
/** @format uint256 */
|
|
274
|
-
gasPrice: string;
|
|
275
|
-
/** @format 32-byte-hash */
|
|
276
|
-
txId: string;
|
|
277
|
-
simulationResult: SimulationResult;
|
|
278
|
-
}
|
|
279
|
-
/** BuildGrouplessDeployContractTx */
|
|
280
|
-
export interface BuildGrouplessDeployContractTx {
|
|
281
|
-
fromAddress: string;
|
|
282
|
-
/** @format hex-string */
|
|
283
|
-
bytecode: string;
|
|
284
|
-
/** @format uint256 */
|
|
285
|
-
initialAttoAlphAmount?: string;
|
|
286
|
-
initialTokenAmounts?: Token[];
|
|
287
|
-
/** @format uint256 */
|
|
288
|
-
issueTokenAmount?: string;
|
|
289
|
-
/** @format address */
|
|
290
|
-
issueTokenTo?: string;
|
|
291
|
-
/** @format uint256 */
|
|
292
|
-
gasPrice?: string;
|
|
293
|
-
/** @format block-hash */
|
|
294
|
-
targetBlockHash?: string;
|
|
295
|
-
}
|
|
255
|
+
export type BuildExecuteScriptTxResult = BuildGrouplessExecuteScriptTxResult | BuildSimpleExecuteScriptTxResult;
|
|
296
256
|
/** BuildGrouplessDeployContractTxResult */
|
|
297
257
|
export interface BuildGrouplessDeployContractTxResult {
|
|
298
|
-
transferTxs:
|
|
299
|
-
deployContractTx:
|
|
300
|
-
|
|
301
|
-
/** BuildGrouplessExecuteScriptTx */
|
|
302
|
-
export interface BuildGrouplessExecuteScriptTx {
|
|
303
|
-
fromAddress: string;
|
|
304
|
-
/** @format hex-string */
|
|
305
|
-
bytecode: string;
|
|
306
|
-
/** @format uint256 */
|
|
307
|
-
attoAlphAmount?: string;
|
|
308
|
-
tokens?: Token[];
|
|
309
|
-
/** @format uint256 */
|
|
310
|
-
gasPrice?: string;
|
|
311
|
-
/** @format block-hash */
|
|
312
|
-
targetBlockHash?: string;
|
|
313
|
-
/** @format double */
|
|
314
|
-
gasEstimationMultiplier?: number;
|
|
258
|
+
transferTxs: BuildSimpleTransferTxResult[];
|
|
259
|
+
deployContractTx: BuildSimpleDeployContractTxResult;
|
|
260
|
+
type: string;
|
|
315
261
|
}
|
|
316
262
|
/** BuildGrouplessExecuteScriptTxResult */
|
|
317
263
|
export interface BuildGrouplessExecuteScriptTxResult {
|
|
318
|
-
transferTxs:
|
|
319
|
-
executeScriptTx:
|
|
264
|
+
transferTxs: BuildSimpleTransferTxResult[];
|
|
265
|
+
executeScriptTx: BuildSimpleExecuteScriptTxResult;
|
|
266
|
+
type: string;
|
|
320
267
|
}
|
|
321
|
-
/**
|
|
322
|
-
export interface
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
gasPrice?: string;
|
|
327
|
-
/** @format block-hash */
|
|
328
|
-
targetBlockHash?: string;
|
|
268
|
+
/** BuildGrouplessTransferTxResult */
|
|
269
|
+
export interface BuildGrouplessTransferTxResult {
|
|
270
|
+
transferTxs: BuildSimpleTransferTxResult[];
|
|
271
|
+
transferTx: BuildSimpleTransferTxResult;
|
|
272
|
+
type: string;
|
|
329
273
|
}
|
|
330
274
|
/** BuildInfo */
|
|
331
275
|
export interface BuildInfo {
|
|
@@ -362,6 +306,54 @@ export interface BuildMultisigAddressResult {
|
|
|
362
306
|
/** @format address */
|
|
363
307
|
address: string;
|
|
364
308
|
}
|
|
309
|
+
/** BuildSimpleDeployContractTxResult */
|
|
310
|
+
export interface BuildSimpleDeployContractTxResult {
|
|
311
|
+
/** @format int32 */
|
|
312
|
+
fromGroup: number;
|
|
313
|
+
/** @format int32 */
|
|
314
|
+
toGroup: number;
|
|
315
|
+
unsignedTx: string;
|
|
316
|
+
/** @format gas */
|
|
317
|
+
gasAmount: number;
|
|
318
|
+
/** @format uint256 */
|
|
319
|
+
gasPrice: string;
|
|
320
|
+
/** @format 32-byte-hash */
|
|
321
|
+
txId: string;
|
|
322
|
+
/** @format address */
|
|
323
|
+
contractAddress: string;
|
|
324
|
+
type: string;
|
|
325
|
+
}
|
|
326
|
+
/** BuildSimpleExecuteScriptTxResult */
|
|
327
|
+
export interface BuildSimpleExecuteScriptTxResult {
|
|
328
|
+
/** @format int32 */
|
|
329
|
+
fromGroup: number;
|
|
330
|
+
/** @format int32 */
|
|
331
|
+
toGroup: number;
|
|
332
|
+
unsignedTx: string;
|
|
333
|
+
/** @format gas */
|
|
334
|
+
gasAmount: number;
|
|
335
|
+
/** @format uint256 */
|
|
336
|
+
gasPrice: string;
|
|
337
|
+
/** @format 32-byte-hash */
|
|
338
|
+
txId: string;
|
|
339
|
+
simulationResult: SimulationResult;
|
|
340
|
+
type: string;
|
|
341
|
+
}
|
|
342
|
+
/** BuildSimpleTransferTxResult */
|
|
343
|
+
export interface BuildSimpleTransferTxResult {
|
|
344
|
+
unsignedTx: string;
|
|
345
|
+
/** @format gas */
|
|
346
|
+
gasAmount: number;
|
|
347
|
+
/** @format uint256 */
|
|
348
|
+
gasPrice: string;
|
|
349
|
+
/** @format 32-byte-hash */
|
|
350
|
+
txId: string;
|
|
351
|
+
/** @format int32 */
|
|
352
|
+
fromGroup: number;
|
|
353
|
+
/** @format int32 */
|
|
354
|
+
toGroup: number;
|
|
355
|
+
type: string;
|
|
356
|
+
}
|
|
365
357
|
/** BuildSweepAddressTransactions */
|
|
366
358
|
export interface BuildSweepAddressTransactions {
|
|
367
359
|
/** @format public-key */
|
|
@@ -421,23 +413,13 @@ export interface BuildTransferTx {
|
|
|
421
413
|
gasAmount?: number;
|
|
422
414
|
/** @format uint256 */
|
|
423
415
|
gasPrice?: string;
|
|
416
|
+
/** @format group-index */
|
|
417
|
+
group?: number;
|
|
424
418
|
/** @format block-hash */
|
|
425
419
|
targetBlockHash?: string;
|
|
426
420
|
}
|
|
427
421
|
/** BuildTransferTxResult */
|
|
428
|
-
export
|
|
429
|
-
unsignedTx: string;
|
|
430
|
-
/** @format gas */
|
|
431
|
-
gasAmount: number;
|
|
432
|
-
/** @format uint256 */
|
|
433
|
-
gasPrice: string;
|
|
434
|
-
/** @format 32-byte-hash */
|
|
435
|
-
txId: string;
|
|
436
|
-
/** @format int32 */
|
|
437
|
-
fromGroup: number;
|
|
438
|
-
/** @format int32 */
|
|
439
|
-
toGroup: number;
|
|
440
|
-
}
|
|
422
|
+
export type BuildTransferTxResult = BuildGrouplessTransferTxResult | BuildSimpleTransferTxResult;
|
|
441
423
|
/** CallContract */
|
|
442
424
|
export interface CallContract {
|
|
443
425
|
/** @format int32 */
|
|
@@ -1133,6 +1115,7 @@ export interface TestContract {
|
|
|
1133
1115
|
args?: Val[];
|
|
1134
1116
|
existingContracts?: ContractState[];
|
|
1135
1117
|
inputAssets?: TestInputAsset[];
|
|
1118
|
+
dustAmount?: string;
|
|
1136
1119
|
}
|
|
1137
1120
|
/** TestContractResult */
|
|
1138
1121
|
export interface TestContractResult {
|
|
@@ -1909,7 +1892,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1909
1892
|
* @summary Build an unsigned transfer transaction to a number of recipients
|
|
1910
1893
|
* @request POST:/transactions/build
|
|
1911
1894
|
*/
|
|
1912
|
-
postTransactionsBuild: (data: BuildTransferTx, params?: RequestParams) => Promise<
|
|
1895
|
+
postTransactionsBuild: (data: BuildTransferTx, params?: RequestParams) => Promise<BuildSimpleTransferTxResult | BuildGrouplessTransferTxResult>;
|
|
1913
1896
|
/**
|
|
1914
1897
|
* No description
|
|
1915
1898
|
*
|
|
@@ -1918,7 +1901,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1918
1901
|
* @summary Build unsigned transfer transactions from an address of one group to addresses of many groups. Each target group requires a dedicated transaction or more in case large number of outputs needed to be split.
|
|
1919
1902
|
* @request POST:/transactions/build-transfer-from-one-to-many-groups
|
|
1920
1903
|
*/
|
|
1921
|
-
postTransactionsBuildTransferFromOneToManyGroups: (data: BuildTransferTx, params?: RequestParams) => Promise<
|
|
1904
|
+
postTransactionsBuildTransferFromOneToManyGroups: (data: BuildTransferTx, params?: RequestParams) => Promise<BuildSimpleTransferTxResult[]>;
|
|
1922
1905
|
/**
|
|
1923
1906
|
* No description
|
|
1924
1907
|
*
|
|
@@ -1927,7 +1910,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
1927
1910
|
* @summary Build an unsigned transaction with multiple addresses to a number of recipients
|
|
1928
1911
|
* @request POST:/transactions/build-multi-addresses
|
|
1929
1912
|
*/
|
|
1930
|
-
postTransactionsBuildMultiAddresses: (data: BuildMultiAddressesTransaction, params?: RequestParams) => Promise<
|
|
1913
|
+
postTransactionsBuildMultiAddresses: (data: BuildMultiAddressesTransaction, params?: RequestParams) => Promise<BuildSimpleTransferTxResult>;
|
|
1931
1914
|
/**
|
|
1932
1915
|
* No description
|
|
1933
1916
|
*
|
|
@@ -2096,7 +2079,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
2096
2079
|
* @summary Build an unsigned script
|
|
2097
2080
|
* @request POST:/contracts/unsigned-tx/execute-script
|
|
2098
2081
|
*/
|
|
2099
|
-
postContractsUnsignedTxExecuteScript: (data: BuildExecuteScriptTx, params?: RequestParams) => Promise<
|
|
2082
|
+
postContractsUnsignedTxExecuteScript: (data: BuildExecuteScriptTx, params?: RequestParams) => Promise<BuildSimpleExecuteScriptTxResult | BuildGrouplessExecuteScriptTxResult>;
|
|
2100
2083
|
/**
|
|
2101
2084
|
* No description
|
|
2102
2085
|
*
|
|
@@ -2123,7 +2106,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
2123
2106
|
* @summary Build an unsigned contract
|
|
2124
2107
|
* @request POST:/contracts/unsigned-tx/deploy-contract
|
|
2125
2108
|
*/
|
|
2126
|
-
postContractsUnsignedTxDeployContract: (data: BuildDeployContractTx, params?: RequestParams) => Promise<
|
|
2109
|
+
postContractsUnsignedTxDeployContract: (data: BuildDeployContractTx, params?: RequestParams) => Promise<BuildSimpleDeployContractTxResult | BuildGrouplessDeployContractTxResult>;
|
|
2127
2110
|
/**
|
|
2128
2111
|
* No description
|
|
2129
2112
|
*
|
|
@@ -2229,7 +2212,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
2229
2212
|
* @summary Build a multisig unsigned transaction
|
|
2230
2213
|
* @request POST:/multisig/build
|
|
2231
2214
|
*/
|
|
2232
|
-
postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<
|
|
2215
|
+
postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<BuildSimpleTransferTxResult>;
|
|
2233
2216
|
/**
|
|
2234
2217
|
* No description
|
|
2235
2218
|
*
|
|
@@ -2374,34 +2357,5 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
|
|
|
2374
2357
|
*/
|
|
2375
2358
|
putUtilsCheckHashIndexing: (params?: RequestParams) => Promise<void>;
|
|
2376
2359
|
};
|
|
2377
|
-
groupless: {
|
|
2378
|
-
/**
|
|
2379
|
-
* No description
|
|
2380
|
-
*
|
|
2381
|
-
* @tags Groupless
|
|
2382
|
-
* @name PostGrouplessTransfer
|
|
2383
|
-
* @summary Build unsigned transfer transactions from a groupless address
|
|
2384
|
-
* @request POST:/groupless/transfer
|
|
2385
|
-
*/
|
|
2386
|
-
postGrouplessTransfer: (data: BuildGrouplessTransferTx, params?: RequestParams) => Promise<BuildTransferTxResult[]>;
|
|
2387
|
-
/**
|
|
2388
|
-
* No description
|
|
2389
|
-
*
|
|
2390
|
-
* @tags Groupless
|
|
2391
|
-
* @name PostGrouplessExecuteScript
|
|
2392
|
-
* @summary Build an unsigned execute script transaction from a groupless address
|
|
2393
|
-
* @request POST:/groupless/execute-script
|
|
2394
|
-
*/
|
|
2395
|
-
postGrouplessExecuteScript: (data: BuildGrouplessExecuteScriptTx, params?: RequestParams) => Promise<BuildGrouplessExecuteScriptTxResult>;
|
|
2396
|
-
/**
|
|
2397
|
-
* No description
|
|
2398
|
-
*
|
|
2399
|
-
* @tags Groupless
|
|
2400
|
-
* @name PostGrouplessDeployContract
|
|
2401
|
-
* @summary Build an unsigned deploy contract transaction from a groupless address
|
|
2402
|
-
* @request POST:/groupless/deploy-contract
|
|
2403
|
-
*/
|
|
2404
|
-
postGrouplessDeployContract: (data: BuildGrouplessDeployContractTx, params?: RequestParams) => Promise<BuildGrouplessDeployContractTxResult>;
|
|
2405
|
-
};
|
|
2406
2360
|
}
|
|
2407
2361
|
export {};
|
|
@@ -1547,56 +1547,6 @@ class Api extends HttpClient {
|
|
|
1547
1547
|
...params
|
|
1548
1548
|
}).then(utils_1.convertHttpResponse)
|
|
1549
1549
|
};
|
|
1550
|
-
this.groupless = {
|
|
1551
|
-
/**
|
|
1552
|
-
* No description
|
|
1553
|
-
*
|
|
1554
|
-
* @tags Groupless
|
|
1555
|
-
* @name PostGrouplessTransfer
|
|
1556
|
-
* @summary Build unsigned transfer transactions from a groupless address
|
|
1557
|
-
* @request POST:/groupless/transfer
|
|
1558
|
-
*/
|
|
1559
|
-
postGrouplessTransfer: (data, params = {}) => this.request({
|
|
1560
|
-
path: `/groupless/transfer`,
|
|
1561
|
-
method: 'POST',
|
|
1562
|
-
body: data,
|
|
1563
|
-
type: ContentType.Json,
|
|
1564
|
-
format: 'json',
|
|
1565
|
-
...params
|
|
1566
|
-
}).then(utils_1.convertHttpResponse),
|
|
1567
|
-
/**
|
|
1568
|
-
* No description
|
|
1569
|
-
*
|
|
1570
|
-
* @tags Groupless
|
|
1571
|
-
* @name PostGrouplessExecuteScript
|
|
1572
|
-
* @summary Build an unsigned execute script transaction from a groupless address
|
|
1573
|
-
* @request POST:/groupless/execute-script
|
|
1574
|
-
*/
|
|
1575
|
-
postGrouplessExecuteScript: (data, params = {}) => this.request({
|
|
1576
|
-
path: `/groupless/execute-script`,
|
|
1577
|
-
method: 'POST',
|
|
1578
|
-
body: data,
|
|
1579
|
-
type: ContentType.Json,
|
|
1580
|
-
format: 'json',
|
|
1581
|
-
...params
|
|
1582
|
-
}).then(utils_1.convertHttpResponse),
|
|
1583
|
-
/**
|
|
1584
|
-
* No description
|
|
1585
|
-
*
|
|
1586
|
-
* @tags Groupless
|
|
1587
|
-
* @name PostGrouplessDeployContract
|
|
1588
|
-
* @summary Build an unsigned deploy contract transaction from a groupless address
|
|
1589
|
-
* @request POST:/groupless/deploy-contract
|
|
1590
|
-
*/
|
|
1591
|
-
postGrouplessDeployContract: (data, params = {}) => this.request({
|
|
1592
|
-
path: `/groupless/deploy-contract`,
|
|
1593
|
-
method: 'POST',
|
|
1594
|
-
body: data,
|
|
1595
|
-
type: ContentType.Json,
|
|
1596
|
-
format: 'json',
|
|
1597
|
-
...params
|
|
1598
|
-
}).then(utils_1.convertHttpResponse)
|
|
1599
|
-
};
|
|
1600
1550
|
}
|
|
1601
1551
|
}
|
|
1602
1552
|
exports.Api = Api;
|
|
@@ -14,7 +14,6 @@ interface NodeProviderApis {
|
|
|
14
14
|
utils: NodeApi<string>['utils'];
|
|
15
15
|
miners: NodeApi<string>['miners'];
|
|
16
16
|
events: NodeApi<string>['events'];
|
|
17
|
-
groupless: NodeApi<string>['groupless'];
|
|
18
17
|
}
|
|
19
18
|
export declare class NodeProvider implements NodeProviderApis {
|
|
20
19
|
readonly wallets: NodeApi<string>['wallets'];
|
|
@@ -28,7 +27,6 @@ export declare class NodeProvider implements NodeProviderApis {
|
|
|
28
27
|
readonly utils: NodeApi<string>['utils'];
|
|
29
28
|
readonly miners: NodeApi<string>['miners'];
|
|
30
29
|
readonly events: NodeApi<string>['events'];
|
|
31
|
-
readonly groupless: NodeApi<string>['groupless'];
|
|
32
30
|
constructor(baseUrl: string, apiKey?: string, customFetch?: typeof fetch);
|
|
33
31
|
constructor(provider: NodeProvider);
|
|
34
32
|
constructor(handler: ApiRequestHandler);
|
|
@@ -185,7 +185,6 @@ class NodeProvider {
|
|
|
185
185
|
this.utils = { ...nodeApi.utils };
|
|
186
186
|
this.miners = { ...nodeApi.miners };
|
|
187
187
|
this.events = { ...nodeApi.events };
|
|
188
|
-
this.groupless = { ...nodeApi.groupless };
|
|
189
188
|
(0, types_1.requestWithLog)(this);
|
|
190
189
|
}
|
|
191
190
|
// This can prevent the proxied node provider from being modified
|
|
@@ -3,6 +3,7 @@ import { SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScri
|
|
|
3
3
|
import { Optional, HexString } from '../utils';
|
|
4
4
|
import { EventSubscribeOptions, EventSubscription } from './events';
|
|
5
5
|
import { contract, Method } from '../codec';
|
|
6
|
+
import { SimulationResult } from '../api/api-alephium';
|
|
6
7
|
export type FieldsSig = node.FieldsSig;
|
|
7
8
|
export type MapsSig = node.MapsSig;
|
|
8
9
|
export type EventSig = node.EventSig;
|
|
@@ -100,7 +101,7 @@ export declare class Script extends Artifact {
|
|
|
100
101
|
static fromJson(artifact: any, bytecodeDebugPatch?: string, structs?: Struct[]): Script;
|
|
101
102
|
static fromArtifactFile(path: string, bytecodeDebugPatch: string, structs?: Struct[]): Promise<Script>;
|
|
102
103
|
toString(): string;
|
|
103
|
-
txParamsForExecution<P extends Fields>(
|
|
104
|
+
txParamsForExecution<P extends Fields>(params: ExecuteScriptParams<P>): Promise<SignExecuteScriptTxParams>;
|
|
104
105
|
buildByteCodeToDeploy(initialFields: Fields): string;
|
|
105
106
|
}
|
|
106
107
|
export declare function fromApiFields(immFields: node.Val[], mutFields: node.Val[], fieldsSig: FieldsSig, structs: Struct[]): NamedVals;
|
|
@@ -131,7 +132,7 @@ export interface ContractStateWithMaps<T extends Fields = Fields, M extends Reco
|
|
|
131
132
|
export type TestContractParamsWithoutMaps<F extends Fields = Fields, A extends Arguments = Arguments> = Omit<TestContractParams<F, A>, 'initialMaps'>;
|
|
132
133
|
export interface TestContractParams<F extends Fields = Fields, A extends Arguments = Arguments, M extends Record<string, Map<Val, Val>> = Record<string, Map<Val, Val>>> {
|
|
133
134
|
group?: number;
|
|
134
|
-
|
|
135
|
+
contractAddress?: string;
|
|
135
136
|
callerContractAddress?: string;
|
|
136
137
|
blockHash?: string;
|
|
137
138
|
blockTimeStamp?: number;
|
|
@@ -139,9 +140,10 @@ export interface TestContractParams<F extends Fields = Fields, A extends Argumen
|
|
|
139
140
|
initialFields: F;
|
|
140
141
|
initialMaps?: M;
|
|
141
142
|
initialAsset?: Asset;
|
|
142
|
-
|
|
143
|
+
args: A;
|
|
143
144
|
existingContracts?: ContractStateWithMaps[];
|
|
144
145
|
inputAssets?: InputAsset[];
|
|
146
|
+
dustAmount?: Number256;
|
|
145
147
|
}
|
|
146
148
|
export interface ContractEvent<T extends Fields = Fields> {
|
|
147
149
|
txId: string;
|
|
@@ -187,6 +189,7 @@ export interface DeployContractParams<P extends Fields = Fields> {
|
|
|
187
189
|
gasAmount?: number;
|
|
188
190
|
gasPrice?: Number256;
|
|
189
191
|
exposePrivateFunctions?: boolean;
|
|
192
|
+
group?: number;
|
|
190
193
|
}
|
|
191
194
|
export type DeployContractResult<T extends ContractInstance> = Omit<SignDeployContractTxResult, 'contractId' | 'contractAddress' | 'groupIndex'> & {
|
|
192
195
|
contractInstance: T;
|
|
@@ -203,11 +206,12 @@ export declare class ExecutableScript<P extends Fields = Fields, R extends Val |
|
|
|
203
206
|
readonly script: Script;
|
|
204
207
|
readonly getContractByCodeHash: (codeHash: string) => Contract;
|
|
205
208
|
constructor(script: Script, getContractByCodeHash: (codeHash: string) => Contract);
|
|
206
|
-
execute(
|
|
209
|
+
execute(params: ExecuteScriptParams<P>): Promise<ExecuteScriptResult>;
|
|
207
210
|
call(params: CallScriptParams<P>): Promise<CallScriptResult<R>>;
|
|
208
211
|
}
|
|
209
212
|
export interface ExecuteScriptParams<P extends Fields = Fields> {
|
|
210
213
|
initialFields: P;
|
|
214
|
+
signer: SignerProvider;
|
|
211
215
|
attoAlphAmount?: Number256;
|
|
212
216
|
tokens?: Token[];
|
|
213
217
|
gasAmount?: number;
|
|
@@ -220,6 +224,7 @@ export interface ExecuteScriptResult {
|
|
|
220
224
|
signature: string;
|
|
221
225
|
gasAmount: number;
|
|
222
226
|
gasPrice: Number256;
|
|
227
|
+
simulationResult: SimulationResult;
|
|
223
228
|
}
|
|
224
229
|
export interface CallScriptParams<P extends Fields = Fields> {
|
|
225
230
|
initialFields: P;
|
|
@@ -273,11 +278,11 @@ export declare function subscribeEventsFromContract<T extends Fields, M extends
|
|
|
273
278
|
export declare function addStdIdToFields<F extends Fields>(contract: Contract, fields: F): F | (F & {
|
|
274
279
|
__stdInterfaceId: HexString;
|
|
275
280
|
});
|
|
276
|
-
export declare function extractMapsFromApiResult(selfAddress: string, params: Optional<TestContractParams, '
|
|
281
|
+
export declare function extractMapsFromApiResult(selfAddress: string, params: Optional<TestContractParams, 'args' | 'initialFields'>, group: number, apiResult: node.TestContractResult, getContractByCodeHash: (codeHash: string) => Contract): {
|
|
277
282
|
address: string;
|
|
278
283
|
maps: Record<string, Map<Val, Val>>;
|
|
279
284
|
}[];
|
|
280
|
-
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>, '
|
|
285
|
+
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>, 'args' | 'initialFields'>, getContractByCodeHash: (codeHash: string) => Contract): Promise<TestContractResult<R, M>>;
|
|
281
286
|
export declare function getDebugMessagesFromTx(txId: HexString, provider?: NodeProvider): Promise<{
|
|
282
287
|
contractAddress: string;
|
|
283
288
|
message: string;
|