@fuel-ts/account 0.0.0-rc-2045-20240417092921 → 0.0.0-rc-2037-20240417131250
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 +85 -39
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +200 -141
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -64
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +11 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +2 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -0
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +10 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +4 -20
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils/index.d.ts +1 -0
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +64 -40
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +173 -135
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +99 -64
- 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/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.80.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
|
/**
|
@@ -39525,6 +39525,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39525
39525
|
name = "NoWitnessByOwnerError";
|
39526
39526
|
};
|
39527
39527
|
|
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) => {
|
39533
|
+
if (isRequestInputCoin(input)) {
|
39534
|
+
return input.owner;
|
39535
|
+
}
|
39536
|
+
return input.recipient;
|
39537
|
+
};
|
39538
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
39539
|
+
var cacheResources = (resources) => resources.reduce(
|
39540
|
+
(cache2, resource) => {
|
39541
|
+
if (isCoin(resource)) {
|
39542
|
+
cache2.utxos.push(resource.id);
|
39543
|
+
} else {
|
39544
|
+
cache2.messages.push(resource.nonce);
|
39545
|
+
}
|
39546
|
+
return cache2;
|
39547
|
+
},
|
39548
|
+
{
|
39549
|
+
utxos: [],
|
39550
|
+
messages: []
|
39551
|
+
}
|
39552
|
+
);
|
39553
|
+
|
39528
39554
|
// src/providers/transaction-request/witness.ts
|
39529
39555
|
var witnessify = (value) => {
|
39530
39556
|
const data = arrayify(value);
|
@@ -39764,8 +39790,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39764
39790
|
* @param predicate - Predicate bytes.
|
39765
39791
|
* @param predicateData - Predicate data bytes.
|
39766
39792
|
*/
|
39767
|
-
addCoinInput(coin
|
39768
|
-
const { assetId, owner, amount } = coin;
|
39793
|
+
addCoinInput(coin) {
|
39794
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
39769
39795
|
let witnessIndex;
|
39770
39796
|
if (predicate) {
|
39771
39797
|
witnessIndex = 0;
|
@@ -39776,14 +39802,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39776
39802
|
}
|
39777
39803
|
}
|
39778
39804
|
const input = {
|
39779
|
-
|
39805
|
+
id,
|
39780
39806
|
type: InputType.Coin,
|
39781
39807
|
owner: owner.toB256(),
|
39782
39808
|
amount,
|
39783
39809
|
assetId,
|
39784
39810
|
txPointer: "0x00000000000000000000000000000000",
|
39785
39811
|
witnessIndex,
|
39786
|
-
predicate
|
39812
|
+
predicate
|
39787
39813
|
};
|
39788
39814
|
this.pushInput(input);
|
39789
39815
|
this.addChangeOutput(owner, assetId);
|
@@ -39796,8 +39822,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39796
39822
|
* @param predicate - Predicate bytes.
|
39797
39823
|
* @param predicateData - Predicate data bytes.
|
39798
39824
|
*/
|
39799
|
-
addMessageInput(message
|
39800
|
-
const { recipient, sender, amount } = message;
|
39825
|
+
addMessageInput(message) {
|
39826
|
+
const { recipient, sender, amount, predicate, nonce } = message;
|
39801
39827
|
const assetId = BaseAssetId;
|
39802
39828
|
let witnessIndex;
|
39803
39829
|
if (predicate) {
|
@@ -39809,13 +39835,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39809
39835
|
}
|
39810
39836
|
}
|
39811
39837
|
const input = {
|
39812
|
-
|
39838
|
+
nonce,
|
39813
39839
|
type: InputType.Message,
|
39814
39840
|
sender: sender.toB256(),
|
39815
39841
|
recipient: recipient.toB256(),
|
39816
39842
|
amount,
|
39817
39843
|
witnessIndex,
|
39818
|
-
predicate
|
39844
|
+
predicate
|
39819
39845
|
};
|
39820
39846
|
this.pushInput(input);
|
39821
39847
|
this.addChangeOutput(recipient, assetId);
|
@@ -39846,32 +39872,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39846
39872
|
resources.forEach((resource) => this.addResource(resource));
|
39847
39873
|
return this;
|
39848
39874
|
}
|
39849
|
-
/**
|
39850
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
39851
|
-
* outputs from the related assetIds.
|
39852
|
-
*
|
39853
|
-
* @param resources - The resources to add.
|
39854
|
-
* @returns This transaction.
|
39855
|
-
*/
|
39856
|
-
addPredicateResource(resource, predicate) {
|
39857
|
-
if (isCoin(resource)) {
|
39858
|
-
this.addCoinInput(resource, predicate);
|
39859
|
-
} else {
|
39860
|
-
this.addMessageInput(resource, predicate);
|
39861
|
-
}
|
39862
|
-
return this;
|
39863
|
-
}
|
39864
|
-
/**
|
39865
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
39866
|
-
* from the related assetIds.
|
39867
|
-
*
|
39868
|
-
* @param resources - The resources to add.
|
39869
|
-
* @returns This transaction.
|
39870
|
-
*/
|
39871
|
-
addPredicateResources(resources, predicate) {
|
39872
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
39873
|
-
return this;
|
39874
|
-
}
|
39875
39875
|
/**
|
39876
39876
|
* Adds a coin output to the transaction.
|
39877
39877
|
*
|
@@ -40020,6 +40020,10 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40020
40020
|
toJSON() {
|
40021
40021
|
return normalizeJSON(this);
|
40022
40022
|
}
|
40023
|
+
removeWitness(index) {
|
40024
|
+
this.witnesses.splice(index, 1);
|
40025
|
+
this.adjustWitnessIndexes(index);
|
40026
|
+
}
|
40023
40027
|
updatePredicateInputs(inputs) {
|
40024
40028
|
this.inputs.forEach((i) => {
|
40025
40029
|
let correspondingInput;
|
@@ -40042,6 +40046,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40042
40046
|
}
|
40043
40047
|
});
|
40044
40048
|
}
|
40049
|
+
adjustWitnessIndexes(removedIndex) {
|
40050
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
40051
|
+
if (input.witnessIndex > removedIndex) {
|
40052
|
+
input.witnessIndex -= 1;
|
40053
|
+
}
|
40054
|
+
});
|
40055
|
+
}
|
40045
40056
|
};
|
40046
40057
|
|
40047
40058
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -47868,10 +47879,15 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47868
47879
|
populateTransactionPredicateData(transactionRequestLike) {
|
47869
47880
|
const request = transactionRequestify(transactionRequestLike);
|
47870
47881
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47871
|
-
|
47872
|
-
|
47882
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
47883
|
+
if (placeholderIndex !== -1) {
|
47884
|
+
request.removeWitness(placeholderIndex);
|
47885
|
+
}
|
47886
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
47887
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
47873
47888
|
input.predicate = this.bytes;
|
47874
47889
|
input.predicateData = this.getPredicateData(policies.length);
|
47890
|
+
input.witnessIndex = 0;
|
47875
47891
|
}
|
47876
47892
|
});
|
47877
47893
|
return request;
|
@@ -47909,6 +47925,20 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47909
47925
|
const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
|
47910
47926
|
return super.simulateTransaction(transactionRequest);
|
47911
47927
|
}
|
47928
|
+
/**
|
47929
|
+
* Retrieves resources satisfying the spend query for the account.
|
47930
|
+
*
|
47931
|
+
* @param quantities - IDs of coins to exclude.
|
47932
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
47933
|
+
* @returns A promise that resolves to an array of Resources.
|
47934
|
+
*/
|
47935
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
47936
|
+
const resources = await super.getResourcesToSpend(quantities, excludedIds);
|
47937
|
+
return resources.map((resource) => ({
|
47938
|
+
...resource,
|
47939
|
+
predicate: hexlify(this.bytes)
|
47940
|
+
}));
|
47941
|
+
}
|
47912
47942
|
getPredicateData(policiesLength) {
|
47913
47943
|
if (!this.predicateData.length) {
|
47914
47944
|
return new Uint8Array();
|
@@ -47988,6 +48018,22 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47988
48018
|
}
|
47989
48019
|
return mutatedBytes;
|
47990
48020
|
}
|
48021
|
+
getIndexFromPlaceholderWitness(request) {
|
48022
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
48023
|
+
let index = -1;
|
48024
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
48025
|
+
if (hasEmptyPredicateInputs) {
|
48026
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
48027
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
48028
|
+
if (!allInputsAreEmpty) {
|
48029
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
48030
|
+
if (wasFilledInputAddedFirst) {
|
48031
|
+
index = -1;
|
48032
|
+
}
|
48033
|
+
}
|
48034
|
+
}
|
48035
|
+
return index;
|
48036
|
+
}
|
47991
48037
|
};
|
47992
48038
|
|
47993
48039
|
// src/connectors/fuel-connector.ts
|