@harmoniclabs/cardano-ledger-ts
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -6,2 +6,3 @@ import { ToCbor, CborObj, CborString, CanBeCborString } from "@harmoniclabs/cbor"; | ||
import { NetworkT } from "./Network.js"; | ||
import { XPrv } from "@harmoniclabs/bip32_ed25519"; | ||
export type AddressStr = `${"addr1" | "addr_test1"}${string}`; | ||
@@ -28,2 +29,18 @@ export declare function isAddressStr(stuff: any): stuff is AddressStr; | ||
static fromBuffer(buff: Uint8Array | string): Address; | ||
/** | ||
* gets the standard address for single address wallets | ||
* | ||
* payment key at path "m/1852'/1815'/0'/0/0" | ||
* stake key at path "m/1852'/1815'/0'/2/0" | ||
*/ | ||
static fromXPrv(xprv: XPrv, network?: NetworkT): Address; | ||
/** | ||
* generates an `XPrv` from entropy and calls `Addres.fromXPrv` | ||
* | ||
* gets the standard address for single address wallets | ||
* | ||
* payment key at path "m/1852'/1815'/0'/0/0" | ||
* stake key at path "m/1852'/1815'/0'/2/0" | ||
*/ | ||
static fromEntropy(entropy: Uint8Array | string, network?: NetworkT): Address; | ||
toCborObj(): CborObj; | ||
@@ -30,0 +47,0 @@ static fromCborObj(buff: CborObj): Address; |
@@ -34,2 +34,3 @@ "use strict"; | ||
var uint8array_utils_1 = require("@harmoniclabs/uint8array-utils"); | ||
var bip32_ed25519_1 = require("@harmoniclabs/bip32_ed25519"); | ||
function isAddressStr(stuff) { | ||
@@ -169,2 +170,34 @@ if (typeof stuff !== "string") | ||
}; | ||
/** | ||
* gets the standard address for single address wallets | ||
* | ||
* payment key at path "m/1852'/1815'/0'/0/0" | ||
* stake key at path "m/1852'/1815'/0'/2/0" | ||
*/ | ||
Address.fromXPrv = function (xprv, network) { | ||
if (network === void 0) { network = "mainnet"; } | ||
var account = xprv | ||
.derive((0, bip32_ed25519_1.harden)(1852)) | ||
.derive((0, bip32_ed25519_1.harden)(1815)) | ||
.derive((0, bip32_ed25519_1.harden)(0)); | ||
var prv = account.derive(0).derive(0); | ||
var pub = new credentials_1.PublicKey(prv.public().toPubKeyBytes()); | ||
var pkh = pub.hash; | ||
var stake_prv = account.derive(2).derive(0); | ||
var stake_pub = new credentials_1.PublicKey(stake_prv.public().toPubKeyBytes()); | ||
var stake_pkh = stake_pub.hash; | ||
return new Address(network, credentials_1.Credential.keyHash(pkh), new credentials_1.StakeCredentials("stakeKey", stake_pkh)); | ||
}; | ||
/** | ||
* generates an `XPrv` from entropy and calls `Addres.fromXPrv` | ||
* | ||
* gets the standard address for single address wallets | ||
* | ||
* payment key at path "m/1852'/1815'/0'/0/0" | ||
* stake key at path "m/1852'/1815'/0'/2/0" | ||
*/ | ||
Address.fromEntropy = function (entropy, network) { | ||
if (network === void 0) { network = "mainnet"; } | ||
return Address.fromXPrv(bip32_ed25519_1.XPrv.fromEntropy(entropy), network); | ||
}; | ||
Address.prototype.toCborObj = function () { | ||
@@ -171,0 +204,0 @@ return new cbor_1.CborBytes(this.toBuffer()); |
@@ -369,3 +369,4 @@ "use strict"; | ||
PlutusScriptV1: cardano_costmodels_ts_1.defaultV1Costs, | ||
PlutusScriptV2: cardano_costmodels_ts_1.defaultV2Costs | ||
PlutusScriptV2: cardano_costmodels_ts_1.defaultV2Costs, | ||
PlutusScriptV3: cardano_costmodels_ts_1.defaultV3Costs | ||
}, | ||
@@ -372,0 +373,0 @@ executionUnitPrices: [ |
@@ -23,2 +23,3 @@ import { ToCbor, CborString, CborObj, CanBeCborString } from "@harmoniclabs/cbor"; | ||
toString(): TxOutRefStr; | ||
static fromString(str: string): TxOutRef; | ||
toData(version?: ToDataVersion): DataConstr; | ||
@@ -25,0 +26,0 @@ toCbor(): CborString; |
@@ -70,2 +70,11 @@ "use strict"; | ||
}; | ||
TxOutRef.fromString = function (str) { | ||
if (typeof str !== "string") | ||
throw new Error("TxOutRef.fromString expects a string"); | ||
var _a = __read(str.split('#'), 2), id = _a[0], idx = _a[1]; | ||
return new TxOutRef({ | ||
id: id, | ||
index: Number(idx) | ||
}); | ||
}; | ||
TxOutRef.prototype.toData = function (version) { | ||
@@ -72,0 +81,0 @@ return new plutus_data_1.DataConstr(0, // PTxOutRef only constructor |
@@ -8,2 +8,3 @@ import { PrivateKey } from "../credentials/index.js"; | ||
import { ITxBody, TxBody } from "./body/index.js"; | ||
import { XPrv } from "@harmoniclabs/bip32_ed25519"; | ||
export interface ITx { | ||
@@ -43,3 +44,3 @@ body: ITxBody; | ||
**/ | ||
readonly signWith: (signer: PrivateKey) => void; | ||
readonly signWith: (signer: PrivateKey | XPrv) => void; | ||
/** | ||
@@ -108,3 +109,5 @@ * signs the transaction using any browser wallet | ||
hash: string; | ||
}; | ||
}; /** | ||
* getter | ||
*/ | ||
} | { | ||
@@ -111,0 +114,0 @@ certType: "GenesisKeyDelegation"; |
@@ -38,2 +38,13 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
@@ -55,13 +66,2 @@ var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
@@ -88,2 +88,3 @@ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
var body_1 = require("./body/index.js"); | ||
var bip32_ed25519_1 = require("@harmoniclabs/bip32_ed25519"); | ||
var Tx = /** @class */ (function () { | ||
@@ -113,4 +114,12 @@ function Tx(tx) { | ||
(0, obj_utils_1.defineReadOnlyProperty)(this, "signWith", function (signer) { | ||
var _a = __read((0, crypto_1.signEd25519)(_this.body.hash.toBuffer(), signer instanceof Uint8Array ? signer : signer.toBuffer()), 2), derivedPubKey = _a[0], signature = _a[1]; | ||
_this.addVKeyWitness(new TxWitnessSet_1.VKeyWitness(new TxWitnessSet_1.VKey(derivedPubKey), new hashes_1.Signature(signature))); | ||
if (signer instanceof Uint8Array && signer.length >= 64) { | ||
signer = bip32_ed25519_1.XPrv.fromExtended(signer.slice(0, 64), new Uint8Array(32)); | ||
} | ||
if (signer instanceof bip32_ed25519_1.XPrv) { | ||
var _a = signer.sign(_this.body.hash.toBuffer()), pubKey_1 = _a.pubKey, signature_1 = _a.signature; | ||
_this.addVKeyWitness(new TxWitnessSet_1.VKeyWitness(new TxWitnessSet_1.VKey(pubKey_1), new hashes_1.Signature(signature_1))); | ||
return; | ||
} | ||
var _b = (0, crypto_1.signEd25519)(_this.body.hash.toBuffer(), signer instanceof Uint8Array ? signer : signer.toBuffer()), pubKey = _b.pubKey, signature = _b.signature; | ||
_this.addVKeyWitness(new TxWitnessSet_1.VKeyWitness(new TxWitnessSet_1.VKey(pubKey), new hashes_1.Signature(signature))); | ||
}); | ||
@@ -117,0 +126,0 @@ (0, obj_utils_1.defineReadOnlyProperty)(this, "signWithCip30Wallet", function (cip30) { return __awaiter(_this, void 0, void 0, function () { |
{ | ||
"name": "@harmoniclabs/cardano-ledger-ts", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "", | ||
@@ -47,2 +47,3 @@ "main": "./dist/index.js", | ||
"@harmoniclabs/pair": "^1.0.0", | ||
"@harmoniclabs/bip32_ed25519": "^0.1.2", | ||
"@harmoniclabs/plutus-data": "^1.2.4", | ||
@@ -49,0 +50,0 @@ "@harmoniclabs/plutus-machine": "^2.0.0-dev0" |
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
603521
12982
11