@fuel-ts/account 0.0.0-rc-2045-20240419094011 → 0.0.0-rc-1976-20240419101644
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 +15 -15
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.81.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);
|
@@ -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;
|
@@ -39550,6 +39549,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39550
39549
|
outputs = [];
|
39551
39550
|
/** List of witnesses */
|
39552
39551
|
witnesses = [];
|
39552
|
+
/** Base asset ID - should be fetched from the chain */
|
39553
|
+
baseAssetId;
|
39553
39554
|
/**
|
39554
39555
|
* Constructor for initializing a base transaction request.
|
39555
39556
|
*
|
@@ -39562,8 +39563,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39562
39563
|
witnessLimit,
|
39563
39564
|
inputs,
|
39564
39565
|
outputs,
|
39565
|
-
witnesses
|
39566
|
-
|
39566
|
+
witnesses,
|
39567
|
+
baseAssetId
|
39568
|
+
}) {
|
39567
39569
|
this.gasPrice = bn(gasPrice);
|
39568
39570
|
this.maturity = maturity ?? 0;
|
39569
39571
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39571,6 +39573,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39571
39573
|
this.inputs = inputs ?? [];
|
39572
39574
|
this.outputs = outputs ?? [];
|
39573
39575
|
this.witnesses = witnesses ?? [];
|
39576
|
+
this.baseAssetId = baseAssetId;
|
39574
39577
|
}
|
39575
39578
|
static getPolicyMeta(req) {
|
39576
39579
|
let policyTypes = 0;
|
@@ -39794,11 +39797,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39794
39797
|
*
|
39795
39798
|
* @param message - Message resource.
|
39796
39799
|
* @param predicate - Predicate bytes.
|
39797
|
-
* @param predicateData - Predicate data bytes.
|
39798
39800
|
*/
|
39799
39801
|
addMessageInput(message, predicate) {
|
39800
39802
|
const { recipient, sender, amount } = message;
|
39801
|
-
const assetId = BaseAssetId;
|
39802
39803
|
let witnessIndex;
|
39803
39804
|
if (predicate) {
|
39804
39805
|
witnessIndex = 0;
|
@@ -39818,7 +39819,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39818
39819
|
predicate: predicate?.bytes
|
39819
39820
|
};
|
39820
39821
|
this.pushInput(input);
|
39821
|
-
this.addChangeOutput(recipient,
|
39822
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39822
39823
|
}
|
39823
39824
|
/**
|
39824
39825
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -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
|
/**
|
@@ -40152,12 +40153,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40152
40153
|
*
|
40153
40154
|
* @param createTransactionRequestLike - The initial values for the instance
|
40154
40155
|
*/
|
40155
|
-
constructor({
|
40156
|
-
bytecodeWitnessIndex,
|
40157
|
-
salt,
|
40158
|
-
storageSlots,
|
40159
|
-
...rest
|
40160
|
-
} = {}) {
|
40156
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40161
40157
|
super(rest);
|
40162
40158
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40163
40159
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40272,7 +40268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40272
40268
|
*
|
40273
40269
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40274
40270
|
*/
|
40275
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40271
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40276
40272
|
super(rest);
|
40277
40273
|
this.gasLimit = bn(gasLimit);
|
40278
40274
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41418,6 +41414,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41418
41414
|
gasPerByte: bn(feeParams.gasPerByte),
|
41419
41415
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41420
41416
|
chainId: bn(consensusParameters.chainId),
|
41417
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41421
41418
|
gasCosts
|
41422
41419
|
},
|
41423
41420
|
gasCosts,
|
@@ -41660,6 +41657,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41660
41657
|
} = this.getChain();
|
41661
41658
|
return chainId.toNumber();
|
41662
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
|
+
}
|
41663
41671
|
/**
|
41664
41672
|
* Submits a transaction to the chain to be executed.
|
41665
41673
|
*
|
@@ -42716,8 +42724,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42716
42724
|
* @param assetId - The asset ID to check the balance for.
|
42717
42725
|
* @returns A promise that resolves to the balance amount.
|
42718
42726
|
*/
|
42719
|
-
async getBalance(assetId
|
42720
|
-
const
|
42727
|
+
async getBalance(assetId) {
|
42728
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42729
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42721
42730
|
return amount;
|
42722
42731
|
}
|
42723
42732
|
/**
|
@@ -42755,9 +42764,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42755
42764
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42756
42765
|
*/
|
42757
42766
|
async fund(request, coinQuantities, fee) {
|
42767
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42758
42768
|
const updatedQuantities = addAmountToAsset({
|
42759
42769
|
amount: bn(fee),
|
42760
|
-
assetId:
|
42770
|
+
assetId: baseAssetId,
|
42761
42771
|
coinQuantities
|
42762
42772
|
});
|
42763
42773
|
const quantitiesDict = {};
|
@@ -42781,8 +42791,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42781
42791
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42782
42792
|
cachedUtxos.push(input.id);
|
42783
42793
|
}
|
42784
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42785
|
-
quantitiesDict[
|
42794
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42795
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42786
42796
|
cachedMessages.push(input.nonce);
|
42787
42797
|
}
|
42788
42798
|
}
|
@@ -42814,11 +42824,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42814
42824
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42815
42825
|
* @returns A promise that resolves to the prepared transaction request.
|
42816
42826
|
*/
|
42817
|
-
async createTransfer(destination, amount, assetId
|
42827
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42818
42828
|
const { minGasPrice } = this.provider.getGasConfig();
|
42819
|
-
const
|
42829
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42830
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42831
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42820
42832
|
const request = new ScriptTransactionRequest(params);
|
42821
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42833
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42822
42834
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42823
42835
|
estimateTxDependencies: true,
|
42824
42836
|
resourcesOwner: this
|
@@ -42844,14 +42856,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42844
42856
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42845
42857
|
* @returns A promise that resolves to the transaction response.
|
42846
42858
|
*/
|
42847
|
-
async transfer(destination, amount, assetId
|
42859
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42848
42860
|
if (bn(amount).lte(0)) {
|
42849
42861
|
throw new FuelError(
|
42850
42862
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42851
42863
|
"Transfer amount must be a positive number."
|
42852
42864
|
);
|
42853
42865
|
}
|
42854
|
-
const
|
42866
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42867
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42855
42868
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42856
42869
|
}
|
42857
42870
|
/**
|
@@ -42863,7 +42876,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42863
42876
|
* @param txParams - The optional transaction parameters.
|
42864
42877
|
* @returns A promise that resolves to the transaction response.
|
42865
42878
|
*/
|
42866
|
-
async transferToContract(contractId, amount, assetId
|
42879
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42867
42880
|
if (bn(amount).lte(0)) {
|
42868
42881
|
throw new FuelError(
|
42869
42882
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42872,11 +42885,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42872
42885
|
}
|
42873
42886
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42874
42887
|
const { minGasPrice } = this.provider.getGasConfig();
|
42875
|
-
const
|
42888
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42889
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42890
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42876
42891
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42877
42892
|
hexlifiedContractId: contractAddress.toB256(),
|
42878
42893
|
amountToTransfer: bn(amount),
|
42879
|
-
assetId
|
42894
|
+
assetId: assetIdToTransfer
|
42880
42895
|
});
|
42881
42896
|
const request = new ScriptTransactionRequest({
|
42882
42897
|
...params,
|
@@ -42886,7 +42901,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42886
42901
|
request.addContractInputAndOutput(contractAddress);
|
42887
42902
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42888
42903
|
request,
|
42889
|
-
[{ amount: bn(amount), assetId: String(
|
42904
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42890
42905
|
);
|
42891
42906
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42892
42907
|
this.validateGas({
|
@@ -42908,6 +42923,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42908
42923
|
*/
|
42909
42924
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42910
42925
|
const { minGasPrice } = this.provider.getGasConfig();
|
42926
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42911
42927
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42912
42928
|
const recipientDataArray = arrayify(
|
42913
42929
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42920,9 +42936,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42920
42936
|
...recipientDataArray,
|
42921
42937
|
...amountDataArray
|
42922
42938
|
]);
|
42923
|
-
const params = {
|
42939
|
+
const params = {
|
42940
|
+
script,
|
42941
|
+
gasPrice: minGasPrice,
|
42942
|
+
baseAssetId,
|
42943
|
+
...txParams
|
42944
|
+
};
|
42924
42945
|
const request = new ScriptTransactionRequest(params);
|
42925
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42946
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42926
42947
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42927
42948
|
request,
|
42928
42949
|
forwardingQuantities
|
@@ -47885,8 +47906,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47885
47906
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47886
47907
|
* @returns A promise that resolves to the prepared transaction request.
|
47887
47908
|
*/
|
47888
|
-
async createTransfer(destination, amount, assetId
|
47889
|
-
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);
|
47890
47912
|
return this.populateTransactionPredicateData(request);
|
47891
47913
|
}
|
47892
47914
|
/**
|