@@ -50,6 +50,7 @@ import { viewFunction, viewState } from "./utils";
50
50
51
51
import type { FungibleToken , NativeToken } from "@near-js/tokens" ;
52
52
import { NEAR } from "@near-js/tokens" ;
53
+ import depd from "depd" ;
53
54
54
55
const {
55
56
addKey,
@@ -772,7 +773,7 @@ export class Account {
772
773
// DEPRECATED FUNCTIONS BELLOW - Please remove in next release
773
774
774
775
/**
775
- * @deprecated please use {@link Account.createSignedMetaTransaction} instead
776
+ * @deprecated Will be removed in the next major release, please use {@link Account.createSignedMetaTransaction} instead
776
777
*
777
778
* Compose and sign a SignedDelegate action to be executed in a transaction on behalf of this Account instance
778
779
*
@@ -786,6 +787,9 @@ export class Account {
786
787
blockHeightTtl,
787
788
receiverId,
788
789
} : SignedDelegateOptions ) : Promise < SignedDelegate > {
790
+ const deprecate = depd ( 'Account.signedDelegate()' ) ;
791
+ deprecate ( 'It will be removed in the next major release, please switch to Account.createSignedMetaTransaction()' ) ;
792
+
789
793
const { header } = await this . provider . viewBlock ( {
790
794
finality : DEFAULT_FINALITY ,
791
795
} ) ;
@@ -813,7 +817,7 @@ export class Account {
813
817
}
814
818
815
819
/**
816
- * @deprecated , accounts no longer use Connections since it's deprecated too
820
+ * @deprecated Will be removed in the next major release , accounts no longer use Connections since it's deprecated too
817
821
*/
818
822
public getConnection ( ) : Connection {
819
823
return new Connection ( "" , this . provider , this . signer ) ;
@@ -833,7 +837,7 @@ export class Account {
833
837
}
834
838
835
839
/**
836
- * @deprecated please use {@link callFunction} instead
840
+ * @deprecated Will be removed in the next major release, please use {@link Account. callFunction} instead
837
841
*
838
842
* Execute a function call.
839
843
* @param options The options for the function call.
@@ -857,6 +861,9 @@ export class Account {
857
861
walletCallbackUrl,
858
862
stringify,
859
863
} : ChangeFunctionCallOptions ) : Promise < FinalExecutionOutcome > {
864
+ const deprecate = depd ( 'Account.functionCall()' ) ;
865
+ deprecate ( 'It will be removed in the next major release, please switch to Account.callFunction()' ) ;
866
+
860
867
this . validateArgs ( args ) ;
861
868
862
869
const stringifyArg =
@@ -880,11 +887,14 @@ export class Account {
880
887
}
881
888
882
889
/**
883
- * @deprecated use instead {@link Provider.viewTransactionStatus}
890
+ * @deprecated Will be removed in the next major release, use instead {@link Provider.viewTransactionStatus}
884
891
*/
885
892
public async getTransactionStatus (
886
893
txHash : string | Uint8Array
887
894
) : Promise < FinalExecutionOutcome > {
895
+ const deprecate = depd ( 'Account.getTransactionStatus()' ) ;
896
+ deprecate ( 'It will be removed in the next major release, please switch to Provider.viewTransactionStatus()' ) ;
897
+
888
898
return this . provider . viewTransactionStatus (
889
899
txHash ,
890
900
this . accountId , // accountId is used to determine on which shard to look for a tx
@@ -893,7 +903,7 @@ export class Account {
893
903
}
894
904
895
905
/**
896
- * @deprecated use ${@link createSignedTransaction}
906
+ * @deprecated Will be removed in the next major release, use ${@link Account. createSignedTransaction}
897
907
* Create a signed transaction which can be broadcast to the network
898
908
* @param receiverId NEAR account receiving the transaction
899
909
* @param actions list of actions to perform as part of the transaction
@@ -904,6 +914,9 @@ export class Account {
904
914
actions : Action [ ] ,
905
915
opts ?: { signer : Signer }
906
916
) : Promise < [ Uint8Array , SignedTransaction ] > {
917
+ const deprecate = depd ( 'Account.signTransaction()' ) ;
918
+ deprecate ( 'It will be removed in the next major release, please switch to Account.createSignedTransaction()' ) ;
919
+
907
920
const signer = opts ?. signer || this . signer ;
908
921
909
922
if ( ! signer ) throw new Error ( `Please set a signer` ) ;
@@ -932,7 +945,8 @@ export class Account {
932
945
}
933
946
934
947
/**
935
- * @deprecated instead please create a transaction with
948
+ * @deprecated Will be removed in the next major release,
949
+ * instead please create a transaction with
936
950
* the actions bellow and broadcast it to the network
937
951
* 1. createAccount
938
952
* 2. transfer some tokens
@@ -952,6 +966,9 @@ export class Account {
952
966
data : Uint8Array ,
953
967
amount : bigint
954
968
) : Promise < Account > {
969
+ const deprecate = depd ( 'Account.createAndDeployContract()' ) ;
970
+ deprecate ( 'It will be removed in the next major release' ) ;
971
+
955
972
const accessKey = fullAccessKey ( ) ;
956
973
await this . signAndSendTransactionLegacy ( {
957
974
receiverId : contractId ,
@@ -966,7 +983,7 @@ export class Account {
966
983
}
967
984
968
985
/**
969
- * @deprecated please instead use {@link transfer}
986
+ * @deprecated Will be removed in the next major release, please instead use {@link Account. transfer}
970
987
*
971
988
* @param receiverId NEAR account receiving Ⓝ
972
989
* @param amount Amount to send in yoctoⓃ
@@ -975,14 +992,17 @@ export class Account {
975
992
receiverId : string ,
976
993
amount : bigint
977
994
) : Promise < FinalExecutionOutcome > {
995
+ const deprecate = depd ( 'Account.sendMoney()' ) ;
996
+ deprecate ( 'It will be removed in the next major release, please switch to Account.transfer()' ) ;
997
+
978
998
return this . signAndSendTransactionLegacy ( {
979
999
receiverId,
980
1000
actions : [ transfer ( amount ) ] ,
981
1001
} ) ;
982
1002
}
983
1003
984
1004
/**
985
- * @deprecated please instead use {@link signAndSendTransaction}
1005
+ * @deprecated Will be removed in the next major release, please instead use {@link Account. signAndSendTransaction}
986
1006
*
987
1007
* Sign a transaction to perform a list of actions and broadcast it using the RPC API.
988
1008
* @see {@link "@near-js/providers".json-rpc-provider.JsonRpcProvider | JsonRpcProvider }
@@ -998,6 +1018,9 @@ export class Account {
998
1018
{ receiverId, actions, returnError } : SignAndSendTransactionOptions ,
999
1019
opts ?: { signer : Signer }
1000
1020
) : Promise < FinalExecutionOutcome > {
1021
+ const deprecate = depd ( 'Account.signAndSendTransactionLegacy()' ) ;
1022
+ deprecate ( 'It will be removed in the next major release, please switch to Account.signAndSendTransaction()' ) ;
1023
+
1001
1024
let txHash , signedTx ;
1002
1025
1003
1026
// Default number of retries with different nonce before giving up on a transaction.
@@ -1087,7 +1110,7 @@ export class Account {
1087
1110
accessKeyByPublicKeyCache : { [ key : string ] : AccessKeyView } = { } ;
1088
1111
1089
1112
/**
1090
- * @deprecated , accounts will no longer handle keystores
1113
+ * @deprecated Will be removed in the next major release , accounts will no longer handle keystores
1091
1114
*
1092
1115
* Finds the {@link AccessKeyView} associated with the accounts {@link PublicKey} stored in the {@link "@near-js/keystores".keystore.KeyStore | Keystore}.
1093
1116
*
@@ -1100,6 +1123,9 @@ export class Account {
1100
1123
receiverId : string ,
1101
1124
actions : Action [ ]
1102
1125
) : Promise < { publicKey : PublicKey ; accessKey : AccessKeyView } > {
1126
+ const deprecate = depd ( 'Account.findAccessKey()' ) ;
1127
+ deprecate ( 'It will be removed in the next major release' ) ;
1128
+
1103
1129
if ( ! this . signer ) throw new Error ( `Please set a signer` ) ;
1104
1130
1105
1131
const publicKey = await this . signer . getPublicKey ( ) ;
@@ -1153,7 +1179,7 @@ export class Account {
1153
1179
}
1154
1180
1155
1181
/**
1156
- * @deprecated please use {@link addFullAccessKey} or {@link addFunctionAccessKey}
1182
+ * @deprecated Will be removed in the next major release, please use {@link Account. addFullAccessKey} or {@link Account. addFunctionAccessKey}
1157
1183
*
1158
1184
* @see [https://docs.near.org/concepts/basics/accounts/access-keys](https://docs.near.org/concepts/basics/accounts/access-keys)
1159
1185
* @todo expand this API to support more options.
@@ -1168,6 +1194,9 @@ export class Account {
1168
1194
methodNames ?: string | string [ ] ,
1169
1195
amount ?: bigint
1170
1196
) : Promise < FinalExecutionOutcome > {
1197
+ const deprecate = depd ( 'Account.addKey()' ) ;
1198
+ deprecate ( 'It will be removed in the next major release, please switch to either Account.addFullAccessKey(), or Account.addFunctionAccessKey()' ) ;
1199
+
1171
1200
if ( ! methodNames ) {
1172
1201
methodNames = [ ] ;
1173
1202
}
@@ -1187,7 +1216,7 @@ export class Account {
1187
1216
}
1188
1217
1189
1218
/**
1190
- * @deprecated please use {@link Provider.callFunction} instead
1219
+ * @deprecated Will be removed in the next major release, please use {@link Provider.callFunction} instead
1191
1220
*
1192
1221
* Invoke a contract view function using the RPC API.
1193
1222
* @see [https://docs.near.org/api/rpc/contracts#call-a-contract-function](https://docs.near.org/api/rpc/contracts#call-a-contract-function)
@@ -1202,11 +1231,13 @@ export class Account {
1202
1231
* @returns {Promise<any> }
1203
1232
*/
1204
1233
async viewFunction ( options : ViewFunctionCallOptions ) : Promise < any > {
1234
+ const deprecate = depd ( 'Account.viewFunction()' ) ;
1235
+ deprecate ( 'It will be removed in the next major release, please switch to either Provider.callFunction()' ) ;
1205
1236
return await viewFunction ( this . getConnection ( ) , options ) ;
1206
1237
}
1207
1238
1208
1239
/**
1209
- * @deprecated please use {@link getContractState} instead
1240
+ * @deprecated Will be removed in the next major release, please use {@link Account. getContractState} instead
1210
1241
*
1211
1242
* Returns the state (key value pairs) of this account's contract based on the key prefix.
1212
1243
* Pass an empty string for prefix if you would like to return the entire state.
@@ -1219,6 +1250,9 @@ export class Account {
1219
1250
prefix : string | Uint8Array ,
1220
1251
blockQuery : BlockReference = { finality : DEFAULT_FINALITY }
1221
1252
) : Promise < Array < { key : Buffer ; value : Buffer } > > {
1253
+ const deprecate = depd ( 'Account.viewState()' ) ;
1254
+ deprecate ( 'It will be removed in the next major release, please switch to either Account.getContractState()' ) ;
1255
+
1222
1256
return await viewState (
1223
1257
this . getConnection ( ) ,
1224
1258
this . accountId ,
@@ -1228,13 +1262,16 @@ export class Account {
1228
1262
}
1229
1263
1230
1264
/**
1231
- * @deprecated please use {@link getAccessKeyList} instead
1265
+ * @deprecated Will be removed in the next major release, please use {@link Account. getAccessKeyList} instead
1232
1266
*
1233
1267
* Get all access keys for the account
1234
1268
* @see [https://docs.near.org/api/rpc/access-keys#view-access-key-list](https://docs.near.org/api/rpc/access-keys#view-access-key-list)
1235
1269
*
1236
1270
*/
1237
1271
async getAccessKeys ( ) : Promise < AccessKeyInfoView [ ] > {
1272
+ const deprecate = depd ( 'Account.getAccessKeys()' ) ;
1273
+ deprecate ( 'It will be removed in the next major release, please switch to either Account.getAccessKeyList()' ) ;
1274
+
1238
1275
const response = await this . provider . query < AccessKeyList > ( {
1239
1276
request_type : "view_access_key_list" ,
1240
1277
account_id : this . accountId ,
@@ -1279,12 +1316,15 @@ export class Account {
1279
1316
}
1280
1317
1281
1318
/**
1282
- * @deprecated please use {@link getState} instead
1319
+ * @deprecated Will be removed in the next major release, please use {@link Account. getState} instead
1283
1320
*
1284
1321
* Returns basic NEAR account information via the `view_account` RPC query method
1285
1322
* @see [https://docs.near.org/api/rpc/contracts#view-account](https://docs.near.org/api/rpc/contracts#view-account)
1286
1323
*/
1287
1324
async state ( ) : Promise < AccountView > {
1325
+ const deprecate = depd ( 'Account.state()' ) ;
1326
+ deprecate ( 'It will be removed in the next major release, please switch to either Account.getState()' ) ;
1327
+
1288
1328
return this . provider . query < AccountView > ( {
1289
1329
request_type : "view_account" ,
1290
1330
account_id : this . accountId ,
@@ -1293,10 +1333,13 @@ export class Account {
1293
1333
}
1294
1334
1295
1335
/**
1296
- * @deprecated please use {@link getState} instead
1336
+ * @deprecated Will be removed in the next major release, please use {@link Account. getState} instead
1297
1337
*
1298
1338
*/
1299
1339
async getAccountBalance ( ) : Promise < AccountBalance > {
1340
+ const deprecate = depd ( 'Account.getAccountBalance()' ) ;
1341
+ deprecate ( 'It will be removed in the next major release, please switch to either Account.getState()' ) ;
1342
+
1300
1343
const protocolConfig = await this . provider . experimental_protocolConfig ( {
1301
1344
finality : DEFAULT_FINALITY ,
1302
1345
} ) ;
@@ -1322,12 +1365,15 @@ export class Account {
1322
1365
/**
1323
1366
* Returns the NEAR tokens balance and validators of a given account that is delegated to the staking pools that are part of the validators set in the current epoch.
1324
1367
*
1325
- * @deprecated
1368
+ * @deprecated Will be removed in the next major release
1326
1369
*
1327
1370
* NOTE: If the tokens are delegated to a staking pool that is currently on pause or does not have enough tokens to participate in validation, they won't be accounted for.
1328
1371
* @returns {Promise<ActiveDelegatedStakeBalance> }
1329
1372
*/
1330
1373
async getActiveDelegatedStakeBalance ( ) : Promise < ActiveDelegatedStakeBalance > {
1374
+ const deprecate = depd ( 'Account.getActiveDelegatedStakeBalance()' ) ;
1375
+ deprecate ( 'It will be removed in the next major release' ) ;
1376
+
1331
1377
const block = await this . provider . block ( {
1332
1378
finality : DEFAULT_FINALITY ,
1333
1379
} ) ;
0 commit comments