@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
@@ -3,6 +3,7 @@ import type { AddressLike, AbstractAddress, BytesLike } from '@fuel-ts/interface
|
|
3
3
|
import type { BN, BigNumberish } from '@fuel-ts/math';
|
4
4
|
import type { TransactionScript, Policy, TransactionCreate } from '@fuel-ts/transactions';
|
5
5
|
import { TransactionType } from '@fuel-ts/transactions';
|
6
|
+
import type { Account } from '../../account';
|
6
7
|
import type { Predicate } from '../../predicate';
|
7
8
|
import type { GqlGasCosts } from '../__generated__/operations';
|
8
9
|
import type { Coin } from '../coin';
|
@@ -95,12 +96,23 @@ export declare abstract class BaseTransactionRequest implements BaseTransactionR
|
|
95
96
|
* Pushes an output to the list without any side effects and returns the index
|
96
97
|
*/
|
97
98
|
protected pushOutput(output: TransactionRequestOutput): number;
|
99
|
+
/**
|
100
|
+
* @hidden
|
101
|
+
*
|
102
|
+
* Pushes a witness to the list and returns the index
|
103
|
+
*
|
104
|
+
* @param signature - The signature to add to the witness.
|
105
|
+
* @returns The index of the created witness.
|
106
|
+
*/
|
107
|
+
addWitness(signature: BytesLike): number;
|
98
108
|
/**
|
99
109
|
* @hidden
|
100
110
|
*
|
101
111
|
* Creates an empty witness without any side effects and returns the index
|
112
|
+
*
|
113
|
+
* @returns The index of the created witness.
|
102
114
|
*/
|
103
|
-
protected
|
115
|
+
protected addEmptyWitness(): number;
|
104
116
|
/**
|
105
117
|
* Updates the witness for a given owner and signature.
|
106
118
|
*
|
@@ -116,6 +128,13 @@ export declare abstract class BaseTransactionRequest implements BaseTransactionR
|
|
116
128
|
* @throws If the witness does not exist.
|
117
129
|
*/
|
118
130
|
updateWitness(index: number, witness: TransactionRequestWitness): void;
|
131
|
+
/**
|
132
|
+
* Helper function to add an external signature to the transaction.
|
133
|
+
*
|
134
|
+
* @param account - The account/s to sign to the transaction.
|
135
|
+
* @returns The transaction with the signature witness added.
|
136
|
+
*/
|
137
|
+
addAccountWitnesses(account: Account | Account[]): Promise<this>;
|
119
138
|
/**
|
120
139
|
* Gets the coin inputs for a transaction.
|
121
140
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transaction-request.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-request/transaction-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAKL,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAM5C,OAAO,KAAK,EACV,uBAAuB,EACvB,2BAA2B,EAE5B,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EACV,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC7B,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"transaction-request.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-request/transaction-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAKL,eAAe,EAChB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AA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C,EAAE,eAAe;IAyC9E;;;;;OAKG;IACH,wBAAwB,IAAI,YAAY,EAAE;IAS1C;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAElD;;;;;OAKG;IACH,MAAM;IAIN,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,EAAE;CA6BxD"}
|
@@ -42882,13 +42882,27 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42882
42882
|
this.outputs.push(output3);
|
42883
42883
|
return this.outputs.length - 1;
|
42884
42884
|
}
|
42885
|
+
/**
|
42886
|
+
* @hidden
|
42887
|
+
*
|
42888
|
+
* Pushes a witness to the list and returns the index
|
42889
|
+
*
|
42890
|
+
* @param signature - The signature to add to the witness.
|
42891
|
+
* @returns The index of the created witness.
|
42892
|
+
*/
|
42893
|
+
addWitness(signature) {
|
42894
|
+
this.witnesses.push(signature);
|
42895
|
+
return this.witnesses.length - 1;
|
42896
|
+
}
|
42885
42897
|
/**
|
42886
42898
|
* @hidden
|
42887
42899
|
*
|
42888
42900
|
* Creates an empty witness without any side effects and returns the index
|
42901
|
+
*
|
42902
|
+
* @returns The index of the created witness.
|
42889
42903
|
*/
|
42890
|
-
|
42891
|
-
this.
|
42904
|
+
addEmptyWitness() {
|
42905
|
+
this.addWitness(concat([ZeroBytes32, ZeroBytes32]));
|
42892
42906
|
return this.witnesses.length - 1;
|
42893
42907
|
}
|
42894
42908
|
/**
|
@@ -42917,6 +42931,21 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42917
42931
|
}
|
42918
42932
|
this.witnesses[index] = witness;
|
42919
42933
|
}
|
42934
|
+
/**
|
42935
|
+
* Helper function to add an external signature to the transaction.
|
42936
|
+
*
|
42937
|
+
* @param account - The account/s to sign to the transaction.
|
42938
|
+
* @returns The transaction with the signature witness added.
|
42939
|
+
*/
|
42940
|
+
async addAccountWitnesses(account) {
|
42941
|
+
const accounts = Array.isArray(account) ? account : [account];
|
42942
|
+
await Promise.all(
|
42943
|
+
accounts.map(async (acc) => {
|
42944
|
+
this.addWitness(await acc.signTransaction(this));
|
42945
|
+
})
|
42946
|
+
);
|
42947
|
+
return this;
|
42948
|
+
}
|
42920
42949
|
/**
|
42921
42950
|
* Gets the coin inputs for a transaction.
|
42922
42951
|
*
|
@@ -42982,7 +43011,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42982
43011
|
} else {
|
42983
43012
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
42984
43013
|
if (typeof witnessIndex !== "number") {
|
42985
|
-
witnessIndex = this.
|
43014
|
+
witnessIndex = this.addEmptyWitness();
|
42986
43015
|
}
|
42987
43016
|
}
|
42988
43017
|
const input = {
|
@@ -43016,7 +43045,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43016
43045
|
} else {
|
43017
43046
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
43018
43047
|
if (typeof witnessIndex !== "number") {
|
43019
|
-
witnessIndex = this.
|
43048
|
+
witnessIndex = this.addEmptyWitness();
|
43020
43049
|
}
|
43021
43050
|
}
|
43022
43051
|
const input = {
|
@@ -45881,6 +45910,21 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45881
45910
|
}
|
45882
45911
|
return this._connector.signMessage(this.address.toString(), message);
|
45883
45912
|
}
|
45913
|
+
/**
|
45914
|
+
* Signs a transaction with the wallet's private key.
|
45915
|
+
*
|
45916
|
+
* @param transactionRequestLike - The transaction request to sign.
|
45917
|
+
* @returns A promise that resolves to the signature of the transaction.
|
45918
|
+
*/
|
45919
|
+
async signTransaction(transactionRequestLike) {
|
45920
|
+
if (!this._connector) {
|
45921
|
+
throw new FuelError(
|
45922
|
+
ErrorCode.MISSING_CONNECTOR,
|
45923
|
+
"A connector is required to sign transactions."
|
45924
|
+
);
|
45925
|
+
}
|
45926
|
+
return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
|
45927
|
+
}
|
45884
45928
|
/**
|
45885
45929
|
* Sends a transaction to the network.
|
45886
45930
|
*
|
@@ -47492,7 +47536,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47492
47536
|
*/
|
47493
47537
|
async signTransaction(transactionRequestLike) {
|
47494
47538
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
47495
|
-
const chainId = this.provider.
|
47539
|
+
const chainId = this.provider.getChainId();
|
47496
47540
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
47497
47541
|
const signature = await this.signer().sign(hashedTransaction);
|
47498
47542
|
return hexlify(signature);
|