Comparing version 0.0.10 to 0.0.11
@@ -50,3 +50,3 @@ { | ||
}, | ||
"version": "0.0.10" | ||
"version": "0.0.11" | ||
} |
@@ -1,4 +0,4 @@ | ||
import AptosAccount, { AptosAccountPrivateKeyObject } from "./aptos_account"; | ||
import AptosAccount, { AptosAccountObject } from "./aptos_account"; | ||
const aptosAccountPrivateKeyObject: AptosAccountPrivateKeyObject = { | ||
const AptosAccountObject: AptosAccountObject = { | ||
"address": "0x978c213990c4833df71548df7ce49d54c759d6b6d932de22b24d56060b7af2aa", | ||
@@ -23,13 +23,13 @@ "privateKeyHex": "0xc5338cd251c22daa8c9c9cc94f498cc8a5c7e1d2e75287a5dda91096fe64efa5de19e5d1880cac87d57484ce9ed2e84cf0f9599f12e7cc3a52e4e7657a763f2c", | ||
test("Deserializes from AptosAccountPrivateKeyObject", () => { | ||
const a1 = AptosAccount.fromAptosAccountPrivateKeyObject(aptosAccountPrivateKeyObject); | ||
expect(a1.address().hex()).toBe(aptosAccountPrivateKeyObject.address); | ||
expect(a1.pubKey().hex()).toBe(aptosAccountPrivateKeyObject.publicKeyHex); | ||
test("Deserializes from AptosAccountObject", () => { | ||
const a1 = AptosAccount.fromAptosAccountObject(AptosAccountObject); | ||
expect(a1.address().hex()).toBe(AptosAccountObject.address); | ||
expect(a1.pubKey().hex()).toBe(AptosAccountObject.publicKeyHex); | ||
}); | ||
test("Deserializes from AptosAccountPrivateKeyObject without address", () => { | ||
const privateKeyObject = { privateKeyHex: aptosAccountPrivateKeyObject.privateKeyHex }; | ||
const a1 = AptosAccount.fromAptosAccountPrivateKeyObject(privateKeyObject); | ||
expect(a1.address().hex()).toBe(aptosAccountPrivateKeyObject.address); | ||
expect(a1.pubKey().hex()).toBe(aptosAccountPrivateKeyObject.publicKeyHex); | ||
test("Deserializes from AptosAccountObject without address", () => { | ||
const privateKeyObject = { privateKeyHex: AptosAccountObject.privateKeyHex }; | ||
const a1 = AptosAccount.fromAptosAccountObject(privateKeyObject); | ||
expect(a1.address().hex()).toBe(AptosAccountObject.address); | ||
expect(a1.pubKey().hex()).toBe(AptosAccountObject.publicKeyHex); | ||
}); | ||
@@ -39,3 +39,3 @@ | ||
const a1 = new AptosAccount(); | ||
const a2 = AptosAccount.fromAptosAccountPrivateKeyObject(a1.toPrivateKeyObject()); | ||
const a2 = AptosAccount.fromAptosAccountObject(a1.toPrivateKeyObject()); | ||
expect(a1.authKey().hex()).toBe(a2.authKey().hex()); | ||
@@ -46,3 +46,3 @@ expect(a1.address().hex()).toBe(a2.address().hex()); | ||
test("Signs Strings", () => { | ||
const a1 = AptosAccount.fromAptosAccountPrivateKeyObject(aptosAccountPrivateKeyObject); | ||
const a1 = AptosAccount.fromAptosAccountObject(AptosAccountObject); | ||
expect(a1.signHexString("0x77777").hex()) | ||
@@ -49,0 +49,0 @@ .toBe( |
@@ -7,3 +7,3 @@ import * as Nacl from "tweetnacl"; | ||
export interface AptosAccountPrivateKeyObject { | ||
export interface AptosAccountObject { | ||
address?: string, | ||
@@ -21,3 +21,3 @@ publicKeyHex?: Types.HexEncodedBytes, | ||
static fromAptosAccountPrivateKeyObject(obj: AptosAccountPrivateKeyObject): AptosAccount { | ||
static fromAptosAccountObject(obj: AptosAccountObject): AptosAccount { | ||
return new AptosAccount(HexString.ensure(obj.privateKeyHex).toUint8Array(), obj.address); | ||
@@ -41,3 +41,4 @@ } | ||
/** Returns the authKey for the associated account */ | ||
/** Returns the authKey for the associated account | ||
* See here for more info: https://aptos.dev/basics/basics-accounts#single-signer-authentication */ | ||
authKey(): HexString { | ||
@@ -68,3 +69,3 @@ if (!this.authKeyCached) { | ||
toPrivateKeyObject(): AptosAccountPrivateKeyObject { | ||
toPrivateKeyObject(): AptosAccountObject { | ||
return { | ||
@@ -71,0 +72,0 @@ address: this.address().hex(), |
3873
205691