@fuel-ts/account 0.0.0-rc-2037-20240411135757 → 0.0.0-rc-1976-20240411153008
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 +135 -104
- 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 +138 -89
- 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);
|
@@ -38864,6 +38860,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38864
38860
|
}
|
38865
38861
|
};
|
38866
38862
|
|
38863
|
+
// ../address/dist/configs.mjs
|
38864
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38865
|
+
|
38867
38866
|
// src/providers/transaction-request/input.ts
|
38868
38867
|
var inputify = (value) => {
|
38869
38868
|
const { type: type3 } = value;
|
@@ -39540,6 +39539,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39540
39539
|
outputs = [];
|
39541
39540
|
/** List of witnesses */
|
39542
39541
|
witnesses = [];
|
39542
|
+
/** Base asset ID - should be fetched from the chain */
|
39543
|
+
baseAssetId;
|
39543
39544
|
/**
|
39544
39545
|
* Constructor for initializing a base transaction request.
|
39545
39546
|
*
|
@@ -39552,8 +39553,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39552
39553
|
witnessLimit,
|
39553
39554
|
inputs,
|
39554
39555
|
outputs,
|
39555
|
-
witnesses
|
39556
|
-
|
39556
|
+
witnesses,
|
39557
|
+
baseAssetId
|
39558
|
+
}) {
|
39557
39559
|
this.gasPrice = bn(gasPrice);
|
39558
39560
|
this.maturity = maturity ?? 0;
|
39559
39561
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39561,6 +39563,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39561
39563
|
this.inputs = inputs ?? [];
|
39562
39564
|
this.outputs = outputs ?? [];
|
39563
39565
|
this.witnesses = witnesses ?? [];
|
39566
|
+
this.baseAssetId = baseAssetId;
|
39564
39567
|
}
|
39565
39568
|
static getPolicyMeta(req) {
|
39566
39569
|
let policyTypes = 0;
|
@@ -39754,8 +39757,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39754
39757
|
* @param predicate - Predicate bytes.
|
39755
39758
|
* @param predicateData - Predicate data bytes.
|
39756
39759
|
*/
|
39757
|
-
addCoinInput(coin) {
|
39758
|
-
const { assetId, owner, amount
|
39760
|
+
addCoinInput(coin, predicate) {
|
39761
|
+
const { assetId, owner, amount } = coin;
|
39759
39762
|
let witnessIndex;
|
39760
39763
|
if (predicate) {
|
39761
39764
|
witnessIndex = 0;
|
@@ -39766,14 +39769,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39766
39769
|
}
|
39767
39770
|
}
|
39768
39771
|
const input = {
|
39769
|
-
|
39772
|
+
...coin,
|
39770
39773
|
type: InputType.Coin,
|
39771
39774
|
owner: owner.toB256(),
|
39772
39775
|
amount,
|
39773
39776
|
assetId,
|
39774
39777
|
txPointer: "0x00000000000000000000000000000000",
|
39775
39778
|
witnessIndex,
|
39776
|
-
predicate
|
39779
|
+
predicate: predicate?.bytes
|
39777
39780
|
};
|
39778
39781
|
this.pushInput(input);
|
39779
39782
|
this.addChangeOutput(owner, assetId);
|
@@ -39784,11 +39787,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39784
39787
|
*
|
39785
39788
|
* @param message - Message resource.
|
39786
39789
|
* @param predicate - Predicate bytes.
|
39787
|
-
* @param predicateData - Predicate data bytes.
|
39788
39790
|
*/
|
39789
|
-
addMessageInput(message) {
|
39790
|
-
const { recipient, sender, amount
|
39791
|
-
const assetId = BaseAssetId;
|
39791
|
+
addMessageInput(message, predicate) {
|
39792
|
+
const { recipient, sender, amount } = message;
|
39792
39793
|
let witnessIndex;
|
39793
39794
|
if (predicate) {
|
39794
39795
|
witnessIndex = 0;
|
@@ -39799,16 +39800,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39799
39800
|
}
|
39800
39801
|
}
|
39801
39802
|
const input = {
|
39802
|
-
|
39803
|
+
...message,
|
39803
39804
|
type: InputType.Message,
|
39804
39805
|
sender: sender.toB256(),
|
39805
39806
|
recipient: recipient.toB256(),
|
39806
39807
|
amount,
|
39807
39808
|
witnessIndex,
|
39808
|
-
predicate
|
39809
|
+
predicate: predicate?.bytes
|
39809
39810
|
};
|
39810
39811
|
this.pushInput(input);
|
39811
|
-
this.addChangeOutput(recipient,
|
39812
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39812
39813
|
}
|
39813
39814
|
/**
|
39814
39815
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39836,6 +39837,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39836
39837
|
resources.forEach((resource) => this.addResource(resource));
|
39837
39838
|
return this;
|
39838
39839
|
}
|
39840
|
+
/**
|
39841
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39842
|
+
* outputs from the related assetIds.
|
39843
|
+
*
|
39844
|
+
* @param resources - The resources to add.
|
39845
|
+
* @returns This transaction.
|
39846
|
+
*/
|
39847
|
+
addPredicateResource(resource, predicate) {
|
39848
|
+
if (isCoin(resource)) {
|
39849
|
+
this.addCoinInput(resource, predicate);
|
39850
|
+
} else {
|
39851
|
+
this.addMessageInput(resource, predicate);
|
39852
|
+
}
|
39853
|
+
return this;
|
39854
|
+
}
|
39855
|
+
/**
|
39856
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39857
|
+
* from the related assetIds.
|
39858
|
+
*
|
39859
|
+
* @param resources - The resources to add.
|
39860
|
+
* @returns This transaction.
|
39861
|
+
*/
|
39862
|
+
addPredicateResources(resources, predicate) {
|
39863
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39864
|
+
return this;
|
39865
|
+
}
|
39839
39866
|
/**
|
39840
39867
|
* Adds a coin output to the transaction.
|
39841
39868
|
*
|
@@ -39843,12 +39870,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39843
39870
|
* @param amount - Amount of coin.
|
39844
39871
|
* @param assetId - Asset ID of coin.
|
39845
39872
|
*/
|
39846
|
-
addCoinOutput(to, amount, assetId
|
39873
|
+
addCoinOutput(to, amount, assetId) {
|
39847
39874
|
this.pushOutput({
|
39848
39875
|
type: OutputType.Coin,
|
39849
39876
|
to: addressify(to).toB256(),
|
39850
39877
|
amount,
|
39851
|
-
assetId
|
39878
|
+
assetId: assetId ?? this.baseAssetId
|
39852
39879
|
});
|
39853
39880
|
return this;
|
39854
39881
|
}
|
@@ -39875,7 +39902,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39875
39902
|
* @param to - Address of the owner.
|
39876
39903
|
* @param assetId - Asset ID of coin.
|
39877
39904
|
*/
|
39878
|
-
addChangeOutput(to, assetId
|
39905
|
+
addChangeOutput(to, assetId) {
|
39879
39906
|
const changeOutput = this.getChangeOutputs().find(
|
39880
39907
|
(output3) => hexlify(output3.assetId) === assetId
|
39881
39908
|
);
|
@@ -39883,7 +39910,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39883
39910
|
this.pushOutput({
|
39884
39911
|
type: OutputType.Change,
|
39885
39912
|
to: addressify(to).toB256(),
|
39886
|
-
assetId
|
39913
|
+
assetId: assetId ?? this.baseAssetId
|
39887
39914
|
});
|
39888
39915
|
}
|
39889
39916
|
}
|
@@ -39965,7 +39992,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39965
39992
|
]);
|
39966
39993
|
}
|
39967
39994
|
};
|
39968
|
-
updateAssetInput(
|
39995
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39969
39996
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39970
39997
|
}
|
39971
39998
|
/**
|
@@ -40122,12 +40149,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40122
40149
|
*
|
40123
40150
|
* @param createTransactionRequestLike - The initial values for the instance
|
40124
40151
|
*/
|
40125
|
-
constructor({
|
40126
|
-
bytecodeWitnessIndex,
|
40127
|
-
salt,
|
40128
|
-
storageSlots,
|
40129
|
-
...rest
|
40130
|
-
} = {}) {
|
40152
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40131
40153
|
super(rest);
|
40132
40154
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40133
40155
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40242,7 +40264,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40242
40264
|
*
|
40243
40265
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40244
40266
|
*/
|
40245
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40267
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40246
40268
|
super(rest);
|
40247
40269
|
this.gasLimit = bn(gasLimit);
|
40248
40270
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41388,6 +41410,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41388
41410
|
gasPerByte: bn(feeParams.gasPerByte),
|
41389
41411
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41390
41412
|
chainId: bn(consensusParameters.chainId),
|
41413
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41391
41414
|
gasCosts
|
41392
41415
|
},
|
41393
41416
|
gasCosts,
|
@@ -41630,6 +41653,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41630
41653
|
} = this.getChain();
|
41631
41654
|
return chainId.toNumber();
|
41632
41655
|
}
|
41656
|
+
/**
|
41657
|
+
* Returns the base asset ID
|
41658
|
+
*
|
41659
|
+
* @returns A promise that resolves to the base asset ID
|
41660
|
+
*/
|
41661
|
+
getBaseAssetId() {
|
41662
|
+
const {
|
41663
|
+
consensusParameters: { baseAssetId }
|
41664
|
+
} = this.getChain();
|
41665
|
+
return baseAssetId;
|
41666
|
+
}
|
41633
41667
|
/**
|
41634
41668
|
* Submits a transaction to the chain to be executed.
|
41635
41669
|
*
|
@@ -42659,8 +42693,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42659
42693
|
* @param assetId - The asset ID to check the balance for.
|
42660
42694
|
* @returns A promise that resolves to the balance amount.
|
42661
42695
|
*/
|
42662
|
-
async getBalance(assetId
|
42663
|
-
const
|
42696
|
+
async getBalance(assetId) {
|
42697
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42698
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42664
42699
|
return amount;
|
42665
42700
|
}
|
42666
42701
|
/**
|
@@ -42698,9 +42733,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42698
42733
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42699
42734
|
*/
|
42700
42735
|
async fund(request, coinQuantities, fee) {
|
42736
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42701
42737
|
const updatedQuantities = addAmountToAsset({
|
42702
42738
|
amount: bn(fee),
|
42703
|
-
assetId:
|
42739
|
+
assetId: baseAssetId,
|
42704
42740
|
coinQuantities
|
42705
42741
|
});
|
42706
42742
|
const quantitiesDict = {};
|
@@ -42724,8 +42760,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42724
42760
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42725
42761
|
cachedUtxos.push(input.id);
|
42726
42762
|
}
|
42727
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42728
|
-
quantitiesDict[
|
42763
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42764
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42729
42765
|
cachedMessages.push(input.nonce);
|
42730
42766
|
}
|
42731
42767
|
}
|
@@ -42757,11 +42793,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42757
42793
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42758
42794
|
* @returns A promise that resolves to the prepared transaction request.
|
42759
42795
|
*/
|
42760
|
-
async createTransfer(destination, amount, assetId
|
42796
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42761
42797
|
const { minGasPrice } = this.provider.getGasConfig();
|
42762
|
-
const
|
42798
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42799
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42800
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42763
42801
|
const request = new ScriptTransactionRequest(params);
|
42764
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42802
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42765
42803
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42766
42804
|
estimateTxDependencies: true,
|
42767
42805
|
resourcesOwner: this
|
@@ -42787,14 +42825,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42787
42825
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42788
42826
|
* @returns A promise that resolves to the transaction response.
|
42789
42827
|
*/
|
42790
|
-
async transfer(destination, amount, assetId
|
42828
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42791
42829
|
if (bn(amount).lte(0)) {
|
42792
42830
|
throw new FuelError(
|
42793
42831
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42794
42832
|
"Transfer amount must be a positive number."
|
42795
42833
|
);
|
42796
42834
|
}
|
42797
|
-
const
|
42835
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42836
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42798
42837
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42799
42838
|
}
|
42800
42839
|
/**
|
@@ -42806,7 +42845,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42806
42845
|
* @param txParams - The optional transaction parameters.
|
42807
42846
|
* @returns A promise that resolves to the transaction response.
|
42808
42847
|
*/
|
42809
|
-
async transferToContract(contractId, amount, assetId
|
42848
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42810
42849
|
if (bn(amount).lte(0)) {
|
42811
42850
|
throw new FuelError(
|
42812
42851
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42815,11 +42854,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42815
42854
|
}
|
42816
42855
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42817
42856
|
const { minGasPrice } = this.provider.getGasConfig();
|
42818
|
-
const
|
42857
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42858
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42859
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42819
42860
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42820
42861
|
hexlifiedContractId: contractAddress.toB256(),
|
42821
42862
|
amountToTransfer: bn(amount),
|
42822
|
-
assetId
|
42863
|
+
assetId: assetIdToTransfer
|
42823
42864
|
});
|
42824
42865
|
const request = new ScriptTransactionRequest({
|
42825
42866
|
...params,
|
@@ -42829,7 +42870,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42829
42870
|
request.addContractInputAndOutput(contractAddress);
|
42830
42871
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42831
42872
|
request,
|
42832
|
-
[{ amount: bn(amount), assetId: String(
|
42873
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42833
42874
|
);
|
42834
42875
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42835
42876
|
this.validateGas({
|
@@ -42851,6 +42892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42851
42892
|
*/
|
42852
42893
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42853
42894
|
const { minGasPrice } = this.provider.getGasConfig();
|
42895
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42854
42896
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42855
42897
|
const recipientDataArray = arrayify(
|
42856
42898
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42863,9 +42905,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42863
42905
|
...recipientDataArray,
|
42864
42906
|
...amountDataArray
|
42865
42907
|
]);
|
42866
|
-
const params = {
|
42908
|
+
const params = {
|
42909
|
+
script,
|
42910
|
+
gasPrice: minGasPrice,
|
42911
|
+
baseAssetId,
|
42912
|
+
...txParams
|
42913
|
+
};
|
42867
42914
|
const request = new ScriptTransactionRequest(params);
|
42868
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42915
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42869
42916
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42870
42917
|
request,
|
42871
42918
|
forwardingQuantities
|
@@ -47815,7 +47862,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47815
47862
|
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47816
47863
|
input.predicate = this.bytes;
|
47817
47864
|
input.predicateData = this.getPredicateData(policies.length);
|
47818
|
-
input.witnessIndex = 0;
|
47819
47865
|
}
|
47820
47866
|
});
|
47821
47867
|
return request;
|
@@ -47829,8 +47875,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47829
47875
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47830
47876
|
* @returns A promise that resolves to the prepared transaction request.
|
47831
47877
|
*/
|
47832
|
-
async createTransfer(destination, amount, assetId
|
47833
|
-
const
|
47878
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47879
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47880
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47834
47881
|
return this.populateTransactionPredicateData(request);
|
47835
47882
|
}
|
47836
47883
|
/**
|
@@ -47853,20 +47900,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47853
47900
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47854
47901
|
return super.simulateTransaction(transactionRequest);
|
47855
47902
|
}
|
47856
|
-
/**
|
47857
|
-
* Retrieves resources satisfying the spend query for the account.
|
47858
|
-
*
|
47859
|
-
* @param quantities - IDs of coins to exclude.
|
47860
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
47861
|
-
* @returns A promise that resolves to an array of Resources.
|
47862
|
-
*/
|
47863
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
47864
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47865
|
-
return resources.map((resource) => ({
|
47866
|
-
...resource,
|
47867
|
-
predicate: hexlify(this.bytes)
|
47868
|
-
}));
|
47869
|
-
}
|
47870
47903
|
getPredicateData(policiesLength) {
|
47871
47904
|
if (!this.predicateData.length) {
|
47872
47905
|
return new Uint8Array();
|