@fuel-ts/account 0.0.0-rc-2037-20240411163513 → 0.0.0-rc-2045-20240411194225
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/index.global.js +37 -26
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +34 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -23
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +1 -9
- package/dist/predicate/predicate.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/transaction-request/transaction-request.d.ts +20 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils.global.js +37 -11
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +34 -8
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +34 -8
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
@@ -1907,8 +1907,8 @@ var BaseTransactionRequest = class {
|
|
1907
1907
|
* @param predicate - Predicate bytes.
|
1908
1908
|
* @param predicateData - Predicate data bytes.
|
1909
1909
|
*/
|
1910
|
-
addCoinInput(coin) {
|
1911
|
-
const { assetId, owner, amount
|
1910
|
+
addCoinInput(coin, predicate) {
|
1911
|
+
const { assetId, owner, amount } = coin;
|
1912
1912
|
let witnessIndex;
|
1913
1913
|
if (predicate) {
|
1914
1914
|
witnessIndex = 0;
|
@@ -1919,14 +1919,14 @@ var BaseTransactionRequest = class {
|
|
1919
1919
|
}
|
1920
1920
|
}
|
1921
1921
|
const input = {
|
1922
|
-
|
1922
|
+
...coin,
|
1923
1923
|
type: InputType2.Coin,
|
1924
1924
|
owner: owner.toB256(),
|
1925
1925
|
amount,
|
1926
1926
|
assetId,
|
1927
1927
|
txPointer: "0x00000000000000000000000000000000",
|
1928
1928
|
witnessIndex,
|
1929
|
-
predicate
|
1929
|
+
predicate: predicate?.bytes
|
1930
1930
|
};
|
1931
1931
|
this.pushInput(input);
|
1932
1932
|
this.addChangeOutput(owner, assetId);
|
@@ -1939,8 +1939,8 @@ var BaseTransactionRequest = class {
|
|
1939
1939
|
* @param predicate - Predicate bytes.
|
1940
1940
|
* @param predicateData - Predicate data bytes.
|
1941
1941
|
*/
|
1942
|
-
addMessageInput(message) {
|
1943
|
-
const { recipient, sender, amount
|
1942
|
+
addMessageInput(message, predicate) {
|
1943
|
+
const { recipient, sender, amount } = message;
|
1944
1944
|
const assetId = BaseAssetId2;
|
1945
1945
|
let witnessIndex;
|
1946
1946
|
if (predicate) {
|
@@ -1952,13 +1952,13 @@ var BaseTransactionRequest = class {
|
|
1952
1952
|
}
|
1953
1953
|
}
|
1954
1954
|
const input = {
|
1955
|
-
|
1955
|
+
...message,
|
1956
1956
|
type: InputType2.Message,
|
1957
1957
|
sender: sender.toB256(),
|
1958
1958
|
recipient: recipient.toB256(),
|
1959
1959
|
amount,
|
1960
1960
|
witnessIndex,
|
1961
|
-
predicate
|
1961
|
+
predicate: predicate?.bytes
|
1962
1962
|
};
|
1963
1963
|
this.pushInput(input);
|
1964
1964
|
this.addChangeOutput(recipient, assetId);
|
@@ -1989,6 +1989,32 @@ var BaseTransactionRequest = class {
|
|
1989
1989
|
resources.forEach((resource) => this.addResource(resource));
|
1990
1990
|
return this;
|
1991
1991
|
}
|
1992
|
+
/**
|
1993
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1994
|
+
* outputs from the related assetIds.
|
1995
|
+
*
|
1996
|
+
* @param resources - The resources to add.
|
1997
|
+
* @returns This transaction.
|
1998
|
+
*/
|
1999
|
+
addPredicateResource(resource, predicate) {
|
2000
|
+
if (isCoin(resource)) {
|
2001
|
+
this.addCoinInput(resource, predicate);
|
2002
|
+
} else {
|
2003
|
+
this.addMessageInput(resource, predicate);
|
2004
|
+
}
|
2005
|
+
return this;
|
2006
|
+
}
|
2007
|
+
/**
|
2008
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2009
|
+
* from the related assetIds.
|
2010
|
+
*
|
2011
|
+
* @param resources - The resources to add.
|
2012
|
+
* @returns This transaction.
|
2013
|
+
*/
|
2014
|
+
addPredicateResources(resources, predicate) {
|
2015
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2016
|
+
return this;
|
2017
|
+
}
|
1992
2018
|
/**
|
1993
2019
|
* Adds a coin output to the transaction.
|
1994
2020
|
*
|
@@ -8739,7 +8765,6 @@ var Predicate = class extends Account {
|
|
8739
8765
|
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8740
8766
|
input.predicate = this.bytes;
|
8741
8767
|
input.predicateData = this.getPredicateData(policies.length);
|
8742
|
-
input.witnessIndex = 0;
|
8743
8768
|
}
|
8744
8769
|
});
|
8745
8770
|
return request;
|
@@ -8777,20 +8802,6 @@ var Predicate = class extends Account {
|
|
8777
8802
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8778
8803
|
return super.simulateTransaction(transactionRequest);
|
8779
8804
|
}
|
8780
|
-
/**
|
8781
|
-
* Retrieves resources satisfying the spend query for the account.
|
8782
|
-
*
|
8783
|
-
* @param quantities - IDs of coins to exclude.
|
8784
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8785
|
-
* @returns A promise that resolves to an array of Resources.
|
8786
|
-
*/
|
8787
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8788
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8789
|
-
return resources.map((resource) => ({
|
8790
|
-
...resource,
|
8791
|
-
predicate: hexlify19(this.bytes)
|
8792
|
-
}));
|
8793
|
-
}
|
8794
8805
|
getPredicateData(policiesLength) {
|
8795
8806
|
if (!this.predicateData.length) {
|
8796
8807
|
return new Uint8Array();
|