@alephium/web3 1.7.4 → 1.8.1

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.
@@ -161,6 +161,40 @@ export interface BrokerInfo {
161
161
  port: number;
162
162
  };
163
163
  }
164
+ /** BuildChainedDeployContractTx */
165
+ export interface BuildChainedDeployContractTx {
166
+ value: BuildDeployContractTx;
167
+ type: string;
168
+ }
169
+ /** BuildChainedDeployContractTxResult */
170
+ export interface BuildChainedDeployContractTxResult {
171
+ value: BuildDeployContractTxResult;
172
+ type: string;
173
+ }
174
+ /** BuildChainedExecuteScriptTx */
175
+ export interface BuildChainedExecuteScriptTx {
176
+ value: BuildExecuteScriptTx;
177
+ type: string;
178
+ }
179
+ /** BuildChainedExecuteScriptTxResult */
180
+ export interface BuildChainedExecuteScriptTxResult {
181
+ value: BuildExecuteScriptTxResult;
182
+ type: string;
183
+ }
184
+ /** BuildChainedTransferTx */
185
+ export interface BuildChainedTransferTx {
186
+ value: BuildTransferTx;
187
+ type: string;
188
+ }
189
+ /** BuildChainedTransferTxResult */
190
+ export interface BuildChainedTransferTxResult {
191
+ value: BuildTransferTxResult;
192
+ type: string;
193
+ }
194
+ /** BuildChainedTx */
195
+ export type BuildChainedTx = BuildChainedDeployContractTx | BuildChainedExecuteScriptTx | BuildChainedTransferTx;
196
+ /** BuildChainedTxResult */
197
+ export type BuildChainedTxResult = BuildChainedDeployContractTxResult | BuildChainedExecuteScriptTxResult | BuildChainedTransferTxResult;
164
198
  /** BuildDeployContractTx */
165
199
  export interface BuildDeployContractTx {
166
200
  /** @format hex-string */
@@ -313,8 +347,8 @@ export interface BuildSweepMultisig {
313
347
  /** @format block-hash */
314
348
  targetBlockHash?: string;
315
349
  }
316
- /** BuildTransaction */
317
- export interface BuildTransaction {
350
+ /** BuildTransferTx */
351
+ export interface BuildTransferTx {
318
352
  /** @format hex-string */
319
353
  fromPublicKey: string;
320
354
  /** @format hex-string */
@@ -328,8 +362,8 @@ export interface BuildTransaction {
328
362
  /** @format block-hash */
329
363
  targetBlockHash?: string;
330
364
  }
331
- /** BuildTransactionResult */
332
- export interface BuildTransactionResult {
365
+ /** BuildTransferTxResult */
366
+ export interface BuildTransferTxResult {
333
367
  unsignedTx: string;
334
368
  /** @format gas */
335
369
  gasAmount: number;
@@ -1070,6 +1104,8 @@ export interface TransactionTemplate {
1070
1104
  unsigned: UnsignedTx;
1071
1105
  inputSignatures: string[];
1072
1106
  scriptSignatures: string[];
1107
+ /** @format int64 */
1108
+ seenAt: number;
1073
1109
  }
1074
1110
  /** Transfer */
1075
1111
  export interface Transfer {
@@ -1289,7 +1325,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
1289
1325
  }
1290
1326
  /**
1291
1327
  * @title Alephium API
1292
- * @version 3.7.0
1328
+ * @version 3.8.1
1293
1329
  * @baseUrl ../
1294
1330
  */
1295
1331
  export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -1800,10 +1836,10 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1800
1836
  *
1801
1837
  * @tags Transactions
1802
1838
  * @name PostTransactionsBuild
1803
- * @summary Build an unsigned transaction to a number of recipients
1839
+ * @summary Build an unsigned transfer transaction to a number of recipients
1804
1840
  * @request POST:/transactions/build
1805
1841
  */
1806
- postTransactionsBuild: (data: BuildTransaction, params?: RequestParams) => Promise<BuildTransactionResult>;
1842
+ postTransactionsBuild: (data: BuildTransferTx, params?: RequestParams) => Promise<BuildTransferTxResult>;
1807
1843
  /**
1808
1844
  * No description
1809
1845
  *
@@ -1812,7 +1848,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1812
1848
  * @summary Build an unsigned transaction with multiple addresses to a number of recipients
1813
1849
  * @request POST:/transactions/build-multi-addresses
1814
1850
  */
1815
- postTransactionsBuildMultiAddresses: (data: BuildMultiAddressesTransaction, params?: RequestParams) => Promise<BuildTransactionResult>;
1851
+ postTransactionsBuildMultiAddresses: (data: BuildMultiAddressesTransaction, params?: RequestParams) => Promise<BuildTransferTxResult>;
1816
1852
  /**
1817
1853
  * No description
1818
1854
  *
@@ -1854,6 +1890,20 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1854
1890
  /** @format int32 */
1855
1891
  toGroup?: number;
1856
1892
  }, params?: RequestParams) => Promise<Transaction>;
1893
+ /**
1894
+ * No description
1895
+ *
1896
+ * @tags Transactions
1897
+ * @name GetTransactionsRichDetailsTxid
1898
+ * @summary Get transaction with enriched input information when node indexes are enabled.
1899
+ * @request GET:/transactions/rich-details/{txId}
1900
+ */
1901
+ getTransactionsRichDetailsTxid: (txId: string, query?: {
1902
+ /** @format int32 */
1903
+ fromGroup?: number;
1904
+ /** @format int32 */
1905
+ toGroup?: number;
1906
+ }, params?: RequestParams) => Promise<RichTransaction>;
1857
1907
  /**
1858
1908
  * No description
1859
1909
  *
@@ -1898,6 +1948,15 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
1898
1948
  /** @format 32-byte-hash */
1899
1949
  key: string;
1900
1950
  }, params?: RequestParams) => Promise<string>;
1951
+ /**
1952
+ * No description
1953
+ *
1954
+ * @tags Transactions
1955
+ * @name PostTransactionsBuildChained
1956
+ * @summary Build a chain of transactions
1957
+ * @request POST:/transactions/build-chained
1958
+ */
1959
+ postTransactionsBuildChained: (data: BuildChainedTx[], params?: RequestParams) => Promise<BuildChainedTxResult[]>;
1901
1960
  };
