@sparkdreamnft/sparkdreamjs 0.0.46 → 0.0.48
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.
- package/amino-schema.d.ts +5741 -0
- package/amino-schema.js +8 -0
- package/chain-amino.d.ts +61 -0
- package/chain-amino.js +670 -0
- package/esm/amino-schema.js +5 -0
- package/esm/chain-amino.js +665 -0
- package/esm/nested-amino.js +7 -1
- package/esm/sparkdream/artifact/v1/query.js +125 -0
- package/esm/sparkdream/artifact/v1/query.lcd.js +7 -0
- package/esm/sparkdream/artifact/v1/query.rpc.Query.js +12 -1
- package/esm/sparkdream/artifact/v1/tx.amino.js +12 -473
- package/esm/sparkdream/artifact/v1/tx.js +13 -1
- package/esm/sparkdream/blog/v1/tx.amino.js +15 -135
- package/esm/sparkdream/collect/v1/tx.amino.js +15 -254
- package/esm/sparkdream/commons/v1/tx.amino.js +12 -258
- package/esm/sparkdream/ecosystem/v1/tx.amino.js +15 -26
- package/esm/sparkdream/federation/v1/tx.amino.js +12 -174
- package/esm/sparkdream/forum/v1/tx.amino.js +15 -231
- package/esm/sparkdream/futarchy/v1/tx.amino.js +16 -38
- package/esm/sparkdream/guardian/v1/tx.amino.js +12 -33
- package/esm/sparkdream/name/v1/tx.amino.js +16 -63
- package/esm/sparkdream/rep/v1/query.js +304 -1
- package/esm/sparkdream/rep/v1/query.lcd.js +19 -0
- package/esm/sparkdream/rep/v1/query.rpc.Query.js +22 -1
- package/esm/sparkdream/rep/v1/tx.amino.js +12 -484
- package/esm/sparkdream/reveal/v1/tx.amino.js +15 -73
- package/esm/sparkdream/season/v1/tx.amino.js +12 -276
- package/esm/sparkdream/service/v1/tx.amino.js +16 -78
- package/esm/sparkdream/session/v1/tx.amino.js +16 -271
- package/esm/sparkdream/shield/v1/tx.amino.js +15 -80
- package/esm/sparkdream/sparkdream/v1/tx.amino.js +16 -8
- package/esm/sparkdream/split/v1/tx.amino.js +16 -8
- package/esm/sparkdream/vault/v1/tx.amino.js +12 -105
- package/nested-amino.d.ts +5 -1
- package/nested-amino.js +8 -1
- package/package.json +1 -1
- package/sparkdream/artifact/v1/query.d.ts +86 -0
- package/sparkdream/artifact/v1/query.js +126 -1
- package/sparkdream/artifact/v1/query.lcd.d.ts +2 -1
- package/sparkdream/artifact/v1/query.lcd.js +7 -0
- package/sparkdream/artifact/v1/query.rpc.Query.d.ts +9 -1
- package/sparkdream/artifact/v1/query.rpc.Query.js +11 -0
- package/sparkdream/artifact/v1/tx.amino.d.ts +1 -353
- package/sparkdream/artifact/v1/tx.amino.js +47 -475
- package/sparkdream/artifact/v1/tx.d.ts +14 -0
- package/sparkdream/artifact/v1/tx.js +13 -1
- package/sparkdream/blog/v1/tx.amino.d.ts +1 -103
- package/sparkdream/blog/v1/tx.amino.js +50 -137
- package/sparkdream/bundle.d.ts +97 -2047
- package/sparkdream/client.d.ts +1 -2009
- package/sparkdream/collect/v1/tx.amino.d.ts +1 -153
- package/sparkdream/collect/v1/tx.amino.js +50 -256
- package/sparkdream/commons/v1/tx.amino.d.ts +1 -123
- package/sparkdream/commons/v1/tx.amino.js +49 -262
- package/sparkdream/ecosystem/v1/tx.amino.d.ts +1 -13
- package/sparkdream/ecosystem/v1/tx.amino.js +50 -28
- package/sparkdream/federation/v1/tx.amino.d.ts +1 -128
- package/sparkdream/federation/v1/tx.amino.js +47 -176
- package/sparkdream/forum/v1/tx.amino.d.ts +1 -203
- package/sparkdream/forum/v1/tx.amino.js +50 -233
- package/sparkdream/futarchy/v1/tx.amino.d.ts +1 -38
- package/sparkdream/futarchy/v1/tx.amino.js +49 -38
- package/sparkdream/guardian/v1/tx.amino.d.ts +1 -7
- package/sparkdream/guardian/v1/tx.amino.js +49 -37
- package/sparkdream/name/v1/tx.amino.d.ts +1 -63
- package/sparkdream/name/v1/tx.amino.js +49 -63
- package/sparkdream/rep/v1/query.d.ts +187 -1
- package/sparkdream/rep/v1/query.js +304 -1
- package/sparkdream/rep/v1/query.lcd.d.ts +3 -1
- package/sparkdream/rep/v1/query.lcd.js +19 -0
- package/sparkdream/rep/v1/query.rpc.Query.d.ts +16 -1
- package/sparkdream/rep/v1/query.rpc.Query.js +21 -0
- package/sparkdream/rep/v1/tx.amino.d.ts +1 -353
- package/sparkdream/rep/v1/tx.amino.js +47 -486
- package/sparkdream/reveal/v1/tx.amino.d.ts +1 -53
- package/sparkdream/reveal/v1/tx.amino.js +50 -75
- package/sparkdream/rpc.query.d.ts +3 -0
- package/sparkdream/season/v1/tx.amino.d.ts +1 -218
- package/sparkdream/season/v1/tx.amino.js +47 -278
- package/sparkdream/service/v1/tx.amino.d.ts +1 -78
- package/sparkdream/service/v1/tx.amino.js +49 -78
- package/sparkdream/session/v1/tx.amino.d.ts +1 -93
- package/sparkdream/session/v1/tx.amino.js +48 -270
- package/sparkdream/shield/v1/tx.amino.d.ts +1 -28
- package/sparkdream/shield/v1/tx.amino.js +50 -82
- package/sparkdream/sparkdream/v1/tx.amino.d.ts +1 -8
- package/sparkdream/sparkdream/v1/tx.amino.js +49 -8
- package/sparkdream/split/v1/tx.amino.d.ts +1 -8
- package/sparkdream/split/v1/tx.amino.js +49 -8
- package/sparkdream/vault/v1/tx.amino.d.ts +1 -43
- package/sparkdream/vault/v1/tx.amino.js +49 -109
- package/varint.d.ts +1 -1
|
@@ -1,272 +1,17 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
// HAND-WRITTEN OVERRIDE — overlaid
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// "<CamelCase oneof name>": {"type": "<oneof_name>", "value": {"<field>": {...}}}
|
|
19
|
-
//
|
|
20
|
-
// e.g. "Payload": {"type": "sparkdream/session/RecurringPullPayload",
|
|
21
|
-
// "value": {"recurring_pull": {...}}}
|
|
22
|
-
//
|
|
23
|
-
// while telescope emits the bare member ("recurring_pull": {...}).
|
|
24
|
-
// 3. Repeated fields must be omitted when empty (omitempty), never `[]`.
|
|
25
|
-
//
|
|
26
|
-
// cosmjs rebuilds the TxBody from fromAmino(signed msgs), so each fromAmino
|
|
27
|
-
// below must exactly invert its toAmino.
|
|
28
|
-
//
|
|
29
|
-
// 64-bit ints are coerced here rather than trusting callers to pass BigInt:
|
|
30
|
-
// cosmjs hands toAmino the caller's raw value (no fromPartial), and a Number
|
|
31
|
-
// 0 would otherwise sign a key the chain omits.
|
|
32
|
-
import { MsgUpdateParams, MsgUpdateOperationalParams, MsgCreateSession, MsgRevokeSession, } from "./tx";
|
|
33
|
-
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
|
34
|
-
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
35
|
-
import { toTimestamp, fromTimestamp } from "../../../helpers";
|
|
36
|
-
import { anyToAmino, aminoToAny } from "../../../nested-amino";
|
|
37
|
-
const str = (v) => (v === "" || v === undefined || v === null ? undefined : v);
|
|
38
|
-
const int64 = (v) => {
|
|
39
|
-
if (v === undefined || v === null || v === "")
|
|
40
|
-
return undefined;
|
|
41
|
-
const b = BigInt(v);
|
|
42
|
-
return b === BigInt(0) ? undefined : b.toString();
|
|
43
|
-
};
|
|
44
|
-
const bool = (v) => (v ? true : undefined);
|
|
45
|
-
const list = (v) => ((v?.length ?? 0) > 0 ? v.map((e) => e) : undefined);
|
|
46
|
-
const coin = (v) => (v ? Coin.toAmino(Coin.fromPartial(v)) : undefined);
|
|
47
|
-
const time = (v) => (v ? Timestamp.toAmino(toTimestamp(v)) : undefined);
|
|
48
|
-
const toBig = (v) => (v === undefined || v === null ? BigInt(0) : BigInt(v));
|
|
49
|
-
const fromCoin = (v) => (v ? Coin.fromAmino(v) : undefined);
|
|
50
|
-
const fromTime = (v) => (v ? fromTimestamp(Timestamp.fromAmino(v)) : undefined);
|
|
51
|
-
// ── Payloads ────────────────────────────────────────────────────────────
|
|
52
|
-
const sessionKeyToAmino = (p) => ({
|
|
53
|
-
allowed_msg_types: list(p.allowedMsgTypes),
|
|
54
|
-
spend_limit: coin(p.spendLimit),
|
|
55
|
-
spent: coin(p.spent),
|
|
56
|
-
max_exec_count: int64(p.maxExecCount),
|
|
57
|
-
exec_count: int64(p.execCount),
|
|
58
|
-
last_used_at: time(p.lastUsedAt),
|
|
59
|
-
allow_self_revoke: bool(p.allowSelfRevoke),
|
|
60
|
-
});
|
|
61
|
-
const sessionKeyFromAmino = (o) => ({
|
|
62
|
-
allowedMsgTypes: o.allowed_msg_types ?? [],
|
|
63
|
-
spendLimit: fromCoin(o.spend_limit),
|
|
64
|
-
spent: fromCoin(o.spent),
|
|
65
|
-
maxExecCount: toBig(o.max_exec_count),
|
|
66
|
-
execCount: toBig(o.exec_count),
|
|
67
|
-
lastUsedAt: fromTime(o.last_used_at),
|
|
68
|
-
allowSelfRevoke: o.allow_self_revoke ?? false,
|
|
69
|
-
});
|
|
70
|
-
const recurringPullToAmino = (p) => ({
|
|
71
|
-
amount_per_period: coin(p.amountPerPeriod),
|
|
72
|
-
period_seconds: int64(p.periodSeconds),
|
|
73
|
-
start_time: int64(p.startTime),
|
|
74
|
-
last_claim_advance: int64(p.lastClaimAdvance),
|
|
75
|
-
claims_made: int64(p.claimsMade),
|
|
76
|
-
max_per_epoch: str(p.maxPerEpoch),
|
|
77
|
-
});
|
|
78
|
-
const recurringPullFromAmino = (o) => ({
|
|
79
|
-
amountPerPeriod: fromCoin(o.amount_per_period),
|
|
80
|
-
periodSeconds: toBig(o.period_seconds),
|
|
81
|
-
startTime: toBig(o.start_time),
|
|
82
|
-
lastClaimAdvance: toBig(o.last_claim_advance),
|
|
83
|
-
claimsMade: toBig(o.claims_made),
|
|
84
|
-
maxPerEpoch: o.max_per_epoch ?? "",
|
|
85
|
-
});
|
|
86
|
-
const spendingAllowanceToAmino = (p) => ({
|
|
87
|
-
max_per_period: coin(p.maxPerPeriod),
|
|
88
|
-
period_seconds: int64(p.periodSeconds),
|
|
89
|
-
current_period_start: int64(p.currentPeriodStart),
|
|
90
|
-
spent_in_current_period: coin(p.spentInCurrentPeriod),
|
|
91
|
-
allowed_recipients: list(p.allowedRecipients),
|
|
92
|
-
denom: str(p.denom),
|
|
93
|
-
});
|
|
94
|
-
const spendingAllowanceFromAmino = (o) => ({
|
|
95
|
-
maxPerPeriod: fromCoin(o.max_per_period),
|
|
96
|
-
periodSeconds: toBig(o.period_seconds),
|
|
97
|
-
currentPeriodStart: toBig(o.current_period_start),
|
|
98
|
-
spentInCurrentPeriod: fromCoin(o.spent_in_current_period),
|
|
99
|
-
allowedRecipients: o.allowed_recipients ?? [],
|
|
100
|
-
denom: o.denom ?? "",
|
|
101
|
-
});
|
|
102
|
-
const scheduledOneshotToAmino = (p) => {
|
|
103
|
-
let action = undefined;
|
|
104
|
-
if (p.transfer) {
|
|
105
|
-
action = {
|
|
106
|
-
type: "sparkdream/session/OneshotTransfer",
|
|
107
|
-
value: { transfer: { recipient: str(p.transfer.recipient), amount: coin(p.transfer.amount) } },
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
else if (p.exec) {
|
|
111
|
-
action = {
|
|
112
|
-
type: "sparkdream/session/OneshotExec",
|
|
113
|
-
value: {
|
|
114
|
-
exec: {
|
|
115
|
-
msg: p.exec.msg ? anyToAmino(p.exec.msg) : undefined,
|
|
116
|
-
gas_limit: int64(p.exec.gasLimit),
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
// aminojson writes `null` for an unset oneof rather than omitting it.
|
|
123
|
-
Action: action ?? null,
|
|
124
|
-
fire_at: int64(p.fireAt),
|
|
125
|
-
fire_error: str(p.fireError),
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
const scheduledOneshotFromAmino = (o) => {
|
|
129
|
-
const v = o.Action?.value ?? {};
|
|
130
|
-
return {
|
|
131
|
-
transfer: v.transfer
|
|
132
|
-
? { recipient: v.transfer.recipient ?? "", amount: fromCoin(v.transfer.amount) }
|
|
133
|
-
: undefined,
|
|
134
|
-
exec: v.exec
|
|
135
|
-
? { msg: v.exec.msg ? aminoToAny(v.exec.msg) : undefined, gasLimit: toBig(v.exec.gas_limit) }
|
|
136
|
-
: undefined,
|
|
137
|
-
fireAt: toBig(o.fire_at),
|
|
138
|
-
fireError: o.fire_error ?? "",
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
const signInToAmino = (p) => ({ service: str(p.service) });
|
|
142
|
-
const signInFromAmino = (o) => ({ service: o.service ?? "" });
|
|
143
|
-
const PAYLOADS = [
|
|
144
|
-
["sessionKey", "session_key", "sparkdream/session/SessionKeyPayload", sessionKeyToAmino, sessionKeyFromAmino],
|
|
145
|
-
["recurringPull", "recurring_pull", "sparkdream/session/RecurringPullPayload", recurringPullToAmino, recurringPullFromAmino],
|
|
146
|
-
["spendingAllowance", "spending_allowance", "sparkdream/session/SpendingAllowancePayload", spendingAllowanceToAmino, spendingAllowanceFromAmino],
|
|
147
|
-
["scheduledOneshot", "scheduled_oneshot", "sparkdream/session/ScheduledOneshotPayload", scheduledOneshotToAmino, scheduledOneshotFromAmino],
|
|
148
|
-
["signIn", "sign_in", "sparkdream/session/SignInPayload", signInToAmino, signInFromAmino],
|
|
149
|
-
];
|
|
150
|
-
// ── Messages ────────────────────────────────────────────────────────────
|
|
151
|
-
// {<signer>, grant_id} messages; each signer field name is a single word, so
|
|
152
|
-
// the proto and amino spellings coincide.
|
|
153
|
-
const grantIdMsg = (signer) => ({
|
|
154
|
-
toAmino: (m) => ({ [signer]: str(m[signer]), grant_id: int64(m.grantId) }),
|
|
155
|
-
fromAmino: (o) => ({ [signer]: o[signer] ?? "", grantId: toBig(o.grant_id) }),
|
|
156
|
-
});
|
|
157
|
-
export const AminoConverter = {
|
|
158
|
-
"/sparkdream.session.v1.MsgUpdateParams": {
|
|
159
|
-
aminoType: "sparkdream/x/session/MsgUpdateParams",
|
|
160
|
-
toAmino: MsgUpdateParams.toAmino,
|
|
161
|
-
fromAmino: MsgUpdateParams.fromAmino,
|
|
162
|
-
},
|
|
163
|
-
"/sparkdream.session.v1.MsgUpdateOperationalParams": {
|
|
164
|
-
aminoType: "sparkdream/x/session/MsgUpdateOperationalParams",
|
|
165
|
-
toAmino: MsgUpdateOperationalParams.toAmino,
|
|
166
|
-
fromAmino: MsgUpdateOperationalParams.fromAmino,
|
|
167
|
-
},
|
|
168
|
-
// `allowed_msg_types` is the repeated string field that gets emitted as `[]`
|
|
169
|
-
// when a session is created with no type allowlist (i.e. allow-all).
|
|
170
|
-
"/sparkdream.session.v1.MsgCreateSession": {
|
|
171
|
-
aminoType: "sparkdream/x/session/MsgCreateSession",
|
|
172
|
-
toAmino(message) {
|
|
173
|
-
const obj = {};
|
|
174
|
-
obj.granter = message.granter === "" ? undefined : message.granter;
|
|
175
|
-
obj.grantee = message.grantee === "" ? undefined : message.grantee;
|
|
176
|
-
obj.allowed_msg_types = (message.allowedMsgTypes?.length ?? 0) > 0
|
|
177
|
-
? message.allowedMsgTypes.map((e) => e)
|
|
178
|
-
: undefined;
|
|
179
|
-
obj.spend_limit = message.spendLimit ? Coin.toAmino(message.spendLimit) : undefined;
|
|
180
|
-
obj.expiration = message.expiration ? Timestamp.toAmino(toTimestamp(message.expiration)) : undefined;
|
|
181
|
-
obj.max_exec_count = message.maxExecCount !== BigInt(0) ? message.maxExecCount?.toString() : undefined;
|
|
182
|
-
return obj;
|
|
183
|
-
},
|
|
184
|
-
fromAmino: MsgCreateSession.fromAmino,
|
|
185
|
-
},
|
|
186
|
-
"/sparkdream.session.v1.MsgRevokeSession": {
|
|
187
|
-
aminoType: "sparkdream/x/session/MsgRevokeSession",
|
|
188
|
-
toAmino: MsgRevokeSession.toAmino,
|
|
189
|
-
fromAmino: MsgRevokeSession.fromAmino,
|
|
190
|
-
},
|
|
191
|
-
"/sparkdream.session.v1.MsgExecSession": {
|
|
192
|
-
aminoType: "sparkdream/x/session/MsgExecSession",
|
|
193
|
-
toAmino(message) {
|
|
194
|
-
const obj = {};
|
|
195
|
-
obj.grantee = message.grantee === "" ? undefined : message.grantee;
|
|
196
|
-
obj.granter = message.granter === "" ? undefined : message.granter;
|
|
197
|
-
// Omit when empty to match the chain's aminojson default for
|
|
198
|
-
// repeated fields.
|
|
199
|
-
obj.msgs = (message.msgs?.length ?? 0) > 0
|
|
200
|
-
? message.msgs.map((a) => anyToAmino(a))
|
|
201
|
-
: undefined;
|
|
202
|
-
return obj;
|
|
203
|
-
},
|
|
204
|
-
fromAmino(object) {
|
|
205
|
-
return {
|
|
206
|
-
grantee: object.grantee ?? "",
|
|
207
|
-
granter: object.granter ?? "",
|
|
208
|
-
msgs: (object.msgs ?? []).map((e) => aminoToAny(e)),
|
|
209
|
-
};
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
"/sparkdream.session.v1.MsgCreateGrant": {
|
|
213
|
-
aminoType: "sparkdream/x/session/MsgCreateGrant",
|
|
214
|
-
toAmino(message) {
|
|
215
|
-
const set = PAYLOADS.find(([key]) => message[key]);
|
|
216
|
-
return {
|
|
217
|
-
granter: str(message.granter),
|
|
218
|
-
grantee: str(message.grantee),
|
|
219
|
-
expires_at: time(message.expiresAt),
|
|
220
|
-
note: str(message.note),
|
|
221
|
-
Payload: set
|
|
222
|
-
? { type: set[2], value: { [set[1]]: set[3](message[set[0]]) } }
|
|
223
|
-
: null,
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
fromAmino(object) {
|
|
227
|
-
const out = {
|
|
228
|
-
granter: object.granter ?? "",
|
|
229
|
-
grantee: object.grantee ?? "",
|
|
230
|
-
expiresAt: fromTime(object.expires_at),
|
|
231
|
-
note: object.note ?? "",
|
|
232
|
-
};
|
|
233
|
-
const inner = object.Payload?.value ?? {};
|
|
234
|
-
for (const [key, field, , , fromAmino] of PAYLOADS) {
|
|
235
|
-
if (inner[field])
|
|
236
|
-
out[key] = fromAmino(inner[field]);
|
|
237
|
-
}
|
|
238
|
-
return out;
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
"/sparkdream.session.v1.MsgClaimRecurringPull": {
|
|
242
|
-
aminoType: "sparkdream/x/session/MsgClaimRecurringPull",
|
|
243
|
-
...grantIdMsg("grantee"),
|
|
244
|
-
},
|
|
245
|
-
"/sparkdream.session.v1.MsgPullAllowance": {
|
|
246
|
-
aminoType: "sparkdream/x/session/MsgPullAllowance",
|
|
247
|
-
toAmino: (m) => ({
|
|
248
|
-
grantee: str(m.grantee),
|
|
249
|
-
grant_id: int64(m.grantId),
|
|
250
|
-
recipient: str(m.recipient),
|
|
251
|
-
amount: coin(m.amount),
|
|
252
|
-
}),
|
|
253
|
-
fromAmino: (o) => ({
|
|
254
|
-
grantee: o.grantee ?? "",
|
|
255
|
-
grantId: toBig(o.grant_id),
|
|
256
|
-
recipient: o.recipient ?? "",
|
|
257
|
-
amount: fromCoin(o.amount),
|
|
258
|
-
}),
|
|
259
|
-
},
|
|
260
|
-
"/sparkdream.session.v1.MsgRetryScheduledOneshot": {
|
|
261
|
-
aminoType: "sparkdream/x/session/MsgRetryScheduledOneshot",
|
|
262
|
-
...grantIdMsg("caller"),
|
|
263
|
-
},
|
|
264
|
-
"/sparkdream.session.v1.MsgRevokeGrant": {
|
|
265
|
-
aminoType: "sparkdream/x/session/MsgRevokeGrant",
|
|
266
|
-
...grantIdMsg("granter"),
|
|
267
|
-
},
|
|
268
|
-
"/sparkdream.session.v1.MsgDeclineGrant": {
|
|
269
|
-
aminoType: "sparkdream/x/session/MsgDeclineGrant",
|
|
270
|
-
...grantIdMsg("grantee"),
|
|
271
|
-
},
|
|
272
|
-
};
|
|
2
|
+
// HAND-WRITTEN OVERRIDE — overlaid on top of the Telescope-generated tx.amino.ts
|
|
3
|
+
// by scripts/codegen.ts after each codegen run. Do not let codegen wipe this.
|
|
4
|
+
//
|
|
5
|
+
// Why: Telescope's generated converters (and the per-message overrides that
|
|
6
|
+
// used to patch them) disagree with the chain's aminojson on empty lists,
|
|
7
|
+
// empty bytes, Dec strings, oneofs and non-nullable messages, and went stale
|
|
8
|
+
// whenever a proto changed. Every Msg of x/session is converted by the
|
|
9
|
+
// schema-driven engine in chain-amino.ts instead, which renders amino JSON
|
|
10
|
+
// from the protobuf bytes exactly as the chain does.
|
|
11
|
+
//
|
|
12
|
+
// MAINTENANCE: none per message. The schema (amino-schema.ts, regenerated from
|
|
13
|
+
// the chain on every proto sync) lists every Msg; __tests__/amino-golden.test.ts
|
|
14
|
+
// checks them all against the chain's encoder.
|
|
15
|
+
import * as tx from "./tx";
|
|
16
|
+
import { chainAminoConverters } from "../../../chain-amino";
|
|
17
|
+
export const AminoConverter = chainAminoConverters("sparkdream.session.v1", tx);
|
|
@@ -1,82 +1,17 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
// HAND-WRITTEN OVERRIDE — overlaid
|
|
3
|
-
//
|
|
2
|
+
// HAND-WRITTEN OVERRIDE — overlaid on top of the Telescope-generated tx.amino.ts
|
|
3
|
+
// by scripts/codegen.ts after each codegen run. Do not let codegen wipe this.
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
aminoType: "sparkdream/x/shield/MsgUpdateParams",
|
|
19
|
-
toAmino: MsgUpdateParams.toAmino,
|
|
20
|
-
fromAmino: MsgUpdateParams.fromAmino,
|
|
21
|
-
},
|
|
22
|
-
"/sparkdream.shield.v1.MsgShieldedExec": {
|
|
23
|
-
aminoType: "sparkdream/x/shield/MsgShieldedExec",
|
|
24
|
-
toAmino(message) {
|
|
25
|
-
const obj = {};
|
|
26
|
-
obj.submitter = message.submitter === "" ? undefined : message.submitter;
|
|
27
|
-
obj.inner_message = message.innerMessage ? anyToAmino(message.innerMessage) : undefined;
|
|
28
|
-
obj.proof = message.proof ? base64FromBytes(message.proof) : undefined;
|
|
29
|
-
obj.nullifier = message.nullifier ? base64FromBytes(message.nullifier) : undefined;
|
|
30
|
-
obj.rate_limit_nullifier = message.rateLimitNullifier ? base64FromBytes(message.rateLimitNullifier) : undefined;
|
|
31
|
-
obj.merkle_root = message.merkleRoot ? base64FromBytes(message.merkleRoot) : undefined;
|
|
32
|
-
obj.proof_domain = message.proofDomain === 0 ? undefined : message.proofDomain;
|
|
33
|
-
obj.min_trust_level = message.minTrustLevel === 0 ? undefined : message.minTrustLevel;
|
|
34
|
-
obj.exec_mode = message.execMode === 0 ? undefined : message.execMode;
|
|
35
|
-
obj.encrypted_payload = message.encryptedPayload ? base64FromBytes(message.encryptedPayload) : undefined;
|
|
36
|
-
obj.target_epoch = message.targetEpoch !== BigInt(0) ? message.targetEpoch?.toString() : undefined;
|
|
37
|
-
return obj;
|
|
38
|
-
},
|
|
39
|
-
fromAmino(object) {
|
|
40
|
-
return {
|
|
41
|
-
submitter: object.submitter ?? "",
|
|
42
|
-
innerMessage: object.inner_message ? aminoToAny(object.inner_message) : undefined,
|
|
43
|
-
proof: object.proof !== undefined && object.proof !== null
|
|
44
|
-
? bytesFromBase64(object.proof)
|
|
45
|
-
: new Uint8Array(),
|
|
46
|
-
nullifier: object.nullifier !== undefined && object.nullifier !== null
|
|
47
|
-
? bytesFromBase64(object.nullifier)
|
|
48
|
-
: new Uint8Array(),
|
|
49
|
-
rateLimitNullifier: object.rate_limit_nullifier !== undefined && object.rate_limit_nullifier !== null
|
|
50
|
-
? bytesFromBase64(object.rate_limit_nullifier)
|
|
51
|
-
: new Uint8Array(),
|
|
52
|
-
merkleRoot: object.merkle_root !== undefined && object.merkle_root !== null
|
|
53
|
-
? bytesFromBase64(object.merkle_root)
|
|
54
|
-
: new Uint8Array(),
|
|
55
|
-
proofDomain: object.proof_domain ?? 0,
|
|
56
|
-
minTrustLevel: object.min_trust_level ?? 0,
|
|
57
|
-
execMode: object.exec_mode ?? 0,
|
|
58
|
-
encryptedPayload: object.encrypted_payload !== undefined && object.encrypted_payload !== null
|
|
59
|
-
? bytesFromBase64(object.encrypted_payload)
|
|
60
|
-
: new Uint8Array(),
|
|
61
|
-
targetEpoch: object.target_epoch !== undefined && object.target_epoch !== null
|
|
62
|
-
? BigInt(object.target_epoch)
|
|
63
|
-
: BigInt(0),
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
"/sparkdream.shield.v1.MsgTriggerDkg": {
|
|
68
|
-
aminoType: "sparkdream/x/shield/MsgTriggerDkg",
|
|
69
|
-
toAmino: MsgTriggerDkg.toAmino,
|
|
70
|
-
fromAmino: MsgTriggerDkg.fromAmino,
|
|
71
|
-
},
|
|
72
|
-
"/sparkdream.shield.v1.MsgRegisterShieldedOp": {
|
|
73
|
-
aminoType: "sparkdream/x/shield/MsgRegisterShieldedOp",
|
|
74
|
-
toAmino: MsgRegisterShieldedOp.toAmino,
|
|
75
|
-
fromAmino: MsgRegisterShieldedOp.fromAmino,
|
|
76
|
-
},
|
|
77
|
-
"/sparkdream.shield.v1.MsgDeregisterShieldedOp": {
|
|
78
|
-
aminoType: "sparkdream/x/shield/MsgDeregisterShieldedOp",
|
|
79
|
-
toAmino: MsgDeregisterShieldedOp.toAmino,
|
|
80
|
-
fromAmino: MsgDeregisterShieldedOp.fromAmino,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
5
|
+
// Why: Telescope's generated converters (and the per-message overrides that
|
|
6
|
+
// used to patch them) disagree with the chain's aminojson on empty lists,
|
|
7
|
+
// empty bytes, Dec strings, oneofs and non-nullable messages, and went stale
|
|
8
|
+
// whenever a proto changed. Every Msg of x/shield is converted by the
|
|
9
|
+
// schema-driven engine in chain-amino.ts instead, which renders amino JSON
|
|
10
|
+
// from the protobuf bytes exactly as the chain does.
|
|
11
|
+
//
|
|
12
|
+
// MAINTENANCE: none per message. The schema (amino-schema.ts, regenerated from
|
|
13
|
+
// the chain on every proto sync) lists every Msg; __tests__/amino-golden.test.ts
|
|
14
|
+
// checks them all against the chain's encoder.
|
|
15
|
+
import * as tx from "./tx";
|
|
16
|
+
import { chainAminoConverters } from "../../../chain-amino";
|
|
17
|
+
export const AminoConverter = chainAminoConverters("sparkdream.shield.v1", tx);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
// HAND-WRITTEN OVERRIDE — overlaid on top of the Telescope-generated tx.amino.ts
|
|
3
|
+
// by scripts/codegen.ts after each codegen run. Do not let codegen wipe this.
|
|
4
|
+
//
|
|
5
|
+
// Why: Telescope's generated converters (and the per-message overrides that
|
|
6
|
+
// used to patch them) disagree with the chain's aminojson on empty lists,
|
|
7
|
+
// empty bytes, Dec strings, oneofs and non-nullable messages, and went stale
|
|
8
|
+
// whenever a proto changed. Every Msg of x/sparkdream is converted by the
|
|
9
|
+
// schema-driven engine in chain-amino.ts instead, which renders amino JSON
|
|
10
|
+
// from the protobuf bytes exactly as the chain does.
|
|
11
|
+
//
|
|
12
|
+
// MAINTENANCE: none per message. The schema (amino-schema.ts, regenerated from
|
|
13
|
+
// the chain on every proto sync) lists every Msg; __tests__/amino-golden.test.ts
|
|
14
|
+
// checks them all against the chain's encoder.
|
|
15
|
+
import * as tx from "./tx";
|
|
16
|
+
import { chainAminoConverters } from "../../../chain-amino";
|
|
17
|
+
export const AminoConverter = chainAminoConverters("sparkdream.sparkdream.v1", tx);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
// HAND-WRITTEN OVERRIDE — overlaid on top of the Telescope-generated tx.amino.ts
|
|
3
|
+
// by scripts/codegen.ts after each codegen run. Do not let codegen wipe this.
|
|
4
|
+
//
|
|
5
|
+
// Why: Telescope's generated converters (and the per-message overrides that
|
|
6
|
+
// used to patch them) disagree with the chain's aminojson on empty lists,
|
|
7
|
+
// empty bytes, Dec strings, oneofs and non-nullable messages, and went stale
|
|
8
|
+
// whenever a proto changed. Every Msg of x/split is converted by the
|
|
9
|
+
// schema-driven engine in chain-amino.ts instead, which renders amino JSON
|
|
10
|
+
// from the protobuf bytes exactly as the chain does.
|
|
11
|
+
//
|
|
12
|
+
// MAINTENANCE: none per message. The schema (amino-schema.ts, regenerated from
|
|
13
|
+
// the chain on every proto sync) lists every Msg; __tests__/amino-golden.test.ts
|
|
14
|
+
// checks them all against the chain's encoder.
|
|
15
|
+
import * as tx from "./tx";
|
|
16
|
+
import { chainAminoConverters } from "../../../chain-amino";
|
|
17
|
+
export const AminoConverter = chainAminoConverters("sparkdream.split.v1", tx);
|
|
@@ -2,110 +2,17 @@
|
|
|
2
2
|
// HAND-WRITTEN OVERRIDE — overlaid on top of the Telescope-generated tx.amino.ts
|
|
3
3
|
// by scripts/codegen.ts after each codegen run. Do not let codegen wipe this.
|
|
4
4
|
//
|
|
5
|
-
// Why: Telescope
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
5
|
+
// Why: Telescope's generated converters (and the per-message overrides that
|
|
6
|
+
// used to patch them) disagree with the chain's aminojson on empty lists,
|
|
7
|
+
// empty bytes, Dec strings, oneofs and non-nullable messages, and went stale
|
|
8
|
+
// whenever a proto changed. Every Msg of x/vault is converted by the
|
|
9
|
+
// schema-driven engine in chain-amino.ts instead, which renders amino JSON
|
|
10
|
+
// from the protobuf bytes exactly as the chain does.
|
|
11
11
|
//
|
|
12
|
-
//
|
|
13
|
-
// proto
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// (see the rep override for the full story).
|
|
18
|
-
//
|
|
19
|
-
// The rest of the converters are unchanged.
|
|
20
|
-
//
|
|
21
|
-
// MAINTENANCE: this map REPLACES the generated one wholesale, so it must list
|
|
22
|
-
// every message in tx.proto. A message added to the proto but not added here
|
|
23
|
-
// ends up with no amino converter at all, and amino (Ledger) signing for it
|
|
24
|
-
// fails at runtime. When syncing protos, diff the message list in
|
|
25
|
-
// protos/sparkdream/vault/v1/tx.proto against the keys below.
|
|
26
|
-
import { MsgUpdateParams, MsgCreateVault, MsgApprove, MsgRevokeApproval, MsgExecute, MsgCancelProposal, MsgUpdateVault } from "./tx";
|
|
27
|
-
import { VaultSigner } from "./vault_signer";
|
|
28
|
-
import { anyToAmino, aminoToAny } from "../../../nested-amino";
|
|
12
|
+
// MAINTENANCE: none per message. The schema (amino-schema.ts, regenerated from
|
|
13
|
+
// the chain on every proto sync) lists every Msg; __tests__/amino-golden.test.ts
|
|
14
|
+
// checks them all against the chain's encoder.
|
|
15
|
+
import * as tx from "./tx";
|
|
16
|
+
import { chainAminoConverters } from "../../../chain-amino";
|
|
29
17
|
export { configureNestedAminoConverter } from "../../../nested-amino";
|
|
30
|
-
export const AminoConverter =
|
|
31
|
-
"/sparkdream.vault.v1.MsgUpdateParams": {
|
|
32
|
-
aminoType: "sparkdream/x/vault/MsgUpdateParams",
|
|
33
|
-
toAmino: MsgUpdateParams.toAmino,
|
|
34
|
-
fromAmino: MsgUpdateParams.fromAmino
|
|
35
|
-
},
|
|
36
|
-
"/sparkdream.vault.v1.MsgCreateVault": {
|
|
37
|
-
aminoType: "sparkdream/x/vault/MsgCreateVault",
|
|
38
|
-
toAmino(message) {
|
|
39
|
-
const obj = {};
|
|
40
|
-
obj.creator = message.creator === "" ? undefined : message.creator;
|
|
41
|
-
obj.signers = (message.signers?.length ?? 0) > 0
|
|
42
|
-
? message.signers.map((e) => e ? VaultSigner.toAmino(e) : undefined)
|
|
43
|
-
: undefined;
|
|
44
|
-
obj.threshold = message.threshold !== BigInt(0) ? message.threshold?.toString() : undefined;
|
|
45
|
-
obj.proposal_ttl = message.proposalTtl !== BigInt(0) ? message.proposalTtl?.toString() : undefined;
|
|
46
|
-
obj.label = message.label === "" ? undefined : message.label;
|
|
47
|
-
return obj;
|
|
48
|
-
},
|
|
49
|
-
fromAmino: MsgCreateVault.fromAmino
|
|
50
|
-
},
|
|
51
|
-
"/sparkdream.vault.v1.MsgPropose": {
|
|
52
|
-
aminoType: "sparkdream/x/vault/MsgPropose",
|
|
53
|
-
toAmino(message) {
|
|
54
|
-
const obj = {};
|
|
55
|
-
obj.signer = message.signer === "" ? undefined : message.signer;
|
|
56
|
-
obj.vault_id = message.vaultId !== BigInt(0) ? message.vaultId?.toString() : undefined;
|
|
57
|
-
// Mirror aminojson's omitempty default for repeated fields: omit when
|
|
58
|
-
// empty rather than emitting `[]`.
|
|
59
|
-
obj.messages = (message.messages?.length ?? 0) > 0
|
|
60
|
-
? message.messages.map((a) => anyToAmino(a))
|
|
61
|
-
: undefined;
|
|
62
|
-
obj.memo = message.memo === "" ? undefined : message.memo;
|
|
63
|
-
obj.execute = message.execute === false ? undefined : message.execute;
|
|
64
|
-
return obj;
|
|
65
|
-
},
|
|
66
|
-
fromAmino(object) {
|
|
67
|
-
return {
|
|
68
|
-
signer: object.signer ?? "",
|
|
69
|
-
vaultId: object.vault_id !== undefined && object.vault_id !== null ? BigInt(object.vault_id) : BigInt(0),
|
|
70
|
-
messages: (object.messages ?? []).map((e) => aminoToAny(e)),
|
|
71
|
-
memo: object.memo ?? "",
|
|
72
|
-
execute: object.execute ?? false,
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
"/sparkdream.vault.v1.MsgApprove": {
|
|
77
|
-
aminoType: "sparkdream/x/vault/MsgApprove",
|
|
78
|
-
toAmino: MsgApprove.toAmino,
|
|
79
|
-
fromAmino: MsgApprove.fromAmino
|
|
80
|
-
},
|
|
81
|
-
"/sparkdream.vault.v1.MsgRevokeApproval": {
|
|
82
|
-
aminoType: "sparkdream/x/vault/MsgRevokeApproval",
|
|
83
|
-
toAmino: MsgRevokeApproval.toAmino,
|
|
84
|
-
fromAmino: MsgRevokeApproval.fromAmino
|
|
85
|
-
},
|
|
86
|
-
"/sparkdream.vault.v1.MsgExecute": {
|
|
87
|
-
aminoType: "sparkdream/x/vault/MsgExecute",
|
|
88
|
-
toAmino: MsgExecute.toAmino,
|
|
89
|
-
fromAmino: MsgExecute.fromAmino
|
|
90
|
-
},
|
|
91
|
-
"/sparkdream.vault.v1.MsgCancelProposal": {
|
|
92
|
-
aminoType: "sparkdream/x/vault/MsgCancelProposal",
|
|
93
|
-
toAmino: MsgCancelProposal.toAmino,
|
|
94
|
-
fromAmino: MsgCancelProposal.fromAmino
|
|
95
|
-
},
|
|
96
|
-
"/sparkdream.vault.v1.MsgUpdateVault": {
|
|
97
|
-
aminoType: "sparkdream/x/vault/MsgUpdateVault",
|
|
98
|
-
toAmino(message) {
|
|
99
|
-
const obj = {};
|
|
100
|
-
obj.vault = message.vault === "" ? undefined : message.vault;
|
|
101
|
-
obj.signers = (message.signers?.length ?? 0) > 0
|
|
102
|
-
? message.signers.map((e) => e ? VaultSigner.toAmino(e) : undefined)
|
|
103
|
-
: undefined;
|
|
104
|
-
obj.threshold = message.threshold !== BigInt(0) ? message.threshold?.toString() : undefined;
|
|
105
|
-
obj.proposal_ttl = message.proposalTtl !== BigInt(0) ? message.proposalTtl?.toString() : undefined;
|
|
106
|
-
obj.label = message.label === "" ? undefined : message.label;
|
|
107
|
-
return obj;
|
|
108
|
-
},
|
|
109
|
-
fromAmino: MsgUpdateVault.fromAmino
|
|
110
|
-
}
|
|
111
|
-
};
|
|
18
|
+
export const AminoConverter = chainAminoConverters("sparkdream.vault.v1", tx);
|
package/nested-amino.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Shared registry + helpers for amino-converting messages that embed a
|
|
3
3
|
* `google.protobuf.Any` field (`MsgSubmitProposal`,
|
|
4
4
|
* `MsgSubmitAnonymousProposal`, `MsgExecSession`, vault `MsgPropose`,
|
|
5
|
-
* guardian `MsgExec`).
|
|
5
|
+
* guardian `MsgExec`). chain-amino.ts renders sparkdream inner messages
|
|
6
|
+
* itself and uses this configuration only for inner types it doesn't know
|
|
7
|
+
* (cosmos-sdk messages inside a proposal).
|
|
6
8
|
*
|
|
7
9
|
* The Telescope-generated `Any.toAmino` just emits `{type, value: Uint8Array}`,
|
|
8
10
|
* which JSON.stringify turns into `{"0":N,"1":N,…}` — numeric keys that aren't
|
|
@@ -58,6 +60,8 @@ export interface NestedAminoConfig {
|
|
|
58
60
|
aminoTypes: AminoTypesLike;
|
|
59
61
|
}
|
|
60
62
|
export declare function configureNestedAminoConverter(next: NestedAminoConfig): void;
|
|
63
|
+
/** The configured registry and AminoTypes, or null before configureNestedAminoConverter. */
|
|
64
|
+
export declare function getNestedAminoConfig(): NestedAminoConfig | null;
|
|
61
65
|
/** Convert one proto-encoded Any to its amino representation. */
|
|
62
66
|
export declare function anyToAmino(any: {
|
|
63
67
|
typeUrl: string;
|
package/nested-amino.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Shared registry + helpers for amino-converting messages that embed a
|
|
5
5
|
* `google.protobuf.Any` field (`MsgSubmitProposal`,
|
|
6
6
|
* `MsgSubmitAnonymousProposal`, `MsgExecSession`, vault `MsgPropose`,
|
|
7
|
-
* guardian `MsgExec`).
|
|
7
|
+
* guardian `MsgExec`). chain-amino.ts renders sparkdream inner messages
|
|
8
|
+
* itself and uses this configuration only for inner types it doesn't know
|
|
9
|
+
* (cosmos-sdk messages inside a proposal).
|
|
8
10
|
*
|
|
9
11
|
* The Telescope-generated `Any.toAmino` just emits `{type, value: Uint8Array}`,
|
|
10
12
|
* which JSON.stringify turns into `{"0":N,"1":N,…}` — numeric keys that aren't
|
|
@@ -20,12 +22,17 @@
|
|
|
20
22
|
*/
|
|
21
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
24
|
exports.configureNestedAminoConverter = configureNestedAminoConverter;
|
|
25
|
+
exports.getNestedAminoConfig = getNestedAminoConfig;
|
|
23
26
|
exports.anyToAmino = anyToAmino;
|
|
24
27
|
exports.aminoToAny = aminoToAny;
|
|
25
28
|
let cfg = null;
|
|
26
29
|
function configureNestedAminoConverter(next) {
|
|
27
30
|
cfg = next;
|
|
28
31
|
}
|
|
32
|
+
/** The configured registry and AminoTypes, or null before configureNestedAminoConverter. */
|
|
33
|
+
function getNestedAminoConfig() {
|
|
34
|
+
return cfg;
|
|
35
|
+
}
|
|
29
36
|
function requireCfg() {
|
|
30
37
|
if (!cfg) {
|
|
31
38
|
throw new Error("@sparkdreamnft/sparkdreamjs: configureNestedAminoConverter({registry, aminoTypes}) " +
|