@buildonspark/spark-sdk 0.0.15 → 0.0.17
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/dist/services/config.d.ts +1 -0
- package/dist/services/config.js +4 -1
- package/dist/services/config.js.map +1 -1
- package/dist/services/wallet-config.d.ts +2 -0
- package/dist/services/wallet-config.js +2 -0
- package/dist/services/wallet-config.js.map +1 -1
- package/dist/signer/signer.js +4 -3
- package/dist/signer/signer.js.map +1 -1
- package/dist/spark-sdk.d.ts +4 -4
- package/dist/spark-sdk.js +26 -10
- package/dist/spark-sdk.js.map +1 -1
- package/package.json +4 -3
- package/src/examples/example.js +247 -0
- package/src/examples/example.ts +207 -0
- package/src/graphql/client.ts +282 -0
- package/src/graphql/mutations/CompleteCoopExit.ts +19 -0
- package/src/graphql/mutations/CompleteLeavesSwap.ts +17 -0
- package/src/graphql/mutations/RequestCoopExit.ts +20 -0
- package/src/graphql/mutations/RequestLightningReceive.ts +26 -0
- package/src/graphql/mutations/RequestLightningSend.ts +17 -0
- package/src/graphql/mutations/RequestSwapLeaves.ts +24 -0
- package/src/graphql/objects/BitcoinNetwork.ts +22 -0
- package/src/graphql/objects/CompleteCoopExitInput.ts +41 -0
- package/src/graphql/objects/CompleteCoopExitOutput.ts +45 -0
- package/src/graphql/objects/CompleteLeavesSwapInput.ts +45 -0
- package/src/graphql/objects/CompleteLeavesSwapOutput.ts +45 -0
- package/src/graphql/objects/CompleteSeedReleaseInput.ts +41 -0
- package/src/graphql/objects/CompleteSeedReleaseOutput.ts +43 -0
- package/src/graphql/objects/Connection.ts +90 -0
- package/src/graphql/objects/CoopExitFeeEstimateInput.ts +41 -0
- package/src/graphql/objects/CoopExitFeeEstimateOutput.ts +52 -0
- package/src/graphql/objects/CoopExitRequest.ts +118 -0
- package/src/graphql/objects/CurrencyAmount.ts +74 -0
- package/src/graphql/objects/CurrencyUnit.ts +32 -0
- package/src/graphql/objects/Entity.ts +202 -0
- package/src/graphql/objects/GetChallengeInput.ts +37 -0
- package/src/graphql/objects/GetChallengeOutput.ts +43 -0
- package/src/graphql/objects/Invoice.ts +83 -0
- package/src/graphql/objects/Leaf.ts +59 -0
- package/src/graphql/objects/LeavesSwapFeeEstimateInput.ts +37 -0
- package/src/graphql/objects/LeavesSwapFeeEstimateOutput.ts +52 -0
- package/src/graphql/objects/LeavesSwapRequest.ts +192 -0
- package/src/graphql/objects/LightningReceiveFeeEstimateInput.ts +41 -0
- package/src/graphql/objects/LightningReceiveFeeEstimateOutput.ts +52 -0
- package/src/graphql/objects/LightningReceiveRequest.ts +147 -0
- package/src/graphql/objects/LightningReceiveRequestStatus.ts +34 -0
- package/src/graphql/objects/LightningSendFeeEstimateInput.ts +37 -0
- package/src/graphql/objects/LightningSendFeeEstimateOutput.ts +52 -0
- package/src/graphql/objects/LightningSendRequest.ts +134 -0
- package/src/graphql/objects/LightningSendRequestStatus.ts +28 -0
- package/src/graphql/objects/NotifyReceiverTransferInput.ts +41 -0
- package/src/graphql/objects/PageInfo.ts +58 -0
- package/src/graphql/objects/Provider.ts +41 -0
- package/src/graphql/objects/RequestCoopExitInput.ts +41 -0
- package/src/graphql/objects/RequestCoopExitOutput.ts +45 -0
- package/src/graphql/objects/RequestLeavesSwapInput.ts +55 -0
- package/src/graphql/objects/RequestLeavesSwapOutput.ts +45 -0
- package/src/graphql/objects/RequestLightningReceiveInput.ts +58 -0
- package/src/graphql/objects/RequestLightningReceiveOutput.ts +45 -0
- package/src/graphql/objects/RequestLightningSendInput.ts +41 -0
- package/src/graphql/objects/RequestLightningSendOutput.ts +45 -0
- package/src/graphql/objects/SparkCoopExitRequestStatus.ts +20 -0
- package/src/graphql/objects/SparkLeavesSwapRequestStatus.ts +20 -0
- package/src/graphql/objects/SparkTransferToLeavesConnection.ts +79 -0
- package/src/graphql/objects/SparkWalletUser.ts +86 -0
- package/src/graphql/objects/StartSeedReleaseInput.ts +37 -0
- package/src/graphql/objects/SwapLeaf.ts +53 -0
- package/src/graphql/objects/Transfer.ts +98 -0
- package/src/graphql/objects/UserLeafInput.ts +28 -0
- package/src/graphql/objects/VerifyChallengeInput.ts +51 -0
- package/src/graphql/objects/VerifyChallengeOutput.ts +43 -0
- package/src/graphql/objects/WalletUserIdentityPublicKeyInput.ts +37 -0
- package/src/graphql/objects/WalletUserIdentityPublicKeyOutput.ts +43 -0
- package/src/graphql/objects/index.ts +67 -0
- package/src/graphql/queries/CoopExitFeeEstimate.ts +18 -0
- package/src/graphql/queries/CurrentUser.ts +10 -0
- package/src/graphql/queries/LightningReceiveFeeEstimate.ts +18 -0
- package/src/graphql/queries/LightningSendFeeEstimate.ts +16 -0
- package/src/proto/common.ts +431 -0
- package/src/proto/google/protobuf/descriptor.ts +6625 -0
- package/src/proto/google/protobuf/duration.ts +197 -0
- package/src/proto/google/protobuf/empty.ts +83 -0
- package/src/proto/google/protobuf/timestamp.ts +226 -0
- package/src/proto/mock.ts +151 -0
- package/src/proto/spark.ts +12727 -0
- package/src/proto/spark_authn.ts +673 -0
- package/src/proto/validate/validate.ts +6047 -0
- package/src/services/config.ts +75 -0
- package/src/services/connection.ts +264 -0
- package/src/services/coop-exit.ts +190 -0
- package/src/services/deposit.ts +327 -0
- package/src/services/lightning.ts +341 -0
- package/src/services/lrc20.ts +42 -0
- package/src/services/token-transactions.ts +499 -0
- package/src/services/transfer.ts +1188 -0
- package/src/services/tree-creation.ts +618 -0
- package/src/services/wallet-config.ts +143 -0
- package/src/signer/signer.ts +532 -0
- package/src/spark-sdk.ts +1665 -0
- package/src/tests/adaptor-signature.test.ts +64 -0
- package/src/tests/bitcoin.test.ts +122 -0
- package/src/tests/coop-exit.test.ts +233 -0
- package/src/tests/deposit.test.ts +98 -0
- package/src/tests/keys.test.ts +82 -0
- package/src/tests/lightning.test.ts +307 -0
- package/src/tests/secret-sharing.test.ts +63 -0
- package/src/tests/swap.test.ts +252 -0
- package/src/tests/test-util.ts +92 -0
- package/src/tests/tokens.test.ts +47 -0
- package/src/tests/transfer.test.ts +371 -0
- package/src/tests/tree-creation.test.ts +56 -0
- package/src/tests/utils/spark-testing-wallet.ts +37 -0
- package/src/tests/utils/test-faucet.ts +257 -0
- package/src/types/grpc.ts +8 -0
- package/src/types/index.ts +3 -0
- package/src/utils/adaptor-signature.ts +189 -0
- package/src/utils/bitcoin.ts +138 -0
- package/src/utils/crypto.ts +14 -0
- package/src/utils/index.ts +12 -0
- package/src/utils/keys.ts +92 -0
- package/src/utils/mempool.ts +42 -0
- package/src/utils/network.ts +70 -0
- package/src/utils/proof.ts +17 -0
- package/src/utils/response-validation.ts +26 -0
- package/src/utils/secret-sharing.ts +263 -0
- package/src/utils/signing.ts +96 -0
- package/src/utils/token-hashing.ts +163 -0
- package/src/utils/token-keyshares.ts +31 -0
- package/src/utils/token-transactions.ts +71 -0
- package/src/utils/transaction.ts +45 -0
- package/src/utils/wasm-wrapper.ts +57 -0
- package/src/utils/wasm.ts +154 -0
- package/src/wasm/spark_bindings.d.ts +208 -0
- package/src/wasm/spark_bindings.js +1161 -0
- package/src/wasm/spark_bindings_bg.wasm +0 -0
- package/src/wasm/spark_bindings_bg.wasm.d.ts +136 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export { default as BitcoinNetwork } from "./BitcoinNetwork.js";
|
|
2
|
+
export { default as CompleteCoopExitInput } from "./CompleteCoopExitInput.js";
|
|
3
|
+
export { default as CompleteCoopExitOutput } from "./CompleteCoopExitOutput.js";
|
|
4
|
+
export { default as CompleteLeavesSwapInput } from "./CompleteLeavesSwapInput.js";
|
|
5
|
+
export { default as CompleteLeavesSwapOutput } from "./CompleteLeavesSwapOutput.js";
|
|
6
|
+
export { default as CompleteSeedReleaseInput } from "./CompleteSeedReleaseInput.js";
|
|
7
|
+
export { default as CompleteSeedReleaseOutput } from "./CompleteSeedReleaseOutput.js";
|
|
8
|
+
export { default as Connection } from "./Connection.js";
|
|
9
|
+
export { default as CoopExitFeeEstimateInput } from "./CoopExitFeeEstimateInput.js";
|
|
10
|
+
export { default as CoopExitFeeEstimateOutput } from "./CoopExitFeeEstimateOutput.js";
|
|
11
|
+
export {
|
|
12
|
+
default as CoopExitRequest,
|
|
13
|
+
getCoopExitRequestQuery,
|
|
14
|
+
} from "./CoopExitRequest.js";
|
|
15
|
+
export { default as CurrencyAmount } from "./CurrencyAmount.js";
|
|
16
|
+
export { default as CurrencyUnit } from "./CurrencyUnit.js";
|
|
17
|
+
export { default as Entity } from "./Entity.js";
|
|
18
|
+
export { default as GetChallengeInput } from "./GetChallengeInput.js";
|
|
19
|
+
export { default as GetChallengeOutput } from "./GetChallengeOutput.js";
|
|
20
|
+
export { default as Invoice } from "./Invoice.js";
|
|
21
|
+
export { default as Leaf } from "./Leaf.js";
|
|
22
|
+
export { default as LeavesSwapFeeEstimateInput } from "./LeavesSwapFeeEstimateInput.js";
|
|
23
|
+
export { default as LeavesSwapFeeEstimateOutput } from "./LeavesSwapFeeEstimateOutput.js";
|
|
24
|
+
export {
|
|
25
|
+
getLeavesSwapRequestQuery,
|
|
26
|
+
default as LeavesSwapRequest,
|
|
27
|
+
} from "./LeavesSwapRequest.js";
|
|
28
|
+
export { default as LightningReceiveFeeEstimateInput } from "./LightningReceiveFeeEstimateInput.js";
|
|
29
|
+
export { default as LightningReceiveFeeEstimateOutput } from "./LightningReceiveFeeEstimateOutput.js";
|
|
30
|
+
export {
|
|
31
|
+
getLightningReceiveRequestQuery,
|
|
32
|
+
default as LightningReceiveRequest,
|
|
33
|
+
} from "./LightningReceiveRequest.js";
|
|
34
|
+
export { default as LightningReceiveRequestStatus } from "./LightningReceiveRequestStatus.js";
|
|
35
|
+
export { default as LightningSendFeeEstimateInput } from "./LightningSendFeeEstimateInput.js";
|
|
36
|
+
export { default as LightningSendFeeEstimateOutput } from "./LightningSendFeeEstimateOutput.js";
|
|
37
|
+
export {
|
|
38
|
+
getLightningSendRequestQuery,
|
|
39
|
+
default as LightningSendRequest,
|
|
40
|
+
} from "./LightningSendRequest.js";
|
|
41
|
+
export { default as LightningSendRequestStatus } from "./LightningSendRequestStatus.js";
|
|
42
|
+
export { default as NotifyReceiverTransferInput } from "./NotifyReceiverTransferInput.js";
|
|
43
|
+
export { default as PageInfo } from "./PageInfo.js";
|
|
44
|
+
export { default as Provider } from "./Provider.js";
|
|
45
|
+
export { default as RequestCoopExitInput } from "./RequestCoopExitInput.js";
|
|
46
|
+
export { default as RequestCoopExitOutput } from "./RequestCoopExitOutput.js";
|
|
47
|
+
export { default as RequestLeavesSwapInput } from "./RequestLeavesSwapInput.js";
|
|
48
|
+
export { default as RequestLeavesSwapOutput } from "./RequestLeavesSwapOutput.js";
|
|
49
|
+
export { default as RequestLightningReceiveInput } from "./RequestLightningReceiveInput.js";
|
|
50
|
+
export { default as RequestLightningReceiveOutput } from "./RequestLightningReceiveOutput.js";
|
|
51
|
+
export { default as RequestLightningSendInput } from "./RequestLightningSendInput.js";
|
|
52
|
+
export { default as RequestLightningSendOutput } from "./RequestLightningSendOutput.js";
|
|
53
|
+
export { default as SparkCoopExitRequestStatus } from "./SparkCoopExitRequestStatus.js";
|
|
54
|
+
export { default as SparkLeavesSwapRequestStatus } from "./SparkLeavesSwapRequestStatus.js";
|
|
55
|
+
export { default as SparkTransferToLeavesConnection } from "./SparkTransferToLeavesConnection.js";
|
|
56
|
+
export {
|
|
57
|
+
getSparkWalletUserQuery,
|
|
58
|
+
default as SparkWalletUser,
|
|
59
|
+
} from "./SparkWalletUser.js";
|
|
60
|
+
export { default as StartSeedReleaseInput } from "./StartSeedReleaseInput.js";
|
|
61
|
+
export { default as SwapLeaf } from "./SwapLeaf.js";
|
|
62
|
+
export { default as Transfer } from "./Transfer.js";
|
|
63
|
+
export { default as UserLeafInput } from "./UserLeafInput.js";
|
|
64
|
+
export { default as VerifyChallengeInput } from "./VerifyChallengeInput.js";
|
|
65
|
+
export { default as VerifyChallengeOutput } from "./VerifyChallengeOutput.js";
|
|
66
|
+
export { default as WalletUserIdentityPublicKeyInput } from "./WalletUserIdentityPublicKeyInput.js";
|
|
67
|
+
export { default as WalletUserIdentityPublicKeyOutput } from "./WalletUserIdentityPublicKeyOutput.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FRAGMENT as CoopExitFeeEstimateOutputFragment } from "../objects/CoopExitFeeEstimateOutput.js";
|
|
2
|
+
|
|
3
|
+
export const CoopExitFeeEstimate = `
|
|
4
|
+
query CoopExitFeeEstimate(
|
|
5
|
+
$leaf_external_ids: [UUID!]!
|
|
6
|
+
$withdrawal_address: String!
|
|
7
|
+
) {
|
|
8
|
+
coop_exit_fee_estimate(
|
|
9
|
+
input: {
|
|
10
|
+
leaf_external_ids: $leaf_external_ids
|
|
11
|
+
withdrawal_address: $withdrawal_address
|
|
12
|
+
}
|
|
13
|
+
) {
|
|
14
|
+
...CoopExitFeeEstimateOutputFragment
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
${CoopExitFeeEstimateOutputFragment}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FRAGMENT as LightningReceiveFeeEstimateOutputFragment } from "../objects/LightningReceiveFeeEstimateOutput.js";
|
|
2
|
+
|
|
3
|
+
export const LightningReceiveFeeEstimate = `
|
|
4
|
+
query LightningReceiveFeeEstimate(
|
|
5
|
+
$network: BitcoinNetwork!
|
|
6
|
+
$amount_sats: Long!
|
|
7
|
+
) {
|
|
8
|
+
lightning_receive_fee_estimate(
|
|
9
|
+
input: {
|
|
10
|
+
network: $network
|
|
11
|
+
amount_sats: $amount_sats
|
|
12
|
+
}
|
|
13
|
+
) {
|
|
14
|
+
...LightningReceiveFeeEstimateOutputFragment
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
${LightningReceiveFeeEstimateOutputFragment}
|
|
18
|
+
`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FRAGMENT as LightningSendFeeEstimateOutputFragment } from "../objects/LightningSendFeeEstimateOutput.js";
|
|
2
|
+
|
|
3
|
+
export const LightningSendFeeEstimate = `
|
|
4
|
+
query LightningSendFeeEstimate(
|
|
5
|
+
$encoded_invoice: String!
|
|
6
|
+
) {
|
|
7
|
+
lightning_send_fee_estimate(
|
|
8
|
+
input: {
|
|
9
|
+
encoded_invoice: $encoded_invoice
|
|
10
|
+
}
|
|
11
|
+
) {
|
|
12
|
+
...LightningSendFeeEstimateOutputFragment
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
${LightningSendFeeEstimateOutputFragment}
|
|
16
|
+
`;
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.6.1
|
|
4
|
+
// protoc v5.29.3
|
|
5
|
+
// source: common.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
9
|
+
|
|
10
|
+
export const protobufPackage = "common";
|
|
11
|
+
|
|
12
|
+
export enum SignatureIntent {
|
|
13
|
+
CREATION = 0,
|
|
14
|
+
TRANSFER = 1,
|
|
15
|
+
AGGREGATE = 2,
|
|
16
|
+
REFRESH = 3,
|
|
17
|
+
EXTEND = 4,
|
|
18
|
+
UNRECOGNIZED = -1,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function signatureIntentFromJSON(object: any): SignatureIntent {
|
|
22
|
+
switch (object) {
|
|
23
|
+
case 0:
|
|
24
|
+
case "CREATION":
|
|
25
|
+
return SignatureIntent.CREATION;
|
|
26
|
+
case 1:
|
|
27
|
+
case "TRANSFER":
|
|
28
|
+
return SignatureIntent.TRANSFER;
|
|
29
|
+
case 2:
|
|
30
|
+
case "AGGREGATE":
|
|
31
|
+
return SignatureIntent.AGGREGATE;
|
|
32
|
+
case 3:
|
|
33
|
+
case "REFRESH":
|
|
34
|
+
return SignatureIntent.REFRESH;
|
|
35
|
+
case 4:
|
|
36
|
+
case "EXTEND":
|
|
37
|
+
return SignatureIntent.EXTEND;
|
|
38
|
+
case -1:
|
|
39
|
+
case "UNRECOGNIZED":
|
|
40
|
+
default:
|
|
41
|
+
return SignatureIntent.UNRECOGNIZED;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function signatureIntentToJSON(object: SignatureIntent): string {
|
|
46
|
+
switch (object) {
|
|
47
|
+
case SignatureIntent.CREATION:
|
|
48
|
+
return "CREATION";
|
|
49
|
+
case SignatureIntent.TRANSFER:
|
|
50
|
+
return "TRANSFER";
|
|
51
|
+
case SignatureIntent.AGGREGATE:
|
|
52
|
+
return "AGGREGATE";
|
|
53
|
+
case SignatureIntent.REFRESH:
|
|
54
|
+
return "REFRESH";
|
|
55
|
+
case SignatureIntent.EXTEND:
|
|
56
|
+
return "EXTEND";
|
|
57
|
+
case SignatureIntent.UNRECOGNIZED:
|
|
58
|
+
default:
|
|
59
|
+
return "UNRECOGNIZED";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A map from a string to a bytes. It's a workaround to have map arrays in proto. */
|
|
64
|
+
export interface PackageMap {
|
|
65
|
+
packages: { [key: string]: Uint8Array };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PackageMap_PackagesEntry {
|
|
69
|
+
key: string;
|
|
70
|
+
value: Uint8Array;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A commitment for frost signing.
|
|
75
|
+
* It's a pair of public keys (points) in secp256k1 curve.
|
|
76
|
+
*/
|
|
77
|
+
export interface SigningCommitment {
|
|
78
|
+
/** The public key for hiding. 33 bytes. */
|
|
79
|
+
hiding: Uint8Array;
|
|
80
|
+
/** The public key for binding. 33 bytes. */
|
|
81
|
+
binding: Uint8Array;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SigningResult {
|
|
85
|
+
signatureShare: Uint8Array;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function createBasePackageMap(): PackageMap {
|
|
89
|
+
return { packages: {} };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const PackageMap: MessageFns<PackageMap> = {
|
|
93
|
+
encode(message: PackageMap, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
94
|
+
Object.entries(message.packages).forEach(([key, value]) => {
|
|
95
|
+
PackageMap_PackagesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
|
|
96
|
+
});
|
|
97
|
+
return writer;
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
decode(input: BinaryReader | Uint8Array, length?: number): PackageMap {
|
|
101
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
102
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
103
|
+
const message = createBasePackageMap();
|
|
104
|
+
while (reader.pos < end) {
|
|
105
|
+
const tag = reader.uint32();
|
|
106
|
+
switch (tag >>> 3) {
|
|
107
|
+
case 1: {
|
|
108
|
+
if (tag !== 10) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const entry1 = PackageMap_PackagesEntry.decode(reader, reader.uint32());
|
|
113
|
+
if (entry1.value !== undefined) {
|
|
114
|
+
message.packages[entry1.key] = entry1.value;
|
|
115
|
+
}
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
reader.skip(tag & 7);
|
|
123
|
+
}
|
|
124
|
+
return message;
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
fromJSON(object: any): PackageMap {
|
|
128
|
+
return {
|
|
129
|
+
packages: isObject(object.packages)
|
|
130
|
+
? Object.entries(object.packages).reduce<{ [key: string]: Uint8Array }>((acc, [key, value]) => {
|
|
131
|
+
acc[key] = bytesFromBase64(value as string);
|
|
132
|
+
return acc;
|
|
133
|
+
}, {})
|
|
134
|
+
: {},
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
toJSON(message: PackageMap): unknown {
|
|
139
|
+
const obj: any = {};
|
|
140
|
+
if (message.packages) {
|
|
141
|
+
const entries = Object.entries(message.packages);
|
|
142
|
+
if (entries.length > 0) {
|
|
143
|
+
obj.packages = {};
|
|
144
|
+
entries.forEach(([k, v]) => {
|
|
145
|
+
obj.packages[k] = base64FromBytes(v);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return obj;
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
create(base?: DeepPartial<PackageMap>): PackageMap {
|
|
153
|
+
return PackageMap.fromPartial(base ?? {});
|
|
154
|
+
},
|
|
155
|
+
fromPartial(object: DeepPartial<PackageMap>): PackageMap {
|
|
156
|
+
const message = createBasePackageMap();
|
|
157
|
+
message.packages = Object.entries(object.packages ?? {}).reduce<{ [key: string]: Uint8Array }>(
|
|
158
|
+
(acc, [key, value]) => {
|
|
159
|
+
if (value !== undefined) {
|
|
160
|
+
acc[key] = value;
|
|
161
|
+
}
|
|
162
|
+
return acc;
|
|
163
|
+
},
|
|
164
|
+
{},
|
|
165
|
+
);
|
|
166
|
+
return message;
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
function createBasePackageMap_PackagesEntry(): PackageMap_PackagesEntry {
|
|
171
|
+
return { key: "", value: new Uint8Array(0) };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const PackageMap_PackagesEntry: MessageFns<PackageMap_PackagesEntry> = {
|
|
175
|
+
encode(message: PackageMap_PackagesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
176
|
+
if (message.key !== "") {
|
|
177
|
+
writer.uint32(10).string(message.key);
|
|
178
|
+
}
|
|
179
|
+
if (message.value.length !== 0) {
|
|
180
|
+
writer.uint32(18).bytes(message.value);
|
|
181
|
+
}
|
|
182
|
+
return writer;
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
decode(input: BinaryReader | Uint8Array, length?: number): PackageMap_PackagesEntry {
|
|
186
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
187
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
188
|
+
const message = createBasePackageMap_PackagesEntry();
|
|
189
|
+
while (reader.pos < end) {
|
|
190
|
+
const tag = reader.uint32();
|
|
191
|
+
switch (tag >>> 3) {
|
|
192
|
+
case 1: {
|
|
193
|
+
if (tag !== 10) {
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
message.key = reader.string();
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
case 2: {
|
|
201
|
+
if (tag !== 18) {
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
message.value = reader.bytes();
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
reader.skip(tag & 7);
|
|
213
|
+
}
|
|
214
|
+
return message;
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
fromJSON(object: any): PackageMap_PackagesEntry {
|
|
218
|
+
return {
|
|
219
|
+
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
|
220
|
+
value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0),
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
toJSON(message: PackageMap_PackagesEntry): unknown {
|
|
225
|
+
const obj: any = {};
|
|
226
|
+
if (message.key !== "") {
|
|
227
|
+
obj.key = message.key;
|
|
228
|
+
}
|
|
229
|
+
if (message.value.length !== 0) {
|
|
230
|
+
obj.value = base64FromBytes(message.value);
|
|
231
|
+
}
|
|
232
|
+
return obj;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
create(base?: DeepPartial<PackageMap_PackagesEntry>): PackageMap_PackagesEntry {
|
|
236
|
+
return PackageMap_PackagesEntry.fromPartial(base ?? {});
|
|
237
|
+
},
|
|
238
|
+
fromPartial(object: DeepPartial<PackageMap_PackagesEntry>): PackageMap_PackagesEntry {
|
|
239
|
+
const message = createBasePackageMap_PackagesEntry();
|
|
240
|
+
message.key = object.key ?? "";
|
|
241
|
+
message.value = object.value ?? new Uint8Array(0);
|
|
242
|
+
return message;
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
function createBaseSigningCommitment(): SigningCommitment {
|
|
247
|
+
return { hiding: new Uint8Array(0), binding: new Uint8Array(0) };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export const SigningCommitment: MessageFns<SigningCommitment> = {
|
|
251
|
+
encode(message: SigningCommitment, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
252
|
+
if (message.hiding.length !== 0) {
|
|
253
|
+
writer.uint32(10).bytes(message.hiding);
|
|
254
|
+
}
|
|
255
|
+
if (message.binding.length !== 0) {
|
|
256
|
+
writer.uint32(18).bytes(message.binding);
|
|
257
|
+
}
|
|
258
|
+
return writer;
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
decode(input: BinaryReader | Uint8Array, length?: number): SigningCommitment {
|
|
262
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
263
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
264
|
+
const message = createBaseSigningCommitment();
|
|
265
|
+
while (reader.pos < end) {
|
|
266
|
+
const tag = reader.uint32();
|
|
267
|
+
switch (tag >>> 3) {
|
|
268
|
+
case 1: {
|
|
269
|
+
if (tag !== 10) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
message.hiding = reader.bytes();
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
case 2: {
|
|
277
|
+
if (tag !== 18) {
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
message.binding = reader.bytes();
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
reader.skip(tag & 7);
|
|
289
|
+
}
|
|
290
|
+
return message;
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
fromJSON(object: any): SigningCommitment {
|
|
294
|
+
return {
|
|
295
|
+
hiding: isSet(object.hiding) ? bytesFromBase64(object.hiding) : new Uint8Array(0),
|
|
296
|
+
binding: isSet(object.binding) ? bytesFromBase64(object.binding) : new Uint8Array(0),
|
|
297
|
+
};
|
|
298
|
+
},
|
|
299
|
+
|
|
300
|
+
toJSON(message: SigningCommitment): unknown {
|
|
301
|
+
const obj: any = {};
|
|
302
|
+
if (message.hiding.length !== 0) {
|
|
303
|
+
obj.hiding = base64FromBytes(message.hiding);
|
|
304
|
+
}
|
|
305
|
+
if (message.binding.length !== 0) {
|
|
306
|
+
obj.binding = base64FromBytes(message.binding);
|
|
307
|
+
}
|
|
308
|
+
return obj;
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
create(base?: DeepPartial<SigningCommitment>): SigningCommitment {
|
|
312
|
+
return SigningCommitment.fromPartial(base ?? {});
|
|
313
|
+
},
|
|
314
|
+
fromPartial(object: DeepPartial<SigningCommitment>): SigningCommitment {
|
|
315
|
+
const message = createBaseSigningCommitment();
|
|
316
|
+
message.hiding = object.hiding ?? new Uint8Array(0);
|
|
317
|
+
message.binding = object.binding ?? new Uint8Array(0);
|
|
318
|
+
return message;
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
function createBaseSigningResult(): SigningResult {
|
|
323
|
+
return { signatureShare: new Uint8Array(0) };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export const SigningResult: MessageFns<SigningResult> = {
|
|
327
|
+
encode(message: SigningResult, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
328
|
+
if (message.signatureShare.length !== 0) {
|
|
329
|
+
writer.uint32(10).bytes(message.signatureShare);
|
|
330
|
+
}
|
|
331
|
+
return writer;
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
decode(input: BinaryReader | Uint8Array, length?: number): SigningResult {
|
|
335
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
336
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
337
|
+
const message = createBaseSigningResult();
|
|
338
|
+
while (reader.pos < end) {
|
|
339
|
+
const tag = reader.uint32();
|
|
340
|
+
switch (tag >>> 3) {
|
|
341
|
+
case 1: {
|
|
342
|
+
if (tag !== 10) {
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
message.signatureShare = reader.bytes();
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
reader.skip(tag & 7);
|
|
354
|
+
}
|
|
355
|
+
return message;
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
fromJSON(object: any): SigningResult {
|
|
359
|
+
return {
|
|
360
|
+
signatureShare: isSet(object.signatureShare) ? bytesFromBase64(object.signatureShare) : new Uint8Array(0),
|
|
361
|
+
};
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
toJSON(message: SigningResult): unknown {
|
|
365
|
+
const obj: any = {};
|
|
366
|
+
if (message.signatureShare.length !== 0) {
|
|
367
|
+
obj.signatureShare = base64FromBytes(message.signatureShare);
|
|
368
|
+
}
|
|
369
|
+
return obj;
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
create(base?: DeepPartial<SigningResult>): SigningResult {
|
|
373
|
+
return SigningResult.fromPartial(base ?? {});
|
|
374
|
+
},
|
|
375
|
+
fromPartial(object: DeepPartial<SigningResult>): SigningResult {
|
|
376
|
+
const message = createBaseSigningResult();
|
|
377
|
+
message.signatureShare = object.signatureShare ?? new Uint8Array(0);
|
|
378
|
+
return message;
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
function bytesFromBase64(b64: string): Uint8Array {
|
|
383
|
+
if ((globalThis as any).Buffer) {
|
|
384
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
385
|
+
} else {
|
|
386
|
+
const bin = globalThis.atob(b64);
|
|
387
|
+
const arr = new Uint8Array(bin.length);
|
|
388
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
389
|
+
arr[i] = bin.charCodeAt(i);
|
|
390
|
+
}
|
|
391
|
+
return arr;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function base64FromBytes(arr: Uint8Array): string {
|
|
396
|
+
if ((globalThis as any).Buffer) {
|
|
397
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
398
|
+
} else {
|
|
399
|
+
const bin: string[] = [];
|
|
400
|
+
arr.forEach((byte) => {
|
|
401
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
402
|
+
});
|
|
403
|
+
return globalThis.btoa(bin.join(""));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
408
|
+
|
|
409
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
410
|
+
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
|
411
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
412
|
+
: T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
|
|
413
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
414
|
+
: Partial<T>;
|
|
415
|
+
|
|
416
|
+
function isObject(value: any): boolean {
|
|
417
|
+
return typeof value === "object" && value !== null;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function isSet(value: any): boolean {
|
|
421
|
+
return value !== null && value !== undefined;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export interface MessageFns<T> {
|
|
425
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
426
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
427
|
+
fromJSON(object: any): T;
|
|
428
|
+
toJSON(message: T): unknown;
|
|
429
|
+
create(base?: DeepPartial<T>): T;
|
|
430
|
+
fromPartial(object: DeepPartial<T>): T;
|
|
431
|
+
}
|