@fuel-ts/account 0.0.0-rc-1866-20240322105123 → 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.js
CHANGED
@@ -1839,13 +1839,27 @@ var BaseTransactionRequest = class {
|
|
1839
1839
|
this.outputs.push(output);
|
1840
1840
|
return this.outputs.length - 1;
|
1841
1841
|
}
|
1842
|
+
/**
|
1843
|
+
* @hidden
|
1844
|
+
*
|
1845
|
+
* Pushes a witness to the list and returns the index
|
1846
|
+
*
|
1847
|
+
* @param signature - The signature to add to the witness.
|
1848
|
+
* @returns The index of the created witness.
|
1849
|
+
*/
|
1850
|
+
addWitness(signature) {
|
1851
|
+
this.witnesses.push(signature);
|
1852
|
+
return this.witnesses.length - 1;
|
1853
|
+
}
|
1842
1854
|
/**
|
1843
1855
|
* @hidden
|
1844
1856
|
*
|
1845
1857
|
* Creates an empty witness without any side effects and returns the index
|
1858
|
+
*
|
1859
|
+
* @returns The index of the created witness.
|
1846
1860
|
*/
|
1847
|
-
|
1848
|
-
this.
|
1861
|
+
addEmptyWitness() {
|
1862
|
+
this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
|
1849
1863
|
return this.witnesses.length - 1;
|
1850
1864
|
}
|
1851
1865
|
/**
|
@@ -1874,6 +1888,21 @@ var BaseTransactionRequest = class {
|
|
1874
1888
|
}
|
1875
1889
|
this.witnesses[index] = witness;
|
1876
1890
|
}
|
1891
|
+
/**
|
1892
|
+
* Helper function to add an external signature to the transaction.
|
1893
|
+
*
|
1894
|
+
* @param account - The account/s to sign to the transaction.
|
1895
|
+
* @returns The transaction with the signature witness added.
|
1896
|
+
*/
|
1897
|
+
async addAccountWitnesses(account) {
|
1898
|
+
const accounts = Array.isArray(account) ? account : [account];
|
1899
|
+
await Promise.all(
|
1900
|
+
accounts.map(async (acc) => {
|
1901
|
+
this.addWitness(await acc.signTransaction(this));
|
1902
|
+
})
|
1903
|
+
);
|
1904
|
+
return this;
|
1905
|
+
}
|
1877
1906
|
/**
|
1878
1907
|
* Gets the coin inputs for a transaction.
|
1879
1908
|
*
|
@@ -1939,7 +1968,7 @@ var BaseTransactionRequest = class {
|
|
1939
1968
|
} else {
|
1940
1969
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
1941
1970
|
if (typeof witnessIndex !== "number") {
|
1942
|
-
witnessIndex = this.
|
1971
|
+
witnessIndex = this.addEmptyWitness();
|
1943
1972
|
}
|
1944
1973
|
}
|
1945
1974
|
const input = {
|
@@ -1973,7 +2002,7 @@ var BaseTransactionRequest = class {
|
|
1973
2002
|
} else {
|
1974
2003
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
1975
2004
|
if (typeof witnessIndex !== "number") {
|
1976
|
-
witnessIndex = this.
|
2005
|
+
witnessIndex = this.addEmptyWitness();
|
1977
2006
|
}
|
1978
2007
|
}
|
1979
2008
|
const input = {
|
@@ -5126,6 +5155,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5126
5155
|
}
|
5127
5156
|
return this._connector.signMessage(this.address.toString(), message);
|
5128
5157
|
}
|
5158
|
+
/**
|
5159
|
+
* Signs a transaction with the wallet's private key.
|
5160
|
+
*
|
5161
|
+
* @param transactionRequestLike - The transaction request to sign.
|
5162
|
+
* @returns A promise that resolves to the signature of the transaction.
|
5163
|
+
*/
|
5164
|
+
async signTransaction(transactionRequestLike) {
|
5165
|
+
if (!this._connector) {
|
5166
|
+
throw new import_errors15.FuelError(
|
5167
|
+
import_errors15.ErrorCode.MISSING_CONNECTOR,
|
5168
|
+
"A connector is required to sign transactions."
|
5169
|
+
);
|
5170
|
+
}
|
5171
|
+
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
5172
|
+
}
|
5129
5173
|
/**
|
5130
5174
|
* Sends a transaction to the network.
|
5131
5175
|
*
|
@@ -5436,7 +5480,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5436
5480
|
*/
|
5437
5481
|
async signTransaction(transactionRequestLike) {
|
5438
5482
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5439
|
-
const chainId = this.provider.
|
5483
|
+
const chainId = this.provider.getChainId();
|
5440
5484
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5441
5485
|
const signature = await this.signer().sign(hashedTransaction);
|
5442
5486
|
return (0, import_utils30.hexlify)(signature);
|
@@ -8977,6 +9021,18 @@ var FuelConnector = class extends import_events2.EventEmitter {
|
|
8977
9021
|
async signMessage(_address, _message) {
|
8978
9022
|
throw new Error("Method not implemented.");
|
8979
9023
|
}
|
9024
|
+
/**
|
9025
|
+
* Should start the sign transaction process and return
|
9026
|
+
* the signed transaction.
|
9027
|
+
*
|
9028
|
+
* @param address - The address to sign the transaction
|
9029
|
+
* @param transaction - The transaction to sign
|
9030
|
+
*
|
9031
|
+
* @returns Transaction signature
|
9032
|
+
*/
|
9033
|
+
async signTransaction(_address, _transaction) {
|
9034
|
+
throw new Error("Method not implemented.");
|
9035
|
+
}
|
8980
9036
|
/**
|
8981
9037
|
* Should start the send transaction process and return
|
8982
9038
|
* the transaction id submitted to the network.
|