@fuel-ts/account 0.0.0-rc-2045-20240411194225 → 0.0.0-rc-1976-20240412134847
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 +67 -45
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +100 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -42
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/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 +5 -2
- 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 +71 -46
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +103 -80
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +65 -42
- 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.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,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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
@@ -28952,7 +28952,7 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
28956
|
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
@@ -31144,7 +31144,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31144
31144
|
toEvmAddress() {
|
31145
31145
|
const b256Address = toB256(this.bech32Address);
|
31146
31146
|
return {
|
31147
|
-
|
31147
|
+
value: clearFirst12BytesFromB256(b256Address)
|
31148
31148
|
};
|
31149
31149
|
}
|
31150
31150
|
/**
|
@@ -31154,7 +31154,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31154
31154
|
*/
|
31155
31155
|
toAssetId() {
|
31156
31156
|
return {
|
31157
|
-
|
31157
|
+
value: this.toB256()
|
31158
31158
|
};
|
31159
31159
|
}
|
31160
31160
|
/**
|
@@ -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;
|
@@ -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
39792
|
addMessageInput(message, predicate) {
|
39791
39793
|
const { recipient, sender, amount } = message;
|
39792
|
-
const assetId = BaseAssetId;
|
39793
39794
|
let witnessIndex;
|
39794
39795
|
if (predicate) {
|
39795
39796
|
witnessIndex = 0;
|
@@ -39809,7 +39810,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39809
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
|
@@ -39870,12 +39871,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39870
39871
|
* @param amount - Amount of coin.
|
39871
39872
|
* @param assetId - Asset ID of coin.
|
39872
39873
|
*/
|
39873
|
-
addCoinOutput(to, amount, assetId
|
39874
|
+
addCoinOutput(to, amount, assetId) {
|
39874
39875
|
this.pushOutput({
|
39875
39876
|
type: OutputType.Coin,
|
39876
39877
|
to: addressify(to).toB256(),
|
39877
39878
|
amount,
|
39878
|
-
assetId
|
39879
|
+
assetId: assetId ?? this.baseAssetId
|
39879
39880
|
});
|
39880
39881
|
return this;
|
39881
39882
|
}
|
@@ -39902,7 +39903,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39902
39903
|
* @param to - Address of the owner.
|
39903
39904
|
* @param assetId - Asset ID of coin.
|
39904
39905
|
*/
|
39905
|
-
addChangeOutput(to, assetId
|
39906
|
+
addChangeOutput(to, assetId) {
|
39906
39907
|
const changeOutput = this.getChangeOutputs().find(
|
39907
39908
|
(output3) => hexlify(output3.assetId) === assetId
|
39908
39909
|
);
|
@@ -39910,7 +39911,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39910
39911
|
this.pushOutput({
|
39911
39912
|
type: OutputType.Change,
|
39912
39913
|
to: addressify(to).toB256(),
|
39913
|
-
assetId
|
39914
|
+
assetId: assetId ?? this.baseAssetId
|
39914
39915
|
});
|
39915
39916
|
}
|
39916
39917
|
}
|
@@ -39986,7 +39987,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39986
39987
|
]);
|
39987
39988
|
}
|
39988
39989
|
};
|
39989
|
-
updateAssetInput(
|
39990
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39990
39991
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39991
39992
|
}
|
39992
39993
|
/**
|
@@ -40143,12 +40144,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40143
40144
|
*
|
40144
40145
|
* @param createTransactionRequestLike - The initial values for the instance
|
40145
40146
|
*/
|
40146
|
-
constructor({
|
40147
|
-
bytecodeWitnessIndex,
|
40148
|
-
salt,
|
40149
|
-
storageSlots,
|
40150
|
-
...rest
|
40151
|
-
} = {}) {
|
40147
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40152
40148
|
super(rest);
|
40153
40149
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40154
40150
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40263,7 +40259,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40263
40259
|
*
|
40264
40260
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40265
40261
|
*/
|
40266
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40262
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40267
40263
|
super(rest);
|
40268
40264
|
this.gasLimit = bn(gasLimit);
|
40269
40265
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41409,6 +41405,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41409
41405
|
gasPerByte: bn(feeParams.gasPerByte),
|
41410
41406
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41411
41407
|
chainId: bn(consensusParameters.chainId),
|
41408
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41412
41409
|
gasCosts
|
41413
41410
|
},
|
41414
41411
|
gasCosts,
|
@@ -41651,6 +41648,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41651
41648
|
} = this.getChain();
|
41652
41649
|
return chainId.toNumber();
|
41653
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
|
+
}
|
41654
41662
|
/**
|
41655
41663
|
* Submits a transaction to the chain to be executed.
|
41656
41664
|
*
|
@@ -42707,8 +42715,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42707
42715
|
* @param assetId - The asset ID to check the balance for.
|
42708
42716
|
* @returns A promise that resolves to the balance amount.
|
42709
42717
|
*/
|
42710
|
-
async getBalance(assetId
|
42711
|
-
const
|
42718
|
+
async getBalance(assetId) {
|
42719
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42720
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42712
42721
|
return amount;
|
42713
42722
|
}
|
42714
42723
|
/**
|
@@ -42746,9 +42755,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42746
42755
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42747
42756
|
*/
|
42748
42757
|
async fund(request, coinQuantities, fee) {
|
42758
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42749
42759
|
const updatedQuantities = addAmountToAsset({
|
42750
42760
|
amount: bn(fee),
|
42751
|
-
assetId:
|
42761
|
+
assetId: baseAssetId,
|
42752
42762
|
coinQuantities
|
42753
42763
|
});
|
42754
42764
|
const quantitiesDict = {};
|
@@ -42772,8 +42782,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42772
42782
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42773
42783
|
cachedUtxos.push(input.id);
|
42774
42784
|
}
|
42775
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42776
|
-
quantitiesDict[
|
42785
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42786
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42777
42787
|
cachedMessages.push(input.nonce);
|
42778
42788
|
}
|
42779
42789
|
}
|
@@ -42805,11 +42815,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42805
42815
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42806
42816
|
* @returns A promise that resolves to the prepared transaction request.
|
42807
42817
|
*/
|
42808
|
-
async createTransfer(destination, amount, assetId
|
42818
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42809
42819
|
const { minGasPrice } = this.provider.getGasConfig();
|
42810
|
-
const
|
42820
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42821
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42822
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42811
42823
|
const request = new ScriptTransactionRequest(params);
|
42812
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42824
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42813
42825
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42814
42826
|
estimateTxDependencies: true,
|
42815
42827
|
resourcesOwner: this
|
@@ -42835,14 +42847,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42835
42847
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42836
42848
|
* @returns A promise that resolves to the transaction response.
|
42837
42849
|
*/
|
42838
|
-
async transfer(destination, amount, assetId
|
42850
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42839
42851
|
if (bn(amount).lte(0)) {
|
42840
42852
|
throw new FuelError(
|
42841
42853
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42842
42854
|
"Transfer amount must be a positive number."
|
42843
42855
|
);
|
42844
42856
|
}
|
42845
|
-
const
|
42857
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42858
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42846
42859
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42847
42860
|
}
|
42848
42861
|
/**
|
@@ -42854,7 +42867,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42854
42867
|
* @param txParams - The optional transaction parameters.
|
42855
42868
|
* @returns A promise that resolves to the transaction response.
|
42856
42869
|
*/
|
42857
|
-
async transferToContract(contractId, amount, assetId
|
42870
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42858
42871
|
if (bn(amount).lte(0)) {
|
42859
42872
|
throw new FuelError(
|
42860
42873
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42863,11 +42876,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42863
42876
|
}
|
42864
42877
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42865
42878
|
const { minGasPrice } = this.provider.getGasConfig();
|
42866
|
-
const
|
42879
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42880
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42881
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42867
42882
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42868
42883
|
hexlifiedContractId: contractAddress.toB256(),
|
42869
42884
|
amountToTransfer: bn(amount),
|
42870
|
-
assetId
|
42885
|
+
assetId: assetIdToTransfer
|
42871
42886
|
});
|
42872
42887
|
const request = new ScriptTransactionRequest({
|
42873
42888
|
...params,
|
@@ -42877,7 +42892,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42877
42892
|
request.addContractInputAndOutput(contractAddress);
|
42878
42893
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42879
42894
|
request,
|
42880
|
-
[{ amount: bn(amount), assetId: String(
|
42895
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42881
42896
|
);
|
42882
42897
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42883
42898
|
this.validateGas({
|
@@ -42899,6 +42914,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42899
42914
|
*/
|
42900
42915
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42901
42916
|
const { minGasPrice } = this.provider.getGasConfig();
|
42917
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42902
42918
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42903
42919
|
const recipientDataArray = arrayify(
|
42904
42920
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42911,9 +42927,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42911
42927
|
...recipientDataArray,
|
42912
42928
|
...amountDataArray
|
42913
42929
|
]);
|
42914
|
-
const params = {
|
42930
|
+
const params = {
|
42931
|
+
script,
|
42932
|
+
gasPrice: minGasPrice,
|
42933
|
+
baseAssetId,
|
42934
|
+
...txParams
|
42935
|
+
};
|
42915
42936
|
const request = new ScriptTransactionRequest(params);
|
42916
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42937
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42917
42938
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42918
42939
|
request,
|
42919
42940
|
forwardingQuantities
|
@@ -47876,8 +47897,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47876
47897
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47877
47898
|
* @returns A promise that resolves to the prepared transaction request.
|
47878
47899
|
*/
|
47879
|
-
async createTransfer(destination, amount, assetId
|
47880
|
-
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);
|
47881
47903
|
return this.populateTransactionPredicateData(request);
|
47882
47904
|
}
|
47883
47905
|
/**
|