New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@penumbra-zone/getters

Package Overview
Dependencies
Maintainers
3
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@penumbra-zone/getters - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

src/get-validator-info-response.ts

7

CHANGELOG.md
# @penumbra-zone/getters
## 3.0.2
### Patch Changes
- Updated dependencies
- @penumbra-zone/bech32m@3.1.0
## 3.0.1

@@ -4,0 +11,0 @@

8

dist/metadata.d.ts

@@ -72,10 +72,2 @@ import { AssetId } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';

/**
* Get the unbonding start height index from the metadata of an unbonding token
* -- that is, the block height at which unbonding started.
*
* For metadata of a non-unbonding token, will return `undefined`.
*/
export declare const getUnbondingStartHeight: Getter<Metadata_2, bigint, false>;
export { }

54

dist/metadata.js

@@ -1,49 +0,13 @@

import { c as s } from "./create-getter-Bi5Cvcfi.js";
class o {
constructor(e) {
this.regex = e;
import { c as n } from "./create-getter-Bi5Cvcfi.js";
const c = n((s) => s == null ? void 0 : s.penumbraAssetId), l = n(
(s) => {
var o;
return (o = s == null ? void 0 : s.denomUnits.find((p) => p.denom === s.display)) == null ? void 0 : o.exponent;
}
matches(e) {
return this.regex.exec(e) !== null;
}
capture(e) {
const i = this.regex.exec(e);
if (i)
return i.groups;
}
}
const r = {
auctionNft: new o(
/^auctionnft_(?<seqNum>[0-9]+)_(?<auctionId>pauctid1[a-zA-HJ-NP-Z0-9]+)$/
),
lpNft: new o(/^lpnft_/),
delegationToken: new o(
/^delegation_(?<idKey>penumbravalid1(?<id>[a-zA-HJ-NP-Z0-9]+))$/
),
proposalNft: new o(/^proposal_/),
unbondingToken: new o(
/^unbonding_start_at_(?<startAt>[0-9]+)_(?<idKey>penumbravalid1(?<id>[a-zA-HJ-NP-Z0-9]+))$/
),
votingReceipt: new o(/^voted_on_/),
ibc: new o(/^transfer\/(?<channel>channel-\d+)\/(?<denom>.*)/)
}, c = s((n) => n == null ? void 0 : n.penumbraAssetId), p = s(
(n) => {
var e;
return (e = n == null ? void 0 : n.denomUnits.find((i) => i.denom === n.display)) == null ? void 0 : e.exponent;
}
), u = s((n) => {
if (!n)
return;
const e = r.unbondingToken.capture(n.display);
if (e) {
const { startAt: i } = e;
return BigInt(i);
}
}), g = s((n) => n == null ? void 0 : n.display), l = s((n) => n == null ? void 0 : n.symbol);
), r = n((s) => s == null ? void 0 : s.display), y = n((s) => s == null ? void 0 : s.symbol);
export {
c as getAssetId,
g as getDisplay,
p as getDisplayDenomExponent,
l as getSymbol,
u as getUnbondingStartHeight
r as getDisplay,
l as getDisplayDenomExponent,
y as getSymbol
};

@@ -74,8 +74,2 @@ import { Amount } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/num/v1/num_pb';

/**
* For a `ValueView` containing an unbonding token, gets the unbonding start
* height.
*/
export declare const getUnbondingStartHeightFromValueView: Getter<ValueView, bigint, false>;
/**
* Only to be used on `ValueView`s that contain delegation tokens -- and thus,

@@ -82,0 +76,0 @@ * validator infos.

{
"name": "@penumbra-zone/getters",
"version": "3.0.1",
"version": "3.0.2",
"license": "(MIT OR Apache-2.0)",

@@ -16,4 +16,3 @@ "description": "Convenience getters for the deeply nested optionals of Penumbra's protobuf types",

"dependencies": {
"@penumbra-zone/bech32m": "3.0.1",
"@penumbra-zone/constants": "4.0.0"
"@penumbra-zone/bech32m": "3.1.0"
},

@@ -20,0 +19,0 @@ "devDependencies": {

@@ -15,2 +15,5 @@ import { BalancesResponse } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb';

export const getDisplayFromBalancesResponse = getBalanceView.pipe(getMetadata).pipe(getDisplay);
export const getDisplayFromBalancesResponse = getBalanceView
.pipe(getMetadata)
.optional()
.pipe(getDisplay);
import { Metadata } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { describe, expect, it } from 'vitest';
import { getDisplayDenomExponent, getUnbondingStartHeight } from './metadata';
import { getDisplayDenomExponent } from './metadata';

@@ -28,19 +28,1 @@ describe('getDisplayDenomExponent()', () => {

});
describe('getUnbondingStartHeight()', () => {
it("gets the unbonding start height, coerced to a `BigInt`, from an unbonding token's asset ID", () => {
const metadata = new Metadata({ display: 'unbonding_start_at_123_penumbravalid1abc123' });
expect(getUnbondingStartHeight(metadata)).toBe(123n);
});
it("returns `undefined` for a non-unbonding token's metadata", () => {
const metadata = new Metadata({ display: 'penumbra' });
expect(getUnbondingStartHeight.optional()(metadata)).toBeUndefined();
});
it('returns `undefined` for undefined metadata', () => {
expect(getUnbondingStartHeight.optional()(undefined)).toBeUndefined();
});
});
import { Metadata } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { createGetter } from './utils/create-getter';
import { assetPatterns } from '@penumbra-zone/constants/assets';

@@ -25,23 +24,4 @@ export const getAssetId = createGetter((metadata?: Metadata) => metadata?.penumbraAssetId);

/**
* Get the unbonding start height index from the metadata of an unbonding token
* -- that is, the block height at which unbonding started.
*
* For metadata of a non-unbonding token, will return `undefined`.
*/
export const getUnbondingStartHeight = createGetter((metadata?: Metadata) => {
if (!metadata) return undefined;
const unbondingMatch = assetPatterns.unbondingToken.capture(metadata.display);
if (unbondingMatch) {
const { startAt } = unbondingMatch;
return BigInt(startAt);
}
return undefined;
});
export const getDisplay = createGetter((metadata?: Metadata) => metadata?.display);
export const getSymbol = createGetter((metadata?: Metadata) => metadata?.symbol);
import { ValueView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb';
import { createGetter } from './utils/create-getter';
import { bech32mAssetId } from '@penumbra-zone/bech32m/passet';
import { getDisplayDenomExponent, getSymbol, getUnbondingStartHeight } from './metadata';
import { getDisplayDenomExponent, getSymbol } from './metadata';
import { Any } from '@bufbuild/protobuf';

@@ -60,8 +60,2 @@ import { ValidatorInfo } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb';

/**
* For a `ValueView` containing an unbonding token, gets the unbonding start
* height.
*/
export const getUnbondingStartHeightFromValueView = getMetadata.pipe(getUnbondingStartHeight);
export const getSymbolFromValueView = getMetadata.pipe(getSymbol);

@@ -68,0 +62,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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