@fuel-ts/account 0.0.0-rc-2037-20240411020051 → 0.0.0-rc-2040-20240411095959
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 +44 -25
- 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 +44 -10
- 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
@@ -1904,8 +1904,8 @@ var BaseTransactionRequest = class {
|
|
1904
1904
|
* @param predicate - Predicate bytes.
|
1905
1905
|
* @param predicateData - Predicate data bytes.
|
1906
1906
|
*/
|
1907
|
-
addCoinInput(coin) {
|
1908
|
-
const { assetId, owner, amount
|
1907
|
+
addCoinInput(coin, predicate) {
|
1908
|
+
const { assetId, owner, amount } = coin;
|
1909
1909
|
let witnessIndex;
|
1910
1910
|
if (predicate) {
|
1911
1911
|
witnessIndex = 0;
|
@@ -1916,14 +1916,14 @@ var BaseTransactionRequest = class {
|
|
1916
1916
|
}
|
1917
1917
|
}
|
1918
1918
|
const input = {
|
1919
|
-
|
1919
|
+
...coin,
|
1920
1920
|
type: InputType2.Coin,
|
1921
1921
|
owner: owner.toB256(),
|
1922
1922
|
amount,
|
1923
1923
|
assetId,
|
1924
1924
|
txPointer: "0x00000000000000000000000000000000",
|
1925
1925
|
witnessIndex,
|
1926
|
-
predicate
|
1926
|
+
predicate: predicate?.bytes
|
1927
1927
|
};
|
1928
1928
|
this.pushInput(input);
|
1929
1929
|
this.addChangeOutput(owner, assetId);
|
@@ -1936,8 +1936,8 @@ var BaseTransactionRequest = class {
|
|
1936
1936
|
* @param predicate - Predicate bytes.
|
1937
1937
|
* @param predicateData - Predicate data bytes.
|
1938
1938
|
*/
|
1939
|
-
addMessageInput(message) {
|
1940
|
-
const { recipient, sender, amount
|
1939
|
+
addMessageInput(message, predicate) {
|
1940
|
+
const { recipient, sender, amount } = message;
|
1941
1941
|
const assetId = BaseAssetId2;
|
1942
1942
|
let witnessIndex;
|
1943
1943
|
if (predicate) {
|
@@ -1949,13 +1949,13 @@ var BaseTransactionRequest = class {
|
|
1949
1949
|
}
|
1950
1950
|
}
|
1951
1951
|
const input = {
|
1952
|
-
|
1952
|
+
...message,
|
1953
1953
|
type: InputType2.Message,
|
1954
1954
|
sender: sender.toB256(),
|
1955
1955
|
recipient: recipient.toB256(),
|
1956
1956
|
amount,
|
1957
1957
|
witnessIndex,
|
1958
|
-
predicate
|
1958
|
+
predicate: predicate?.bytes
|
1959
1959
|
};
|
1960
1960
|
this.pushInput(input);
|
1961
1961
|
this.addChangeOutput(recipient, assetId);
|
@@ -1986,6 +1986,32 @@ var BaseTransactionRequest = class {
|
|
1986
1986
|
resources.forEach((resource) => this.addResource(resource));
|
1987
1987
|
return this;
|
1988
1988
|
}
|
1989
|
+
/**
|
1990
|
+
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
1991
|
+
* outputs from the related assetIds.
|
1992
|
+
*
|
1993
|
+
* @param resources - The resources to add.
|
1994
|
+
* @returns This transaction.
|
1995
|
+
*/
|
1996
|
+
addPredicateResource(resource, predicate) {
|
1997
|
+
if (isCoin(resource)) {
|
1998
|
+
this.addCoinInput(resource, predicate);
|
1999
|
+
} else {
|
2000
|
+
this.addMessageInput(resource, predicate);
|
2001
|
+
}
|
2002
|
+
return this;
|
2003
|
+
}
|
2004
|
+
/**
|
2005
|
+
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2006
|
+
* from the related assetIds.
|
2007
|
+
*
|
2008
|
+
* @param resources - The resources to add.
|
2009
|
+
* @returns This transaction.
|
2010
|
+
*/
|
2011
|
+
addPredicateResources(resources, predicate) {
|
2012
|
+
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2013
|
+
return this;
|
2014
|
+
}
|
1989
2015
|
/**
|
1990
2016
|
* Adds a coin output to the transaction.
|
1991
2017
|
*
|
@@ -8715,7 +8741,6 @@ var Predicate = class extends Account {
|
|
8715
8741
|
if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
|
8716
8742
|
input.predicate = this.bytes;
|
8717
8743
|
input.predicateData = this.getPredicateData(policies.length);
|
8718
|
-
input.witnessIndex = 0;
|
8719
8744
|
}
|
8720
8745
|
});
|
8721
8746
|
return request;
|
@@ -8753,20 +8778,6 @@ var Predicate = class extends Account {
|
|
8753
8778
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
8754
8779
|
return super.simulateTransaction(transactionRequest);
|
8755
8780
|
}
|
8756
|
-
/**
|
8757
|
-
* Retrieves resources satisfying the spend query for the account.
|
8758
|
-
*
|
8759
|
-
* @param quantities - IDs of coins to exclude.
|
8760
|
-
* @param excludedIds - IDs of resources to be excluded from the query.
|
8761
|
-
* @returns A promise that resolves to an array of Resources.
|
8762
|
-
*/
|
8763
|
-
async getResourcesToSpend(quantities, excludedIds) {
|
8764
|
-
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
8765
|
-
return resources.map((resource) => ({
|
8766
|
-
...resource,
|
8767
|
-
predicate: hexlify19(this.bytes)
|
8768
|
-
}));
|
8769
|
-
}
|
8770
8781
|
getPredicateData(policiesLength) {
|
8771
8782
|
if (!this.predicateData.length) {
|
8772
8783
|
return new Uint8Array();
|