@fuel-ts/account 0.0.0-rc-2037-20240412171107 → 0.0.0-rc-1976-20240415100843
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.map +1 -1
- package/dist/index.global.js +98 -65
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +134 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -65
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +1 -9
- 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/coin.d.ts +1 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.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/script-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +25 -4
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +102 -51
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +137 -88
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +99 -50
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
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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AQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IA+C/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;IA+CzB,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
@@ -31272,10 +31272,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31272
31272
|
}
|
31273
31273
|
};
|
31274
31274
|
|
31275
|
-
// ../address/dist/configs.mjs
|
31276
|
-
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
31277
|
-
var BaseAssetId = ZeroBytes32;
|
31278
|
-
|
31279
31275
|
// ../math/dist/index.mjs
|
31280
31276
|
var import_bn = __toESM(require_bn(), 1);
|
31281
31277
|
var DEFAULT_PRECISION = 9;
|
@@ -31506,11 +31502,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31506
31502
|
let max2;
|
31507
31503
|
if (Array.isArray(coinQuantityLike)) {
|
31508
31504
|
amount = coinQuantityLike[0];
|
31509
|
-
assetId = coinQuantityLike[1]
|
31510
|
-
max2 = coinQuantityLike[2]
|
31505
|
+
assetId = coinQuantityLike[1];
|
31506
|
+
max2 = coinQuantityLike[2];
|
31511
31507
|
} else {
|
31512
31508
|
amount = coinQuantityLike.amount;
|
31513
|
-
assetId = coinQuantityLike.assetId
|
31509
|
+
assetId = coinQuantityLike.assetId;
|
31514
31510
|
max2 = coinQuantityLike.max ?? void 0;
|
31515
31511
|
}
|
31516
31512
|
const bnAmount = bn(amount);
|
@@ -38865,6 +38861,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38865
38861
|
}
|
38866
38862
|
};
|
38867
38863
|
|
38864
|
+
// ../address/dist/configs.mjs
|
38865
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38866
|
+
|
38868
38867
|
// src/providers/transaction-request/input.ts
|
38869
38868
|
var inputify = (value) => {
|
38870
38869
|
const { type: type3 } = value;
|
@@ -39541,6 +39540,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39541
39540
|
outputs = [];
|
39542
39541
|
/** List of witnesses */
|
39543
39542
|
witnesses = [];
|
39543
|
+
/** Base asset ID - should be fetched from the chain */
|
39544
|
+
baseAssetId;
|
39544
39545
|
/**
|
39545
39546
|
* Constructor for initializing a base transaction request.
|
39546
39547
|
*
|
@@ -39553,8 +39554,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39553
39554
|
witnessLimit,
|
39554
39555
|
inputs,
|
39555
39556
|
outputs,
|
39556
|
-
witnesses
|
39557
|
-
|
39557
|
+
witnesses,
|
39558
|
+
baseAssetId
|
39559
|
+
}) {
|
39558
39560
|
this.gasPrice = bn(gasPrice);
|
39559
39561
|
this.maturity = maturity ?? 0;
|
39560
39562
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39562,6 +39564,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39562
39564
|
this.inputs = inputs ?? [];
|
39563
39565
|
this.outputs = outputs ?? [];
|
39564
39566
|
this.witnesses = witnesses ?? [];
|
39567
|
+
this.baseAssetId = baseAssetId;
|
39565
39568
|
}
|
39566
39569
|
static getPolicyMeta(req) {
|
39567
39570
|
let policyTypes = 0;
|
@@ -39755,8 +39758,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39755
39758
|
* @param predicate - Predicate bytes.
|
39756
39759
|
* @param predicateData - Predicate data bytes.
|
39757
39760
|
*/
|
39758
|
-
addCoinInput(coin) {
|
39759
|
-
const { assetId, owner, amount
|
39761
|
+
addCoinInput(coin, predicate) {
|
39762
|
+
const { assetId, owner, amount } = coin;
|
39760
39763
|
let witnessIndex;
|
39761
39764
|
if (predicate) {
|
39762
39765
|
witnessIndex = 0;
|
@@ -39767,14 +39770,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39767
39770
|
}
|
39768
39771
|
}
|
39769
39772
|
const input = {
|
39770
|
-
|
39773
|
+
...coin,
|
39771
39774
|
type: InputType.Coin,
|
39772
39775
|
owner: owner.toB256(),
|
39773
39776
|
amount,
|
39774
39777
|
assetId,
|
39775
39778
|
txPointer: "0x00000000000000000000000000000000",
|
39776
39779
|
witnessIndex,
|
39777
|
-
predicate
|
39780
|
+
predicate: predicate?.bytes
|
39778
39781
|
};
|
39779
39782
|
this.pushInput(input);
|
39780
39783
|
this.addChangeOutput(owner, assetId);
|
@@ -39785,11 +39788,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39785
39788
|
*
|
39786
39789
|
* @param message - Message resource.
|
39787
39790
|
* @param predicate - Predicate bytes.
|
39788
|
-
* @param predicateData - Predicate data bytes.
|
39789
39791
|
*/
|
39790
|
-
addMessageInput(message) {
|
39791
|
-
const { recipient, sender, amount
|
39792
|
-
const assetId = BaseAssetId;
|
39792
|
+
addMessageInput(message, predicate) {
|
39793
|
+
const { recipient, sender, amount } = message;
|
39793
39794
|
let witnessIndex;
|
39794
39795
|
if (predicate) {
|
39795
39796
|
witnessIndex = 0;
|
@@ -39800,16 +39801,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39800
39801
|
}
|
39801
39802
|
}
|
39802
39803
|
const input = {
|
39803
|
-
|
39804
|
+
...message,
|
39804
39805
|
type: InputType.Message,
|
39805
39806
|
sender: sender.toB256(),
|
39806
39807
|
recipient: recipient.toB256(),
|
39807
39808
|
amount,
|
39808
39809
|
witnessIndex,
|
39809
|
-
predicate
|
39810
|
+
predicate: predicate?.bytes
|
39810
39811
|
};
|
39811
39812
|
this.pushInput(input);
|
39812
|
-
this.addChangeOutput(recipient,
|
39813
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39813
39814
|
}
|
39814
39815
|
/**
|
39815
39816
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39837,6 +39838,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39837
39838
|
resources.forEach((resource) => this.addResource(resource));
|
39838
39839
|
return this;
|
39839
39840
|
}
|
39841
|
+
/**
|
39842
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39843
|
+
* outputs from the related assetIds.
|
39844
|
+
*
|
39845
|
+
* @param resources - The resources to add.
|
39846
|
+
* @returns This transaction.
|
39847
|
+
*/
|
39848
|
+
addPredicateResource(resource, predicate) {
|
39849
|
+
if (isCoin(resource)) {
|
39850
|
+
this.addCoinInput(resource, predicate);
|
39851
|
+
} else {
|
39852
|
+
this.addMessageInput(resource, predicate);
|
39853
|
+
}
|
39854
|
+
return this;
|
39855
|
+
}
|
39856
|
+
/**
|
39857
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39858
|
+
* from the related assetIds.
|
39859
|
+
*
|
39860
|
+
* @param resources - The resources to add.
|
39861
|
+
* @returns This transaction.
|
39862
|
+
*/
|
39863
|
+
addPredicateResources(resources, predicate) {
|
39864
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39865
|
+
return this;
|
39866
|
+
}
|
39840
39867
|
/**
|
39841
39868
|
* Adds a coin output to the transaction.
|
39842
39869
|
*
|
@@ -39844,12 +39871,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39844
39871
|
* @param amount - Amount of coin.
|
39845
39872
|
* @param assetId - Asset ID of coin.
|
39846
39873
|
*/
|
39847
|
-
addCoinOutput(to, amount, assetId
|
39874
|
+
addCoinOutput(to, amount, assetId) {
|
39848
39875
|
this.pushOutput({
|
39849
39876
|
type: OutputType.Coin,
|
39850
39877
|
to: addressify(to).toB256(),
|
39851
39878
|
amount,
|
39852
|
-
assetId
|
39879
|
+
assetId: assetId ?? this.baseAssetId
|
39853
39880
|
});
|
39854
39881
|
return this;
|
39855
39882
|
}
|
@@ -39876,7 +39903,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39876
39903
|
* @param to - Address of the owner.
|
39877
39904
|
* @param assetId - Asset ID of coin.
|
39878
39905
|
*/
|
39879
|
-
addChangeOutput(to, assetId
|
39906
|
+
addChangeOutput(to, assetId) {
|
39880
39907
|
const changeOutput = this.getChangeOutputs().find(
|
39881
39908
|
(output3) => hexlify(output3.assetId) === assetId
|
39882
39909
|
);
|
@@ -39884,7 +39911,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39884
39911
|
this.pushOutput({
|
39885
39912
|
type: OutputType.Change,
|
39886
39913
|
to: addressify(to).toB256(),
|
39887
|
-
assetId
|
39914
|
+
assetId: assetId ?? this.baseAssetId
|
39888
39915
|
});
|
39889
39916
|
}
|
39890
39917
|
}
|
@@ -39960,7 +39987,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39960
39987
|
]);
|
39961
39988
|
}
|
39962
39989
|
};
|
39963
|
-
updateAssetInput(
|
39990
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39964
39991
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39965
39992
|
}
|
39966
39993
|
/**
|
@@ -40117,12 +40144,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40117
40144
|
*
|
40118
40145
|
* @param createTransactionRequestLike - The initial values for the instance
|
40119
40146
|
*/
|
40120
|
-
constructor({
|
40121
|
-
bytecodeWitnessIndex,
|
40122
|
-
salt,
|
40123
|
-
storageSlots,
|
40124
|
-
...rest
|
40125
|
-
} = {}) {
|
40147
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40126
40148
|
super(rest);
|
40127
40149
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40128
40150
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40237,7 +40259,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40237
40259
|
*
|
40238
40260
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40239
40261
|
*/
|
40240
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40262
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40241
40263
|
super(rest);
|
40242
40264
|
this.gasLimit = bn(gasLimit);
|
40243
40265
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41383,6 +41405,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41383
41405
|
gasPerByte: bn(feeParams.gasPerByte),
|
41384
41406
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41385
41407
|
chainId: bn(consensusParameters.chainId),
|
41408
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41386
41409
|
gasCosts
|
41387
41410
|
},
|
41388
41411
|
gasCosts,
|
@@ -41625,6 +41648,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41625
41648
|
} = this.getChain();
|
41626
41649
|
return chainId.toNumber();
|
41627
41650
|
}
|
41651
|
+
/**
|
41652
|
+
* Returns the base asset ID
|
41653
|
+
*
|
41654
|
+
* @returns A promise that resolves to the base asset ID
|
41655
|
+
*/
|
41656
|
+
getBaseAssetId() {
|
41657
|
+
const {
|
41658
|
+
consensusParameters: { baseAssetId }
|
41659
|
+
} = this.getChain();
|
41660
|
+
return baseAssetId;
|
41661
|
+
}
|
41628
41662
|
/**
|
41629
41663
|
* Submits a transaction to the chain to be executed.
|
41630
41664
|
*
|
@@ -42681,8 +42715,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42681
42715
|
* @param assetId - The asset ID to check the balance for.
|
42682
42716
|
* @returns A promise that resolves to the balance amount.
|
42683
42717
|
*/
|
42684
|
-
async getBalance(assetId
|
42685
|
-
const
|
42718
|
+
async getBalance(assetId) {
|
42719
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42720
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42686
42721
|
return amount;
|
42687
42722
|
}
|
42688
42723
|
/**
|
@@ -42720,9 +42755,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42720
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42721
42756
|
*/
|
42722
42757
|
async fund(request, coinQuantities, fee) {
|
42758
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42723
42759
|
const updatedQuantities = addAmountToAsset({
|
42724
42760
|
amount: bn(fee),
|
42725
|
-
assetId:
|
42761
|
+
assetId: baseAssetId,
|
42726
42762
|
coinQuantities
|
42727
42763
|
});
|
42728
42764
|
const quantitiesDict = {};
|
@@ -42746,8 +42782,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42746
42782
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42747
42783
|
cachedUtxos.push(input.id);
|
42748
42784
|
}
|
42749
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42750
|
-
quantitiesDict[
|
42785
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42786
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42751
42787
|
cachedMessages.push(input.nonce);
|
42752
42788
|
}
|
42753
42789
|
}
|
@@ -42779,11 +42815,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42779
42815
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42780
42816
|
* @returns A promise that resolves to the prepared transaction request.
|
42781
42817
|
*/
|
42782
|
-
async createTransfer(destination, amount, assetId
|
42818
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42783
42819
|
const { minGasPrice } = this.provider.getGasConfig();
|
42784
|
-
const
|
42820
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42821
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42822
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42785
42823
|
const request = new ScriptTransactionRequest(params);
|
42786
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42824
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42787
42825
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42788
42826
|
estimateTxDependencies: true,
|
42789
42827
|
resourcesOwner: this
|
@@ -42809,14 +42847,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42809
42847
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42810
42848
|
* @returns A promise that resolves to the transaction response.
|
42811
42849
|
*/
|
42812
|
-
async transfer(destination, amount, assetId
|
42850
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42813
42851
|
if (bn(amount).lte(0)) {
|
42814
42852
|
throw new FuelError(
|
42815
42853
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42816
42854
|
"Transfer amount must be a positive number."
|
42817
42855
|
);
|
42818
42856
|
}
|
42819
|
-
const
|
42857
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42858
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42820
42859
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42821
42860
|
}
|
42822
42861
|
/**
|
@@ -42828,7 +42867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42828
42867
|
* @param txParams - The optional transaction parameters.
|
42829
42868
|
* @returns A promise that resolves to the transaction response.
|
42830
42869
|
*/
|
42831
|
-
async transferToContract(contractId, amount, assetId
|
42870
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42832
42871
|
if (bn(amount).lte(0)) {
|
42833
42872
|
throw new FuelError(
|
42834
42873
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42837,11 +42876,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42837
42876
|
}
|
42838
42877
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42839
42878
|
const { minGasPrice } = this.provider.getGasConfig();
|
42840
|
-
const
|
42879
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42880
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42881
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42841
42882
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42842
42883
|
hexlifiedContractId: contractAddress.toB256(),
|
42843
42884
|
amountToTransfer: bn(amount),
|
42844
|
-
assetId
|
42885
|
+
assetId: assetIdToTransfer
|
42845
42886
|
});
|
42846
42887
|
const request = new ScriptTransactionRequest({
|
42847
42888
|
...params,
|
@@ -42851,7 +42892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42851
42892
|
request.addContractInputAndOutput(contractAddress);
|
42852
42893
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42853
42894
|
request,
|
42854
|
-
[{ amount: bn(amount), assetId: String(
|
42895
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42855
42896
|
);
|
42856
42897
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42857
42898
|
this.validateGas({
|
@@ -42873,6 +42914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42873
42914
|
*/
|
42874
42915
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42875
42916
|
const { minGasPrice } = this.provider.getGasConfig();
|
42917
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42876
42918
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42877
42919
|
const recipientDataArray = arrayify(
|
42878
42920
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42885,9 +42927,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42885
42927
|
...recipientDataArray,
|
42886
42928
|
...amountDataArray
|
42887
42929
|
]);
|
42888
|
-
const params = {
|
42930
|
+
const params = {
|
42931
|
+
script,
|
42932
|
+
gasPrice: minGasPrice,
|
42933
|
+
baseAssetId,
|
42934
|
+
...txParams
|
42935
|
+
};
|
42889
42936
|
const request = new ScriptTransactionRequest(params);
|
42890
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42937
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42891
42938
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42892
42939
|
request,
|
42893
42940
|
forwardingQuantities
|
@@ -47837,7 +47884,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47837
47884
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47838
47885
|
input.predicate = this.bytes;
|
47839
47886
|
input.predicateData = this.getPredicateData(policies.length);
|
47840
|
-
input.witnessIndex = 0;
|
47841
47887
|
}
|
47842
47888
|
});
|
47843
47889
|
return request;
|
@@ -47851,8 +47897,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47851
47897
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47852
47898
|
* @returns A promise that resolves to the prepared transaction request.
|
47853
47899
|
*/
|
47854
|
-
async createTransfer(destination, amount, assetId
|
47855
|
-
const
|
47900
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47901
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47902
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47856
47903
|
return this.populateTransactionPredicateData(request);
|
47857
47904
|
}
|
47858
47905
|
/**
|
@@ -47875,20 +47922,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47875
47922
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47876
47923
|
return super.simulateTransaction(transactionRequest);
|
47877
47924
|
}
|
47878
|
-
/**
|
47879
|
-
* Retrieves resources satisfying the spend query for the account.
|
47880
|
-
*
|
47881
|
-
* @param quantities - IDs of coins to exclude.
|
47882
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
47883
|
-
* @returns A promise that resolves to an array of Resources.
|
47884
|
-
*/
|
47885
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
47886
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47887
|
-
return resources.map((resource) => ({
|
47888
|
-
...resource,
|
47889
|
-
predicate: hexlify(this.bytes)
|
47890
|
-
}));
|
47891
|
-
}
|
47892
47925
|
getPredicateData(policiesLength) {
|
47893
47926
|
if (!this.predicateData.length) {
|
47894
47927
|
return new Uint8Array();
|