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