@sparkdreamnft/sparkdreamjs 0.0.40 → 0.0.41
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/esm/sparkdream/federation/v1/genesis.js +397 -2
- package/esm/sparkdream/federation/v1/query.js +49 -1
- package/esm/sparkdream/federation/v1/query.lcd.js +13 -3
- package/esm/sparkdream/federation/v1/query.rpc.Query.js +1 -3
- package/esm/sparkdream/federation/v1/tx.js +14 -2
- package/esm/sparkdream/federation/v1/types.js +159 -3
- package/esm/sparkdream/session/v1/tx.amino.js +205 -3
- package/package.json +1 -1
- package/sparkdream/bundle.d.ts +114 -2
- package/sparkdream/client.d.ts +64 -0
- package/sparkdream/federation/v1/genesis.d.ts +221 -1
- package/sparkdream/federation/v1/genesis.js +397 -2
- package/sparkdream/federation/v1/query.d.ts +30 -0
- package/sparkdream/federation/v1/query.js +49 -1
- package/sparkdream/federation/v1/query.lcd.d.ts +1 -1
- package/sparkdream/federation/v1/query.lcd.js +13 -3
- package/sparkdream/federation/v1/query.rpc.Query.d.ts +3 -3
- package/sparkdream/federation/v1/query.rpc.Query.js +1 -3
- package/sparkdream/federation/v1/tx.d.ts +15 -1
- package/sparkdream/federation/v1/tx.js +13 -1
- package/sparkdream/federation/v1/types.d.ts +142 -0
- package/sparkdream/federation/v1/types.js +160 -4
- package/sparkdream/rpc.query.d.ts +1 -1
- package/sparkdream/session/v1/tx.amino.d.ts +65 -0
- package/sparkdream/session/v1/tx.amino.js +204 -2
|
@@ -176,6 +176,30 @@ export var FederatedContentStatus;
|
|
|
176
176
|
FederatedContentStatus[FederatedContentStatus["FEDERATED_CONTENT_STATUS_DISPUTED"] = 4] = "FEDERATED_CONTENT_STATUS_DISPUTED";
|
|
177
177
|
FederatedContentStatus[FederatedContentStatus["FEDERATED_CONTENT_STATUS_CHALLENGED"] = 5] = "FEDERATED_CONTENT_STATUS_CHALLENGED";
|
|
178
178
|
FederatedContentStatus[FederatedContentStatus["FEDERATED_CONTENT_STATUS_REJECTED"] = 6] = "FEDERATED_CONTENT_STATUS_REJECTED";
|
|
179
|
+
/**
|
|
180
|
+
* FEDERATED_CONTENT_STATUS_UNRESOLVED - UNRESOLVED is system-assigned: the arbiter resolution window expired
|
|
181
|
+
* without quorum, so no finding was ever made about the content. It is
|
|
182
|
+
* terminal, deliberately excluded from MsgModerateContent (OpsComm
|
|
183
|
+
* moderates HIDDEN/ACTIVE/VERIFIED/REJECTED, not system states), and
|
|
184
|
+
* was chosen over reverting to PENDING_VERIFICATION because a revived
|
|
185
|
+
* record would have no VerificationWindow queue entry and a verification
|
|
186
|
+
* deadline already in the past — unverifiable and unreapable until
|
|
187
|
+
* content_ttl. Local state only: FederatedContentStatus never crosses
|
|
188
|
+
* the IBC wire (see packet_wire_compat_test.go).
|
|
189
|
+
*/
|
|
190
|
+
FederatedContentStatus[FederatedContentStatus["FEDERATED_CONTENT_STATUS_UNRESOLVED"] = 7] = "FEDERATED_CONTENT_STATUS_UNRESOLVED";
|
|
191
|
+
/**
|
|
192
|
+
* FEDERATED_CONTENT_STATUS_SUPERSEDED - SUPERSEDED is system-assigned: the submitting operator anchored a newer
|
|
193
|
+
* version of the same content_uri (an edit) while this record was still
|
|
194
|
+
* PENDING_VERIFICATION. The anchored version no longer exists at the
|
|
195
|
+
* source, so no verifier can ever confirm it; retiring it here keeps it
|
|
196
|
+
* out of the verification-expiry sweep, which would otherwise count it
|
|
197
|
+
* against an honest operator as unverified. Terminal and excluded from
|
|
198
|
+
* MsgModerateContent for the same reason as UNRESOLVED: moderating it
|
|
199
|
+
* could manufacture a VERIFIED status for bytes nobody verified. Local
|
|
200
|
+
* state only; never crosses the IBC wire.
|
|
201
|
+
*/
|
|
202
|
+
FederatedContentStatus[FederatedContentStatus["FEDERATED_CONTENT_STATUS_SUPERSEDED"] = 8] = "FEDERATED_CONTENT_STATUS_SUPERSEDED";
|
|
179
203
|
FederatedContentStatus[FederatedContentStatus["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
180
204
|
})(FederatedContentStatus || (FederatedContentStatus = {}));
|
|
181
205
|
export const FederatedContentStatusAmino = FederatedContentStatus;
|
|
@@ -202,6 +226,12 @@ export function federatedContentStatusFromJSON(object) {
|
|
|
202
226
|
case 6:
|
|
203
227
|
case "FEDERATED_CONTENT_STATUS_REJECTED":
|
|
204
228
|
return FederatedContentStatus.FEDERATED_CONTENT_STATUS_REJECTED;
|
|
229
|
+
case 7:
|
|
230
|
+
case "FEDERATED_CONTENT_STATUS_UNRESOLVED":
|
|
231
|
+
return FederatedContentStatus.FEDERATED_CONTENT_STATUS_UNRESOLVED;
|
|
232
|
+
case 8:
|
|
233
|
+
case "FEDERATED_CONTENT_STATUS_SUPERSEDED":
|
|
234
|
+
return FederatedContentStatus.FEDERATED_CONTENT_STATUS_SUPERSEDED;
|
|
205
235
|
case -1:
|
|
206
236
|
case "UNRECOGNIZED":
|
|
207
237
|
default:
|
|
@@ -224,6 +254,10 @@ export function federatedContentStatusToJSON(object) {
|
|
|
224
254
|
return "FEDERATED_CONTENT_STATUS_CHALLENGED";
|
|
225
255
|
case FederatedContentStatus.FEDERATED_CONTENT_STATUS_REJECTED:
|
|
226
256
|
return "FEDERATED_CONTENT_STATUS_REJECTED";
|
|
257
|
+
case FederatedContentStatus.FEDERATED_CONTENT_STATUS_UNRESOLVED:
|
|
258
|
+
return "FEDERATED_CONTENT_STATUS_UNRESOLVED";
|
|
259
|
+
case FederatedContentStatus.FEDERATED_CONTENT_STATUS_SUPERSEDED:
|
|
260
|
+
return "FEDERATED_CONTENT_STATUS_SUPERSEDED";
|
|
227
261
|
case FederatedContentStatus.UNRECOGNIZED:
|
|
228
262
|
default:
|
|
229
263
|
return "UNRECOGNIZED";
|
|
@@ -629,7 +663,8 @@ function createBasePeerPolicy() {
|
|
|
629
663
|
allowReputationQueries: false,
|
|
630
664
|
acceptReputationAttestations: false,
|
|
631
665
|
requireReview: false,
|
|
632
|
-
blockedIdentities: []
|
|
666
|
+
blockedIdentities: [],
|
|
667
|
+
contentHosts: []
|
|
633
668
|
};
|
|
634
669
|
}
|
|
635
670
|
/**
|
|
@@ -671,6 +706,9 @@ export const PeerPolicy = {
|
|
|
671
706
|
for (const v of message.blockedIdentities) {
|
|
672
707
|
writer.uint32(74).string(v);
|
|
673
708
|
}
|
|
709
|
+
for (const v of message.contentHosts) {
|
|
710
|
+
writer.uint32(90).string(v);
|
|
711
|
+
}
|
|
674
712
|
return writer;
|
|
675
713
|
},
|
|
676
714
|
decode(input, length) {
|
|
@@ -710,6 +748,9 @@ export const PeerPolicy = {
|
|
|
710
748
|
case 9:
|
|
711
749
|
message.blockedIdentities.push(reader.string());
|
|
712
750
|
break;
|
|
751
|
+
case 11:
|
|
752
|
+
message.contentHosts.push(reader.string());
|
|
753
|
+
break;
|
|
713
754
|
default:
|
|
714
755
|
reader.skipType(tag & 7);
|
|
715
756
|
break;
|
|
@@ -729,6 +770,7 @@ export const PeerPolicy = {
|
|
|
729
770
|
message.acceptReputationAttestations = object.acceptReputationAttestations ?? false;
|
|
730
771
|
message.requireReview = object.requireReview ?? false;
|
|
731
772
|
message.blockedIdentities = object.blockedIdentities?.map(e => e) || [];
|
|
773
|
+
message.contentHosts = object.contentHosts?.map(e => e) || [];
|
|
732
774
|
return message;
|
|
733
775
|
},
|
|
734
776
|
fromAmino(object) {
|
|
@@ -757,6 +799,7 @@ export const PeerPolicy = {
|
|
|
757
799
|
message.requireReview = object.require_review;
|
|
758
800
|
}
|
|
759
801
|
message.blockedIdentities = object.blocked_identities?.map(e => e) || [];
|
|
802
|
+
message.contentHosts = object.content_hosts?.map(e => e) || [];
|
|
760
803
|
return message;
|
|
761
804
|
},
|
|
762
805
|
toAmino(message) {
|
|
@@ -786,6 +829,12 @@ export const PeerPolicy = {
|
|
|
786
829
|
else {
|
|
787
830
|
obj.blocked_identities = message.blockedIdentities;
|
|
788
831
|
}
|
|
832
|
+
if (message.contentHosts) {
|
|
833
|
+
obj.content_hosts = message.contentHosts.map(e => e);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
obj.content_hosts = message.contentHosts;
|
|
837
|
+
}
|
|
789
838
|
return obj;
|
|
790
839
|
},
|
|
791
840
|
fromAminoMsg(object) {
|
|
@@ -1090,7 +1139,8 @@ function createBaseVerificationRecord() {
|
|
|
1090
1139
|
lastChallengeResolvedAt: BigInt(0),
|
|
1091
1140
|
challenger: "",
|
|
1092
1141
|
escrowedChallengeFee: "",
|
|
1093
|
-
pendingVerifierVerdict: 0
|
|
1142
|
+
pendingVerifierVerdict: 0,
|
|
1143
|
+
commitmentReleased: false
|
|
1094
1144
|
};
|
|
1095
1145
|
}
|
|
1096
1146
|
/**
|
|
@@ -1141,6 +1191,9 @@ export const VerificationRecord = {
|
|
|
1141
1191
|
if (message.pendingVerifierVerdict !== 0) {
|
|
1142
1192
|
writer.uint32(104).int32(message.pendingVerifierVerdict);
|
|
1143
1193
|
}
|
|
1194
|
+
if (message.commitmentReleased === true) {
|
|
1195
|
+
writer.uint32(112).bool(message.commitmentReleased);
|
|
1196
|
+
}
|
|
1144
1197
|
return writer;
|
|
1145
1198
|
},
|
|
1146
1199
|
decode(input, length) {
|
|
@@ -1189,6 +1242,9 @@ export const VerificationRecord = {
|
|
|
1189
1242
|
case 13:
|
|
1190
1243
|
message.pendingVerifierVerdict = reader.int32();
|
|
1191
1244
|
break;
|
|
1245
|
+
case 14:
|
|
1246
|
+
message.commitmentReleased = reader.bool();
|
|
1247
|
+
break;
|
|
1192
1248
|
default:
|
|
1193
1249
|
reader.skipType(tag & 7);
|
|
1194
1250
|
break;
|
|
@@ -1211,6 +1267,7 @@ export const VerificationRecord = {
|
|
|
1211
1267
|
message.challenger = object.challenger ?? "";
|
|
1212
1268
|
message.escrowedChallengeFee = object.escrowedChallengeFee ?? "";
|
|
1213
1269
|
message.pendingVerifierVerdict = object.pendingVerifierVerdict ?? 0;
|
|
1270
|
+
message.commitmentReleased = object.commitmentReleased ?? false;
|
|
1214
1271
|
return message;
|
|
1215
1272
|
},
|
|
1216
1273
|
fromAmino(object) {
|
|
@@ -1254,6 +1311,9 @@ export const VerificationRecord = {
|
|
|
1254
1311
|
if (object.pending_verifier_verdict !== undefined && object.pending_verifier_verdict !== null) {
|
|
1255
1312
|
message.pendingVerifierVerdict = object.pending_verifier_verdict;
|
|
1256
1313
|
}
|
|
1314
|
+
if (object.commitment_released !== undefined && object.commitment_released !== null) {
|
|
1315
|
+
message.commitmentReleased = object.commitment_released;
|
|
1316
|
+
}
|
|
1257
1317
|
return message;
|
|
1258
1318
|
},
|
|
1259
1319
|
toAmino(message) {
|
|
@@ -1271,6 +1331,7 @@ export const VerificationRecord = {
|
|
|
1271
1331
|
obj.challenger = message.challenger === "" ? undefined : message.challenger;
|
|
1272
1332
|
obj.escrowed_challenge_fee = message.escrowedChallengeFee === "" ? undefined : message.escrowedChallengeFee;
|
|
1273
1333
|
obj.pending_verifier_verdict = message.pendingVerifierVerdict === 0 ? undefined : message.pendingVerifierVerdict;
|
|
1334
|
+
obj.commitment_released = message.commitmentReleased === false ? undefined : message.commitmentReleased;
|
|
1274
1335
|
return obj;
|
|
1275
1336
|
},
|
|
1276
1337
|
fromAminoMsg(object) {
|
|
@@ -1547,7 +1608,9 @@ function createBaseFederatedContent() {
|
|
|
1547
1608
|
submittedBy: "",
|
|
1548
1609
|
status: 0,
|
|
1549
1610
|
expiresAt: BigInt(0),
|
|
1550
|
-
contentHash: new Uint8Array()
|
|
1611
|
+
contentHash: new Uint8Array(),
|
|
1612
|
+
supersedes: undefined,
|
|
1613
|
+
supersededBy: BigInt(0)
|
|
1551
1614
|
};
|
|
1552
1615
|
}
|
|
1553
1616
|
/**
|
|
@@ -1607,6 +1670,12 @@ export const FederatedContent = {
|
|
|
1607
1670
|
if (message.contentHash.length !== 0) {
|
|
1608
1671
|
writer.uint32(130).bytes(message.contentHash);
|
|
1609
1672
|
}
|
|
1673
|
+
if (message.supersedes !== undefined) {
|
|
1674
|
+
ContentRef.encode(message.supersedes, writer.uint32(138).fork()).ldelim();
|
|
1675
|
+
}
|
|
1676
|
+
if (message.supersededBy !== BigInt(0)) {
|
|
1677
|
+
writer.uint32(144).uint64(message.supersededBy);
|
|
1678
|
+
}
|
|
1610
1679
|
return writer;
|
|
1611
1680
|
},
|
|
1612
1681
|
decode(input, length) {
|
|
@@ -1664,6 +1733,12 @@ export const FederatedContent = {
|
|
|
1664
1733
|
case 16:
|
|
1665
1734
|
message.contentHash = reader.bytes();
|
|
1666
1735
|
break;
|
|
1736
|
+
case 17:
|
|
1737
|
+
message.supersedes = ContentRef.decode(reader, reader.uint32());
|
|
1738
|
+
break;
|
|
1739
|
+
case 18:
|
|
1740
|
+
message.supersededBy = reader.uint64();
|
|
1741
|
+
break;
|
|
1667
1742
|
default:
|
|
1668
1743
|
reader.skipType(tag & 7);
|
|
1669
1744
|
break;
|
|
@@ -1689,6 +1764,8 @@ export const FederatedContent = {
|
|
|
1689
1764
|
message.status = object.status ?? 0;
|
|
1690
1765
|
message.expiresAt = object.expiresAt !== undefined && object.expiresAt !== null ? BigInt(object.expiresAt.toString()) : BigInt(0);
|
|
1691
1766
|
message.contentHash = object.contentHash ?? new Uint8Array();
|
|
1767
|
+
message.supersedes = object.supersedes !== undefined && object.supersedes !== null ? ContentRef.fromPartial(object.supersedes) : undefined;
|
|
1768
|
+
message.supersededBy = object.supersededBy !== undefined && object.supersededBy !== null ? BigInt(object.supersededBy.toString()) : BigInt(0);
|
|
1692
1769
|
return message;
|
|
1693
1770
|
},
|
|
1694
1771
|
fromAmino(object) {
|
|
@@ -1741,6 +1818,12 @@ export const FederatedContent = {
|
|
|
1741
1818
|
if (object.content_hash !== undefined && object.content_hash !== null) {
|
|
1742
1819
|
message.contentHash = bytesFromBase64(object.content_hash);
|
|
1743
1820
|
}
|
|
1821
|
+
if (object.supersedes !== undefined && object.supersedes !== null) {
|
|
1822
|
+
message.supersedes = ContentRef.fromAmino(object.supersedes);
|
|
1823
|
+
}
|
|
1824
|
+
if (object.superseded_by !== undefined && object.superseded_by !== null) {
|
|
1825
|
+
message.supersededBy = BigInt(object.superseded_by);
|
|
1826
|
+
}
|
|
1744
1827
|
return message;
|
|
1745
1828
|
},
|
|
1746
1829
|
toAmino(message) {
|
|
@@ -1761,6 +1844,8 @@ export const FederatedContent = {
|
|
|
1761
1844
|
obj.status = message.status === 0 ? undefined : message.status;
|
|
1762
1845
|
obj.expires_at = message.expiresAt !== BigInt(0) ? message.expiresAt?.toString() : undefined;
|
|
1763
1846
|
obj.content_hash = message.contentHash ? base64FromBytes(message.contentHash) : undefined;
|
|
1847
|
+
obj.supersedes = message.supersedes ? ContentRef.toAmino(message.supersedes) : undefined;
|
|
1848
|
+
obj.superseded_by = message.supersededBy !== BigInt(0) ? message.supersededBy?.toString() : undefined;
|
|
1764
1849
|
return obj;
|
|
1765
1850
|
},
|
|
1766
1851
|
fromAminoMsg(object) {
|
|
@@ -1779,6 +1864,77 @@ export const FederatedContent = {
|
|
|
1779
1864
|
};
|
|
1780
1865
|
}
|
|
1781
1866
|
};
|
|
1867
|
+
function createBaseContentRef() {
|
|
1868
|
+
return {
|
|
1869
|
+
contentId: BigInt(0)
|
|
1870
|
+
};
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* ContentRef points at a FederatedContent record. A message rather than a
|
|
1874
|
+
* bare uint64 because content ids start at 0: a nil ref is "none", which
|
|
1875
|
+
* a zero id could not express.
|
|
1876
|
+
* @name ContentRef
|
|
1877
|
+
* @package sparkdream.federation.v1
|
|
1878
|
+
* @see proto type: sparkdream.federation.v1.ContentRef
|
|
1879
|
+
*/
|
|
1880
|
+
export const ContentRef = {
|
|
1881
|
+
typeUrl: "/sparkdream.federation.v1.ContentRef",
|
|
1882
|
+
encode(message, writer = BinaryWriter.create()) {
|
|
1883
|
+
if (message.contentId !== BigInt(0)) {
|
|
1884
|
+
writer.uint32(8).uint64(message.contentId);
|
|
1885
|
+
}
|
|
1886
|
+
return writer;
|
|
1887
|
+
},
|
|
1888
|
+
decode(input, length) {
|
|
1889
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1890
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1891
|
+
const message = createBaseContentRef();
|
|
1892
|
+
while (reader.pos < end) {
|
|
1893
|
+
const tag = reader.uint32();
|
|
1894
|
+
switch (tag >>> 3) {
|
|
1895
|
+
case 1:
|
|
1896
|
+
message.contentId = reader.uint64();
|
|
1897
|
+
break;
|
|
1898
|
+
default:
|
|
1899
|
+
reader.skipType(tag & 7);
|
|
1900
|
+
break;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
return message;
|
|
1904
|
+
},
|
|
1905
|
+
fromPartial(object) {
|
|
1906
|
+
const message = createBaseContentRef();
|
|
1907
|
+
message.contentId = object.contentId !== undefined && object.contentId !== null ? BigInt(object.contentId.toString()) : BigInt(0);
|
|
1908
|
+
return message;
|
|
1909
|
+
},
|
|
1910
|
+
fromAmino(object) {
|
|
1911
|
+
const message = createBaseContentRef();
|
|
1912
|
+
if (object.content_id !== undefined && object.content_id !== null) {
|
|
1913
|
+
message.contentId = BigInt(object.content_id);
|
|
1914
|
+
}
|
|
1915
|
+
return message;
|
|
1916
|
+
},
|
|
1917
|
+
toAmino(message) {
|
|
1918
|
+
const obj = {};
|
|
1919
|
+
obj.content_id = message.contentId !== BigInt(0) ? message.contentId?.toString() : undefined;
|
|
1920
|
+
return obj;
|
|
1921
|
+
},
|
|
1922
|
+
fromAminoMsg(object) {
|
|
1923
|
+
return ContentRef.fromAmino(object.value);
|
|
1924
|
+
},
|
|
1925
|
+
fromProtoMsg(message) {
|
|
1926
|
+
return ContentRef.decode(message.value);
|
|
1927
|
+
},
|
|
1928
|
+
toProto(message) {
|
|
1929
|
+
return ContentRef.encode(message).finish();
|
|
1930
|
+
},
|
|
1931
|
+
toProtoMsg(message) {
|
|
1932
|
+
return {
|
|
1933
|
+
typeUrl: "/sparkdream.federation.v1.ContentRef",
|
|
1934
|
+
value: ContentRef.encode(message).finish()
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1782
1938
|
function createBaseIdentityLink() {
|
|
1783
1939
|
return {
|
|
1784
1940
|
localAddress: "",
|
|
@@ -2,13 +2,155 @@
|
|
|
2
2
|
// HAND-WRITTEN OVERRIDE — overlaid by scripts/codegen.ts after telescope.
|
|
3
3
|
// See ../../commons/v1/tx.amino.ts for rationale.
|
|
4
4
|
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// Because this file replaces the generated one wholesale, EVERY Msg in
|
|
6
|
+
// session/v1/tx.proto must have an entry here — a message added to the proto
|
|
7
|
+
// but not to this map ships in the registry with no amino converter, and
|
|
8
|
+
// Keplr/Ledger (amino-json) signing of it fails.
|
|
9
|
+
//
|
|
10
|
+
// Three shapes telescope gets wrong for this module:
|
|
11
|
+
//
|
|
12
|
+
// 1. MsgExecSession / OneshotExec carry google.protobuf.Any, which needs the
|
|
13
|
+
// recursive conversion in ../../../nested-amino.
|
|
14
|
+
// 2. MsgCreateGrant.payload and ScheduledOneshotPayload.action are oneofs
|
|
15
|
+
// with (amino.oneof_name). cosmossdk.io/x/tx/signing/aminojson renders a
|
|
16
|
+
// set oneof member as
|
|
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.
|
|
7
32
|
import { MsgUpdateParams, MsgUpdateOperationalParams, MsgCreateSession, MsgRevokeSession, } from "./tx";
|
|
8
33
|
import { Coin } from "../../../cosmos/base/v1beta1/coin";
|
|
9
34
|
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
10
|
-
import { toTimestamp } from "../../../helpers";
|
|
35
|
+
import { toTimestamp, fromTimestamp } from "../../../helpers";
|
|
11
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 PAYLOADS = [
|
|
142
|
+
["sessionKey", "session_key", "sparkdream/session/SessionKeyPayload", sessionKeyToAmino, sessionKeyFromAmino],
|
|
143
|
+
["recurringPull", "recurring_pull", "sparkdream/session/RecurringPullPayload", recurringPullToAmino, recurringPullFromAmino],
|
|
144
|
+
["spendingAllowance", "spending_allowance", "sparkdream/session/SpendingAllowancePayload", spendingAllowanceToAmino, spendingAllowanceFromAmino],
|
|
145
|
+
["scheduledOneshot", "scheduled_oneshot", "sparkdream/session/ScheduledOneshotPayload", scheduledOneshotToAmino, scheduledOneshotFromAmino],
|
|
146
|
+
];
|
|
147
|
+
// ── Messages ────────────────────────────────────────────────────────────
|
|
148
|
+
// {<signer>, grant_id} messages; each signer field name is a single word, so
|
|
149
|
+
// the proto and amino spellings coincide.
|
|
150
|
+
const grantIdMsg = (signer) => ({
|
|
151
|
+
toAmino: (m) => ({ [signer]: str(m[signer]), grant_id: int64(m.grantId) }),
|
|
152
|
+
fromAmino: (o) => ({ [signer]: o[signer] ?? "", grantId: toBig(o.grant_id) }),
|
|
153
|
+
});
|
|
12
154
|
export const AminoConverter = {
|
|
13
155
|
"/sparkdream.session.v1.MsgUpdateParams": {
|
|
14
156
|
aminoType: "sparkdream/x/session/MsgUpdateParams",
|
|
@@ -64,4 +206,64 @@ export const AminoConverter = {
|
|
|
64
206
|
};
|
|
65
207
|
},
|
|
66
208
|
},
|
|
209
|
+
"/sparkdream.session.v1.MsgCreateGrant": {
|
|
210
|
+
aminoType: "sparkdream/x/session/MsgCreateGrant",
|
|
211
|
+
toAmino(message) {
|
|
212
|
+
const set = PAYLOADS.find(([key]) => message[key]);
|
|
213
|
+
return {
|
|
214
|
+
granter: str(message.granter),
|
|
215
|
+
grantee: str(message.grantee),
|
|
216
|
+
expires_at: time(message.expiresAt),
|
|
217
|
+
note: str(message.note),
|
|
218
|
+
Payload: set
|
|
219
|
+
? { type: set[2], value: { [set[1]]: set[3](message[set[0]]) } }
|
|
220
|
+
: null,
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
fromAmino(object) {
|
|
224
|
+
const out = {
|
|
225
|
+
granter: object.granter ?? "",
|
|
226
|
+
grantee: object.grantee ?? "",
|
|
227
|
+
expiresAt: fromTime(object.expires_at),
|
|
228
|
+
note: object.note ?? "",
|
|
229
|
+
};
|
|
230
|
+
const inner = object.Payload?.value ?? {};
|
|
231
|
+
for (const [key, field, , , fromAmino] of PAYLOADS) {
|
|
232
|
+
if (inner[field])
|
|
233
|
+
out[key] = fromAmino(inner[field]);
|
|
234
|
+
}
|
|
235
|
+
return out;
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
"/sparkdream.session.v1.MsgClaimRecurringPull": {
|
|
239
|
+
aminoType: "sparkdream/x/session/MsgClaimRecurringPull",
|
|
240
|
+
...grantIdMsg("grantee"),
|
|
241
|
+
},
|
|
242
|
+
"/sparkdream.session.v1.MsgPullAllowance": {
|
|
243
|
+
aminoType: "sparkdream/x/session/MsgPullAllowance",
|
|
244
|
+
toAmino: (m) => ({
|
|
245
|
+
grantee: str(m.grantee),
|
|
246
|
+
grant_id: int64(m.grantId),
|
|
247
|
+
recipient: str(m.recipient),
|
|
248
|
+
amount: coin(m.amount),
|
|
249
|
+
}),
|
|
250
|
+
fromAmino: (o) => ({
|
|
251
|
+
grantee: o.grantee ?? "",
|
|
252
|
+
grantId: toBig(o.grant_id),
|
|
253
|
+
recipient: o.recipient ?? "",
|
|
254
|
+
amount: fromCoin(o.amount),
|
|
255
|
+
}),
|
|
256
|
+
},
|
|
257
|
+
"/sparkdream.session.v1.MsgRetryScheduledOneshot": {
|
|
258
|
+
aminoType: "sparkdream/x/session/MsgRetryScheduledOneshot",
|
|
259
|
+
...grantIdMsg("caller"),
|
|
260
|
+
},
|
|
261
|
+
"/sparkdream.session.v1.MsgRevokeGrant": {
|
|
262
|
+
aminoType: "sparkdream/x/session/MsgRevokeGrant",
|
|
263
|
+
...grantIdMsg("granter"),
|
|
264
|
+
},
|
|
265
|
+
"/sparkdream.session.v1.MsgDeclineGrant": {
|
|
266
|
+
aminoType: "sparkdream/x/session/MsgDeclineGrant",
|
|
267
|
+
...grantIdMsg("grantee"),
|
|
268
|
+
},
|
|
67
269
|
};
|