Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@near-js/transactions

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@near-js/transactions - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

58

lib/action_creators.d.ts

@@ -7,6 +7,31 @@ /// <reference types="node" />

import { Signature } from './signature';
/**
* Creates a full access key with full access permissions.
* @returns A new full access key.
*/
declare function fullAccessKey(): AccessKey;
/**
* Creates an access key with function call permission for a specific receiver and method names.
* @param receiverId The NEAR account ID of the function call receiver.
* @param methodNames An array of method names allowed for function calls.
* @param allowance An optional allowance (maximum amount) for the function call. Default: Unlimited.
* @returns A new access key with function call permission.
*/
declare function functionCallAccessKey(receiverId: string, methodNames: string[], allowance?: BN): AccessKey;
/**
* Creates a new action for creating a new NEAR account.
* @returns A new action for creating a new account.
*/
declare function createAccount(): Action;
/**
* Creates a new action for deploying a contract with the provided code.
* @param code The Uint8Array representing the code of the contract.
* @returns A new action for deploying a contract.
*/
declare function deployContract(code: Uint8Array): Action;
/**
* Converts an input argument to a Buffer, handling cases for both JSON and Uint8Array.
* @param args The input argument, either JSON object or Uint8Array.
* @returns A Buffer representation of the input argument.
*/
export declare function stringifyJsonOrBytes(args: any): Buffer;

