@fuel-ts/account 0.0.0-rc-2037-20240423110545 → 0.0.0-rc-1976-20240423111125
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 -125
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +241 -281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -160
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +2 -17
- 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":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CACjE,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAQ,SAAQ,eAAe;IAC1C;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC;IAE/B,SAAS,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAErC;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,aAAa;IAO7F;;;;;;OAMG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAMvB;IAED;;;;OAIG;IACH,IAAI,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAE9B;IAED;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ;IAKrC;;;;;;OAMG;IACG,mBAAmB,CACvB,UAAU,EAAE,gBAAgB,EAAE,CAAC,8BAA8B,EAC7D,WAAW,CAAC,EAAE,sBAAsB,GACnC,OAAO,CAAC,QAAQ,EAAE,CAAC;IAItB;;;;;OAKG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IA6BpD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IA6BvC;;;;;OAKG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,EAAE,CAAC;IAMlD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IA6B5C;;;;;;;OAOG;IACG,IAAI,CAAC,CAAC,SAAS,kBAAkB,EACrC,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,YAAY,EAAE,EAC9B,GAAG,EAAE,EAAE,GACN,OAAO,CAAC,IAAI,CAAC;IAmEhB;;;;;;;;OAQG;IACG,cAAc;IAClB,iCAAiC;IACjC,WAAW,EAAE,MAAM,GAAG,eAAe;IACrC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,kBAAkB,CAAC;IA8B9B;;;;;;;;OAQG;IACG,QAAQ;IACZ,iCAAiC;IACjC,WAAW,EAAE,MAAM,GAAG,eAAe;IACrC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAY/B;;;;;;;;OAQG;IACG,kBAAkB;IACtB,uBAAuB;IACvB,UAAU,EAAE,MAAM,GAAG,eAAe;IACpC,sBAAsB;IACtB,MAAM,EAAE,YAAY;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,SAAS;IACnB,gBAAgB;IAChB,QAAQ,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);
|
@@ -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,27 +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) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
39533
|
-
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
39534
|
-
var cacheResources = (resources) => resources.reduce(
|
39535
|
-
(cache2, resource) => {
|
39536
|
-
if (isCoin(resource)) {
|
39537
|
-
cache2.utxos.push(resource.id);
|
39538
|
-
} else {
|
39539
|
-
cache2.messages.push(resource.nonce);
|
39540
|
-
}
|
39541
|
-
return cache2;
|
39542
|
-
},
|
39543
|
-
{
|
39544
|
-
utxos: [],
|
39545
|
-
messages: []
|
39546
|
-
}
|
39547
|
-
);
|
39548
|
-
|
39549
39527
|
// src/providers/transaction-request/witness.ts
|
39550
39528
|
var witnessify = (value) => {
|
39551
39529
|
const data = arrayify(value);
|
@@ -39571,6 +39549,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39571
39549
|
outputs = [];
|
39572
39550
|
/** List of witnesses */
|
39573
39551
|
witnesses = [];
|
39552
|
+
/** Base asset ID - should be fetched from the chain */
|
39553
|
+
baseAssetId;
|
39574
39554
|
/**
|
39575
39555
|
* Constructor for initializing a base transaction request.
|
39576
39556
|
*
|
@@ -39583,8 +39563,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39583
39563
|
witnessLimit,
|
39584
39564
|
inputs,
|
39585
39565
|
outputs,
|
39586
|
-
witnesses
|
39587
|
-
|
39566
|
+
witnesses,
|
39567
|
+
baseAssetId
|
39568
|
+
}) {
|
39588
39569
|
this.gasPrice = bn(gasPrice);
|
39589
39570
|
this.maturity = maturity ?? 0;
|
39590
39571
|
this.witnessLimit = witnessLimit ? bn(witnessLimit) : void 0;
|
@@ -39592,6 +39573,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39592
39573
|
this.inputs = inputs ?? [];
|
39593
39574
|
this.outputs = outputs ?? [];
|
39594
39575
|
this.witnesses = witnesses ?? [];
|
39576
|
+
this.baseAssetId = baseAssetId;
|
39595
39577
|
}
|
39596
39578
|
static getPolicyMeta(req) {
|
39597
39579
|
let policyTypes = 0;
|
@@ -39785,8 +39767,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39785
39767
|
* @param predicate - Predicate bytes.
|
39786
39768
|
* @param predicateData - Predicate data bytes.
|
39787
39769
|
*/
|
39788
|
-
addCoinInput(coin) {
|
39789
|
-
const { assetId, owner, amount
|
39770
|
+
addCoinInput(coin, predicate) {
|
39771
|
+
const { assetId, owner, amount } = coin;
|
39790
39772
|
let witnessIndex;
|
39791
39773
|
if (predicate) {
|
39792
39774
|
witnessIndex = 0;
|
@@ -39797,14 +39779,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39797
39779
|
}
|
39798
39780
|
}
|
39799
39781
|
const input = {
|
39800
|
-
|
39782
|
+
...coin,
|
39801
39783
|
type: InputType.Coin,
|
39802
39784
|
owner: owner.toB256(),
|
39803
39785
|
amount,
|
39804
39786
|
assetId,
|
39805
39787
|
txPointer: "0x00000000000000000000000000000000",
|
39806
39788
|
witnessIndex,
|
39807
|
-
predicate
|
39789
|
+
predicate: predicate?.bytes
|
39808
39790
|
};
|
39809
39791
|
this.pushInput(input);
|
39810
39792
|
this.addChangeOutput(owner, assetId);
|
@@ -39815,11 +39797,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39815
39797
|
*
|
39816
39798
|
* @param message - Message resource.
|
39817
39799
|
* @param predicate - Predicate bytes.
|
39818
|
-
* @param predicateData - Predicate data bytes.
|
39819
39800
|
*/
|
39820
|
-
addMessageInput(message) {
|
39821
|
-
const { recipient, sender, amount
|
39822
|
-
const assetId = BaseAssetId;
|
39801
|
+
addMessageInput(message, predicate) {
|
39802
|
+
const { recipient, sender, amount } = message;
|
39823
39803
|
let witnessIndex;
|
39824
39804
|
if (predicate) {
|
39825
39805
|
witnessIndex = 0;
|
@@ -39830,16 +39810,16 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39830
39810
|
}
|
39831
39811
|
}
|
39832
39812
|
const input = {
|
39833
|
-
|
39813
|
+
...message,
|
39834
39814
|
type: InputType.Message,
|
39835
39815
|
sender: sender.toB256(),
|
39836
39816
|
recipient: recipient.toB256(),
|
39837
39817
|
amount,
|
39838
39818
|
witnessIndex,
|
39839
|
-
predicate
|
39819
|
+
predicate: predicate?.bytes
|
39840
39820
|
};
|
39841
39821
|
this.pushInput(input);
|
39842
|
-
this.addChangeOutput(recipient,
|
39822
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
39843
39823
|
}
|
39844
39824
|
/**
|
39845
39825
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -39867,6 +39847,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39867
39847
|
resources.forEach((resource) => this.addResource(resource));
|
39868
39848
|
return this;
|
39869
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
|
+
}
|
39870
39876
|
/**
|
39871
39877
|
* Adds a coin output to the transaction.
|
39872
39878
|
*
|
@@ -39874,12 +39880,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39874
39880
|
* @param amount - Amount of coin.
|
39875
39881
|
* @param assetId - Asset ID of coin.
|
39876
39882
|
*/
|
39877
|
-
addCoinOutput(to, amount, assetId
|
39883
|
+
addCoinOutput(to, amount, assetId) {
|
39878
39884
|
this.pushOutput({
|
39879
39885
|
type: OutputType.Coin,
|
39880
39886
|
to: addressify(to).toB256(),
|
39881
39887
|
amount,
|
39882
|
-
assetId
|
39888
|
+
assetId: assetId ?? this.baseAssetId
|
39883
39889
|
});
|
39884
39890
|
return this;
|
39885
39891
|
}
|
@@ -39906,7 +39912,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39906
39912
|
* @param to - Address of the owner.
|
39907
39913
|
* @param assetId - Asset ID of coin.
|
39908
39914
|
*/
|
39909
|
-
addChangeOutput(to, assetId
|
39915
|
+
addChangeOutput(to, assetId) {
|
39910
39916
|
const changeOutput = this.getChangeOutputs().find(
|
39911
39917
|
(output3) => hexlify(output3.assetId) === assetId
|
39912
39918
|
);
|
@@ -39914,7 +39920,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39914
39920
|
this.pushOutput({
|
39915
39921
|
type: OutputType.Change,
|
39916
39922
|
to: addressify(to).toB256(),
|
39917
|
-
assetId
|
39923
|
+
assetId: assetId ?? this.baseAssetId
|
39918
39924
|
});
|
39919
39925
|
}
|
39920
39926
|
}
|
@@ -39990,7 +39996,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39990
39996
|
]);
|
39991
39997
|
}
|
39992
39998
|
};
|
39993
|
-
updateAssetInput(
|
39999
|
+
updateAssetInput(this.baseAssetId, bn(1e11));
|
39994
40000
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
39995
40001
|
}
|
39996
40002
|
/**
|
@@ -40015,10 +40021,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40015
40021
|
toJSON() {
|
40016
40022
|
return normalizeJSON(this);
|
40017
40023
|
}
|
40018
|
-
removeWitness(index) {
|
40019
|
-
this.witnesses.splice(index, 1);
|
40020
|
-
this.adjustWitnessIndexes(index);
|
40021
|
-
}
|
40022
40024
|
updatePredicateInputs(inputs) {
|
40023
40025
|
this.inputs.forEach((i) => {
|
40024
40026
|
let correspondingInput;
|
@@ -40041,13 +40043,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40041
40043
|
}
|
40042
40044
|
});
|
40043
40045
|
}
|
40044
|
-
adjustWitnessIndexes(removedIndex) {
|
40045
|
-
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
40046
|
-
if (input.witnessIndex > removedIndex) {
|
40047
|
-
input.witnessIndex -= 1;
|
40048
|
-
}
|
40049
|
-
});
|
40050
|
-
}
|
40051
40046
|
};
|
40052
40047
|
|
40053
40048
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40158,12 +40153,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40158
40153
|
*
|
40159
40154
|
* @param createTransactionRequestLike - The initial values for the instance
|
40160
40155
|
*/
|
40161
|
-
constructor({
|
40162
|
-
bytecodeWitnessIndex,
|
40163
|
-
salt,
|
40164
|
-
storageSlots,
|
40165
|
-
...rest
|
40166
|
-
} = {}) {
|
40156
|
+
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
40167
40157
|
super(rest);
|
40168
40158
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
40169
40159
|
this.salt = hexlify(salt ?? ZeroBytes32);
|
@@ -40278,7 +40268,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40278
40268
|
*
|
40279
40269
|
* @param scriptTransactionRequestLike - The initial values for the instance.
|
40280
40270
|
*/
|
40281
|
-
constructor({ script, scriptData, gasLimit, ...rest }
|
40271
|
+
constructor({ script, scriptData, gasLimit, ...rest }) {
|
40282
40272
|
super(rest);
|
40283
40273
|
this.gasLimit = bn(gasLimit);
|
40284
40274
|
this.script = arrayify(script ?? returnZeroScript.bytes);
|
@@ -41424,6 +41414,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41424
41414
|
gasPerByte: bn(feeParams.gasPerByte),
|
41425
41415
|
maxMessageDataLength: bn(predicateParams.maxMessageDataLength),
|
41426
41416
|
chainId: bn(consensusParameters.chainId),
|
41417
|
+
baseAssetId: consensusParameters.baseAssetId,
|
41427
41418
|
gasCosts
|
41428
41419
|
},
|
41429
41420
|
gasCosts,
|
@@ -41666,6 +41657,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41666
41657
|
} = this.getChain();
|
41667
41658
|
return chainId.toNumber();
|
41668
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
|
+
}
|
41669
41671
|
/**
|
41670
41672
|
* Submits a transaction to the chain to be executed.
|
41671
41673
|
*
|
@@ -42722,8 +42724,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42722
42724
|
* @param assetId - The asset ID to check the balance for.
|
42723
42725
|
* @returns A promise that resolves to the balance amount.
|
42724
42726
|
*/
|
42725
|
-
async getBalance(assetId
|
42726
|
-
const
|
42727
|
+
async getBalance(assetId) {
|
42728
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
42729
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
42727
42730
|
return amount;
|
42728
42731
|
}
|
42729
42732
|
/**
|
@@ -42761,9 +42764,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42761
42764
|
* @returns A promise that resolves when the resources are added to the transaction.
|
42762
42765
|
*/
|
42763
42766
|
async fund(request, coinQuantities, fee) {
|
42767
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42764
42768
|
const updatedQuantities = addAmountToAsset({
|
42765
42769
|
amount: bn(fee),
|
42766
|
-
assetId:
|
42770
|
+
assetId: baseAssetId,
|
42767
42771
|
coinQuantities
|
42768
42772
|
});
|
42769
42773
|
const quantitiesDict = {};
|
@@ -42787,8 +42791,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42787
42791
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
42788
42792
|
cachedUtxos.push(input.id);
|
42789
42793
|
}
|
42790
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
42791
|
-
quantitiesDict[
|
42794
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
42795
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
42792
42796
|
cachedMessages.push(input.nonce);
|
42793
42797
|
}
|
42794
42798
|
}
|
@@ -42820,11 +42824,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42820
42824
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42821
42825
|
* @returns A promise that resolves to the prepared transaction request.
|
42822
42826
|
*/
|
42823
|
-
async createTransfer(destination, amount, assetId
|
42827
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
42824
42828
|
const { minGasPrice } = this.provider.getGasConfig();
|
42825
|
-
const
|
42829
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42830
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42831
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42826
42832
|
const request = new ScriptTransactionRequest(params);
|
42827
|
-
request.addCoinOutput(Address.fromAddressOrString(destination), amount,
|
42833
|
+
request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
42828
42834
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
42829
42835
|
estimateTxDependencies: true,
|
42830
42836
|
resourcesOwner: this
|
@@ -42850,14 +42856,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42850
42856
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
42851
42857
|
* @returns A promise that resolves to the transaction response.
|
42852
42858
|
*/
|
42853
|
-
async transfer(destination, amount, assetId
|
42859
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
42854
42860
|
if (bn(amount).lte(0)) {
|
42855
42861
|
throw new FuelError(
|
42856
42862
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
42857
42863
|
"Transfer amount must be a positive number."
|
42858
42864
|
);
|
42859
42865
|
}
|
42860
|
-
const
|
42866
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42867
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
42861
42868
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
42862
42869
|
}
|
42863
42870
|
/**
|
@@ -42869,7 +42876,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42869
42876
|
* @param txParams - The optional transaction parameters.
|
42870
42877
|
* @returns A promise that resolves to the transaction response.
|
42871
42878
|
*/
|
42872
|
-
async transferToContract(contractId, amount, assetId
|
42879
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
42873
42880
|
if (bn(amount).lte(0)) {
|
42874
42881
|
throw new FuelError(
|
42875
42882
|
ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -42878,11 +42885,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42878
42885
|
}
|
42879
42886
|
const contractAddress = Address.fromAddressOrString(contractId);
|
42880
42887
|
const { minGasPrice } = this.provider.getGasConfig();
|
42881
|
-
const
|
42888
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42889
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
42890
|
+
const params = { gasPrice: minGasPrice, baseAssetId, ...txParams };
|
42882
42891
|
const { script, scriptData } = await assembleTransferToContractScript({
|
42883
42892
|
hexlifiedContractId: contractAddress.toB256(),
|
42884
42893
|
amountToTransfer: bn(amount),
|
42885
|
-
assetId
|
42894
|
+
assetId: assetIdToTransfer
|
42886
42895
|
});
|
42887
42896
|
const request = new ScriptTransactionRequest({
|
42888
42897
|
...params,
|
@@ -42892,7 +42901,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42892
42901
|
request.addContractInputAndOutput(contractAddress);
|
42893
42902
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
42894
42903
|
request,
|
42895
|
-
[{ amount: bn(amount), assetId: String(
|
42904
|
+
[{ amount: bn(amount), assetId: String(assetIdToTransfer) }]
|
42896
42905
|
);
|
42897
42906
|
request.gasLimit = bn(params.gasLimit ?? gasUsed);
|
42898
42907
|
this.validateGas({
|
@@ -42914,6 +42923,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42914
42923
|
*/
|
42915
42924
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
42916
42925
|
const { minGasPrice } = this.provider.getGasConfig();
|
42926
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
42917
42927
|
const recipientAddress = Address.fromAddressOrString(recipient);
|
42918
42928
|
const recipientDataArray = arrayify(
|
42919
42929
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
@@ -42926,9 +42936,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
42926
42936
|
...recipientDataArray,
|
42927
42937
|
...amountDataArray
|
42928
42938
|
]);
|
42929
|
-
const params = {
|
42939
|
+
const params = {
|
42940
|
+
script,
|
42941
|
+
gasPrice: minGasPrice,
|
42942
|
+
baseAssetId,
|
42943
|
+
...txParams
|
42944
|
+
};
|
42930
42945
|
const request = new ScriptTransactionRequest(params);
|
42931
|
-
const forwardingQuantities = [{ amount: bn(amount), assetId:
|
42946
|
+
const forwardingQuantities = [{ amount: bn(amount), assetId: baseAssetId }];
|
42932
42947
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
42933
42948
|
request,
|
42934
42949
|
forwardingQuantities
|
@@ -47874,15 +47889,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47874
47889
|
populateTransactionPredicateData(transactionRequestLike) {
|
47875
47890
|
const request = transactionRequestify(transactionRequestLike);
|
47876
47891
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47877
|
-
|
47878
|
-
|
47879
|
-
request.removeWitness(placeholderIndex);
|
47880
|
-
}
|
47881
|
-
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
47882
|
-
if (isRequestInputResourceFromOwner(input, this.address)) {
|
47892
|
+
request.inputs?.forEach((input) => {
|
47893
|
+
if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
|
47883
47894
|
input.predicate = this.bytes;
|
47884
47895
|
input.predicateData = this.getPredicateData(policies.length);
|
47885
|
-
input.witnessIndex = 0;
|
47886
47896
|
}
|
47887
47897
|
});
|
47888
47898
|
return request;
|
@@ -47896,8 +47906,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47896
47906
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
47897
47907
|
* @returns A promise that resolves to the prepared transaction request.
|
47898
47908
|
*/
|
47899
|
-
async createTransfer(destination, amount, assetId
|
47900
|
-
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);
|
47901
47912
|
return this.populateTransactionPredicateData(request);
|
47902
47913
|
}
|
47903
47914
|
/**
|
@@ -47920,20 +47931,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47920
47931
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47921
47932
|
return super.simulateTransaction(transactionRequest);
|
47922
47933
|
}
|
47923
|
-
/**
|
47924
|
-
* Retrieves resources satisfying the spend query for the account.
|
47925
|
-
*
|
47926
|
-
* @param quantities - Coins to retrieve.
|
47927
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
47928
|
-
* @returns A promise that resolves to an array of Resources.
|
47929
|
-
*/
|
47930
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
47931
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47932
|
-
return resources.map((resource) => ({
|
47933
|
-
...resource,
|
47934
|
-
predicate: hexlify(this.bytes)
|
47935
|
-
}));
|
47936
|
-
}
|
47937
47934
|
getPredicateData(policiesLength) {
|
47938
47935
|
if (!this.predicateData.length) {
|
47939
47936
|
return new Uint8Array();
|
@@ -48013,28 +48010,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
48013
48010
|
}
|
48014
48011
|
return mutatedBytes;
|
48015
48012
|
}
|
48016
|
-
/**
|
48017
|
-
* Returns the index of the witness placeholder that was added to this predicate.
|
48018
|
-
* If no witness placeholder was added, it returns -1.
|
48019
|
-
* @param request - The transaction request.
|
48020
|
-
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
48021
|
-
*/
|
48022
|
-
getIndexFromPlaceholderWitness(request) {
|
48023
|
-
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
48024
|
-
let index = -1;
|
48025
|
-
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
48026
|
-
if (hasEmptyPredicateInputs) {
|
48027
|
-
index = hasEmptyPredicateInputs.witnessIndex;
|
48028
|
-
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
48029
|
-
if (!allInputsAreEmpty) {
|
48030
|
-
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
48031
|
-
if (wasFilledInputAddedFirst) {
|
48032
|
-
index = -1;
|
48033
|
-
}
|
48034
|
-
}
|
48035
|
-
}
|
48036
|
-
return index;
|
48037
|
-
}
|
48038
48013
|
};
|
48039
48014
|
|
48040
48015
|
// src/connectors/fuel-connector.ts
|