1902
1961
  mempool: {
1903
1962
  /**
@@ -2082,7 +2141,7 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
2082
2141
  * @summary Build a multisig unsigned transaction
2083
2142
  * @request POST:/multisig/build
2084
2143
  */
2085
- postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<BuildTransactionResult>;
2144
+ postMultisigBuild: (data: BuildMultisig, params?: RequestParams) => Promise<BuildTransferTxResult>;
2086
2145
  /**
2087
2146
  * No description
2088
2147
  *
@@ -151,7 +151,7 @@ class HttpClient {
151
151
  exports.HttpClient = HttpClient;
152
152
  /**
153
153
  * @title Alephium API
154
- * @version 3.7.0
154
+ * @version 3.8.1
155
155
  * @baseUrl ../
156
156
  */
157
157
  class Api extends HttpClient {
@@ -857,7 +857,7 @@ class Api extends HttpClient {
857
857
  *
858
858
  * @tags Transactions
859
859
  * @name PostTransactionsBuild
860
- * @summary Build an unsigned transaction to a number of recipients
860
+ * @summary Build an unsigned transfer transaction to a number of recipients
861
861
  * @request POST:/transactions/build
862
862
  */
863
863
  postTransactionsBuild: (data, params = {}) => this.request({
@@ -947,6 +947,21 @@ class Api extends HttpClient {
947
947
  format: 'json',
948
948
  ...params
949
949
  }).then(utils_1.convertHttpResponse),
950
+ /**
951
+ * No description
952
+ *
953
+ * @tags Transactions
954
+ * @name GetTransactionsRichDetailsTxid
955
+ * @summary Get transaction with enriched input information when node indexes are enabled.
956
+ * @request GET:/transactions/rich-details/{txId}
957
+ */
958
+ getTransactionsRichDetailsTxid: (txId, query, params = {}) => this.request({
959
+ path: `/transactions/rich-details/${txId}`,
960
+ method: 'GET',
961
+ query: query,
962
+ format: 'json',
963
+ ...params
964
+ }).then(utils_1.convertHttpResponse),
950
965
  /**
951
966
  * No description
952
967
  *
@@ -991,6 +1006,22 @@ class Api extends HttpClient {
991
1006
  query: query,
992
1007
  format: 'json',
993
1008
  ...params
1009
+ }).then(utils_1.convertHttpResponse),
1010
+ /**
1011
+ * No description
1012
+ *
1013
+ * @tags Transactions
1014
+ * @name PostTransactionsBuildChained
1015
+ * @summary Build a chain of transactions
1016
+ * @request POST:/transactions/build-chained
1017
+ */
1018
+ postTransactionsBuildChained: (data, params = {}) => this.request({
1019
+ path: `/transactions/build-chained`,
1020
+ method: 'POST',
1021
+ body: data,
1022
+ type: ContentType.Json,
1023
+ format: 'json',
1024
+ ...params
994
1025
  }).then(utils_1.convertHttpResponse)
995
1026
  };
996
1027
  this.mempool = {
@@ -1,6 +1,6 @@
1
1
  import { ExplorerProvider, NodeProvider } from '../api';
2
2
  import { node } from '../api';
3
- import { Account, EnableOptionsBase, Destination, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignMessageParams, SignMessageResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult, SubmissionResult, SubmitTransactionParams, KeyType, MessageHasher } from './types';
3
+ import { Account, EnableOptionsBase, Destination, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignMessageParams, SignMessageResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult, SubmissionResult, SubmitTransactionParams, KeyType, MessageHasher, SignChainedTxParams, SignChainedTxResult } from './types';
4
4
  export declare abstract class SignerProvider {
5
5
  abstract get nodeProvider(): NodeProvider | undefined;
6
6
  abstract get explorerProvider(): ExplorerProvider | undefined;
@@ -11,6 +11,7 @@ export declare abstract class SignerProvider {
11
11
  abstract signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
12
12
  abstract signAndSubmitExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
13
13
  abstract signAndSubmitUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
14
+ abstract signAndSubmitChainedTx(params: SignChainedTxParams[]): Promise<SignChainedTxResult[]>;
14
15
  abstract signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
15
16
  abstract signMessage(params: SignMessageParams): Promise<SignMessageResult>;
16
17
  }
@@ -26,14 +27,16 @@ export declare abstract class SignerProviderSimple extends SignerProvider {
26
27
  signAndSubmitDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
27
28
  signAndSubmitExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
28
29
  signAndSubmitUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
30
+ signAndSubmitChainedTx(params: SignChainedTxParams[]): Promise<SignChainedTxResult[]>;
29
31
  protected abstract getPublicKey(address: string): Promise<string>;
30
- private usePublicKey;
31
32
  signTransferTx(params: SignTransferTxParams): Promise<SignTransferTxResult>;
32
33
  buildTransferTx(params: SignTransferTxParams): Promise<Omit<SignTransferTxResult, 'signature'>>;
33
34
  signDeployContractTx(params: SignDeployContractTxParams): Promise<SignDeployContractTxResult>;
34
35
  buildDeployContractTx(params: SignDeployContractTxParams): Promise<Omit<SignDeployContractTxResult, 'signature'>>;
35
36
  signExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<SignExecuteScriptTxResult>;
36
37
  buildExecuteScriptTx(params: SignExecuteScriptTxParams): Promise<Omit<SignExecuteScriptTxResult, 'signature'>>;
38
+ signChainedTx(params: SignChainedTxParams[]): Promise<SignChainedTxResult[]>;
39
+ buildChainedTx(params: SignChainedTxParams[]): Promise<Omit<SignChainedTxResult, 'signature'>[]>;
37
40
  signUnsignedTx(params: SignUnsignedTxParams): Promise<SignUnsignedTxResult>;
38
41
  signMessage(params: SignMessageParams): Promise<SignMessageResult>;
39
42
  abstract signRaw(signerAddress: string, hexString: string): Promise<string>;
@@ -99,10 +99,12 @@ class SignerProviderSimple extends SignerProvider {
99
99
  await this.submitTransaction(signResult);
100
100
  return signResult;
101
101
  }
102
- async usePublicKey(params) {
103
- const { signerAddress, ...restParams } = params;
104
- const publicKey = await this.getPublicKey(signerAddress);
105
- return { fromPublicKey: publicKey, ...restParams };
102
+ async signAndSubmitChainedTx(params) {
103
+ const signResults = await this.signChainedTx(params);
104
+ for (const r of signResults) {
105
+ await this.submitTransaction(r);
106
+ }
107
+ return signResults;
106
108
  }
107
109
  async signTransferTx(params) {
108
110
  const response = await this.buildTransferTx(params);
@@ -128,6 +130,14 @@ class SignerProviderSimple extends SignerProvider {
128
130
  async buildExecuteScriptTx(params) {
129
131
  return tx_builder_1.TransactionBuilder.from(this.nodeProvider).buildExecuteScriptTx(params, await this.getPublicKey(params.signerAddress));
130
132
  }
133
+ async signChainedTx(params) {
134
+ const response = await this.buildChainedTx(params);
135
+ const signatures = await Promise.all(response.map((r, i) => this.signRaw(params[`${i}`].signerAddress, r.txId)));
136
+ return response.map((r, i) => ({ ...r, signature: signatures[`${i}`] }));
137
+ }
138
+ async buildChainedTx(params) {
139
+ return tx_builder_1.TransactionBuilder.from(this.nodeProvider).buildChainedTx(params, await Promise.all(params.map((p) => this.getPublicKey(p.signerAddress))));
140
+ }
131
141
  // in general, wallet should show the decoded information to user for confirmation
132
142
  // please overwrite this function for real wallet
133
143
  async signUnsignedTx(params) {
@@ -1,5 +1,5 @@
1
1
  import { NodeProvider } from '../api';
2
- import { SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult } from './types';
2
+ import { SignChainedTxParams, SignChainedTxResult, SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScriptTxParams, SignExecuteScriptTxResult, SignTransferTxParams, SignTransferTxResult, SignUnsignedTxParams, SignUnsignedTxResult } from './types';
3
3
  export declare abstract class TransactionBuilder {
4
4
  abstract get nodeProvider(): NodeProvider;
5
5
  static from(nodeProvider: NodeProvider): TransactionBuilder;
@@ -8,5 +8,12 @@ export declare abstract class TransactionBuilder {
8
8
  buildTransferTx(params: SignTransferTxParams, publicKey: string): Promise<Omit<SignTransferTxResult, 'signature'>>;
9
9
  buildDeployContractTx(params: SignDeployContractTxParams, publicKey: string): Promise<Omit<SignDeployContractTxResult, 'signature'>>;
10
10
  buildExecuteScriptTx(params: SignExecuteScriptTxParams, publicKey: string): Promise<Omit<SignExecuteScriptTxResult, 'signature'>>;
11
+ buildChainedTx(params: SignChainedTxParams[], publicKeys: string[]): Promise<Omit<SignChainedTxResult, 'signature'>[]>;
11
12
  buildUnsignedTx(params: SignUnsignedTxParams): Omit<SignUnsignedTxResult, 'signature'>;
13
+ private buildTransferTxParams;
14
+ private buildDeployContractTxParams;
15
+ private buildExecuteScriptTxParams;
16
+ private convertTransferTxResult;
17
+ private convertDeployContractTxResult;
18
+ private convertExecuteScriptTxResult;
12
19
  }
@@ -41,22 +41,103 @@ class TransactionBuilder {
41
41
  }
42
42
  }
43
43
  async buildTransferTx(params, publicKey) {
44
+ const data = this.buildTransferTxParams(params, publicKey);
45
+ const response = await this.nodeProvider.transactions.postTransactionsBuild(data);
46
+ return this.convertTransferTxResult(response);
47
+ }
48
+ async buildDeployContractTx(params, publicKey) {
49
+ const data = this.buildDeployContractTxParams(params, publicKey);
50
+ const response = await this.nodeProvider.contracts.postContractsUnsignedTxDeployContract(data);
51
+ return this.convertDeployContractTxResult(response);
52
+ }
53
+ async buildExecuteScriptTx(params, publicKey) {
54
+ const data = this.buildExecuteScriptTxParams(params, publicKey);
55
+ const response = await this.nodeProvider.contracts.postContractsUnsignedTxExecuteScript(data);
56
+ return this.convertExecuteScriptTxResult(response);
57
+ }
58
+ async buildChainedTx(params, publicKeys) {
59
+ if (params.length !== publicKeys.length) {
60
+ throw new Error('The number of build chained transaction parameters must match the number of public keys provided');
61
+ }
62
+ const data = params.map((param, index) => {
63
+ const paramType = param.type;
64
+ switch (paramType) {
65
+ case 'Transfer': {
66
+ const value = this.buildTransferTxParams(param, publicKeys[index]);
67
+ return { type: paramType, value };
68
+ }
69
+ case 'DeployContract': {
70
+ const value = this.buildDeployContractTxParams(param, publicKeys[index]);
71
+ return { type: paramType, value };
72
+ }
73
+ case 'ExecuteScript': {
74
+ const value = this.buildExecuteScriptTxParams(param, publicKeys[index]);
75
+ return { type: paramType, value };
76
+ }
77
+ default:
78
+ throw new Error(`Unsupported transaction type: ${paramType}`);
79
+ }
80
+ });
81
+ const buildChainedTxsResponse = await this.nodeProvider.transactions.postTransactionsBuildChained(data);
82
+ const results = buildChainedTxsResponse.map((buildResult) => {
83
+ const buildResultType = buildResult.type;
84
+ switch (buildResultType) {
85
+ case 'Transfer': {
86
+ const buildTransferTxResult = buildResult.value;
87
+ return {
88
+ ...this.convertTransferTxResult(buildTransferTxResult),
89
+ type: buildResultType
90
+ };
91
+ }
92
+ case 'DeployContract': {
93
+ const buildDeployContractTxResult = buildResult.value;
94
+ return {
95
+ ...this.convertDeployContractTxResult(buildDeployContractTxResult),
96
+ type: buildResultType
97
+ };
98
+ }
99
+ case 'ExecuteScript': {
100
+ const buildExecuteScriptTxResult = buildResult.value;
101
+ return {
102
+ ...this.convertExecuteScriptTxResult(buildExecuteScriptTxResult),
103
+ type: buildResultType
104
+ };
105
+ }
106
+ default:
107
+ throw new Error(`Unexpected transaction type: ${buildResultType} for ${buildResult.value.txId}`);
108
+ }
109
+ });
110
+ return results;
111
+ }
112
+ buildUnsignedTx(params) {
113
+ const unsignedTxBin = (0, utils_1.hexToBinUnsafe)(params.unsignedTx);
114
+ const decoded = codec_1.unsignedTxCodec.decode(unsignedTxBin);
115
+ const txId = (0, utils_1.binToHex)((0, hash_1.blakeHash)(unsignedTxBin));
116
+ const [fromGroup, toGroup] = (0, transaction_1.groupIndexOfTransaction)(decoded);
117
+ return {
118
+ fromGroup: fromGroup,
119
+ toGroup: toGroup,
120
+ unsignedTx: params.unsignedTx,
121
+ txId: txId,
122
+ gasAmount: decoded.gasAmount,
123
+ gasPrice: decoded.gasPrice
124
+ };
125
+ }
126
+ buildTransferTxParams(params, publicKey) {
44
127
  TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType);
45
128
  const { destinations, gasPrice, ...rest } = params;
46
- const data = {
129
+ return {
47
130
  fromPublicKey: publicKey,
48
131
  fromPublicKeyType: params.signerKeyType,
49
132
  destinations: (0, signer_1.toApiDestinations)(destinations),
50
133
  gasPrice: (0, api_1.toApiNumber256Optional)(gasPrice),
51
134
  ...rest
52
135
  };
53
- const response = await this.nodeProvider.transactions.postTransactionsBuild(data);
54
- return { ...response, gasPrice: (0, api_1.fromApiNumber256)(response.gasPrice) };
55
136
  }
56
- async buildDeployContractTx(params, publicKey) {
137
+ buildDeployContractTxParams(params, publicKey) {
57
138
  TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType);
58
139
  const { initialAttoAlphAmount, initialTokenAmounts, issueTokenAmount, gasPrice, ...rest } = params;
59
- const data = {
140
+ return {
60
141
  fromPublicKey: publicKey,
61
142
  fromPublicKeyType: params.signerKeyType,
62
143
  initialAttoAlphAmount: (0, api_1.toApiNumber256Optional)(initialAttoAlphAmount),
@@ -65,14 +146,11 @@ class TransactionBuilder {
65
146
  gasPrice: (0, api_1.toApiNumber256Optional)(gasPrice),
66
147
  ...rest
67
148
  };
68
- const response = await this.nodeProvider.contracts.postContractsUnsignedTxDeployContract(data);
69
- const contractId = (0, utils_1.binToHex)((0, address_1.contractIdFromAddress)(response.contractAddress));
70
- return { ...response, groupIndex: response.fromGroup, contractId, gasPrice: (0, api_1.fromApiNumber256)(response.gasPrice) };
71
149
  }
72
- async buildExecuteScriptTx(params, publicKey) {
150
+ buildExecuteScriptTxParams(params, publicKey) {
73
151
  TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType);
74
152
  const { attoAlphAmount, tokens, gasPrice, ...rest } = params;
75
- const data = {
153
+ return {
76
154
  fromPublicKey: publicKey,
77
155
  fromPublicKeyType: params.signerKeyType,
78
156
  attoAlphAmount: (0, api_1.toApiNumber256Optional)(attoAlphAmount),
@@ -80,21 +158,27 @@ class TransactionBuilder {
80
158
  gasPrice: (0, api_1.toApiNumber256Optional)(gasPrice),
81
159
  ...rest
82
160
  };
83
- const response = await this.nodeProvider.contracts.postContractsUnsignedTxExecuteScript(data);
84
- return { ...response, groupIndex: response.fromGroup, gasPrice: (0, api_1.fromApiNumber256)(response.gasPrice) };
85
161
  }
86
- buildUnsignedTx(params) {
87
- const unsignedTxBin = (0, utils_1.hexToBinUnsafe)(params.unsignedTx);
88
- const decoded = codec_1.unsignedTxCodec.decode(unsignedTxBin);
89
- const txId = (0, utils_1.binToHex)((0, hash_1.blakeHash)(unsignedTxBin));
90
- const [fromGroup, toGroup] = (0, transaction_1.groupIndexOfTransaction)(decoded);
162
+ convertTransferTxResult(result) {
91
163
  return {
92
- fromGroup: fromGroup,
93
- toGroup: toGroup,
94
- unsignedTx: params.unsignedTx,
95
- txId: txId,
96
- gasAmount: decoded.gasAmount,
97
- gasPrice: decoded.gasPrice
164
+ ...result,
165
+ gasPrice: (0, api_1.fromApiNumber256)(result.gasPrice)
166
+ };
167
+ }
168
+ convertDeployContractTxResult(result) {
169
+ const contractId = (0, utils_1.binToHex)((0, address_1.contractIdFromAddress)(result.contractAddress));
170
+ return {
171
+ ...result,
172
+ groupIndex: result.fromGroup,
173
+ contractId,
174
+ gasPrice: (0, api_1.fromApiNumber256)(result.gasPrice)
175
+ };
176
+ }
177
+ convertExecuteScriptTxResult(result) {
178
+ return {
179
+ ...result,
180
+ groupIndex: result.fromGroup,
181
+ gasPrice: (0, api_1.fromApiNumber256)(result.gasPrice)
98
182
  };
99
183
  }
100
184
  }
@@ -91,6 +91,26 @@ export interface SignUnsignedTxResult {
91
91
  gasAmount: number;
92
92
  gasPrice: Number256;
93
93
  }
94
+ export type SignTransferChainedTxParams = SignTransferTxParams & {
95
+ type: 'Transfer';
96
+ };
97
+ export type SignDeployContractChainedTxParams = SignDeployContractTxParams & {
98
+ type: 'DeployContract';
99
+ };
100
+ export type SignExecuteScriptChainedTxParams = SignExecuteScriptTxParams & {
101
+ type: 'ExecuteScript';
102
+ };
103
+ export type SignChainedTxParams = SignTransferChainedTxParams | SignDeployContractChainedTxParams | SignExecuteScriptChainedTxParams;
104
+ export type SignTransferChainedTxResult = SignTransferTxResult & {
105
+ type: 'Transfer';
106
+ };
107
+ export type SignDeployContractChainedTxResult = SignDeployContractTxResult & {
108
+ type: 'DeployContract';
109
+ };
110
+ export type SignExecuteScriptChainedTxResult = SignExecuteScriptTxResult & {
111
+ type: 'ExecuteScript';
112
+ };
113
+ export type SignChainedTxResult = SignTransferChainedTxResult | SignDeployContractChainedTxResult | SignExecuteScriptChainedTxResult;
94
114
  export type MessageHasher = 'alephium' | 'sha256' | 'blake2b' | 'identity';
95
115
  export interface SignMessageParams {
96
116
  signerAddress: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "1.7.4",
3
+ "version": "1.8.1",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "author": "Alephium dev <dev@alephium.org>",
35
35
  "config": {
36
- "alephium_version": "3.7.0",
36
+ "alephium_version": "3.8.1",
37
37
  "explorer_backend_version": "2.2.3"
38
38
  },
39
39
  "type": "commonjs",