@@ -25,7 +50,40 @@ /**

declare function functionCall(methodName: string, args: Uint8Array | object, gas?: BN, deposit?: BN, stringify?: typeof stringifyJsonOrBytes, jsContract?: boolean): Action;
/**
* Creates a new action for transferring funds, optionally specifying a deposit amount.
* @param deposit The amount to be deposited along with the transfer. Default: 0.
* @returns A new action for transferring funds.
*/
declare function transfer(deposit?: BN): Action;
/**
* Creates a new action for staking tokens, specifying the stake amount and public key.
* @param stake The amount to be staked. Default: 0.
* @param publicKey The public key associated with the staking action.
* @returns A new action for staking tokens.
*/
declare function stake(stake: BN, publicKey: PublicKey): Action;
/**
* Creates a new action for adding a public key with a specified access key.
* @param publicKey The public key to be added.
* @param accessKey The access key associated with the added public key.
* @returns A new action for adding a public key.
*/
declare function addKey(publicKey: PublicKey, accessKey: AccessKey): Action;
/**
* Creates a new action for deleting a public key.
* @param publicKey The public key to be deleted.
* @returns A new action for deleting a public key.
*/
declare function deleteKey(publicKey: PublicKey): Action;
/**
* Creates a new action for deleting an account with the specified beneficiary ID.
* @param beneficiaryId The NEAR account ID of the beneficiary.
* @returns A new action for deleting an account.
*/
declare function deleteAccount(beneficiaryId: string): Action;
/**
* Creates a new action for a signed delegation, specifying the delegate action and signature.
* @param delegateAction The delegate action to be performed.
* @param signature The signature associated with the delegate action.
* @returns A new action for a signed delegation.
*/
declare function signedDelegate({ delegateAction, signature }: {

@@ -32,0 +90,0 @@ delegateAction: DelegateAction;

@@ -9,2 +9,6 @@ "use strict";

const actions_1 = require("./actions");
/**
* Creates a full access key with full access permissions.
* @returns A new full access key.
*/
function fullAccessKey() {

@@ -18,2 +22,9 @@ return new actions_1.AccessKey({

}
/**
* Creates an access key with function call permission for a specific receiver and method names.
* @param receiverId The NEAR account ID of the function call receiver.
* @param methodNames An array of method names allowed for function calls.
* @param allowance An optional allowance (maximum amount) for the function call. Default: Unlimited.
* @returns A new access key with function call permission.
*/
function functionCallAccessKey(receiverId, methodNames, allowance) {

@@ -27,8 +38,22 @@ return new actions_1.AccessKey({

}
/**
* Creates a new action for creating a new NEAR account.
* @returns A new action for creating a new account.
*/
function createAccount() {
return new actions_1.Action({ createAccount: new actions_1.CreateAccount({}) });
}
/**
* Creates a new action for deploying a contract with the provided code.
* @param code The Uint8Array representing the code of the contract.
* @returns A new action for deploying a contract.
*/
function deployContract(code) {
return new actions_1.Action({ deployContract: new actions_1.DeployContract({ code }) });
}
/**
* Converts an input argument to a Buffer, handling cases for both JSON and Uint8Array.
* @param args The input argument, either JSON object or Uint8Array.
* @returns A Buffer representation of the input argument.
*/
function stringifyJsonOrBytes(args) {

@@ -63,17 +88,50 @@ const isUint8Array = args.byteLength !== undefined && args.byteLength === args.length;

}
/**
* Creates a new action for transferring funds, optionally specifying a deposit amount.
* @param deposit The amount to be deposited along with the transfer. Default: 0.
* @returns A new action for transferring funds.
*/
function transfer(deposit = new bn_js_1.default(0)) {
return new actions_1.Action({ transfer: new actions_1.Transfer({ deposit }) });
}
/**
* Creates a new action for staking tokens, specifying the stake amount and public key.
* @param stake The amount to be staked. Default: 0.
* @param publicKey The public key associated with the staking action.
* @returns A new action for staking tokens.
*/
function stake(stake = new bn_js_1.default(0), publicKey) {
return new actions_1.Action({ stake: new actions_1.Stake({ stake, publicKey }) });
}
/**
* Creates a new action for adding a public key with a specified access key.
* @param publicKey The public key to be added.
* @param accessKey The access key associated with the added public key.
* @returns A new action for adding a public key.
*/
function addKey(publicKey, accessKey) {
return new actions_1.Action({ addKey: new actions_1.AddKey({ publicKey, accessKey }) });
}
/**
* Creates a new action for deleting a public key.
* @param publicKey The public key to be deleted.
* @returns A new action for deleting a public key.
*/
function deleteKey(publicKey) {
return new actions_1.Action({ deleteKey: new actions_1.DeleteKey({ publicKey }) });
}
/**
* Creates a new action for deleting an account with the specified beneficiary ID.
* @param beneficiaryId The NEAR account ID of the beneficiary.
* @returns A new action for deleting an account.
*/
function deleteAccount(beneficiaryId) {
return new actions_1.Action({ deleteAccount: new actions_1.DeleteAccount({ beneficiaryId }) });
}
/**
* Creates a new action for a signed delegation, specifying the delegate action and signature.
* @param delegateAction The delegate action to be performed.
* @param signature The signature associated with the delegate action.
* @returns A new action for a signed delegation.
*/
function signedDelegate({ delegateAction, signature }) {

@@ -80,0 +138,0 @@ return new actions_1.Action({ signedDelegate: new actions_1.SignedDelegate({ delegateAction, signature }) });

@@ -5,3 +5,13 @@ import { PublicKey } from '@near-js/crypto';

import { Transaction } from './schema';
/**
* Creates a new transaction object with the provided parameters.
* @param signerId The NEAR account ID of the transaction signer.
* @param publicKey The public key associated with the signer.
* @param receiverId The NEAR account ID of the transaction receiver.
* @param nonce The nonce value for the transaction, represented as a BN, string, or number.
* @param actions An array of transaction actions to be performed.
* @param blockHash The hash of the block where the transaction will be included.
* @returns A new transaction object initialized with the provided parameters.
*/
export declare function createTransaction(signerId: string, publicKey: PublicKey, receiverId: string, nonce: BN | string | number, actions: Action[], blockHash: Uint8Array): Transaction;
//# sourceMappingURL=create_transaction.d.ts.map

@@ -9,2 +9,12 @@ "use strict";

const schema_1 = require("./schema");
/**
* Creates a new transaction object with the provided parameters.
* @param signerId The NEAR account ID of the transaction signer.
* @param publicKey The public key associated with the signer.
* @param receiverId The NEAR account ID of the transaction receiver.
* @param nonce The nonce value for the transaction, represented as a BN, string, or number.
* @param actions An array of transaction actions to be performed.
* @param blockHash The hash of the block where the transaction will be included.
* @returns A new transaction object initialized with the provided parameters.
*/
function createTransaction(signerId, publicKey, receiverId, nonce, actions, blockHash) {

@@ -11,0 +21,0 @@ return new schema_1.Transaction({ signerId, publicKey, nonce: new bn_js_1.default(nonce), receiverId, actions, blockHash });

12

lib/delegate.d.ts

@@ -15,10 +15,10 @@ import { PublicKey } from '@near-js/crypto';

* Compose a delegate action for inclusion with a meta transaction signed on the sender's behalf
* @params.actions The set of actions to be included in the meta transaction
* @params.maxBlockHeight The maximum block height for which this action can be executed as part of a transaction
* @params.nonce Current nonce on the access key used to sign the delegate action
* @params.publicKey Public key for the access key used to sign the delegate action
* @params.receiverId Account ID for the intended receiver of the meta transaction
* @params.senderId Account ID for the intended signer of the delegate action
* @param actions The set of actions to be included in the meta transaction
* @param maxBlockHeight The maximum block height for which this action can be executed as part of a transaction
* @param nonce Current nonce on the access key used to sign the delegate action
* @param publicKey Public key for the access key used to sign the delegate action
* @param receiverId Account ID for the intended receiver of the meta transaction
* @param senderId Account ID for the intended signer of the delegate action
*/
export declare function buildDelegateAction({ actions, maxBlockHeight, nonce, publicKey, receiverId, senderId, }: DelegateAction): DelegateAction;
//# sourceMappingURL=delegate.d.ts.map

@@ -12,8 +12,8 @@ "use strict";

* Compose a delegate action for inclusion with a meta transaction signed on the sender's behalf
* @params.actions The set of actions to be included in the meta transaction
* @params.maxBlockHeight The maximum block height for which this action can be executed as part of a transaction
* @params.nonce Current nonce on the access key used to sign the delegate action
* @params.publicKey Public key for the access key used to sign the delegate action
* @params.receiverId Account ID for the intended receiver of the meta transaction
* @params.senderId Account ID for the intended signer of the delegate action
* @param actions The set of actions to be included in the meta transaction
* @param maxBlockHeight The maximum block height for which this action can be executed as part of a transaction
* @param nonce Current nonce on the access key used to sign the delegate action
* @param publicKey Public key for the access key used to sign the delegate action
* @param receiverId Account ID for the intended receiver of the meta transaction
* @param senderId Account ID for the intended signer of the delegate action
*/

@@ -20,0 +20,0 @@ function buildDelegateAction({ actions, maxBlockHeight, nonce, publicKey, receiverId, senderId, }) {

@@ -20,2 +20,7 @@ import { PublicKey } from '@near-js/crypto';

export declare function encodeSignedDelegate(signedDelegate: SignedDelegate): Uint8Array;
/**
* Borsh-encode a transaction or signed transaction into a serialized form.
* @param transaction The transaction or signed transaction object to be encoded.
* @returns A serialized representation of the input transaction.
*/
export declare function encodeTransaction(transaction: Transaction | SignedTransaction): Uint8Array;

@@ -22,0 +27,0 @@ /**

@@ -28,2 +28,7 @@ "use strict";

exports.encodeSignedDelegate = encodeSignedDelegate;
/**
* Borsh-encode a transaction or signed transaction into a serialized form.
* @param transaction The transaction or signed transaction object to be encoded.
* @returns A serialized representation of the input transaction.
*/
function encodeTransaction(transaction) {

@@ -30,0 +35,0 @@ const schema = transaction instanceof SignedTransaction ? exports.SCHEMA.SignedTransaction : exports.SCHEMA.Transaction;

@@ -21,4 +21,5 @@ import { Signer } from '@near-js/signers';

* Sign a delegate action
* @params.delegateAction Delegate action to be signed by the meta transaction sender
* @params.signer Signer instance for the meta transaction sender
* @options SignDelegate options
* @param options.delegateAction Delegate action to be signed by the meta transaction sender
* @param options.signer Signer instance for the meta transaction sender
*/

@@ -25,0 +26,0 @@ export declare function signDelegateAction({ delegateAction, signer }: SignDelegateOptions): Promise<SignedDelegateWithHash>;

@@ -54,4 +54,5 @@ "use strict";

* Sign a delegate action
* @params.delegateAction Delegate action to be signed by the meta transaction sender
* @params.signer Signer instance for the meta transaction sender
* @options SignDelegate options
* @param options.delegateAction Delegate action to be signed by the meta transaction sender
* @param options.signer Signer instance for the meta transaction sender
*/

@@ -58,0 +59,0 @@ function signDelegateAction({ delegateAction, signer }) {

{
"name": "@near-js/transactions",
"version": "1.1.0",
"version": "1.1.1",
"description": "Functions and data types for transactions on NEAR",

@@ -13,6 +13,6 @@ "main": "lib/index.js",

"@noble/hashes": "1.3.3",
"@near-js/crypto": "1.2.0",
"@near-js/signers": "0.1.0",
"@near-js/crypto": "1.2.1",
"@near-js/signers": "0.1.1",
"@near-js/types": "0.0.4",
"@near-js/utils": "0.0.5"
"@near-js/utils": "0.1.0"
},

@@ -24,3 +24,3 @@ "devDependencies": {

"typescript": "4.9.4",
"@near-js/keystores": "0.0.8"
"@near-js/keystores": "0.0.9"
},

@@ -27,0 +27,0 @@ "files": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc