@near-js/transactions
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -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: { |
@@ -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
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
54092
1085
+ Added@near-js/crypto@1.3.0(transitive)
+ Added@near-js/keystores@0.1.0(transitive)
+ Added@near-js/signers@0.1.5(transitive)
+ Added@near-js/utils@0.3.0(transitive)
+ Addedbn.js@4.12.0(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedelliptic@6.6.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednode-addon-api@5.1.0(transitive)
+ Addednode-gyp-build@4.8.2(transitive)
+ Addedsecp256k1@5.0.0(transitive)
- Removed@near-js/crypto@1.2.4(transitive)
- Removed@near-js/keystores@0.0.12(transitive)
- Removed@near-js/signers@0.1.4(transitive)
- Removed@near-js/utils@0.2.2(transitive)
Updated@near-js/crypto@1.3.0
Updated@near-js/signers@0.1.5
Updated@near-js/utils@0.3.0