@fuel-ts/account 0.0.0-rc-2037-20240417131250 → 0.0.0-rc-1976-20240417144614
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 +100 -124
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +241 -280
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -159
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -11
- 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/index.d.ts +0 -1
- package/dist/providers/transaction-request/index.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 -6
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +0 -1
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +105 -104
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +238 -253
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +129 -141
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -15
- package/dist/providers/transaction-request/helpers.d.ts +0 -10
- package/dist/providers/transaction-request/helpers.d.ts.map +0 -1
- package/dist/test-utils/resources.d.ts +0 -4
- package/dist/test-utils/resources.d.ts.map +0 -1
- package/dist/test-utils/transactionRequest.d.ts +0 -5
- package/dist/test-utils/transactionRequest.d.ts.map +0 -1
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":"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"}
|
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);
|
@@ -38874,6 +38870,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38874
38870
|
}
|
38875
38871
|
};
|
38876
38872
|
|
38873
|
+
// ../address/dist/configs.mjs
|
38874
|
+
var ZeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
38875
|
+
|
38877
38876
|
// src/providers/transaction-request/input.ts
|
38878
38877
|
var inputify = (value) => {
|
38879
38878
|
const { type: type3 } = value;
|
@@ -39525,32 +39524,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39525
39524
|
name = "NoWitnessByOwnerError";
|
39526
39525
|
};
|
39527
39526
|
|
39528
|
-
// src/providers/transaction-request/helpers.ts
|
39529
|
-
var isRequestInputCoin = (input) => input.type === InputType.Coin;
|
39530
|
-
var isRequestInputMessage = (input) => input.type === InputType.Message;
|
39531
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
39532
|
-
var getRequestInputResourceOwner = (input) => {
|
39533
|
-
if (isRequestInputCoin(input)) {
|
39534
|
-
return input.owner;
|
39535
|
-
}
|
39536
|
-
return input.recipient;
|
39537
|
-
};
|
39538
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
39539
|
-
var cacheResources = (resources) => resources.reduce(
|
39540
|
-
(cache2, resource) => {
|
39541
|
-
if (isCoin(resource)) {
|
39542
|
-
cache2.utxos.push(resource.id);
|
39543
|
-
} else {
|
39544
|
-
cache2.messages.push(resource.nonce);
|
39545
|
-
}
|
39546
|
-
return cache2;
|
39547
|
-
},
|
39548
|
-
{
|
39549
|
-
utxos: [],
|
39550
|
-
messages: []
|
39551
|
-
}
|
39552
|
-
);
|
39553
|
-
|
39554
39527
|
// src/providers/transaction-request/witness.ts
|
39555
39528
|
var witnessify = (value) => {
|
39556
39529
|
const data = arrayify(value);
|
@@ -39576,6 +39549,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39576
39549
|
outputs = [];
|
39577
39550
|
/** List of witnesses */
|
39578
39551
|
witnesses = [];
|
39552
|
+
/** Base asset ID - should be fetched from the chain */
|
39553
|
+
baseAssetId;
|
39579
39554
|
/**
|
39580
39555
|
* Constructor for initializing a base transaction request.
|
39581
39556
|
*
|
@@ -39588,8 +39563,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39588
39563
|
witnessLimit,
|
39589
39564
|
inputs,
|
39590
39565
|
outputs,
|
39591
|
-
witnesses
|
39592
|
-
|
39566
|
+
witnesses,
|
39567
|
+
baseAssetId
|
39568
|
+
}) {
|
39593
39569
|
this.gasPrice = bn(gasPrice);
|
39594
39570
|
this.maturity = maturity ?? 0;
|
39595
39571
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39597,6 +39573,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39597
39573
|
this.inputs = inputs ?? [];
|
39598
39574
|
this.outputs = outputs ?? [];
|
39599
39575
|
this.witnesses = witnesses ?? [];
|
39576
|
+
this.baseAssetId = baseAssetId;
|
39600
39577
|
}
|
39601
39578
|
static getPolicyMeta(req) {
|
39602
39579
|
let policyTypes = 0;
|
@@ -39790,8 +39767,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39790
39767
|
* @param predicate - Predicate bytes.
|
39791
39768
|
* @param predicateData - Predicate data bytes.
|
39792
39769
|
*/
|
39793
|
-
addCoinInput(coin) {
|
39794
|
-
const { assetId, owner, amount
|
39770
|
+
addCoinInput(coin, predicate) {
|
39771
|
+
const { assetId, owner, amount } = coin;
|
39795
39772
|
let witnessIndex;
|
39796
39773
|
if (predicate) {
|
39797
39774
|
witnessIndex = 0;
|
@@ -39802,14 +39779,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39802
39779
|
}
|
39803
39780
|
}
|
39804
39781
|
const input = {
|
39805
|
-
|
39782
|
+
...coin,
|
39806
39783
|
type: InputType.Coin,
|
39807
39784
|
owner: owner.toB256(),
|
39808
39785
|
amount,
|
39809
39786
|
assetId,
|
39810
39787
|
txPointer: "0x00000000000000000000000000000000",
|
39811
39788
|
witnessIndex,
|
39812
|
-
predicate
|
39789
|
+
predicate: predicate?.bytes
|
39813
39790
|
};
|
39814
39791
|
this.pushInput(input);
|
39815
39792
|
this.addChangeOutput(owner, assetId);
|
@@ -39820,11 +39797,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39820
39797
|
*
|
39821
39798
|
* @param message - Message resource.
|
39822
39799
|
* @param predicate - Predicate bytes.
|
39823
|
-
* @param predicateData - Predicate data bytes.
|
39824
39800
|
*/
|
39825
|
-
addMessageInput(message) {
|
39826
|
-
const { recipient, sender, amount
|
39827
|
-
const assetId = BaseAssetId;
|
39801
|
+
addMessageInput(message, predicate) {
|
39802
|
+
const { recipient, sender, amount } = message;
|
39828
39803
|
let witnessIndex;
|
39829
39804
|
if (predicate) {
|
39830
39805
|
witnessIndex = 0;
|
@@ -39835,16 +39810,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39835
39810
|
}
|
39836
39811
|
}
|
39837
39812
|
const input = {
|
39838
|
-
|
39813
|
+
...message,
|
39839
39814
|
type: InputType.Message,
|
39840
39815
|
sender: sender.toB256(),
|
39841
39816
|
recipient: recipient.toB256(),
|
39842
39817
|
amount,
|
39843
39818
|
witnessIndex,
|
39844
|
-
predicate
|
39819
|
+
predicate: predicate?.bytes
|
39845
39820
|
};
|
39846
39821
|
this.pushInput(input);
|
39847
|
-
this.addChangeOutput(recipient,
|
39822
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39848
39823
|
}
|
39849
39824
|
/**
|
39850
39825
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39872,6 +39847,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39872
39847
|
resources.forEach((resource) => this.addResource(resource));
|
39873
39848
|
return this;
|
39874
39849
|
}
|
39850
|
+
/**
|
39851
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39852
|
+
* outputs from the related assetIds.
|
39853
|
+
*
|
39854
|
+
* @param resources - The resources to add.
|
39855
|
+
* @returns This transaction.
|
39856
|
+
*/
|
39857
|
+
addPredicateResource(resource, predicate) {
|
39858
|
+
if (isCoin(resource)) {
|
39859
|
+
this.addCoinInput(resource, predicate);
|
39860
|
+
} else {
|
39861
|
+
this.addMessageInput(resource, predicate);
|
39862
|
+
}
|
39863
|
+
return this;
|
39864
|
+
}
|
39865
|
+
/**
|
39866
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39867
|
+
* from the related assetIds.
|
39868
|
+
*
|
39869
|
+
* @param resources - The resources to add.
|
39870
|
+
* @returns This transaction.
|
39871
|
+
*/
|
39872
|
+
addPredicateResources(resources, predicate) {
|
39873
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39874
|
+
return this;
|
39875
|
+
}
|
39875
39876
|
/**
|
39876
39877
|
* Adds a coin output to the transaction.
|
39877
39878
|
*
|
@@ -39879,12 +39880,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39879
39880
|
* @param amount - Amount of coin.
|
39880
39881
|
* @param assetId - Asset ID of coin.
|
39881
39882
|
*/
|
39882
|
-
addCoinOutput(to, amount, assetId
|
39883
|
+
addCoinOutput(to, amount, assetId) {
|
39883
39884
|
this.pushOutput({
|
39884
39885
|
type: OutputType.Coin,
|
39885
39886
|
to: addressify(to).toB256(),
|
39886
39887
|
amount,
|
39887
|
-
assetId
|
39888
|
+
assetId: assetId ?? this.baseAssetId
|
39888
39889
|
});
|
39889
39890
|
return this;
|
39890
39891
|
}
|
@@ -39911,7 +39912,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39911
39912
|
* @param to - Address of the owner.
|
39912
39913
|
* @param assetId - Asset ID of coin.
|
39913
39914
|
*/
|
39914
|
-
addChangeOutput(to, assetId
|
39915
|
+
addChangeOutput(to, assetId) {
|
39915
39916
|
const changeOutput = this.getChangeOutputs().find(
|
39916
39917
|
(output3) => hexlify(output3.assetId) === assetId
|
39917
39918
|
);
|
@@ -39919,7 +39920,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39919
39920
|
this.pushOutput({
|
39920
39921
|
type: OutputType.Change,
|
39921
39922
|
to: addressify(to).toB256(),
|
39922
|
-
assetId
|
39923
|
+
assetId: assetId ?? this.baseAssetId
|
39923
39924
|
});
|
39924
39925
|
}
|
39925
39926
|
}
|
@@ -39995,7 +39996,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39995
39996
|
]);
|
39996
39997
|
}
|
39997
39998
|
};
|
39998
|
-
updateAssetInput(
|
39999
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39999
40000
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
40000
40001
|
}
|
40001
40002
|
/**
|
@@ -40020,10 +40021,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40020
40021
|
toJSON() {
|
40021
40022
|
return normalizeJSON(this);
|
40022
40023
|
}
|
40023
|
-
removeWitness(index) {
|
40024
|
-
this.witnesses.splice(index, 1);
|
40025
|
-
this.adjustWitnessIndexes(index);
|
40026
|
-
}
|
40027
40024
|
updatePredicateInputs(inputs) {
|
40028
40025
|
this.inputs.forEach((i) => {
|
40029
40026
|
let correspondingInput;
|
@@ -40046,13 +40043,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40046
40043
|
}
|
40047
40044
|
});
|
40048
40045
|
}
|
40049
|
-
adjustWitnessIndexes(removedIndex) {
|
40050
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
40051
|
-
if (input.witnessIndex > removedIndex) {
|
40052
|
-
input.witnessIndex -= 1;
|
40053
|
-
}
|
40054
|
-
});
|
40055
|
-
}
|
40056
40046
|
};
|
40057
40047
|
|
40058
40048
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40163,12 +40153,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40163
40153
|
*
|
40164
40154
|
* @param createTransactionRequestLike - The initial values for the instance
|
40165
40155
|
*/
|
40166
|
-
constructor({
|
40167
|
-
bytecodeWitnessIndex,
|
40168
|
-
salt,
|
40169
|
-
storageSlots,
|
40170
|
-
...rest
|
40171
|
-
} = {}) {
|
40156
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40172
40157
|
super(rest);
|
40173
40158
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40174
40159
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40283,7 +40268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40283
40268
|
*
|
40284
40269
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40285
40270
|
*/
|
40286
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40271
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40287
40272
|
super(rest);
|
40288
40273
|
this.gasLimit = bn(gasLimit);
|
40289
40274
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41429,6 +41414,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41429
41414
|
gasPerByte: bn(feeParams.gasPerByte),
|
41430
41415
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41431
41416
|
chainId: bn(consensusParameters.chainId),
|
41417
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41432
41418
|
gasCosts
|
41433
41419
|
},
|
41434
41420
|
gasCosts,
|
@@ -41671,6 +41657,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41671
41657
|
} = this.getChain();
|
41672
41658
|
return chainId.toNumber();
|
41673
41659
|
}
|
41660
|
+
/**
|
41661
|
+
* Returns the base asset ID
|
41662
|
+
*
|
41663
|
+
* @returns A promise that resolves to the base asset ID
|
41664
|
+
*/
|
41665
|
+
getBaseAssetId() {
|
41666
|
+
const {
|
41667
|
+
consensusParameters: { baseAssetId }
|
41668
|
+
} = this.getChain();
|
41669
|
+
return baseAssetId;
|
41670
|
+
}
|
41674
41671
|
/**
|
41675
41672
|
* Submits a transaction to the chain to be executed.
|
41676
41673
|
*
|
@@ -42727,8 +42724,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42727
42724
|
* @param assetId - The asset ID to check the balance for.
|
42728
42725
|
* @returns A promise that resolves to the balance amount.
|
42729
42726
|
*/
|
42730
|
-
async getBalance(assetId
|
42731
|
-
const
|
42727
|
+
async getBalance(assetId) {
|
42728
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42729
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42732
42730
|
return amount;
|
42733
42731
|
}
|
42734
42732
|
/**
|
@@ -42766,9 +42764,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42766
42764
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42767
42765
|
*/
|
42768
42766
|
async fund(request, coinQuantities, fee) {
|
42767
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42769
42768
|
const updatedQuantities = addAmountToAsset({
|
42770
42769
|
amount: bn(fee),
|
42771
|
-
assetId:
|
42770
|
+
assetId: baseAssetId,
|
42772
42771
|
coinQuantities
|
42773
42772
|
});
|
42774
42773
|
const quantitiesDict = {};
|
@@ -42792,8 +42791,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42792
42791
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42793
42792
|
cachedUtxos.push(input.id);
|
42794
42793
|
}
|
42795
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42796
|
-
quantitiesDict[
|
42794
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42795
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42797
42796
|
cachedMessages.push(input.nonce);
|
42798
42797
|
}
|
42799
42798
|
}
|
@@ -42825,11 +42824,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42825
42824
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42826
42825
|
* @returns A promise that resolves to the prepared transaction request.
|
42827
42826
|
*/
|
42828
|
-
async createTransfer(destination, amount, assetId
|
42827
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42829
42828
|
const { minGasPrice } = this.provider.getGasConfig();
|
42830
|
-
const
|
42829
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42830
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42831
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42831
42832
|
const request = new ScriptTransactionRequest(params);
|
42832
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42833
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42833
42834
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42834
42835
|
estimateTxDependencies: true,
|
42835
42836
|
resourcesOwner: this
|
@@ -42855,14 +42856,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42855
42856
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42856
42857
|
* @returns A promise that resolves to the transaction response.
|
42857
42858
|
*/
|
42858
|
-
async transfer(destination, amount, assetId
|
42859
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42859
42860
|
if (bn(amount).lte(0)) {
|
42860
42861
|
throw new FuelError(
|
42861
42862
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42862
42863
|
"Transfer amount must be a positive number."
|
42863
42864
|
);
|
42864
42865
|
}
|
42865
|
-
const
|
42866
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42867
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42866
42868
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42867
42869
|
}
|
42868
42870
|
/**
|
@@ -42874,7 +42876,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42874
42876
|
* @param txParams - The optional transaction parameters.
|
42875
42877
|
* @returns A promise that resolves to the transaction response.
|
42876
42878
|
*/
|
42877
|
-
async transferToContract(contractId, amount, assetId
|
42879
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42878
42880
|
if (bn(amount).lte(0)) {
|
42879
42881
|
throw new FuelError(
|
42880
42882
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42883,11 +42885,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42883
42885
|
}
|
42884
42886
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42885
42887
|
const { minGasPrice } = this.provider.getGasConfig();
|
42886
|
-
const
|
42888
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42889
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42890
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42887
42891
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42888
42892
|
hexlifiedContractId: contractAddress.toB256(),
|
42889
42893
|
amountToTransfer: bn(amount),
|
42890
|
-
assetId
|
42894
|
+
assetId: assetIdToTransfer
|
42891
42895
|
});
|
42892
42896
|
const request = new ScriptTransactionRequest({
|
42893
42897
|
...params,
|
@@ -42897,7 +42901,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42897
42901
|
request.addContractInputAndOutput(contractAddress);
|
42898
42902
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42899
42903
|
request,
|
42900
|
-
[{ amount: bn(amount), assetId: String(
|
42904
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42901
42905
|
);
|
42902
42906
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42903
42907
|
this.validateGas({
|
@@ -42919,6 +42923,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42919
42923
|
*/
|
42920
42924
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42921
42925
|
const { minGasPrice } = this.provider.getGasConfig();
|
42926
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42922
42927
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42923
42928
|
const recipientDataArray = arrayify(
|
42924
42929
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42931,9 +42936,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42931
42936
|
...recipientDataArray,
|
42932
42937
|
...amountDataArray
|
42933
42938
|
]);
|
42934
|
-
const params = {
|
42939
|
+
const params = {
|
42940
|
+
script,
|
42941
|
+
gasPrice: minGasPrice,
|
42942
|
+
baseAssetId,
|
42943
|
+
...txParams
|
42944
|
+
};
|
42935
42945
|
const request = new ScriptTransactionRequest(params);
|
42936
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42946
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42937
42947
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42938
42948
|
request,
|
42939
42949
|
forwardingQuantities
|
@@ -47879,15 +47889,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47879
47889
|
populateTransactionPredicateData(transactionRequestLike) {
|
47880
47890
|
const request = transactionRequestify(transactionRequestLike);
|
47881
47891
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47882
|
-
|
47883
|
-
|
47884
|
-
request.removeWitness(placeholderIndex);
|
47885
|
-
}
|
47886
|
-
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
47887
|
-
if (isRequestInputResourceFromOwner(input, this.address)) {
|
47892
|
+
request.inputs?.forEach((input) => {
|
47893
|
+
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47888
47894
|
input.predicate = this.bytes;
|
47889
47895
|
input.predicateData = this.getPredicateData(policies.length);
|
47890
|
-
input.witnessIndex = 0;
|
47891
47896
|
}
|
47892
47897
|
});
|
47893
47898
|
return request;
|
@@ -47901,8 +47906,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47901
47906
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47902
47907
|
* @returns A promise that resolves to the prepared transaction request.
|
47903
47908
|
*/
|
47904
|
-
async createTransfer(destination, amount, assetId
|
47905
|
-
const
|
47909
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
47910
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
47911
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
47906
47912
|
return this.populateTransactionPredicateData(request);
|
47907
47913
|
}
|
47908
47914
|
/**
|
@@ -47925,20 +47931,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47925
47931
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47926
47932
|
return super.simulateTransaction(transactionRequest);
|
47927
47933
|
}
|
47928
|
-
/**
|
47929
|
-
* Retrieves resources satisfying the spend query for the account.
|
47930
|
-
*
|
47931
|
-
* @param quantities - IDs of coins to exclude.
|
47932
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
47933
|
-
* @returns A promise that resolves to an array of Resources.
|
47934
|
-
*/
|
47935
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
47936
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47937
|
-
return resources.map((resource) => ({
|
47938
|
-
...resource,
|
47939
|
-
predicate: hexlify(this.bytes)
|
47940
|
-
}));
|
47941
|
-
}
|
47942
47934
|
getPredicateData(policiesLength) {
|
47943
47935
|
if (!this.predicateData.length) {
|
47944
47936
|
return new Uint8Array();
|
@@ -48018,22 +48010,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48018
48010
|
}
|
48019
48011
|
return mutatedBytes;
|
48020
48012
|
}
|
48021
|
-
getIndexFromPlaceholderWitness(request) {
|
48022
|
-
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
48023
|
-
let index = -1;
|
48024
|
-
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
48025
|
-
if (hasEmptyPredicateInputs) {
|
48026
|
-
index = hasEmptyPredicateInputs.witnessIndex;
|
48027
|
-
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
48028
|
-
if (!allInputsAreEmpty) {
|
48029
|
-
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
48030
|
-
if (wasFilledInputAddedFirst) {
|
48031
|
-
index = -1;
|
48032
|
-
}
|
48033
|
-
}
|
48034
|
-
}
|
48035
|
-
return index;
|
48036
|
-
}
|
48037
48013
|
};
|
48038
48014
|
|
48039
48015
|
// src/connectors/fuel-connector.ts
|