@near-js/accounts
Advanced tools
Comparing version 0.0.2 to 0.1.0
/// <reference types="node" /> | ||
import BN from 'bn.js'; | ||
import { Action, SignedTransaction } from '@near-js/transactions'; | ||
import { PublicKey } from '@near-js/crypto'; | ||
import { Action, IAction, SignedDelegate, SignedTransaction } from '@near-js/transactions'; | ||
import { FinalExecutionOutcome, AccountView, AccessKeyView, AccessKeyInfoView, BlockReference } from '@near-js/types'; | ||
import BN from 'bn.js'; | ||
import { Connection } from './connection'; | ||
@@ -88,2 +88,7 @@ export interface AccountBalance { | ||
} | ||
interface SignedDelegateOptions { | ||
actions: IAction[]; | ||
blockHeightTtl: number; | ||
receiverId: string; | ||
} | ||
/** | ||
@@ -189,2 +194,10 @@ * This class provides common account related RPC calls including signing transactions with a {@link utils/key_pair!KeyPair}. | ||
stake(publicKey: string | PublicKey, amount: BN): Promise<FinalExecutionOutcome>; | ||
/** | ||
* Compose and sign a SignedDelegate action to be executed in a transaction on behalf of this Account instance | ||
* | ||
* @param actions Actions to be included in the meta transaction | ||
* @param blockHeightTtl Number of blocks past the current block height for which the SignedDelegate action may be included in a meta transaction | ||
* @param receiverId Receiver account of the meta transaction | ||
*/ | ||
signedDelegate({ actions, blockHeightTtl, receiverId, }: SignedDelegateOptions): Promise<SignedDelegate>; | ||
/** @hidden */ | ||
@@ -191,0 +204,0 @@ private validateArgs; |
@@ -16,8 +16,8 @@ "use strict"; | ||
exports.Account = void 0; | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const utils_1 = require("@near-js/utils"); | ||
const crypto_1 = require("@near-js/crypto"); | ||
const providers_1 = require("@near-js/providers"); | ||
const transactions_1 = require("@near-js/transactions"); | ||
const crypto_1 = require("@near-js/crypto"); | ||
const types_1 = require("@near-js/types"); | ||
const utils_1 = require("@near-js/utils"); | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const borsh_1 = require("borsh"); | ||
@@ -331,2 +331,34 @@ const { addKey, createAccount, deleteAccount, deleteKey, deployContract, fullAccessKey, functionCall, functionCallAccessKey, stake, transfer, } = transactions_1.actionCreators; | ||
} | ||
/** | ||
* Compose and sign a SignedDelegate action to be executed in a transaction on behalf of this Account instance | ||
* | ||
* @param actions Actions to be included in the meta transaction | ||
* @param blockHeightTtl Number of blocks past the current block height for which the SignedDelegate action may be included in a meta transaction | ||
* @param receiverId Receiver account of the meta transaction | ||
*/ | ||
signedDelegate({ actions, blockHeightTtl, receiverId, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { provider, signer } = this.connection; | ||
const { header } = yield provider.block({ finality: 'final' }); | ||
const { accessKey, publicKey } = yield this.findAccessKey(null, null); | ||
const delegateAction = (0, transactions_1.buildDelegateAction)({ | ||
actions, | ||
maxBlockHeight: new bn_js_1.default(header.height).add(new bn_js_1.default(blockHeightTtl)), | ||
nonce: new bn_js_1.default(accessKey.nonce).add(new bn_js_1.default(1)), | ||
publicKey, | ||
receiverId, | ||
senderId: this.accountId, | ||
}); | ||
const { signedDelegateAction } = yield (0, transactions_1.signDelegateAction)({ | ||
delegateAction, | ||
signer: { | ||
sign: (message) => __awaiter(this, void 0, void 0, function* () { | ||
const { signature } = yield signer.signMessage(message, delegateAction.senderId, this.connection.networkId); | ||
return signature; | ||
}), | ||
} | ||
}); | ||
return signedDelegateAction; | ||
}); | ||
} | ||
/** @hidden */ | ||
@@ -333,0 +365,0 @@ validateArgs(args) { |
@@ -19,3 +19,3 @@ import { AbiRoot } from 'near-abi'; | ||
*/ | ||
abi: AbiRoot; | ||
abi?: AbiRoot; | ||
} | ||
@@ -22,0 +22,0 @@ /** |
{ | ||
"name": "@near-js/accounts", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "Classes encapsulating account-specific functionality", | ||
@@ -16,8 +16,8 @@ "main": "lib/index.js", | ||
"near-abi": "0.1.1", | ||
"@near-js/crypto": "0.0.2", | ||
"@near-js/providers": "0.0.2", | ||
"@near-js/signers": "0.0.2", | ||
"@near-js/transactions": "0.0.2", | ||
"@near-js/types": "0.0.2", | ||
"@near-js/utils": "0.0.2" | ||
"@near-js/crypto": "0.0.3", | ||
"@near-js/providers": "0.0.3", | ||
"@near-js/signers": "0.0.3", | ||
"@near-js/transactions": "0.1.0", | ||
"@near-js/types": "0.0.3", | ||
"@near-js/utils": "0.0.3" | ||
}, | ||
@@ -31,3 +31,3 @@ "devDependencies": { | ||
"typescript": "^4.9.4", | ||
"@near-js/keystores": "0.0.2" | ||
"@near-js/keystores": "0.0.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101200
1935
+ Added@near-js/crypto@0.0.3(transitive)
+ Added@near-js/keystores@0.0.3(transitive)
+ Added@near-js/providers@0.0.3(transitive)
+ Added@near-js/signers@0.0.3(transitive)
+ Added@near-js/transactions@0.1.0(transitive)
+ Added@near-js/types@0.0.3(transitive)
+ Added@near-js/utils@0.0.3(transitive)
- Removed@near-js/crypto@0.0.2(transitive)
- Removed@near-js/keystores@0.0.2(transitive)
- Removed@near-js/providers@0.0.2(transitive)
- Removed@near-js/signers@0.0.2(transitive)
- Removed@near-js/transactions@0.0.2(transitive)
- Removed@near-js/types@0.0.2(transitive)
- Removed@near-js/utils@0.0.2(transitive)
Updated@near-js/crypto@0.0.3
Updated@near-js/providers@0.0.3
Updated@near-js/signers@0.0.3
Updated@near-js/transactions@0.1.0
Updated@near-js/types@0.0.3
Updated@near-js/utils@0.0.3