@fuel-ts/account 0.0.0-rc-1356-20240520180710 → 0.0.0-rc-2333-20240520181329
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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts +36 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +86 -28
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +202 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -22
- package/dist/index.mjs.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/sleep.d.ts +3 -0
- package/dist/providers/utils/sleep.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +1 -8
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +144 -415
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +244 -424
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +142 -318
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -16
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +0 -33
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +0 -1
- package/dist/test-utils/test-message.d.ts +0 -29
- package/dist/test-utils/test-message.d.ts.map +0 -1
- package/dist/test-utils/wallet-config.d.ts +0 -55
- package/dist/test-utils/wallet-config.d.ts.map +0 -1
package/dist/account.d.ts
CHANGED
@@ -3,7 +3,13 @@ import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces';
|
|
3
3
|
import type { BigNumberish, BN } from '@fuel-ts/math';
|
4
4
|
import type { FuelConnector } from './connectors';
|
5
5
|
import type { TransactionRequestLike, CallResult, TransactionRequest, Coin, CoinQuantityLike, CoinQuantity, Message, Resource, ExcludeResourcesOption, Provider, ScriptTransactionRequestLike, ProviderSendTxParams, TransactionResponse, EstimateTransactionParams, TransactionCost } from './providers';
|
6
|
+
import { ScriptTransactionRequest } from './providers';
|
6
7
|
export type TxParamsType = Pick<ScriptTransactionRequestLike, 'gasLimit' | 'tip' | 'maturity' | 'maxFee' | 'witnessLimit'>;
|
8
|
+
export type TransferParams = {
|
9
|
+
destination: string | AbstractAddress;
|
10
|
+
amount: BigNumberish;
|
11
|
+
assetId?: BytesLike;
|
12
|
+
};
|
7
13
|
export type EstimatedTxParams = Pick<TransactionCost, 'estimatedPredicates' | 'addedSignatures' | 'requiredQuantities' | 'updateMaxFee'>;
|
8
14
|
/**
|
9
15
|
* `Account` provides an abstraction for interacting with accounts or wallets on the network.
|
@@ -125,6 +131,30 @@ export declare class Account extends AbstractAccount {
|
|
125
131
|
assetId?: BytesLike,
|
126
132
|
/** Tx Params */
|
127
133
|
txParams?: TxParamsType): Promise<TransactionResponse>;
|
134
|
+
/**
|
135
|
+
* Transfers multiple amounts of a token to multiple recipients.
|
136
|
+
*
|
137
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
138
|
+
* @param txParams - Optional transaction parameters.
|
139
|
+
* @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
|
140
|
+
*/
|
141
|
+
batchTransfer(transferParams: TransferParams[], txParams?: TxParamsType): Promise<TransactionResponse>;
|
142
|
+
/**
|
143
|
+
* Adds a transfer to the given transaction request.
|
144
|
+
*
|
145
|
+
* @param request - The script transaction request to add transfers to.
|
146
|
+
* @param transferParams - The object representing the transfer to be made.
|
147
|
+
* @returns The updated transaction request with the added transfer.
|
148
|
+
*/
|
149
|
+
addTransfer(request: ScriptTransactionRequest, transferParams: TransferParams): ScriptTransactionRequest;
|
150
|
+
/**
|
151
|
+
* Adds multiple transfers to a script transaction request.
|
152
|
+
*
|
153
|
+
* @param request - The script transaction request to add transfers to.
|
154
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
155
|
+
* @returns The updated script transaction request.
|
156
|
+
*/
|
157
|
+
addBatchTransfer(request: ScriptTransactionRequest, transferParams: TransferParams[]): ScriptTransactionRequest;
|
128
158
|
/**
|
129
159
|
* Transfers coins to a contract address.
|
130
160
|
*
|
@@ -158,6 +188,7 @@ export declare class Account extends AbstractAccount {
|
|
158
188
|
amount: BigNumberish,
|
159
189
|
/** Tx Params */
|
160
190
|
txParams?: TxParamsType): Promise<TransactionResponse>;
|
191
|
+
/** @hidden * */
|
161
192
|
signMessage(message: string): Promise<string>;
|
162
193
|
/**
|
163
194
|
* Signs a transaction with the wallet's private key.
|
@@ -180,6 +211,11 @@ export declare class Account extends AbstractAccount {
|
|
180
211
|
* @returns A promise that resolves to the call result.
|
181
212
|
*/
|
182
213
|
simulateTransaction(transactionRequestLike: TransactionRequestLike, { estimateTxDependencies }?: EstimateTransactionParams): Promise<CallResult>;
|
214
|
+
/** @hidden * */
|
215
|
+
private validateTransferAmount;
|
216
|
+
/** @hidden * */
|
217
|
+
private estimateAndFundTransaction;
|
218
|
+
/** @hidden * */
|
183
219
|
private validateGasLimitAndMaxFee;
|
184
220
|
}
|
185
221
|
//# sourceMappingURL=account.d.ts.map
|
package/dist/account.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,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C;IAUtF;;;;;OAKG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;OAKG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB,gBAAgB;IAChB,OAAO,CAAC,sBAAsB;IAS9B,gBAAgB;YACF,0BAA0B;IAkBxC,gBAAgB;IAChB,OAAO,CAAC,yBAAyB;CAiClC"}
|
package/dist/index.global.js
CHANGED
@@ -29985,13 +29985,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29985
29985
|
};
|
29986
29986
|
var DateTime = _DateTime;
|
29987
29987
|
__publicField3(DateTime, "TAI64_NULL", "");
|
29988
|
-
function sleep(time) {
|
29989
|
-
return new Promise((resolve) => {
|
29990
|
-
setTimeout(() => {
|
29991
|
-
resolve(true);
|
29992
|
-
}, time);
|
29993
|
-
});
|
29994
|
-
}
|
29995
29988
|
function isDefined(value) {
|
29996
29989
|
return value !== void 0;
|
29997
29990
|
}
|
@@ -38334,6 +38327,15 @@ ${MessageCoinFragmentDoc}`;
|
|
38334
38327
|
return normalize2(clone_default(root));
|
38335
38328
|
}
|
38336
38329
|
|
38330
|
+
// src/providers/utils/sleep.ts
|
38331
|
+
function sleep(time) {
|
38332
|
+
return new Promise((resolve) => {
|
38333
|
+
setTimeout(() => {
|
38334
|
+
resolve(true);
|
38335
|
+
}, time);
|
38336
|
+
});
|
38337
|
+
}
|
38338
|
+
|
38337
38339
|
// src/providers/utils/extract-tx-error.ts
|
38338
38340
|
var assemblePanicError = (statusReason) => {
|
38339
38341
|
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
@@ -42028,19 +42030,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42028
42030
|
*/
|
42029
42031
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42030
42032
|
let request = new ScriptTransactionRequest(txParams);
|
42031
|
-
|
42032
|
-
request.
|
42033
|
-
const txCost = await this.provider.getTransactionCost(request, {
|
42034
|
-
estimateTxDependencies: true,
|
42035
|
-
resourcesOwner: this
|
42036
|
-
});
|
42037
|
-
request = this.validateGasLimitAndMaxFee({
|
42038
|
-
transactionRequest: request,
|
42039
|
-
gasUsed: txCost.gasUsed,
|
42040
|
-
maxFee: txCost.maxFee,
|
42041
|
-
txParams
|
42042
|
-
});
|
42043
|
-
await this.fund(request, txCost);
|
42033
|
+
request = this.addTransfer(request, { destination, amount, assetId });
|
42034
|
+
request = await this.estimateAndFundTransaction(request, txParams);
|
42044
42035
|
return request;
|
42045
42036
|
}
|
42046
42037
|
/**
|
@@ -42053,16 +42044,57 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42053
42044
|
* @returns A promise that resolves to the transaction response.
|
42054
42045
|
*/
|
42055
42046
|
async transfer(destination, amount, assetId, txParams = {}) {
|
42056
|
-
|
42057
|
-
|
42058
|
-
|
42059
|
-
|
42060
|
-
|
42061
|
-
|
42062
|
-
|
42063
|
-
|
42047
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
42048
|
+
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42049
|
+
}
|
42050
|
+
/**
|
42051
|
+
* Transfers multiple amounts of a token to multiple recipients.
|
42052
|
+
*
|
42053
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
42054
|
+
* @param txParams - Optional transaction parameters.
|
42055
|
+
* @returns A promise that resolves to a `TransactionResponse` object representing the transaction result.
|
42056
|
+
*/
|
42057
|
+
async batchTransfer(transferParams, txParams = {}) {
|
42058
|
+
let request = new ScriptTransactionRequest(txParams);
|
42059
|
+
request = this.addBatchTransfer(request, transferParams);
|
42060
|
+
request = await this.estimateAndFundTransaction(request, txParams);
|
42064
42061
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42065
42062
|
}
|
42063
|
+
/**
|
42064
|
+
* Adds a transfer to the given transaction request.
|
42065
|
+
*
|
42066
|
+
* @param request - The script transaction request to add transfers to.
|
42067
|
+
* @param transferParams - The object representing the transfer to be made.
|
42068
|
+
* @returns The updated transaction request with the added transfer.
|
42069
|
+
*/
|
42070
|
+
addTransfer(request, transferParams) {
|
42071
|
+
const { destination, amount, assetId } = transferParams;
|
42072
|
+
this.validateTransferAmount(amount);
|
42073
|
+
request.addCoinOutput(
|
42074
|
+
Address.fromAddressOrString(destination),
|
42075
|
+
amount,
|
42076
|
+
assetId ?? this.provider.getBaseAssetId()
|
42077
|
+
);
|
42078
|
+
return request;
|
42079
|
+
}
|
42080
|
+
/**
|
42081
|
+
* Adds multiple transfers to a script transaction request.
|
42082
|
+
*
|
42083
|
+
* @param request - The script transaction request to add transfers to.
|
42084
|
+
* @param transferParams - An array of `TransferParams` objects representing the transfers to be made.
|
42085
|
+
* @returns The updated script transaction request.
|
42086
|
+
*/
|
42087
|
+
addBatchTransfer(request, transferParams) {
|
42088
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42089
|
+
transferParams.forEach(({ destination, amount, assetId }) => {
|
42090
|
+
this.addTransfer(request, {
|
42091
|
+
destination,
|
42092
|
+
amount,
|
42093
|
+
assetId: assetId ?? baseAssetId
|
42094
|
+
});
|
42095
|
+
});
|
42096
|
+
return request;
|
42097
|
+
}
|
42066
42098
|
/**
|
42067
42099
|
* Transfers coins to a contract address.
|
42068
42100
|
*
|
@@ -42140,6 +42172,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42140
42172
|
await this.fund(request, txCost);
|
42141
42173
|
return this.sendTransaction(request);
|
42142
42174
|
}
|
42175
|
+
/** @hidden * */
|
42143
42176
|
async signMessage(message) {
|
42144
42177
|
if (!this._connector) {
|
42145
42178
|
throw new FuelError(ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
@@ -42195,6 +42228,31 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42195
42228
|
}
|
42196
42229
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
42197
42230
|
}
|
42231
|
+
/** @hidden * */
|
42232
|
+
validateTransferAmount(amount) {
|
42233
|
+
if (bn(amount).lte(0)) {
|
42234
|
+
throw new FuelError(
|
42235
|
+
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42236
|
+
"Transfer amount must be a positive number."
|
42237
|
+
);
|
42238
|
+
}
|
42239
|
+
}
|
42240
|
+
/** @hidden * */
|
42241
|
+
async estimateAndFundTransaction(transactionRequest, txParams) {
|
42242
|
+
let request = transactionRequest;
|
42243
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
42244
|
+
resourcesOwner: this
|
42245
|
+
});
|
42246
|
+
request = this.validateGasLimitAndMaxFee({
|
42247
|
+
transactionRequest: request,
|
42248
|
+
gasUsed: txCost.gasUsed,
|
42249
|
+
maxFee: txCost.maxFee,
|
42250
|
+
txParams
|
42251
|
+
});
|
42252
|
+
request = await this.fund(request, txCost);
|
42253
|
+
return request;
|
42254
|
+
}
|
42255
|
+
/** @hidden * */
|
42198
42256
|
validateGasLimitAndMaxFee({
|
42199
42257
|
gasUsed,
|
42200
42258
|
maxFee,
|