@verana-labs/verana-types 0.10.1-dev.7 → 0.10.1-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsgIncreaseActiveGovernanceFrameworkVersionAminoConverter = exports.MsgAddGovernanceFrameworkDocumentAminoConverter = exports.MsgArchiveTrustRegistryAminoConverter = exports.MsgUpdateTrustRegistryAminoConverter = exports.MsgCreateTrustRegistryAminoConverter = void 0;
4
+ const tx_1 = require("../codec/verana/tr/v1/tx");
5
+ exports.MsgCreateTrustRegistryAminoConverter = {
6
+ aminoType: "/verana.tr.v1.MsgCreateTrustRegistry",
7
+ toAmino: ({ authority, operator, did, aka, language, docUrl, docDigestSri }) => ({
8
+ authority,
9
+ operator,
10
+ did,
11
+ aka,
12
+ language,
13
+ doc_url: docUrl,
14
+ doc_digest_sri: docDigestSri,
15
+ }),
16
+ fromAmino: (value) => tx_1.MsgCreateTrustRegistry.fromPartial({
17
+ authority: value.authority,
18
+ operator: value.operator,
19
+ did: value.did,
20
+ aka: value.aka,
21
+ language: value.language,
22
+ docUrl: value.doc_url,
23
+ docDigestSri: value.doc_digest_sri,
24
+ }),
25
+ };
26
+ exports.MsgUpdateTrustRegistryAminoConverter = {
27
+ aminoType: "/verana.tr.v1.MsgUpdateTrustRegistry",
28
+ toAmino: ({ authority, operator, id, did, aka }) => ({
29
+ authority,
30
+ operator,
31
+ id: id != null ? id.toString() : undefined,
32
+ did,
33
+ aka,
34
+ }),
35
+ fromAmino: (value) => tx_1.MsgUpdateTrustRegistry.fromPartial({
36
+ authority: value.authority,
37
+ operator: value.operator,
38
+ id: value.id != null ? Number(value.id) : 0,
39
+ did: value.did,
40
+ aka: value.aka,
41
+ }),
42
+ };
43
+ exports.MsgArchiveTrustRegistryAminoConverter = {
44
+ aminoType: "/verana.tr.v1.MsgArchiveTrustRegistry",
45
+ toAmino: ({ authority, operator, id, archive }) => ({
46
+ authority,
47
+ operator,
48
+ id: id != null ? id.toString() : undefined,
49
+ archive,
50
+ }),
51
+ fromAmino: (value) => tx_1.MsgArchiveTrustRegistry.fromPartial({
52
+ authority: value.authority,
53
+ operator: value.operator,
54
+ id: value.id != null ? Number(value.id) : 0,
55
+ archive: value.archive,
56
+ }),
57
+ };
58
+ exports.MsgAddGovernanceFrameworkDocumentAminoConverter = {
59
+ aminoType: "/verana.tr.v1.MsgAddGovernanceFrameworkDocument",
60
+ toAmino: ({ authority, operator, id, docLanguage, docUrl, docDigestSri, version, }) => ({
61
+ authority,
62
+ operator,
63
+ id: id != null ? id.toString() : undefined,
64
+ doc_language: docLanguage,
65
+ doc_url: docUrl,
66
+ doc_digest_sri: docDigestSri,
67
+ version,
68
+ }),
69
+ fromAmino: (value) => tx_1.MsgAddGovernanceFrameworkDocument.fromPartial({
70
+ authority: value.authority,
71
+ operator: value.operator,
72
+ id: value.id != null ? Number(value.id) : 0,
73
+ docLanguage: value.doc_language,
74
+ docUrl: value.doc_url,
75
+ docDigestSri: value.doc_digest_sri,
76
+ version: value.version,
77
+ }),
78
+ };
79
+ exports.MsgIncreaseActiveGovernanceFrameworkVersionAminoConverter = {
80
+ aminoType: "/verana.tr.v1.MsgIncreaseActiveGovernanceFrameworkVersion",
81
+ toAmino: ({ authority, operator, id }) => ({
82
+ authority,
83
+ operator,
84
+ id: id != null ? id.toString() : undefined,
85
+ }),
86
+ fromAmino: (value) => tx_1.MsgIncreaseActiveGovernanceFrameworkVersion.fromPartial({
87
+ authority: value.authority,
88
+ operator: value.operator,
89
+ id: value.id != null ? Number(value.id) : 0,
90
+ }),
91
+ };
@@ -0,0 +1,30 @@
1
+ import Long from "long";
2
+ import type { Duration } from "../../codec/google/protobuf/duration";
3
+ import type { OptionalUInt32 } from "../../codec/verana/cs/v1/tx";
4
+ export declare const clean: <T extends Record<string, any>>(o: T) => T;
5
+ export declare const u64ToStr: (v?: Long | string | number | null) => string | undefined;
6
+ export declare const u64ToStrIfNonZero: (v?: Long | string | number | null) => string | undefined;
7
+ export declare const strToU64: (s?: string | null) => Long | undefined;
8
+ export declare const u32ToAmino: (n?: number | null) => number | undefined;
9
+ export declare const pickOptionalUInt32: (v: any) => OptionalUInt32 | undefined;
10
+ export declare const pickU32: (v: any) => OptionalUInt32 | undefined;
11
+ export declare const toOptU32Amino: (m?: {
12
+ value: number;
13
+ } | undefined) => {
14
+ value?: undefined;
15
+ } | {
16
+ value: number;
17
+ } | undefined;
18
+ export declare const fromOptU32Amino: (x: any) => OptionalUInt32 | undefined;
19
+ export declare const dateToIsoAmino: (d?: Date | null) => string | undefined;
20
+ export declare const isoToDate: (s?: string | null) => Date | undefined;
21
+ export declare const dateToAmino: (d?: Date | null) => string | undefined;
22
+ export declare const dateFromAmino: (s?: string | null) => Date | undefined;
23
+ export declare const durationToAmino: (d?: Duration | null) => {
24
+ seconds: string;
25
+ nanos: number | undefined;
26
+ } | undefined;
27
+ export declare const aminoToDuration: (d?: {
28
+ seconds?: string | number | null;
29
+ nanos?: string | number | null;
30
+ } | null) => Duration | undefined;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.aminoToDuration = exports.durationToAmino = exports.dateFromAmino = exports.dateToAmino = exports.isoToDate = exports.dateToIsoAmino = exports.fromOptU32Amino = exports.toOptU32Amino = exports.pickU32 = exports.pickOptionalUInt32 = exports.u32ToAmino = exports.strToU64 = exports.u64ToStrIfNonZero = exports.u64ToStr = exports.clean = void 0;
7
+ const long_1 = __importDefault(require("long"));
8
+ const clean = (o) => {
9
+ Object.keys(o).forEach((k) => o[k] === undefined && delete o[k]);
10
+ return o;
11
+ };
12
+ exports.clean = clean;
13
+ const u64ToStr = (v) => v != null ? long_1.default.fromValue(v).toString() : undefined;
14
+ exports.u64ToStr = u64ToStr;
15
+ const u64ToStrIfNonZero = (v) => {
16
+ if (v == null)
17
+ return undefined;
18
+ const value = long_1.default.fromValue(v);
19
+ return value.isZero() ? undefined : value.toString();
20
+ };
21
+ exports.u64ToStrIfNonZero = u64ToStrIfNonZero;
22
+ const strToU64 = (s) => s != null ? long_1.default.fromString(s) : undefined;
23
+ exports.strToU64 = strToU64;
24
+ const u32ToAmino = (n) => n == null ? undefined : (((n >>> 0) === 0) ? 0 : (n >>> 0));
25
+ exports.u32ToAmino = u32ToAmino;
26
+ const pickOptionalUInt32 = (v) => {
27
+ if (v === undefined || v === null)
28
+ return undefined;
29
+ if (typeof v === "string" && v.trim() === "")
30
+ return undefined;
31
+ const n = Number(v);
32
+ if (!Number.isFinite(n))
33
+ return undefined;
34
+ return { value: n >>> 0 };
35
+ };
36
+ exports.pickOptionalUInt32 = pickOptionalUInt32;
37
+ exports.pickU32 = exports.pickOptionalUInt32;
38
+ const toOptU32Amino = (m) => {
39
+ if (!m)
40
+ return undefined;
41
+ const value = Number(m.value) >>> 0;
42
+ return value === 0 ? {} : { value };
43
+ };
44
+ exports.toOptU32Amino = toOptU32Amino;
45
+ const fromOptU32Amino = (x) => {
46
+ if (x == null)
47
+ return undefined;
48
+ if (typeof x === "object" && x.value == null)
49
+ return { value: 0 };
50
+ const n = typeof x === "object" ? x.value : x;
51
+ if (n === undefined || n === null)
52
+ return undefined;
53
+ if (typeof n === "string" && n.trim() === "")
54
+ return undefined;
55
+ return { value: Number(n) >>> 0 };
56
+ };
57
+ exports.fromOptU32Amino = fromOptU32Amino;
58
+ const dateToIsoAmino = (d) => {
59
+ if (d == null)
60
+ return undefined;
61
+ return d
62
+ .toISOString()
63
+ .replace(/\.000Z$/, "Z")
64
+ .replace(/(\.\d*?[1-9])0+Z$/, "$1Z");
65
+ };
66
+ exports.dateToIsoAmino = dateToIsoAmino;
67
+ const isoToDate = (s) => s != null ? new Date(s) : undefined;
68
+ exports.isoToDate = isoToDate;
69
+ exports.dateToAmino = exports.dateToIsoAmino;
70
+ exports.dateFromAmino = exports.isoToDate;
71
+ const durationToAmino = (d) => {
72
+ if (!d)
73
+ return undefined;
74
+ return (0, exports.clean)({
75
+ seconds: long_1.default.fromValue(d.seconds).toString(),
76
+ nanos: d.nanos === 0 ? undefined : d.nanos,
77
+ });
78
+ };
79
+ exports.durationToAmino = durationToAmino;
80
+ const aminoToDuration = (d) => {
81
+ if (!d)
82
+ return undefined;
83
+ return {
84
+ seconds: d.seconds == null ? 0 : Number(d.seconds),
85
+ nanos: d.nanos == null ? 0 : Number(d.nanos),
86
+ };
87
+ };
88
+ exports.aminoToDuration = aminoToDuration;
@@ -0,0 +1,4 @@
1
+ import type { AminoConverter } from "@cosmjs/stargate";
2
+ export declare const MsgCreateExchangeRateAminoConverter: AminoConverter;
3
+ export declare const MsgUpdateExchangeRateAminoConverter: AminoConverter;
4
+ export declare const MsgToggleExchangeRateStateAminoConverter: AminoConverter;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsgToggleExchangeRateStateAminoConverter = exports.MsgUpdateExchangeRateAminoConverter = exports.MsgCreateExchangeRateAminoConverter = void 0;
4
+ const tx_1 = require("../codec/verana/xr/v1/tx");
5
+ const helpers_1 = require("./util/helpers");
6
+ exports.MsgCreateExchangeRateAminoConverter = {
7
+ aminoType: "/verana.xr.v1.MsgCreateExchangeRate",
8
+ toAmino: (m) => {
9
+ var _a, _b;
10
+ return (0, helpers_1.clean)({
11
+ authority: m.authority || undefined,
12
+ base_asset_type: (_a = m.baseAssetType) !== null && _a !== void 0 ? _a : 0,
13
+ base_asset: m.baseAsset || undefined,
14
+ quote_asset_type: (_b = m.quoteAssetType) !== null && _b !== void 0 ? _b : 0,
15
+ quote_asset: m.quoteAsset || undefined,
16
+ rate: m.rate || undefined,
17
+ rate_scale: (0, helpers_1.u32ToAmino)(m.rateScale),
18
+ validity_duration: (0, helpers_1.durationToAmino)(m.validityDuration),
19
+ });
20
+ },
21
+ fromAmino: (a) => {
22
+ var _a, _b, _c, _d, _e, _f, _g;
23
+ return tx_1.MsgCreateExchangeRate.fromPartial({
24
+ authority: (_a = a.authority) !== null && _a !== void 0 ? _a : "",
25
+ baseAssetType: (_b = a.base_asset_type) !== null && _b !== void 0 ? _b : 0,
26
+ baseAsset: (_c = a.base_asset) !== null && _c !== void 0 ? _c : "",
27
+ quoteAssetType: (_d = a.quote_asset_type) !== null && _d !== void 0 ? _d : 0,
28
+ quoteAsset: (_e = a.quote_asset) !== null && _e !== void 0 ? _e : "",
29
+ rate: (_f = a.rate) !== null && _f !== void 0 ? _f : "",
30
+ rateScale: (_g = a.rate_scale) !== null && _g !== void 0 ? _g : 0,
31
+ validityDuration: (0, helpers_1.aminoToDuration)(a.validity_duration),
32
+ });
33
+ },
34
+ };
35
+ exports.MsgUpdateExchangeRateAminoConverter = {
36
+ aminoType: "/verana.xr.v1.MsgUpdateExchangeRate",
37
+ toAmino: (m) => (0, helpers_1.clean)({
38
+ authority: m.authority || undefined,
39
+ operator: m.operator || undefined,
40
+ id: (0, helpers_1.u64ToStr)(m.id),
41
+ rate: m.rate || undefined,
42
+ }),
43
+ fromAmino: (a) => {
44
+ var _a, _b, _c;
45
+ return tx_1.MsgUpdateExchangeRate.fromPartial({
46
+ authority: (_a = a.authority) !== null && _a !== void 0 ? _a : "",
47
+ operator: (_b = a.operator) !== null && _b !== void 0 ? _b : "",
48
+ id: (0, helpers_1.strToU64)(a.id) != null ? Number((0, helpers_1.strToU64)(a.id).toString()) : 0,
49
+ rate: (_c = a.rate) !== null && _c !== void 0 ? _c : "",
50
+ });
51
+ },
52
+ };
53
+ exports.MsgToggleExchangeRateStateAminoConverter = {
54
+ aminoType: "/verana.xr.v1.MsgToggleExchangeRateState",
55
+ toAmino: (m) => (0, helpers_1.clean)({
56
+ authority: m.authority || undefined,
57
+ id: (0, helpers_1.u64ToStr)(m.id),
58
+ state: m.state ? true : undefined,
59
+ }),
60
+ fromAmino: (a) => {
61
+ var _a, _b;
62
+ return tx_1.MsgToggleExchangeRateState.fromPartial({
63
+ authority: (_a = a.authority) !== null && _a !== void 0 ? _a : "",
64
+ id: (0, helpers_1.strToU64)(a.id) != null ? Number((0, helpers_1.strToU64)(a.id).toString()) : 0,
65
+ state: (_b = a.state) !== null && _b !== void 0 ? _b : false,
66
+ });
67
+ },
68
+ };
@@ -1,32 +1,8 @@
1
- /**
2
- * Amino Converters for Verana Message Types
3
- *
4
- * These converters match the frontend implementation to ensure compatibility.
5
- * They convert between Proto messages and Amino JSON format.
6
- */
7
- import type { AminoConverter } from "@cosmjs/stargate";
8
- export declare const MsgCreateTrustRegistryAminoConverter: AminoConverter;
9
- export declare const MsgUpdateTrustRegistryAminoConverter: AminoConverter;
10
- export declare const MsgArchiveTrustRegistryAminoConverter: AminoConverter;
11
- export declare const MsgAddGovernanceFrameworkDocumentAminoConverter: AminoConverter;
12
- export declare const MsgIncreaseActiveGovernanceFrameworkVersionAminoConverter: AminoConverter;
13
- export declare const MsgCreateCredentialSchemaAminoConverter: AminoConverter;
14
- export declare const MsgUpdateCredentialSchemaAminoConverter: AminoConverter;
15
- export declare const MsgArchiveCredentialSchemaAminoConverter: AminoConverter;
16
- export declare const MsgReclaimTrustDepositAminoConverter: AminoConverter;
17
- export declare const MsgReclaimTrustDepositYieldAminoConverter: AminoConverter;
18
- export declare const MsgRepaySlashedTrustDepositAminoConverter: AminoConverter;
19
- export declare const MsgSlashTrustDepositAminoConverter: AminoConverter;
20
- export declare const MsgCreateRootPermissionAminoConverter: AminoConverter;
21
- export declare const MsgAdjustPermissionAminoConverter: AminoConverter;
22
- export declare const MsgRevokePermissionAminoConverter: AminoConverter;
23
- export declare const MsgStartPermissionVPAminoConverter: AminoConverter;
24
- export declare const MsgRenewPermissionVPAminoConverter: AminoConverter;
25
- export declare const MsgSetPermissionVPToValidatedAminoConverter: AminoConverter;
26
- export declare const MsgCancelPermissionVPLastRequestAminoConverter: AminoConverter;
27
- export declare const MsgCreateOrUpdatePermissionSessionAminoConverter: AminoConverter;
28
- export declare const MsgSlashPermissionTrustDepositAminoConverter: AminoConverter;
29
- export declare const MsgRepayPermissionSlashedTrustDepositAminoConverter: AminoConverter;
30
- export declare const MsgCreatePermissionAminoConverter: AminoConverter;
31
- export declare const MsgGrantOperatorAuthorizationAminoConverter: AminoConverter;
32
- export declare const MsgRevokeOperatorAuthorizationAminoConverter: AminoConverter;
1
+ export * from "../amino-converter/tr";
2
+ export * from "../amino-converter/cs";
3
+ export * from "../amino-converter/td";
4
+ export * from "../amino-converter/perm";
5
+ export * from "../amino-converter/de";
6
+ export * from "../amino-converter/di";
7
+ export * from "../amino-converter/xr";
8
+ export * from "../amino-converter/util/helpers";