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.2.2 to 1.2.3

4

lib/schema.d.ts

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

export declare const SCHEMA: {
Ed25519Signature: Schema;
Secp256k1Signature: Schema;
Signature: Schema;
Ed25519Data: Schema;
Secp256k1Data: Schema;
PublicKey: Schema;

@@ -55,0 +59,0 @@ FunctionCallPermission: Schema;

@@ -74,14 +74,34 @@ "use strict";

constructor() {
this.Signature = {
this.Ed25519Signature = {
struct: {
keyType: 'u8',
data: { array: { type: 'u8', len: 64 } },
}
};
this.PublicKey = {
this.Secp256k1Signature = {
struct: {
keyType: 'u8',
data: { array: { type: 'u8', len: 65 } },
}
};
this.Signature = {
enum: [
{ struct: { ed25519Signature: this.Ed25519Signature } },
{ struct: { secp256k1Signature: this.Secp256k1Signature } },
]
};
this.Ed25519Data = {
struct: {
data: { array: { type: 'u8', len: 32 } },
}
};
this.Secp256k1Data = {
struct: {
data: { array: { type: 'u8', len: 64 } },
}
};
this.PublicKey = {
enum: [
{ struct: { ed25519Key: this.Ed25519Data } },
{ struct: { secp256k1Key: this.Secp256k1Data } },
]
};
this.FunctionCallPermission = {

@@ -88,0 +108,0 @@ struct: {

7

lib/sign.js

@@ -18,2 +18,3 @@ "use strict";

const signature_1 = require("./signature");
const crypto_1 = require("@near-js/crypto");
/**

@@ -31,5 +32,6 @@ * Signs a given transaction from an account with given keys, applied to the given network

const signature = yield signer.signMessage(message, accountId, networkId);
const keyType = transaction.publicKey.ed25519Key ? crypto_1.KeyType.ED25519 : crypto_1.KeyType.SECP256K1;
const signedTx = new schema_1.SignedTransaction({
transaction,
signature: new signature_1.Signature({ keyType: transaction.publicKey.keyType, data: signature.signature })
signature: new signature_1.Signature({ keyType, data: signature.signature })
});

@@ -64,6 +66,7 @@ return [hash, signedTx];

const signature = yield signer.sign(message);
const keyType = delegateAction.publicKey.ed25519Key ? crypto_1.KeyType.ED25519 : crypto_1.KeyType.SECP256K1;
const signedDelegateAction = new actions_1.SignedDelegate({
delegateAction,
signature: new signature_1.Signature({
keyType: delegateAction.publicKey.keyType,
keyType,
data: signature,

@@ -70,0 +73,0 @@ }),

import { KeyType } from '@near-js/crypto';
import { Assignable } from '@near-js/types';
export declare class Signature extends Assignable {
declare class ED25519Signature extends Assignable {
keyType: KeyType;
data: Uint8Array;
}
declare class SECP256K1Signature extends Assignable {
keyType: KeyType;
data: Uint8Array;
}
export declare class Signature extends Assignable {
ed25519Signature?: ED25519Signature;
secp256k1Signature?: SECP256K1Signature;
constructor({ keyType, data }: {
keyType: KeyType;
data: Uint8Array;
});
get signature(): ED25519Signature | SECP256K1Signature;
get signatureType(): KeyType;
get data(): Uint8Array;
}
export {};
//# sourceMappingURL=signature.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Signature = void 0;
const crypto_1 = require("@near-js/crypto");
const types_1 = require("@near-js/types");
class ED25519Signature extends types_1.Assignable {
constructor() {
super(...arguments);
this.keyType = crypto_1.KeyType.ED25519;
}
}
class SECP256K1Signature extends types_1.Assignable {
constructor() {
super(...arguments);
this.keyType = crypto_1.KeyType.SECP256K1;
}
}
class Signature extends types_1.Assignable {
constructor({ keyType, data }) {
super({});
if (keyType === crypto_1.KeyType.ED25519) {
this.ed25519Signature = { keyType, data };
}
else if (keyType === crypto_1.KeyType.SECP256K1) {
this.secp256k1Signature = { keyType, data };
}
}
get signature() {
return this.ed25519Signature || this.secp256k1Signature;
}
get signatureType() {
return this.signature.keyType;
}
get data() {
return this.signature.data;
}
}
exports.Signature = Signature;
{
"name": "@near-js/transactions",
"version": "1.2.2",
"version": "1.2.3",
"description": "Functions and data types for transactions on NEAR",

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

"@noble/hashes": "1.3.3",
"@near-js/crypto": "1.2.4",
"@near-js/signers": "0.1.4",
"@near-js/crypto": "1.3.0",
"@near-js/signers": "0.1.5",
"@near-js/types": "0.2.1",
"@near-js/utils": "0.2.2"
"@near-js/utils": "0.3.0"
},

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

"typescript": "4.9.4",
"@near-js/keystores": "0.0.12"
"@near-js/keystores": "0.1.0"
},

@@ -26,0 +26,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

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