@fuel-ts/account 0.0.0-rc-1866-20240322113439 → 0.0.0-rc-1815-20240322115843
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 +7 -0
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +10 -0
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/index.global.js +61 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +61 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +61 -5
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +20 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils.global.js +49 -5
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +49 -5
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +49 -5
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
@@ -1703,13 +1703,27 @@ var BaseTransactionRequest = class {
|
|
1703
1703
|
this.outputs.push(output);
|
1704
1704
|
return this.outputs.length - 1;
|
1705
1705
|
}
|
1706
|
+
/**
|
1707
|
+
* @hidden
|
1708
|
+
*
|
1709
|
+
* Pushes a witness to the list and returns the index
|
1710
|
+
*
|
1711
|
+
* @param signature - The signature to add to the witness.
|
1712
|
+
* @returns The index of the created witness.
|
1713
|
+
*/
|
1714
|
+
addWitness(signature) {
|
1715
|
+
this.witnesses.push(signature);
|
1716
|
+
return this.witnesses.length - 1;
|
1717
|
+
}
|
1706
1718
|
/**
|
1707
1719
|
* @hidden
|
1708
1720
|
*
|
1709
1721
|
* Creates an empty witness without any side effects and returns the index
|
1722
|
+
*
|
1723
|
+
* @returns The index of the created witness.
|
1710
1724
|
*/
|
1711
|
-
|
1712
|
-
this.
|
1725
|
+
addEmptyWitness() {
|
1726
|
+
this.addWitness(concat([ZeroBytes324, ZeroBytes324]));
|
1713
1727
|
return this.witnesses.length - 1;
|
1714
1728
|
}
|
1715
1729
|
/**
|
@@ -1738,6 +1752,21 @@ var BaseTransactionRequest = class {
|
|
1738
1752
|
}
|
1739
1753
|
this.witnesses[index] = witness;
|
1740
1754
|
}
|
1755
|
+
/**
|
1756
|
+
* Helper function to add an external signature to the transaction.
|
1757
|
+
*
|
1758
|
+
* @param account - The account/s to sign to the transaction.
|
1759
|
+
* @returns The transaction with the signature witness added.
|
1760
|
+
*/
|
1761
|
+
async addAccountWitnesses(account) {
|
1762
|
+
const accounts = Array.isArray(account) ? account : [account];
|
1763
|
+
await Promise.all(
|
1764
|
+
accounts.map(async (acc) => {
|
1765
|
+
this.addWitness(await acc.signTransaction(this));
|
1766
|
+
})
|
1767
|
+
);
|
1768
|
+
return this;
|
1769
|
+
}
|
1741
1770
|
/**
|
1742
1771
|
* Gets the coin inputs for a transaction.
|
1743
1772
|
*
|
@@ -1803,7 +1832,7 @@ var BaseTransactionRequest = class {
|
|
1803
1832
|
} else {
|
1804
1833
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1805
1834
|
if (typeof witnessIndex !== "number") {
|
1806
|
-
witnessIndex = this.
|
1835
|
+
witnessIndex = this.addEmptyWitness();
|
1807
1836
|
}
|
1808
1837
|
}
|
1809
1838
|
const input = {
|
@@ -1837,7 +1866,7 @@ var BaseTransactionRequest = class {
|
|
1837
1866
|
} else {
|
1838
1867
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
1839
1868
|
if (typeof witnessIndex !== "number") {
|
1840
|
-
witnessIndex = this.
|
1869
|
+
witnessIndex = this.addEmptyWitness();
|
1841
1870
|
}
|
1842
1871
|
}
|
1843
1872
|
const input = {
|
@@ -4990,6 +5019,21 @@ var Account = class extends AbstractAccount {
|
|
4990
5019
|
}
|
4991
5020
|
return this._connector.signMessage(this.address.toString(), message);
|
4992
5021
|
}
|
5022
|
+
/**
|
5023
|
+
* Signs a transaction with the wallet's private key.
|
5024
|
+
*
|
5025
|
+
* @param transactionRequestLike - The transaction request to sign.
|
5026
|
+
* @returns A promise that resolves to the signature of the transaction.
|
5027
|
+
*/
|
5028
|
+
async signTransaction(transactionRequestLike) {
|
5029
|
+
if (!this._connector) {
|
5030
|
+
throw new FuelError14(
|
5031
|
+
ErrorCode14.MISSING_CONNECTOR,
|
5032
|
+
"A connector is required to sign transactions."
|
5033
|
+
);
|
5034
|
+
}
|
5035
|
+
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
5036
|
+
}
|
4993
5037
|
/**
|
4994
5038
|
* Sends a transaction to the network.
|
4995
5039
|
*
|
@@ -5308,7 +5352,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5308
5352
|
*/
|
5309
5353
|
async signTransaction(transactionRequestLike) {
|
5310
5354
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5311
|
-
const chainId = this.provider.
|
5355
|
+
const chainId = this.provider.getChainId();
|
5312
5356
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5313
5357
|
const signature = await this.signer().sign(hashedTransaction);
|
5314
5358
|
return hexlify15(signature);
|
@@ -8855,6 +8899,18 @@ var FuelConnector = class extends EventEmitter2 {
|
|
8855
8899
|
async signMessage(_address, _message) {
|
8856
8900
|
throw new Error("Method not implemented.");
|
8857
8901
|
}
|
8902
|
+
/**
|
8903
|
+
* Should start the sign transaction process and return
|
8904
|
+
* the signed transaction.
|
8905
|
+
*
|
8906
|
+
* @param address - The address to sign the transaction
|
8907
|
+
* @param transaction - The transaction to sign
|
8908
|
+
*
|
8909
|
+
* @returns Transaction signature
|
8910
|
+
*/
|
8911
|
+
async signTransaction(_address, _transaction) {
|
8912
|
+
throw new Error("Method not implemented.");
|
8913
|
+
}
|
8858
8914
|
/**
|
8859
8915
|
* Should start the send transaction process and return
|
8860
8916
|
* the transaction id submitted to the network.
|