@fuel-ts/account 0.0.0-rc-2143-20240424152333 → 0.0.0-rc-1976-20240424153519
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/README.md +2 -2
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +57 -41
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +93 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -41
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -5
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/utils/merge-quantities.d.ts +1 -1
- package/dist/providers/utils/merge-quantities.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -4
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +60 -44
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +95 -81
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +57 -43
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
@@ -44,14 +44,14 @@ These test utilities are exported to assist in testing apps using Fuels.
|
|
44
44
|
|
45
45
|
```ts
|
46
46
|
import { bn } from "@fuel-ts/math";
|
47
|
-
import { BaseAssetId } from "fuels";
|
48
47
|
import { seedTestWallet, generateTestWallet } from "@account/test-utils";
|
49
48
|
|
50
49
|
const provider = await Provider.create("http://127.0.0.1:4000/graphql");
|
51
50
|
|
52
51
|
// seeding
|
53
52
|
const wallet = Wallet.fromPrivateKey("0x...", provider);
|
54
|
-
|
53
|
+
const baseAssetId = await provider.getBaseAssetId();
|
54
|
+
seedTestWallet(wallet, [{ assetId: baseAssetId, amount: bn(100_000) }]);
|
55
55
|
|
56
56
|
// generating
|
57
57
|
const wallet = await generateTestWallet(provider, [[1_000, BaseAssetId]]);
|
package/dist/account.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"
|
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;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CACjE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;IAE/B,SAAS,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAErC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,aAAa;IAO7F;;;;;;OAMG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAMvB;IAED;;;;OAIG;IACH,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAE9B;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAKrC;;;;;;OAMG;IACG,mBAAmB,CACvB,UAAU,EAAE,gBAAgB,EAAE,CAAC,8BAA8B,EAC7D,WAAW,CAAC,EAAE,sBAAsB,GACnC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAItB;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IA6BpD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IA6BvC;;;;;OAKG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;IAMlD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IA6B5C;;;;;;;OAOG;IACG,IAAI,CAAC,CAAC,SAAS,kBAAkB,EACrC,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,YAAY,EAAE,EAC9B,GAAG,EAAE,EAAE,GACN,OAAO,CAAC,IAAI,CAAC;IAmEhB;;;;;;;;OAQG;IACG,cAAc;IAClB,iCAAiC;IACjC,WAAW,EAAE,MAAM,GAAG,eAAe;IACrC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IA6B9B;;;;;;;;OAQG;IACG,QAAQ;IACZ,iCAAiC;IACjC,WAAW,EAAE,MAAM,GAAG,eAAe;IACrC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAY/B;;;;;;;;OAQG;IACG,kBAAkB;IACtB,uBAAuB;IACvB,UAAU,EAAE,MAAM,GAAG,eAAe;IACpC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA8C/B;;;;;;;OAOG;IACG,mBAAmB;IACvB,iDAAiD;IACjD,SAAS,EAAE,MAAM,GAAG,eAAe;IACnC,2BAA2B;IAC3B,MAAM,EAAE,YAAY;IACpB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA8CzB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;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,OAAO,CAAC,WAAW;CAyBpB"}
|
package/dist/index.global.js
CHANGED
@@ -31271,10 +31271,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31271
31271
|
}
|
31272
31272
|
};
|
31273
31273
|
|
31274
|
-
// ../address/dist/configs.mjs
|
31275
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31276
|
-
var BaseAssetId = ZeroBytes32;
|
31277
|
-
|
31278
31274
|
// ../math/dist/index.mjs
|
31279
31275
|
var import_bn = __toESM(require_bn(), 1);
|
31280
31276
|
var DEFAULT_PRECISION = 9;
|
@@ -31505,11 +31501,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31505
31501
|
let max2;
|
31506
31502
|
if (Array.isArray(coinQuantityLike)) {
|
31507
31503
|
amount = coinQuantityLike[0];
|
31508
|
-
assetId = coinQuantityLike[1]
|
31509
|
-
max2 = coinQuantityLike[2]
|
31504
|
+
assetId = coinQuantityLike[1];
|
31505
|
+
max2 = coinQuantityLike[2];
|
31510
31506
|
} else {
|
31511
31507
|
amount = coinQuantityLike.amount;
|
31512
|
-
assetId = coinQuantityLike.assetId
|
31508
|
+
assetId = coinQuantityLike.assetId;
|
31513
31509
|
max2 = coinQuantityLike.max ?? void 0;
|
31514
31510
|
}
|
31515
31511
|
const bnAmount = bn(amount);
|
@@ -38888,6 +38884,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38888
38884
|
}
|
38889
38885
|
};
|
38890
38886
|
|
38887
|
+
// ../address/dist/configs.mjs
|
38888
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38889
|
+
|
38891
38890
|
// src/providers/transaction-request/input.ts
|
38892
38891
|
var inputify = (value) => {
|
38893
38892
|
const { type: type3 } = value;
|
@@ -39804,15 +39803,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39804
39803
|
}
|
39805
39804
|
/**
|
39806
39805
|
* Adds a single message input to the transaction and a change output for the
|
39807
|
-
*
|
39806
|
+
* asset against the message
|
39808
39807
|
*
|
39809
39808
|
* @param message - Message resource.
|
39810
39809
|
* @param predicate - Predicate bytes.
|
39811
|
-
* @param predicateData - Predicate data bytes.
|
39812
39810
|
*/
|
39813
39811
|
addMessageInput(message, predicate) {
|
39814
|
-
const { recipient, sender, amount } = message;
|
39815
|
-
const assetId = BaseAssetId;
|
39812
|
+
const { recipient, sender, amount, assetId } = message;
|
39816
39813
|
let witnessIndex;
|
39817
39814
|
if (predicate) {
|
39818
39815
|
witnessIndex = 0;
|
@@ -39893,7 +39890,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39893
39890
|
* @param amount - Amount of coin.
|
39894
39891
|
* @param assetId - Asset ID of coin.
|
39895
39892
|
*/
|
39896
|
-
addCoinOutput(to, amount, assetId
|
39893
|
+
addCoinOutput(to, amount, assetId) {
|
39897
39894
|
this.pushOutput({
|
39898
39895
|
type: OutputType.Coin,
|
39899
39896
|
to: addressify(to).toB256(),
|
@@ -39925,7 +39922,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39925
39922
|
* @param to - Address of the owner.
|
39926
39923
|
* @param assetId - Asset ID of coin.
|
39927
39924
|
*/
|
39928
|
-
addChangeOutput(to, assetId
|
39925
|
+
addChangeOutput(to, assetId) {
|
39929
39926
|
const changeOutput = this.getChangeOutputs().find(
|
39930
39927
|
(output3) => hexlify(output3.assetId) === assetId
|
39931
39928
|
);
|
@@ -39982,8 +39979,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39982
39979
|
* quantities array.
|
39983
39980
|
*
|
39984
39981
|
* @param quantities - CoinQuantity Array.
|
39982
|
+
* @param baseAssetId - The base asset to fund the transaction.
|
39985
39983
|
*/
|
39986
|
-
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39984
|
+
fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
|
39987
39985
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39988
39986
|
if ("assetId" in input) {
|
39989
39987
|
return input.assetId === assetId;
|
@@ -40009,7 +40007,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40009
40007
|
]);
|
40010
40008
|
}
|
40011
40009
|
};
|
40012
|
-
updateAssetInput(
|
40010
|
+
updateAssetInput(baseAssetId, bn(1e11));
|
40013
40011
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40014
40012
|
}
|
40015
40013
|
/**
|
@@ -40166,12 +40164,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40166
40164
|
*
|
40167
40165
|
* @param createTransactionRequestLike - The initial values for the instance
|
40168
40166
|
*/
|
40169
|
-
constructor({
|
40170
|
-
bytecodeWitnessIndex,
|
40171
|
-
salt,
|
40172
|
-
storageSlots,
|
40173
|
-
...rest
|
40174
|
-
} = {}) {
|
40167
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40175
40168
|
super(rest);
|
40176
40169
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40177
40170
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -41394,7 +41387,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41394
41387
|
}
|
41395
41388
|
|
41396
41389
|
// src/providers/utils/merge-quantities.ts
|
41397
|
-
var mergeQuantities = (
|
41390
|
+
var mergeQuantities = (...coinQuantities) => {
|
41398
41391
|
const resultMap = {};
|
41399
41392
|
function addToMap({ amount, assetId }) {
|
41400
41393
|
if (resultMap[assetId]) {
|
@@ -41403,8 +41396,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41403
41396
|
resultMap[assetId] = amount;
|
41404
41397
|
}
|
41405
41398
|
}
|
41406
|
-
|
41407
|
-
arr2.forEach(addToMap);
|
41399
|
+
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
41408
41400
|
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
41409
41401
|
};
|
41410
41402
|
|
@@ -41432,6 +41424,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41432
41424
|
gasPerByte: bn(feeParams.gasPerByte),
|
41433
41425
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41434
41426
|
chainId: bn(consensusParameters.chainId),
|
41427
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41435
41428
|
gasCosts
|
41436
41429
|
},
|
41437
41430
|
gasCosts,
|
@@ -41674,6 +41667,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41674
41667
|
} = this.getChain();
|
41675
41668
|
return chainId.toNumber();
|
41676
41669
|
}
|
41670
|
+
/**
|
41671
|
+
* Returns the base asset ID
|
41672
|
+
*
|
41673
|
+
* @returns A promise that resolves to the base asset ID
|
41674
|
+
*/
|
41675
|
+
getBaseAssetId() {
|
41676
|
+
const {
|
41677
|
+
consensusParameters: { baseAssetId }
|
41678
|
+
} = this.getChain();
|
41679
|
+
return baseAssetId;
|
41680
|
+
}
|
41677
41681
|
/**
|
41678
41682
|
* Submits a transaction to the chain to be executed.
|
41679
41683
|
*
|
@@ -41904,9 +41908,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41904
41908
|
const { minGasPrice } = this.getGasConfig();
|
41905
41909
|
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41906
41910
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41911
|
+
const baseAssetId = this.getBaseAssetId();
|
41907
41912
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41908
41913
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41909
|
-
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41914
|
+
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
41910
41915
|
if (isScriptTransaction) {
|
41911
41916
|
txRequestClone.gasLimit = bn(0);
|
41912
41917
|
}
|
@@ -42730,8 +42735,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42730
42735
|
* @param assetId - The asset ID to check the balance for.
|
42731
42736
|
* @returns A promise that resolves to the balance amount.
|
42732
42737
|
*/
|
42733
|
-
async getBalance(assetId
|
42734
|
-
const
|
42738
|
+
async getBalance(assetId) {
|
42739
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42740
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42735
42741
|
return amount;
|
42736
42742
|
}
|
42737
42743
|
/**
|
@@ -42769,9 +42775,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42769
42775
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42770
42776
|
*/
|
42771
42777
|
async fund(request, coinQuantities, fee) {
|
42778
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42772
42779
|
const updatedQuantities = addAmountToAsset({
|
42773
42780
|
amount: bn(fee),
|
42774
|
-
assetId:
|
42781
|
+
assetId: baseAssetId,
|
42775
42782
|
coinQuantities
|
42776
42783
|
});
|
42777
42784
|
const quantitiesDict = {};
|
@@ -42795,8 +42802,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42795
42802
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42796
42803
|
cachedUtxos.push(input.id);
|
42797
42804
|
}
|
42798
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42799
|
-
quantitiesDict[
|
42805
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42806
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42800
42807
|
cachedMessages.push(input.nonce);
|
42801
42808
|
}
|
42802
42809
|
}
|
@@ -42828,11 +42835,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42828
42835
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42829
42836
|
* @returns A promise that resolves to the prepared transaction request.
|
42830
42837
|
*/
|
42831
|
-
async createTransfer(destination, amount, assetId
|
42838
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42832
42839
|
const { minGasPrice } = this.provider.getGasConfig();
|
42840
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42833
42841
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42834
42842
|
const request = new ScriptTransactionRequest(params);
|
42835
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42843
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42836
42844
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42837
42845
|
estimateTxDependencies: true,
|
42838
42846
|
resourcesOwner: this
|
@@ -42858,14 +42866,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42858
42866
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42859
42867
|
* @returns A promise that resolves to the transaction response.
|
42860
42868
|
*/
|
42861
|
-
async transfer(destination, amount, assetId
|
42869
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42862
42870
|
if (bn(amount).lte(0)) {
|
42863
42871
|
throw new FuelError(
|
42864
42872
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42865
42873
|
"Transfer amount must be a positive number."
|
42866
42874
|
);
|
42867
42875
|
}
|
42868
|
-
const
|
42876
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42877
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42869
42878
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42870
42879
|
}
|
42871
42880
|
/**
|
@@ -42877,7 +42886,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42877
42886
|
* @param txParams - The optional transaction parameters.
|
42878
42887
|
* @returns A promise that resolves to the transaction response.
|
42879
42888
|
*/
|
42880
|
-
async transferToContract(contractId, amount, assetId
|
42889
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42881
42890
|
if (bn(amount).lte(0)) {
|
42882
42891
|
throw new FuelError(
|
42883
42892
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42886,11 +42895,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42886
42895
|
}
|
42887
42896
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42888
42897
|
const { minGasPrice } = this.provider.getGasConfig();
|
42898
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42889
42899
|
const params = { gasPrice: minGasPrice, ...txParams };
|
42890
42900
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42891
42901
|
hexlifiedContractId: contractAddress.toB256(),
|
42892
42902
|
amountToTransfer: bn(amount),
|
42893
|
-
assetId
|
42903
|
+
assetId: assetIdToTransfer
|
42894
42904
|
});
|
42895
42905
|
const request = new ScriptTransactionRequest({
|
42896
42906
|
...params,
|
@@ -42900,7 +42910,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42900
42910
|
request.addContractInputAndOutput(contractAddress);
|
42901
42911
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42902
42912
|
request,
|
42903
|
-
[{ amount: bn(amount), assetId: String(
|
42913
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42904
42914
|
);
|
42905
42915
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42906
42916
|
this.validateGas({
|
@@ -42922,6 +42932,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42922
42932
|
*/
|
42923
42933
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42924
42934
|
const { minGasPrice } = this.provider.getGasConfig();
|
42935
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42925
42936
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42926
42937
|
const recipientDataArray = arrayify(
|
42927
42938
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42934,9 +42945,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42934
42945
|
...recipientDataArray,
|
42935
42946
|
...amountDataArray
|
42936
42947
|
]);
|
42937
|
-
const params = {
|
42948
|
+
const params = {
|
42949
|
+
script,
|
42950
|
+
gasPrice: minGasPrice,
|
42951
|
+
...txParams
|
42952
|
+
};
|
42938
42953
|
const request = new ScriptTransactionRequest(params);
|
42939
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42954
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42940
42955
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42941
42956
|
request,
|
42942
42957
|
forwardingQuantities
|
@@ -47899,8 +47914,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47899
47914
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47900
47915
|
* @returns A promise that resolves to the prepared transaction request.
|
47901
47916
|
*/
|
47902
|
-
async createTransfer(destination, amount, assetId
|
47903
|
-
const
|
47917
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47918
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47919
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47904
47920
|
return this.populateTransactionPredicateData(request);
|
47905
47921
|
}
|
47906
47922
|
/**
|