@thruputchain/client 0.0.0-stage → 0.26.0
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/LICENSE +201 -0
- package/README.md +953 -2
- package/dist/actions-CXx6qzsv.cjs +513 -0
- package/dist/actions-CXx6qzsv.cjs.map +1 -0
- package/dist/actions-QHgiCqT6.js +430 -0
- package/dist/actions-QHgiCqT6.js.map +1 -0
- package/dist/actions.cjs +23 -0
- package/dist/actions.d.cts +4 -0
- package/dist/actions.d.ts +4 -0
- package/dist/actions.js +3 -0
- package/dist/artifact-BM_MVzhL.d.cts +35 -0
- package/dist/artifact-BM_MVzhL.d.cts.map +1 -0
- package/dist/artifact-BM_MVzhL.d.ts +35 -0
- package/dist/artifact-BM_MVzhL.d.ts.map +1 -0
- package/dist/client-JixxskeH.d.cts +746 -0
- package/dist/client-JixxskeH.d.cts.map +1 -0
- package/dist/client-JixxskeH.d.ts +746 -0
- package/dist/client-JixxskeH.d.ts.map +1 -0
- package/dist/codec-BHKoSaOP.js +9506 -0
- package/dist/codec-BHKoSaOP.js.map +1 -0
- package/dist/codec-C3OlYm98.cjs +9566 -0
- package/dist/codec-C3OlYm98.cjs.map +1 -0
- package/dist/contract-C7T2H2Oi.cjs +1628 -0
- package/dist/contract-C7T2H2Oi.cjs.map +1 -0
- package/dist/contract-DzvyyFCI.js +1472 -0
- package/dist/contract-DzvyyFCI.js.map +1 -0
- package/dist/contract.cjs +63 -0
- package/dist/contract.d.cts +4 -0
- package/dist/contract.d.ts +4 -0
- package/dist/contract.js +2 -0
- package/dist/contracts.cjs +1050 -0
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.d.cts +397 -0
- package/dist/contracts.d.cts.map +1 -0
- package/dist/contracts.d.ts +397 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +1030 -0
- package/dist/contracts.js.map +1 -0
- package/dist/dev_wallet-CSMA1PCt.js +497 -0
- package/dist/dev_wallet-CSMA1PCt.js.map +1 -0
- package/dist/dev_wallet-GX-NCAFk.cjs +530 -0
- package/dist/dev_wallet-GX-NCAFk.cjs.map +1 -0
- package/dist/domainSeparator-B_vU_zUD.cjs +102 -0
- package/dist/domainSeparator-B_vU_zUD.cjs.map +1 -0
- package/dist/domainSeparator-CBCvxIj-.js +79 -0
- package/dist/domainSeparator-CBCvxIj-.js.map +1 -0
- package/dist/execution-DYqPDn4O.d.cts +227 -0
- package/dist/execution-DYqPDn4O.d.cts.map +1 -0
- package/dist/execution-Dj6E4B_b.d.ts +227 -0
- package/dist/execution-Dj6E4B_b.d.ts.map +1 -0
- package/dist/hex-DIcaALXL.js +112 -0
- package/dist/hex-DIcaALXL.js.map +1 -0
- package/dist/hex-DkGpiZ5e.cjs +189 -0
- package/dist/hex-DkGpiZ5e.cjs.map +1 -0
- package/dist/index--5LsCotr.d.ts +192 -0
- package/dist/index--5LsCotr.d.ts.map +1 -0
- package/dist/index-1-rFirYe.d.cts +90 -0
- package/dist/index-1-rFirYe.d.cts.map +1 -0
- package/dist/index-B5KqSHeL.d.cts +192 -0
- package/dist/index-B5KqSHeL.d.cts.map +1 -0
- package/dist/index-BraLWObY.d.cts +164 -0
- package/dist/index-BraLWObY.d.cts.map +1 -0
- package/dist/index-ByNNqY7S.d.cts +83 -0
- package/dist/index-ByNNqY7S.d.cts.map +1 -0
- package/dist/index-ByvV2UF6.d.ts +164 -0
- package/dist/index-ByvV2UF6.d.ts.map +1 -0
- package/dist/index-CG2WRtGa.d.cts +164 -0
- package/dist/index-CG2WRtGa.d.cts.map +1 -0
- package/dist/index-CIHK7Ew9.d.cts +303 -0
- package/dist/index-CIHK7Ew9.d.cts.map +1 -0
- package/dist/index-CIHK7Ew9.d.ts +303 -0
- package/dist/index-CIHK7Ew9.d.ts.map +1 -0
- package/dist/index-CVrhB9Dr.d.cts +263 -0
- package/dist/index-CVrhB9Dr.d.cts.map +1 -0
- package/dist/index-D89ur7mO.d.ts +164 -0
- package/dist/index-D89ur7mO.d.ts.map +1 -0
- package/dist/index-DzrLv3EA.d.cts +82 -0
- package/dist/index-DzrLv3EA.d.cts.map +1 -0
- package/dist/index-DzrLv3EA.d.ts +82 -0
- package/dist/index-DzrLv3EA.d.ts.map +1 -0
- package/dist/index-SV-inhhO.d.ts +90 -0
- package/dist/index-SV-inhhO.d.ts.map +1 -0
- package/dist/index-dJ65V8se.d.ts +263 -0
- package/dist/index-dJ65V8se.d.ts.map +1 -0
- package/dist/index-fdTURpBk.d.ts +83 -0
- package/dist/index-fdTURpBk.d.ts.map +1 -0
- package/dist/index.cjs +445 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +174 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.cjs +101 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +2 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +76 -0
- package/dist/provider.js.map +1 -0
- package/dist/readError-AoNjzW75.cjs +604 -0
- package/dist/readError-AoNjzW75.cjs.map +1 -0
- package/dist/readError-CZPYcW__.js +551 -0
- package/dist/readError-CZPYcW__.js.map +1 -0
- package/dist/readViews-DJyqc7im.d.cts +604 -0
- package/dist/readViews-DJyqc7im.d.cts.map +1 -0
- package/dist/readViews-DQoaUORa.d.ts +604 -0
- package/dist/readViews-DQoaUORa.d.ts.map +1 -0
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/dist/sendInvocation-BwabRa2N.js +505 -0
- package/dist/sendInvocation-BwabRa2N.js.map +1 -0
- package/dist/sendInvocation-qO8AZcmU.cjs +661 -0
- package/dist/sendInvocation-qO8AZcmU.cjs.map +1 -0
- package/dist/sign-BewmV_EL.cjs +139 -0
- package/dist/sign-BewmV_EL.cjs.map +1 -0
- package/dist/sign-DVIRyW8Y.js +122 -0
- package/dist/sign-DVIRyW8Y.js.map +1 -0
- package/dist/sign-Ve0eetRO.d.ts +48 -0
- package/dist/sign-Ve0eetRO.d.ts.map +1 -0
- package/dist/sign-eUT0iGQG.d.cts +48 -0
- package/dist/sign-eUT0iGQG.d.cts.map +1 -0
- package/dist/signed-op.cjs +9 -0
- package/dist/signed-op.d.cts +3 -0
- package/dist/signed-op.d.ts +3 -0
- package/dist/signed-op.js +3 -0
- package/dist/signedOp-C52gOgpR.js +166 -0
- package/dist/signedOp-C52gOgpR.js.map +1 -0
- package/dist/signedOp-oqAXEqmE.cjs +183 -0
- package/dist/signedOp-oqAXEqmE.cjs.map +1 -0
- package/dist/signed_op-BokEDWr-.js +154 -0
- package/dist/signed_op-BokEDWr-.js.map +1 -0
- package/dist/signed_op-C4lY_TCc.d.ts +58 -0
- package/dist/signed_op-C4lY_TCc.d.ts.map +1 -0
- package/dist/signed_op-DX5WuyEh.d.cts +58 -0
- package/dist/signed_op-DX5WuyEh.d.cts.map +1 -0
- package/dist/signed_op-q8KKSm5e.cjs +175 -0
- package/dist/signed_op-q8KKSm5e.cjs.map +1 -0
- package/dist/signers-BFP84wJP.cjs +137 -0
- package/dist/signers-BFP84wJP.cjs.map +1 -0
- package/dist/signers-CzOSedwJ.js +120 -0
- package/dist/signers-CzOSedwJ.js.map +1 -0
- package/dist/signers.cjs +5 -0
- package/dist/signers.d.cts +3 -0
- package/dist/signers.d.ts +3 -0
- package/dist/signers.js +2 -0
- package/dist/size-506oTE28.js +91 -0
- package/dist/size-506oTE28.js.map +1 -0
- package/dist/size-OAFfOthl.cjs +108 -0
- package/dist/size-OAFfOthl.cjs.map +1 -0
- package/dist/transaction-CwkQxQOx.js +24 -0
- package/dist/transaction-CwkQxQOx.js.map +1 -0
- package/dist/transaction-DrSrCJ5y.cjs +47 -0
- package/dist/transaction-DrSrCJ5y.cjs.map +1 -0
- package/dist/transaction.cjs +13 -0
- package/dist/transaction.d.cts +3 -0
- package/dist/transaction.d.ts +3 -0
- package/dist/transaction.js +4 -0
- package/dist/transactionHash-CO9ajbvU.js +24 -0
- package/dist/transactionHash-CO9ajbvU.js.map +1 -0
- package/dist/transactionHash-D5yf4KoL.cjs +29 -0
- package/dist/transactionHash-D5yf4KoL.cjs.map +1 -0
- package/dist/transport-CBFwAIIv.js +261 -0
- package/dist/transport-CBFwAIIv.js.map +1 -0
- package/dist/transport-tWxKhXUt.cjs +279 -0
- package/dist/transport-tWxKhXUt.cjs.map +1 -0
- package/dist/transport.cjs +19 -0
- package/dist/transport.d.cts +3 -0
- package/dist/transport.d.ts +3 -0
- package/dist/transport.js +4 -0
- package/dist/types-BE40oD_Q.d.cts +18 -0
- package/dist/types-BE40oD_Q.d.cts.map +1 -0
- package/dist/types-BE40oD_Q.d.ts +18 -0
- package/dist/types-BE40oD_Q.d.ts.map +1 -0
- package/dist/validation-4w-vDGAi.cjs +543 -0
- package/dist/validation-4w-vDGAi.cjs.map +1 -0
- package/dist/validation-eXATmgO0.js +411 -0
- package/dist/validation-eXATmgO0.js.map +1 -0
- package/dist/wallet-7RELuTkf.js +667 -0
- package/dist/wallet-7RELuTkf.js.map +1 -0
- package/dist/wallet-T_JazXRc.cjs +709 -0
- package/dist/wallet-T_JazXRc.cjs.map +1 -0
- package/dist/wallet.cjs +27 -0
- package/dist/wallet.d.cts +3 -0
- package/dist/wallet.d.ts +3 -0
- package/dist/wallet.js +3 -0
- package/package.json +122 -4
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { r as SIGNED_OP } from "./domainSeparator-CBCvxIj-.js";
|
|
2
|
+
import { g as createContractCodecContext, h as createContractCodec, j as formatSpecId } from "./contract-DzvyyFCI.js";
|
|
3
|
+
import "./signed_op-BokEDWr-.js";
|
|
4
|
+
import { CryptographicScheme, CxsWriter, blockHeight, codec, ed25519Signature } from "@thruputchain/protocol";
|
|
5
|
+
import { ContractTypeDefKind, ContractTypeKind, codec as codec$1 } from "@thruputchain/contract-spec";
|
|
6
|
+
import { randomBytes } from "@noble/hashes/utils.js";
|
|
7
|
+
//#region src/signedOp/preimage.ts
|
|
8
|
+
/**
|
|
9
|
+
* The message a signed-operation signature covers:
|
|
10
|
+
*
|
|
11
|
+
* ```text
|
|
12
|
+
* cxs(DomainSeparator("SignedOp")) || network || verifyingContract
|
|
13
|
+
* || cxs(typeDef) || cxs(uniquifier) || body
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the
|
|
17
|
+
* chain's own `Uniquifier` encoding, so the replay pair is spelled the way a
|
|
18
|
+
* transaction spells its own. The result is signed directly, like
|
|
19
|
+
* {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must
|
|
20
|
+
* match the Rust `thruput_domain_separator::SignedOp::preimage` byte for
|
|
21
|
+
* byte, or the verifying contract rejects the signature. Only the first 74
|
|
22
|
+
* bytes are fixed-width: the uniquifier's two fields are CXS varints.
|
|
23
|
+
*
|
|
24
|
+
* {@link defineSignedOperation} calls this after encoding the payload; reach
|
|
25
|
+
* for it directly only when the payload is already CXS bytes.
|
|
26
|
+
*/
|
|
27
|
+
function signedOperationPreimage(preimage) {
|
|
28
|
+
const writer = new CxsWriter();
|
|
29
|
+
writer.writeFixedOpaque(preimage.network, 32);
|
|
30
|
+
writer.writeFixedOpaque(preimage.verifyingContract, 32);
|
|
31
|
+
codec$1.ContractTypeDef.encode(writer, preimage.typeDef);
|
|
32
|
+
codec.Uniquifier.encode(writer, {
|
|
33
|
+
block_expiry_height: preimage.blockExpiryHeight,
|
|
34
|
+
nonce: preimage.nonce
|
|
35
|
+
});
|
|
36
|
+
writer.writeFixedOpaque(preimage.body, preimage.body.length);
|
|
37
|
+
const payload = writer.finish();
|
|
38
|
+
const prefix = SIGNED_OP.bytes;
|
|
39
|
+
const message = new Uint8Array(prefix.length + payload.length);
|
|
40
|
+
message.set(prefix, 0);
|
|
41
|
+
message.set(payload, prefix.length);
|
|
42
|
+
return message;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/signedOp/operation.ts
|
|
46
|
+
/**
|
|
47
|
+
* A uniformly random `u64` for {@link Operation.nonce}.
|
|
48
|
+
*
|
|
49
|
+
* Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying
|
|
50
|
+
* contract, not to the signing key, so a random nonce is the choice that
|
|
51
|
+
* stays safe when several keys sign for one contract; a lone key may count
|
|
52
|
+
* instead. Draws from the platform's `crypto.getRandomValues`.
|
|
53
|
+
*/
|
|
54
|
+
function randomNonce() {
|
|
55
|
+
let nonce = 0n;
|
|
56
|
+
for (const byte of randomBytes(8)) nonce = nonce << 8n | BigInt(byte);
|
|
57
|
+
return nonce;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Bind signing helpers to a `#[contract_type]` payload.
|
|
61
|
+
*
|
|
62
|
+
* A signed operation authorizes an on-chain action off-chain, so the signer
|
|
63
|
+
* need not submit the transaction: the pattern behind permits, session keys,
|
|
64
|
+
* and delegated wallet actions. The verifying contract embeds
|
|
65
|
+
* `thruput_signed_op::SignedOpReplayCache` and checks the operation with
|
|
66
|
+
* `consume::<Payload>` against the key it holds; this is the client half,
|
|
67
|
+
* producing the `Operation` and signature that contract expects.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import {
|
|
72
|
+
* defineSignedOperation,
|
|
73
|
+
* randomNonce,
|
|
74
|
+
* } from "@thruputchain/client/signed-op";
|
|
75
|
+
* import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
|
|
76
|
+
*
|
|
77
|
+
* const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
|
|
78
|
+
* typeDefs: spec.type_defs,
|
|
79
|
+
* typeName: "Transfer",
|
|
80
|
+
* });
|
|
81
|
+
* const { op, signature } = await transfer.sign(signer, {
|
|
82
|
+
* network: networkHash,
|
|
83
|
+
* verifyingContract: walletAddress,
|
|
84
|
+
* blockExpiryHeight: currentHeight + 100n,
|
|
85
|
+
* nonce: randomNonce(),
|
|
86
|
+
* body: { to: recipient, amount: 42n },
|
|
87
|
+
* });
|
|
88
|
+
* // `op` and `signature` are the arguments of the contract's submit entrypoint.
|
|
89
|
+
* const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
|
|
90
|
+
* op,
|
|
91
|
+
* signature,
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @throws If `typeName` selects none, or more than one, of `typeDefs`.
|
|
96
|
+
*/
|
|
97
|
+
function defineSignedOperation(options) {
|
|
98
|
+
const typeDefs = structuredClone([...options.typeDefs]);
|
|
99
|
+
const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));
|
|
100
|
+
const id = typeDefId(typeDef);
|
|
101
|
+
const bodyCodec = createContractCodec(createContractCodecContext(typeDefs), {
|
|
102
|
+
v: ContractTypeKind.Named,
|
|
103
|
+
named: id
|
|
104
|
+
}, `${formatSpecId(id)} payload`);
|
|
105
|
+
const preimageOf = (request, blockExpiryHeight, nonce, body) => signedOperationPreimage({
|
|
106
|
+
network: request.network,
|
|
107
|
+
verifyingContract: request.verifyingContract,
|
|
108
|
+
typeDef,
|
|
109
|
+
blockExpiryHeight: blockHeight(blockExpiryHeight),
|
|
110
|
+
nonce,
|
|
111
|
+
body
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
typeName: id.declared,
|
|
115
|
+
typeDef,
|
|
116
|
+
encodeBody: (body) => bodyCodec.encode(body),
|
|
117
|
+
preimage: (request) => preimageOf(request, request.blockExpiryHeight, request.nonce, bodyCodec.encode(request.body)),
|
|
118
|
+
async sign(signer, request) {
|
|
119
|
+
if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) throw new Error("Signed operations require an Ed25519 signer");
|
|
120
|
+
const blockExpiryHeight = request.blockExpiryHeight;
|
|
121
|
+
const nonce = request.nonce;
|
|
122
|
+
const body = bodyCodec.encode(request.body);
|
|
123
|
+
const message = preimageOf(request, blockExpiryHeight, nonce, body);
|
|
124
|
+
const signature = await signer.sign(message);
|
|
125
|
+
if (signature.scheme !== CryptographicScheme.Ed25519) throw new Error("Signer did not return an Ed25519 signature");
|
|
126
|
+
return {
|
|
127
|
+
op: {
|
|
128
|
+
block_expiry_height: blockExpiryHeight,
|
|
129
|
+
nonce,
|
|
130
|
+
body
|
|
131
|
+
},
|
|
132
|
+
signature: ed25519Signature(new Uint8Array(signature.ed25519))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function deepFreeze(value) {
|
|
138
|
+
if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
|
|
139
|
+
Object.freeze(value);
|
|
140
|
+
for (const inner of Object.values(value)) deepFreeze(inner);
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
function typeDefId(typeDef) {
|
|
145
|
+
switch (typeDef.v) {
|
|
146
|
+
case ContractTypeDefKind.TypeDefStruct: return typeDef.struct_def.name;
|
|
147
|
+
case ContractTypeDefKind.TypeDefEnum: return typeDef.enum_def.name;
|
|
148
|
+
case ContractTypeDefKind.TypeDefUnion: return typeDef.union_def.name;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function findTypeDef(typeDefs, selector) {
|
|
152
|
+
const selects = typeof selector === "string" ? (id) => id.declared === selector : (id) => id.crate_name === selector.crate_name && id.major === selector.major && id.module_path === selector.module_path && id.declared === selector.declared;
|
|
153
|
+
const label = typeof selector === "string" ? `"${selector}"` : formatSpecId(selector);
|
|
154
|
+
const matches = typeDefs.filter((def) => selects(typeDefId(def)));
|
|
155
|
+
const [typeDef] = matches;
|
|
156
|
+
if (typeDef === void 0) throw new Error(`Contract type ${label} is not defined in the given type definitions`);
|
|
157
|
+
if (matches.length > 1) {
|
|
158
|
+
const ids = matches.map((def) => formatSpecId(typeDefId(def)));
|
|
159
|
+
throw new Error(`Contract type ${label} is ambiguous in the given type definitions: ${ids.join(", ")}; select one by its full spec id`);
|
|
160
|
+
}
|
|
161
|
+
return typeDef;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { randomNonce as n, signedOperationPreimage as r, defineSignedOperation as t };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=signedOp-C52gOgpR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signedOp-C52gOgpR.js","names":[],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typeDef;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UACY;CACZ,MAAM,SAAS,IAAI,UAAU;CAC7B,OAAO,iBAAiB,SAAS,SAAS,EAAE;CAC5C,OAAO,iBAAiB,SAAS,mBAAmB,EAAE;CACtD,QAAkB,gBAAgB,OAAO,QAAQ,SAAS,OAAO;CACjE,MAAM,WAAW,OAAO,QAAQ;EAC9B,qBAAqB,SAAS;EAC9B,OAAO,SAAS;CAClB,CAAC;CACD,OAAO,iBAAiB,SAAS,MAAM,SAAS,KAAK,MAAM;CAC3D,MAAM,UAAU,OAAO,OAAO;CAE9B,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T"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const require_domainSeparator = require("./domainSeparator-B_vU_zUD.cjs");
|
|
2
|
+
const require_contract = require("./contract-C7T2H2Oi.cjs");
|
|
3
|
+
require("./signed_op-q8KKSm5e.cjs");
|
|
4
|
+
let _thruputchain_protocol = require("@thruputchain/protocol");
|
|
5
|
+
let _thruputchain_contract_spec = require("@thruputchain/contract-spec");
|
|
6
|
+
let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
|
|
7
|
+
//#region src/signedOp/preimage.ts
|
|
8
|
+
/**
|
|
9
|
+
* The message a signed-operation signature covers:
|
|
10
|
+
*
|
|
11
|
+
* ```text
|
|
12
|
+
* cxs(DomainSeparator("SignedOp")) || network || verifyingContract
|
|
13
|
+
* || cxs(typeDef) || cxs(uniquifier) || body
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the
|
|
17
|
+
* chain's own `Uniquifier` encoding, so the replay pair is spelled the way a
|
|
18
|
+
* transaction spells its own. The result is signed directly, like
|
|
19
|
+
* {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must
|
|
20
|
+
* match the Rust `thruput_domain_separator::SignedOp::preimage` byte for
|
|
21
|
+
* byte, or the verifying contract rejects the signature. Only the first 74
|
|
22
|
+
* bytes are fixed-width: the uniquifier's two fields are CXS varints.
|
|
23
|
+
*
|
|
24
|
+
* {@link defineSignedOperation} calls this after encoding the payload; reach
|
|
25
|
+
* for it directly only when the payload is already CXS bytes.
|
|
26
|
+
*/
|
|
27
|
+
function signedOperationPreimage(preimage) {
|
|
28
|
+
const writer = new _thruputchain_protocol.CxsWriter();
|
|
29
|
+
writer.writeFixedOpaque(preimage.network, 32);
|
|
30
|
+
writer.writeFixedOpaque(preimage.verifyingContract, 32);
|
|
31
|
+
_thruputchain_contract_spec.codec.ContractTypeDef.encode(writer, preimage.typeDef);
|
|
32
|
+
_thruputchain_protocol.codec.Uniquifier.encode(writer, {
|
|
33
|
+
block_expiry_height: preimage.blockExpiryHeight,
|
|
34
|
+
nonce: preimage.nonce
|
|
35
|
+
});
|
|
36
|
+
writer.writeFixedOpaque(preimage.body, preimage.body.length);
|
|
37
|
+
const payload = writer.finish();
|
|
38
|
+
const prefix = require_domainSeparator.SIGNED_OP.bytes;
|
|
39
|
+
const message = new Uint8Array(prefix.length + payload.length);
|
|
40
|
+
message.set(prefix, 0);
|
|
41
|
+
message.set(payload, prefix.length);
|
|
42
|
+
return message;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/signedOp/operation.ts
|
|
46
|
+
/**
|
|
47
|
+
* A uniformly random `u64` for {@link Operation.nonce}.
|
|
48
|
+
*
|
|
49
|
+
* Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying
|
|
50
|
+
* contract, not to the signing key, so a random nonce is the choice that
|
|
51
|
+
* stays safe when several keys sign for one contract; a lone key may count
|
|
52
|
+
* instead. Draws from the platform's `crypto.getRandomValues`.
|
|
53
|
+
*/
|
|
54
|
+
function randomNonce() {
|
|
55
|
+
let nonce = 0n;
|
|
56
|
+
for (const byte of (0, _noble_hashes_utils_js.randomBytes)(8)) nonce = nonce << 8n | BigInt(byte);
|
|
57
|
+
return nonce;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Bind signing helpers to a `#[contract_type]` payload.
|
|
61
|
+
*
|
|
62
|
+
* A signed operation authorizes an on-chain action off-chain, so the signer
|
|
63
|
+
* need not submit the transaction: the pattern behind permits, session keys,
|
|
64
|
+
* and delegated wallet actions. The verifying contract embeds
|
|
65
|
+
* `thruput_signed_op::SignedOpReplayCache` and checks the operation with
|
|
66
|
+
* `consume::<Payload>` against the key it holds; this is the client half,
|
|
67
|
+
* producing the `Operation` and signature that contract expects.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import {
|
|
72
|
+
* defineSignedOperation,
|
|
73
|
+
* randomNonce,
|
|
74
|
+
* } from "@thruputchain/client/signed-op";
|
|
75
|
+
* import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
|
|
76
|
+
*
|
|
77
|
+
* const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
|
|
78
|
+
* typeDefs: spec.type_defs,
|
|
79
|
+
* typeName: "Transfer",
|
|
80
|
+
* });
|
|
81
|
+
* const { op, signature } = await transfer.sign(signer, {
|
|
82
|
+
* network: networkHash,
|
|
83
|
+
* verifyingContract: walletAddress,
|
|
84
|
+
* blockExpiryHeight: currentHeight + 100n,
|
|
85
|
+
* nonce: randomNonce(),
|
|
86
|
+
* body: { to: recipient, amount: 42n },
|
|
87
|
+
* });
|
|
88
|
+
* // `op` and `signature` are the arguments of the contract's submit entrypoint.
|
|
89
|
+
* const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
|
|
90
|
+
* op,
|
|
91
|
+
* signature,
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @throws If `typeName` selects none, or more than one, of `typeDefs`.
|
|
96
|
+
*/
|
|
97
|
+
function defineSignedOperation(options) {
|
|
98
|
+
const typeDefs = structuredClone([...options.typeDefs]);
|
|
99
|
+
const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));
|
|
100
|
+
const id = typeDefId(typeDef);
|
|
101
|
+
const bodyCodec = require_contract.createContractCodec(require_contract.createContractCodecContext(typeDefs), {
|
|
102
|
+
v: _thruputchain_contract_spec.ContractTypeKind.Named,
|
|
103
|
+
named: id
|
|
104
|
+
}, `${require_contract.formatSpecId(id)} payload`);
|
|
105
|
+
const preimageOf = (request, blockExpiryHeight, nonce, body) => signedOperationPreimage({
|
|
106
|
+
network: request.network,
|
|
107
|
+
verifyingContract: request.verifyingContract,
|
|
108
|
+
typeDef,
|
|
109
|
+
blockExpiryHeight: (0, _thruputchain_protocol.blockHeight)(blockExpiryHeight),
|
|
110
|
+
nonce,
|
|
111
|
+
body
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
typeName: id.declared,
|
|
115
|
+
typeDef,
|
|
116
|
+
encodeBody: (body) => bodyCodec.encode(body),
|
|
117
|
+
preimage: (request) => preimageOf(request, request.blockExpiryHeight, request.nonce, bodyCodec.encode(request.body)),
|
|
118
|
+
async sign(signer, request) {
|
|
119
|
+
if (signer.publicKey.scheme !== _thruputchain_protocol.CryptographicScheme.Ed25519) throw new Error("Signed operations require an Ed25519 signer");
|
|
120
|
+
const blockExpiryHeight = request.blockExpiryHeight;
|
|
121
|
+
const nonce = request.nonce;
|
|
122
|
+
const body = bodyCodec.encode(request.body);
|
|
123
|
+
const message = preimageOf(request, blockExpiryHeight, nonce, body);
|
|
124
|
+
const signature = await signer.sign(message);
|
|
125
|
+
if (signature.scheme !== _thruputchain_protocol.CryptographicScheme.Ed25519) throw new Error("Signer did not return an Ed25519 signature");
|
|
126
|
+
return {
|
|
127
|
+
op: {
|
|
128
|
+
block_expiry_height: blockExpiryHeight,
|
|
129
|
+
nonce,
|
|
130
|
+
body
|
|
131
|
+
},
|
|
132
|
+
signature: (0, _thruputchain_protocol.ed25519Signature)(new Uint8Array(signature.ed25519))
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function deepFreeze(value) {
|
|
138
|
+
if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
|
|
139
|
+
Object.freeze(value);
|
|
140
|
+
for (const inner of Object.values(value)) deepFreeze(inner);
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
function typeDefId(typeDef) {
|
|
145
|
+
switch (typeDef.v) {
|
|
146
|
+
case _thruputchain_contract_spec.ContractTypeDefKind.TypeDefStruct: return typeDef.struct_def.name;
|
|
147
|
+
case _thruputchain_contract_spec.ContractTypeDefKind.TypeDefEnum: return typeDef.enum_def.name;
|
|
148
|
+
case _thruputchain_contract_spec.ContractTypeDefKind.TypeDefUnion: return typeDef.union_def.name;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function findTypeDef(typeDefs, selector) {
|
|
152
|
+
const selects = typeof selector === "string" ? (id) => id.declared === selector : (id) => id.crate_name === selector.crate_name && id.major === selector.major && id.module_path === selector.module_path && id.declared === selector.declared;
|
|
153
|
+
const label = typeof selector === "string" ? `"${selector}"` : require_contract.formatSpecId(selector);
|
|
154
|
+
const matches = typeDefs.filter((def) => selects(typeDefId(def)));
|
|
155
|
+
const [typeDef] = matches;
|
|
156
|
+
if (typeDef === void 0) throw new Error(`Contract type ${label} is not defined in the given type definitions`);
|
|
157
|
+
if (matches.length > 1) {
|
|
158
|
+
const ids = matches.map((def) => require_contract.formatSpecId(typeDefId(def)));
|
|
159
|
+
throw new Error(`Contract type ${label} is ambiguous in the given type definitions: ${ids.join(", ")}; select one by its full spec id`);
|
|
160
|
+
}
|
|
161
|
+
return typeDef;
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
Object.defineProperty(exports, "defineSignedOperation", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return defineSignedOperation;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, "randomNonce", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function() {
|
|
173
|
+
return randomNonce;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "signedOperationPreimage", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function() {
|
|
179
|
+
return signedOperationPreimage;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
//# sourceMappingURL=signedOp-oqAXEqmE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signedOp-oqAXEqmE.cjs","names":["CxsWriter","SIGNED_OP","createContractCodec","createContractCodecContext","ContractTypeKind","formatSpecId","CryptographicScheme","ContractTypeDefKind"],"sources":["../src/signedOp/preimage.ts","../src/signedOp/operation.ts"],"sourcesContent":["import type {\n BlockHeight,\n ContractAddress,\n NetworkHash,\n} from \"@thruputchain/protocol\";\nimport { CxsWriter, codec } from \"@thruputchain/protocol\";\nimport {\n codec as contractSpecCodec,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport { SIGNED_OP } from \"../derivation/domainSeparator.js\";\n\n/** Everything a signed-operation signature commits to. */\nexport interface SignedOperationPreimage {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract entitled to act on the operation. */\n readonly verifyingContract: ContractAddress;\n /**\n * Spec definition of the payload type, as a generated binding ships it in\n * `spec.type_defs`. Part of the signed bytes, so a signature over one\n * payload type is never a signature over another with the same encoding.\n */\n readonly typeDef: ContractTypeDef;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: BlockHeight;\n /**\n * Signer-chosen value that, with `blockExpiryHeight`, the verifying\n * contract consumes exactly once.\n */\n readonly nonce: bigint;\n /** CXS encoding of the payload value. */\n readonly body: Uint8Array;\n}\n\n/**\n * The message a signed-operation signature covers:\n *\n * ```text\n * cxs(DomainSeparator(\"SignedOp\")) || network || verifyingContract\n * || cxs(typeDef) || cxs(uniquifier) || body\n * ```\n *\n * where `cxs(uniquifier)` is `cxs(blockExpiryHeight) || cxs(nonce)`: the\n * chain's own `Uniquifier` encoding, so the replay pair is spelled the way a\n * transaction spells its own. The result is signed directly, like\n * {@link transactionSignaturePreimage}; Ed25519 does its own hashing. It must\n * match the Rust `thruput_domain_separator::SignedOp::preimage` byte for\n * byte, or the verifying contract rejects the signature. Only the first 74\n * bytes are fixed-width: the uniquifier's two fields are CXS varints.\n *\n * {@link defineSignedOperation} calls this after encoding the payload; reach\n * for it directly only when the payload is already CXS bytes.\n */\nexport function signedOperationPreimage(\n preimage: SignedOperationPreimage,\n): Uint8Array {\n const writer = new CxsWriter();\n writer.writeFixedOpaque(preimage.network, 32);\n writer.writeFixedOpaque(preimage.verifyingContract, 32);\n contractSpecCodec.ContractTypeDef.encode(writer, preimage.typeDef);\n codec.Uniquifier.encode(writer, {\n block_expiry_height: preimage.blockExpiryHeight,\n nonce: preimage.nonce,\n });\n writer.writeFixedOpaque(preimage.body, preimage.body.length);\n const payload = writer.finish();\n\n const prefix = SIGNED_OP.bytes;\n const message = new Uint8Array(prefix.length + payload.length);\n message.set(prefix, 0);\n message.set(payload, prefix.length);\n return message;\n}\n","import type { ContractAddress, NetworkHash } from \"@thruputchain/protocol\";\nimport {\n CryptographicScheme,\n blockHeight,\n ed25519Signature,\n} from \"@thruputchain/protocol\";\nimport {\n ContractTypeDefKind,\n ContractTypeKind,\n type ContractSpecId,\n type ContractTypeDef,\n} from \"@thruputchain/contract-spec\";\nimport type { FixedBytes } from \"@thruputchain/xdr\";\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n createContractCodec,\n createContractCodecContext,\n} from \"../contract/codec.js\";\nimport { formatSpecId } from \"../contract/spec.js\";\nimport type { Signer } from \"../signers/types.js\";\nimport { signedOperationPreimage } from \"./preimage.js\";\n\n/**\n * Wire form of a signed operation: the `Operation` struct of the\n * `thruput-signed-op-if` interface, in the shape generated bindings give it.\n *\n * The network hash, the verifying contract, and the signing key are covered\n * by the signature but deliberately absent here. The verifying contract\n * supplies the first two from its own syscalls and checks the signature\n * against the key it holds, so a submitter can name neither the network or\n * contract a signature was meant for nor the key it is checked against.\n *\n * `block_expiry_height` and `nonce` are the chain's `Uniquifier`, in its\n * field order, so their encoding is byte for byte a transaction's.\n */\nexport interface Operation {\n /** Last block height (inclusive) at which the operation may execute. */\n block_expiry_height: bigint;\n /**\n * Chosen by the signer: any value, as long as the pair\n * `(nonce, block_expiry_height)` has not been consumed at the verifying\n * contract. There is no ordering. Consumed pairs are the contract's, not\n * the key's, so where several keys sign for one contract, draw nonces at\n * random ({@link randomNonce}) rather than counting; a lone key may do\n * either.\n */\n nonce: bigint;\n /** CXS encoding of the payload value. */\n body: Uint8Array;\n}\n\n/** An {@link Operation} and the Ed25519 signature over its preimage. */\nexport interface SignedOperation {\n readonly op: Operation;\n readonly signature: FixedBytes<64>;\n}\n\n/** What a signer supplies to produce one operation. */\nexport interface SignedOperationRequest<TBody> {\n /** Hash of the network the operation is valid on. */\n readonly network: NetworkHash;\n /** Address of the contract that will verify and act on the operation. */\n readonly verifyingContract: ContractAddress;\n /** Last block height (inclusive) at which the operation may execute. */\n readonly blockExpiryHeight: bigint;\n /**\n * Signer-chosen replay guard; see {@link Operation.nonce}. Nothing on\n * chain needs reading to pick one: {@link randomNonce} is always safe.\n */\n readonly nonce: bigint;\n /** The payload value, in the field shape generated bindings use. */\n readonly body: TBody;\n}\n\n/** Signing helpers bound to one payload type. */\nexport interface SignedOperationType<TBody> {\n /**\n * Declared name of the payload type: the `declared` segment of its spec id.\n * {@link SignedOperationType.typeDef} carries the full id.\n */\n readonly typeName: string;\n /** The payload type's spec definition, as bound into every preimage. */\n readonly typeDef: ContractTypeDef;\n /** CXS-encode a payload value the way the contract decodes it. */\n encodeBody(body: TBody): Uint8Array;\n /** The bytes a signature over `request` covers. */\n preimage(request: SignedOperationRequest<TBody>): Uint8Array;\n /** Encode, sign, and package `request` for the verifying contract. */\n sign(\n signer: Signer,\n request: SignedOperationRequest<TBody>,\n ): Promise<SignedOperation>;\n}\n\n/** Options for {@link defineSignedOperation}. */\nexport interface DefineSignedOperationOptions {\n /**\n * Type definitions the payload type is resolved against: a generated\n * binding's `spec.type_defs`, which carries the payload type and every type\n * it references.\n */\n readonly typeDefs: readonly ContractTypeDef[];\n /**\n * The payload type: either its name as declared with `#[contract_type]`\n * (the `declared` segment of its spec id), which must name exactly one of\n * `typeDefs`, or its full spec id, which selects one type even when another\n * crate or module declares the same name.\n */\n readonly typeName: string | ContractTypeSelector;\n}\n\n/**\n * Every segment of a payload type's spec id, as plain strings. A\n * `ContractSpecId` taken from a generated spec is assignable to it.\n */\nexport interface ContractTypeSelector {\n readonly crate_name: string;\n readonly major: string;\n readonly module_path: string;\n readonly declared: string;\n}\n\n/**\n * A uniformly random `u64` for {@link Operation.nonce}.\n *\n * Consumed `(nonce, block_expiry_height)` pairs are scoped to the verifying\n * contract, not to the signing key, so a random nonce is the choice that\n * stays safe when several keys sign for one contract; a lone key may count\n * instead. Draws from the platform's `crypto.getRandomValues`.\n */\nexport function randomNonce(): bigint {\n let nonce = 0n;\n for (const byte of randomBytes(8)) {\n nonce = (nonce << 8n) | BigInt(byte);\n }\n return nonce;\n}\n\n/**\n * Bind signing helpers to a `#[contract_type]` payload.\n *\n * A signed operation authorizes an on-chain action off-chain, so the signer\n * need not submit the transaction: the pattern behind permits, session keys,\n * and delegated wallet actions. The verifying contract embeds\n * `thruput_signed_op::SignedOpReplayCache` and checks the operation with\n * `consume::<Payload>` against the key it holds; this is the client half,\n * producing the `Operation` and signature that contract expects.\n *\n * @example\n * ```ts\n * import {\n * defineSignedOperation,\n * randomNonce,\n * } from \"@thruputchain/client/signed-op\";\n * import { spec, MyWallet, type my_wallet } from \"./generated/my_wallet.js\";\n *\n * const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({\n * typeDefs: spec.type_defs,\n * typeName: \"Transfer\",\n * });\n * const { op, signature } = await transfer.sign(signer, {\n * network: networkHash,\n * verifyingContract: walletAddress,\n * blockExpiryHeight: currentHeight + 100n,\n * nonce: randomNonce(),\n * body: { to: recipient, amount: 42n },\n * });\n * // `op` and `signature` are the arguments of the contract's submit entrypoint.\n * const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {\n * op,\n * signature,\n * });\n * ```\n *\n * @throws If `typeName` selects none, or more than one, of `typeDefs`.\n */\nexport function defineSignedOperation<TBody>(\n options: DefineSignedOperationOptions,\n): SignedOperationType<TBody> {\n // Snapshot once: the codec context clones what it is given, so the\n // definition bound into every preimage must come from the same frozen copy\n // or a later mutation of the caller's array would split the two.\n const typeDefs = structuredClone([...options.typeDefs]);\n const typeDef = deepFreeze(findTypeDef(typeDefs, options.typeName));\n const id = typeDefId(typeDef);\n const context = createContractCodecContext(typeDefs);\n const bodyCodec = createContractCodec<TBody>(\n context,\n { v: ContractTypeKind.Named, named: id },\n `${formatSpecId(id)} payload`,\n );\n\n const preimageOf = (\n request: SignedOperationRequest<TBody>,\n blockExpiryHeight: bigint,\n nonce: bigint,\n body: Uint8Array,\n ): Uint8Array =>\n signedOperationPreimage({\n network: request.network,\n verifyingContract: request.verifyingContract,\n typeDef,\n blockExpiryHeight: blockHeight(blockExpiryHeight),\n nonce,\n body,\n });\n\n return {\n typeName: id.declared,\n typeDef,\n encodeBody: (body) => bodyCodec.encode(body),\n preimage: (request) =>\n preimageOf(\n request,\n request.blockExpiryHeight,\n request.nonce,\n bodyCodec.encode(request.body),\n ),\n async sign(signer, request) {\n if (signer.publicKey.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signed operations require an Ed25519 signer\");\n }\n // Everything the returned operation carries is taken before the signer\n // is awaited, so a request mutated while a wallet prompt is pending\n // cannot make the operation disagree with the message that was signed.\n // The signature bytes are copied for the same reason, and the\n // constructor rejects any length but the 64 the wire struct's fixed\n // array encodes.\n const blockExpiryHeight = request.blockExpiryHeight;\n const nonce = request.nonce;\n const body = bodyCodec.encode(request.body);\n const message = preimageOf(request, blockExpiryHeight, nonce, body);\n const signature = await signer.sign(message);\n if (signature.scheme !== CryptographicScheme.Ed25519) {\n throw new Error(\"Signer did not return an Ed25519 signature\");\n }\n return {\n op: { block_expiry_height: blockExpiryHeight, nonce, body },\n signature: ed25519Signature(new Uint8Array(signature.ed25519)),\n };\n },\n };\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null && !Object.isFrozen(value)) {\n Object.freeze(value);\n for (const inner of Object.values(value as object)) {\n deepFreeze(inner);\n }\n }\n return value;\n}\n\nfunction typeDefId(typeDef: ContractTypeDef): ContractSpecId {\n switch (typeDef.v) {\n case ContractTypeDefKind.TypeDefStruct:\n return typeDef.struct_def.name;\n case ContractTypeDefKind.TypeDefEnum:\n return typeDef.enum_def.name;\n case ContractTypeDefKind.TypeDefUnion:\n return typeDef.union_def.name;\n }\n}\n\nfunction findTypeDef(\n typeDefs: readonly ContractTypeDef[],\n selector: string | ContractTypeSelector,\n): ContractTypeDef {\n const selects =\n typeof selector === \"string\"\n ? (id: ContractSpecId) => id.declared === selector\n : (id: ContractSpecId) =>\n id.crate_name === selector.crate_name &&\n id.major === selector.major &&\n id.module_path === selector.module_path &&\n id.declared === selector.declared;\n const label =\n typeof selector === \"string\" ? `\"${selector}\"` : formatSpecId(selector);\n const matches = typeDefs.filter((def) => selects(typeDefId(def)));\n const [typeDef] = matches;\n if (typeDef === undefined) {\n throw new Error(\n `Contract type ${label} is not defined in the given type definitions`,\n );\n }\n if (matches.length > 1) {\n const ids = matches.map((def) => formatSpecId(typeDefId(def)));\n throw new Error(\n `Contract type ${label} is ambiguous in the given type definitions: ${ids.join(\", \")}; select one by its full spec id`,\n );\n }\n return typeDef;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,wBACd,UACY;CACZ,MAAM,SAAS,IAAIA,uBAAAA,UAAU;CAC7B,OAAO,iBAAiB,SAAS,SAAS,EAAE;CAC5C,OAAO,iBAAiB,SAAS,mBAAmB,EAAE;CACtD,4BAAA,MAAkB,gBAAgB,OAAO,QAAQ,SAAS,OAAO;CACjE,uBAAA,MAAM,WAAW,OAAO,QAAQ;EAC9B,qBAAqB,SAAS;EAC9B,OAAO,SAAS;CAClB,CAAC;CACD,OAAO,iBAAiB,SAAS,MAAM,SAAS,KAAK,MAAM;CAC3D,MAAM,UAAU,OAAO,OAAO;CAE9B,MAAM,SAASC,wBAAAA,UAAU;CACzB,MAAM,UAAU,IAAI,WAAW,OAAO,SAAS,QAAQ,MAAM;CAC7D,QAAQ,IAAI,QAAQ,CAAC;CACrB,QAAQ,IAAI,SAAS,OAAO,MAAM;CAClC,OAAO;AACT;;;;;;;;;;;ACyDA,SAAgB,cAAsB;CACpC,IAA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
import { g as createContractCodecContext, m as defineContractMethod } from "./contract-DzvyyFCI.js";
|
|
2
|
+
import * as __gh_protocol from "@thruputchain/protocol";
|
|
3
|
+
import * as __gh_contract_spec from "@thruputchain/contract-spec";
|
|
4
|
+
import * as __gh_protocol_utils from "@thruputchain/protocol/utils";
|
|
5
|
+
//#region src/contracts/signed_op.ts
|
|
6
|
+
const __gh_s = __gh_contract_spec.contractSpecString;
|
|
7
|
+
const __gh_entrypoints = { SignedOp: { v0_1: { executeSignedOp: __gh_protocol.contractEntrypointID(__gh_protocol_utils.fromHex("c281dc2ffb5eeb1e")) } } };
|
|
8
|
+
const spec = {
|
|
9
|
+
interfaces: [{
|
|
10
|
+
name: __gh_s("SignedOp"),
|
|
11
|
+
vers: __gh_s("0.1.68"),
|
|
12
|
+
throws: [{
|
|
13
|
+
selector: 15548170127105669969n,
|
|
14
|
+
ty: {
|
|
15
|
+
v: __gh_contract_spec.ContractTypeKind.Named,
|
|
16
|
+
named: {
|
|
17
|
+
crate_name: __gh_s("thruput-signed-op-if"),
|
|
18
|
+
major: __gh_s("0.1"),
|
|
19
|
+
module_path: __gh_s("thruput_signed_op_if::error"),
|
|
20
|
+
declared: __gh_s("SignedOpError")
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}],
|
|
24
|
+
methods: [{
|
|
25
|
+
name: __gh_s("execute_signed_op"),
|
|
26
|
+
args: [{
|
|
27
|
+
name: __gh_s("op"),
|
|
28
|
+
ty: {
|
|
29
|
+
v: __gh_contract_spec.ContractTypeKind.Named,
|
|
30
|
+
named: {
|
|
31
|
+
crate_name: __gh_s("thruput-signed-op-if"),
|
|
32
|
+
major: __gh_s("0.1"),
|
|
33
|
+
module_path: __gh_s("thruput_signed_op_if"),
|
|
34
|
+
declared: __gh_s("Operation")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}, {
|
|
38
|
+
name: __gh_s("signature"),
|
|
39
|
+
ty: {
|
|
40
|
+
v: __gh_contract_spec.ContractTypeKind.Array,
|
|
41
|
+
array: {
|
|
42
|
+
element: { v: __gh_contract_spec.ContractTypeKind.U8 },
|
|
43
|
+
len: 64n
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}],
|
|
47
|
+
return_type: {
|
|
48
|
+
v: __gh_contract_spec.ContractTypeKind.SignedToken,
|
|
49
|
+
signed_token_preimage: { preimage_type: null }
|
|
50
|
+
},
|
|
51
|
+
effect: null
|
|
52
|
+
}]
|
|
53
|
+
}],
|
|
54
|
+
type_defs: [{
|
|
55
|
+
v: __gh_contract_spec.ContractTypeDefKind.TypeDefStruct,
|
|
56
|
+
struct_def: {
|
|
57
|
+
name: {
|
|
58
|
+
crate_name: __gh_s("thruput-signed-op-if"),
|
|
59
|
+
major: __gh_s("0.1"),
|
|
60
|
+
module_path: __gh_s("thruput_signed_op_if"),
|
|
61
|
+
declared: __gh_s("Operation")
|
|
62
|
+
},
|
|
63
|
+
fields: [
|
|
64
|
+
{
|
|
65
|
+
name: __gh_s("block_expiry_height"),
|
|
66
|
+
ty: { v: __gh_contract_spec.ContractTypeKind.I64 }
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: __gh_s("nonce"),
|
|
70
|
+
ty: { v: __gh_contract_spec.ContractTypeKind.U64 }
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: __gh_s("body"),
|
|
74
|
+
ty: {
|
|
75
|
+
v: __gh_contract_spec.ContractTypeKind.Vector,
|
|
76
|
+
vector: {
|
|
77
|
+
element: { v: __gh_contract_spec.ContractTypeKind.U8 },
|
|
78
|
+
max_len: 4294967295n
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
v: __gh_contract_spec.ContractTypeDefKind.TypeDefEnum,
|
|
86
|
+
enum_def: {
|
|
87
|
+
name: {
|
|
88
|
+
crate_name: __gh_s("thruput-signed-op-if"),
|
|
89
|
+
major: __gh_s("0.1"),
|
|
90
|
+
module_path: __gh_s("thruput_signed_op_if::error"),
|
|
91
|
+
declared: __gh_s("SignedOpError")
|
|
92
|
+
},
|
|
93
|
+
variants: [
|
|
94
|
+
{
|
|
95
|
+
name: __gh_s("InvalidSignature"),
|
|
96
|
+
value: 1n
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: __gh_s("Expired"),
|
|
100
|
+
value: 2n
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: __gh_s("AlreadyConsumed"),
|
|
104
|
+
value: 3n
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: __gh_s("MalformedBody"),
|
|
108
|
+
value: 4n
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: __gh_s("NotYetExpired"),
|
|
112
|
+
value: 5n
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
}],
|
|
117
|
+
events: []
|
|
118
|
+
};
|
|
119
|
+
const __gh_codecs = createContractCodecContext(spec.type_defs);
|
|
120
|
+
const SignedOp = { v0_1: { executeSignedOp: defineContractMethod({
|
|
121
|
+
interfaceName: "SignedOp",
|
|
122
|
+
interfaceVersion: "0.1.68",
|
|
123
|
+
abiName: "execute_signed_op",
|
|
124
|
+
publicName: "executeSignedOp",
|
|
125
|
+
entrypoint: __gh_entrypoints.SignedOp.v0_1.executeSignedOp,
|
|
126
|
+
effect: spec.interfaces[0].methods[0].effect,
|
|
127
|
+
args: [{
|
|
128
|
+
abiName: "op",
|
|
129
|
+
publicName: "op",
|
|
130
|
+
type: spec.interfaces[0].methods[0].args[0].ty
|
|
131
|
+
}, {
|
|
132
|
+
abiName: "signature",
|
|
133
|
+
publicName: "signature",
|
|
134
|
+
type: spec.interfaces[0].methods[0].args[1].ty
|
|
135
|
+
}],
|
|
136
|
+
returnType: spec.interfaces[0].methods[0].return_type,
|
|
137
|
+
throws: [{
|
|
138
|
+
selector: 15548170127105669969n,
|
|
139
|
+
name: "SignedOpError",
|
|
140
|
+
type: spec.interfaces[0].throws[0].ty
|
|
141
|
+
}],
|
|
142
|
+
codecs: __gh_codecs
|
|
143
|
+
}) } };
|
|
144
|
+
const thruput_signed_op_if = { v0_1: { error: { SignedOpError: {
|
|
145
|
+
InvalidSignature: 1n,
|
|
146
|
+
Expired: 2n,
|
|
147
|
+
AlreadyConsumed: 3n,
|
|
148
|
+
MalformedBody: 4n,
|
|
149
|
+
NotYetExpired: 5n
|
|
150
|
+
} } } };
|
|
151
|
+
//#endregion
|
|
152
|
+
export { spec as n, thruput_signed_op_if as r, SignedOp as t };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=signed_op-BokEDWr-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed_op-BokEDWr-.js","names":["__gh_client_contract.createContractCodecContext","__gh_client_contract.defineContractMethod"],"sources":["../src/contracts/signed_op.ts"],"sourcesContent":["// Generated from signed_op.spec.xdr - SignedOp interface v0.1.68\n// DO NOT EDIT. Re-run codegen to update.\n\nimport * as __gh_protocol from \"@thruputchain/protocol\";\nimport * as __gh_protocol_utils from \"@thruputchain/protocol/utils\";\nimport * as __gh_contract_spec from \"@thruputchain/contract-spec\";\nimport * as __gh_client_contract from \"../contract/index.js\";\n\nconst __gh_s = __gh_contract_spec.contractSpecString;\n\nconst __gh_entrypoints = {\n SignedOp: {\n v0_1: {\n executeSignedOp: __gh_protocol.contractEntrypointID(\n __gh_protocol_utils.fromHex(\"c281dc2ffb5eeb1e\"),\n ),\n },\n },\n} as const;\n\nexport namespace thruput_signed_op_if {\n export namespace v0_1 {\n export interface Operation {\n block_expiry_height: bigint;\n nonce: bigint;\n body: globalThis.Uint8Array;\n }\n\n export namespace error {\n export type SignedOpError = 1n | 2n | 3n | 4n | 5n;\n }\n }\n}\n\nexport namespace SignedOp {\n export namespace v0_1 {\n export interface ExecuteSignedOpArgs {\n op: __gh_codegen.thruput_signed_op_if$v0_1$Operation;\n signature: __gh_client_contract.FixedBytes<64>;\n }\n export type ExecuteSignedOpResult = __gh_client_contract.SignedToken;\n\n export type DeclaredException = {\n kind: \"declared\";\n name: \"SignedOpError\";\n selector: 0xd7c6325a55793b51n;\n value: __gh_codegen.thruput_signed_op_if$v0_1$error$SignedOpError;\n };\n export type Exception =\n __gh_client_contract.ContractException<DeclaredException>;\n }\n}\n\nexport const spec: __gh_client_contract.ContractSpec = {\n interfaces: [\n {\n name: __gh_s(\"SignedOp\"),\n vers: __gh_s(\"0.1.68\"),\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n },\n },\n ],\n methods: [\n {\n name: __gh_s(\"execute_signed_op\"),\n args: [\n {\n name: __gh_s(\"op\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Named,\n named: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n },\n },\n {\n name: __gh_s(\"signature\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Array,\n array: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n len: 64n,\n },\n },\n },\n ],\n return_type: {\n v: __gh_contract_spec.ContractTypeKind.SignedToken,\n signed_token_preimage: { preimage_type: null },\n },\n effect: null,\n },\n ],\n },\n ],\n type_defs: [\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefStruct,\n struct_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if\"),\n declared: __gh_s(\"Operation\"),\n },\n fields: [\n {\n name: __gh_s(\"block_expiry_height\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.I64 },\n },\n {\n name: __gh_s(\"nonce\"),\n ty: { v: __gh_contract_spec.ContractTypeKind.U64 },\n },\n {\n name: __gh_s(\"body\"),\n ty: {\n v: __gh_contract_spec.ContractTypeKind.Vector,\n vector: {\n element: { v: __gh_contract_spec.ContractTypeKind.U8 },\n max_len: 4294967295n,\n },\n },\n },\n ],\n },\n },\n {\n v: __gh_contract_spec.ContractTypeDefKind.TypeDefEnum,\n enum_def: {\n name: {\n crate_name: __gh_s(\"thruput-signed-op-if\"),\n major: __gh_s(\"0.1\"),\n module_path: __gh_s(\"thruput_signed_op_if::error\"),\n declared: __gh_s(\"SignedOpError\"),\n },\n variants: [\n { name: __gh_s(\"InvalidSignature\"), value: 1n },\n { name: __gh_s(\"Expired\"), value: 2n },\n { name: __gh_s(\"AlreadyConsumed\"), value: 3n },\n { name: __gh_s(\"MalformedBody\"), value: 4n },\n { name: __gh_s(\"NotYetExpired\"), value: 5n },\n ],\n },\n },\n ],\n events: [],\n};\n\nconst __gh_codecs = __gh_client_contract.createContractCodecContext(\n spec.type_defs,\n);\n\nexport const SignedOp = {\n v0_1: {\n executeSignedOp: __gh_client_contract.defineContractMethod<\n SignedOp.v0_1.ExecuteSignedOpArgs,\n SignedOp.v0_1.ExecuteSignedOpResult,\n SignedOp.v0_1.DeclaredException\n >({\n interfaceName: \"SignedOp\",\n interfaceVersion: \"0.1.68\",\n abiName: \"execute_signed_op\",\n publicName: \"executeSignedOp\",\n entrypoint: __gh_entrypoints.SignedOp.v0_1.executeSignedOp,\n effect: spec.interfaces[0]!.methods[0]!.effect,\n args: [\n {\n abiName: \"op\",\n publicName: \"op\",\n type: spec.interfaces[0]!.methods[0]!.args[0]!.ty,\n },\n {\n abiName: \"signature\",\n publicName: \"signature\",\n type: spec.interfaces[0]!.methods[0]!.args[1]!.ty,\n },\n ],\n returnType: spec.interfaces[0]!.methods[0]!.return_type,\n throws: [\n {\n selector: 0xd7c6325a55793b51n,\n name: \"SignedOpError\",\n type: spec.interfaces[0]!.throws[0]!.ty,\n },\n ],\n codecs: __gh_codecs,\n }),\n },\n} as const;\n\nexport const thruput_signed_op_if = {\n v0_1: {\n error: {\n SignedOpError: {\n InvalidSignature: 1n,\n Expired: 2n,\n AlreadyConsumed: 3n,\n MalformedBody: 4n,\n NotYetExpired: 5n,\n },\n },\n },\n} as const;\n\n// The types the namespaces above refer to, under names no declaration can capture.\nexport namespace __gh_codegen {\n export type thruput_signed_op_if$v0_1$Operation =\n thruput_signed_op_if.v0_1.Operation;\n export type thruput_signed_op_if$v0_1$error$SignedOpError =\n thruput_signed_op_if.v0_1.error.SignedOpError;\n}\n"],"mappings":";;;;;AAQA,MAAM,SAAS,mBAAmB;AAElC,MAAM,mBAAmB,EACvB,UAAU,EACR,MAAM,EACJ,iBAAiB,cAAc,qBAC7B,oBAAoB,QAAQ,kBAAkB,CAChD,EACF,EACF,EACF;AAmCA,MAAa,OAA0C;CACrD,YAAY,CACV;EACE,MAAM,OAAO,UAAU;EACvB,MAAM,OAAO,QAAQ;EACrB,QAAQ,CACN;GACE,UAAU;GACV,IAAI;IACF,GAAG,mBAAmB,iBAAiB;IACvC,OAAO;KACL,YAAY,OAAO,sBAAsB;KACzC,OAAO,OAAO,KAAK;KACnB,aAAa,OAAO,6BAA6B;KACjD,UAAU,OAAO,eAAe;IAClC;GACF;EACF,CACF;EACA,SAAS,CACP;GACE,MAAM,OAAO,mBAAmB;GAChC,MAAM,CACJ;IACE,MAAM,OAAO,IAAI;IACjB,IAAI;KACF,GAAG,mBAAmB,iBAAiB;KACvC,OAAO;MACL,YAAY,OAAO,sBAAsB;MACzC,OAAO,OAAO,KAAK;MACnB,aAAa,OAAO,sBAAsB;MAC1C,UAAU,OAAO,WAAW;KAC9B;IACF;GACF,GACA;IACE,MAAM,OAAO,WAAW;IACxB,IAAI;KACF,GAAG,mBAAmB,iBAAiB;KACvC,OAAO;MACL,SAAS,EAAE,GAAG,mBAAmB,iBAAiB,GAAG;MACrD,KAAK;KACP;IACF;GACF,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YAAY;CACZ,YAAY,iBAAiB,SAAS,KAAK;CAC3C,QAAQ,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE;CACxC,MAAM,CACJ;EACE,SAAS;EACT,YAAY;EACZ,MAAM,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAE;CACjD,GACA;EACE,SAAS;EACT,YAAY;EACZ,MAAM,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAE;CACjD,CACF;CACA,YAAY,KAAK,WAAW,EAAE,CAAE,QAAQ,EAAE,CAAE;CAC5C,QAAQ,CACN;EACE,UAAU;EACV,MAAM;EACN,MAAM,KAAK,WAAW,EAAE,CAAE,OAAO,EAAE,CAAE;CACvC,CACF;CACA,QAAQ;AACV,CAAC,EACH,EACF;AAEA,MAAa,uBAAuB,EAClC,MAAM,EACJ,OAAO,EACL,eAAe;CACb,kBAAkB;CAClB,SAAS;CACT,iBAAiB;CACjB,eAAe;CACf,eAAe;AACjB,EACF,EACF,EACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Ot as ContractSpec, l as ContractMethod, s as ContractException } from "./readViews-DQoaUORa.js";
|
|
2
|
+
import { c as SignedToken, n as FixedBytes } from "./index-D89ur7mO.js";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/signed_op.d.ts
|
|
5
|
+
declare namespace thruput_signed_op_if {
|
|
6
|
+
namespace v0_1 {
|
|
7
|
+
interface Operation {
|
|
8
|
+
block_expiry_height: bigint;
|
|
9
|
+
nonce: bigint;
|
|
10
|
+
body: globalThis.Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
namespace error {
|
|
13
|
+
type SignedOpError = 1n | 2n | 3n | 4n | 5n;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
declare namespace SignedOp {
|
|
18
|
+
namespace v0_1 {
|
|
19
|
+
interface ExecuteSignedOpArgs {
|
|
20
|
+
op: __gh_codegen.thruput_signed_op_if$v0_1$Operation;
|
|
21
|
+
signature: FixedBytes<64>;
|
|
22
|
+
}
|
|
23
|
+
type ExecuteSignedOpResult = SignedToken;
|
|
24
|
+
type DeclaredException = {
|
|
25
|
+
kind: "declared";
|
|
26
|
+
name: "SignedOpError";
|
|
27
|
+
selector: 0xd7c6325a55793b51n;
|
|
28
|
+
value: __gh_codegen.thruput_signed_op_if$v0_1$error$SignedOpError;
|
|
29
|
+
};
|
|
30
|
+
type Exception = ContractException<DeclaredException>;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
declare const spec: ContractSpec;
|
|
34
|
+
declare const SignedOp: {
|
|
35
|
+
readonly v0_1: {
|
|
36
|
+
readonly executeSignedOp: ContractMethod<SignedOp.v0_1.ExecuteSignedOpArgs, SignedOp.v0_1.ExecuteSignedOpResult, SignedOp.v0_1.DeclaredException>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
declare const thruput_signed_op_if: {
|
|
40
|
+
readonly v0_1: {
|
|
41
|
+
readonly error: {
|
|
42
|
+
readonly SignedOpError: {
|
|
43
|
+
readonly InvalidSignature: 1n;
|
|
44
|
+
readonly Expired: 2n;
|
|
45
|
+
readonly AlreadyConsumed: 3n;
|
|
46
|
+
readonly MalformedBody: 4n;
|
|
47
|
+
readonly NotYetExpired: 5n;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
declare namespace __gh_codegen {
|
|
53
|
+
type thruput_signed_op_if$v0_1$Operation = thruput_signed_op_if.v0_1.Operation;
|
|
54
|
+
type thruput_signed_op_if$v0_1$error$SignedOpError = thruput_signed_op_if.v0_1.error.SignedOpError;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { spec as n, thruput_signed_op_if as r, SignedOp as t };
|
|
58
|
+
//# sourceMappingURL=signed_op-C4lY_TCc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signed_op-C4lY_TCc.d.ts","names":[],"sources":["../src/contracts/signed_op.ts"],"mappings":";;;;kBAoBiB,oBAAA;EAAA,UACE,IAAA;IAAA,UACE,SAAA;MACf,mBAAA;MACA,KAAA;MACA,IAAA,EAAM,UAAA,CAAW,UAAU;IAAA;IAAA,UAGZ,KAAA;MAAA,KACH,aAAA;IAAA;EAAA;AAAA;AAAA,kBAKD,QAAA;EAAA,UACE,IAAA;IAAA,UACE,mBAAA;MACf,EAAA,EAAI,YAAA,CAAa,mCAAA;MACjB,SAAA,EAAW,UAAA;IAAA;IAAA,KAED,qBAAA,GAAwB,WAAA;IAAA,KAExB,iBAAA;MACV,IAAA;MACA,IAAA;MACA,QAAA;MACA,KAAA,EAAO,YAAA,CAAa,6CAAA;IAAA;IAAA,KAEV,SAAA,GACV,iBAAA,CAAuC,iBAAA;EAAA;AAAA;AAAA,cAIhC,IAAA,EAAM,YA2GlB;AAAA,cAMY,QAAA;EAAA;;;;cAsCA,oBAAA;EAAA;;;;;;;;;;;;kBAeI,YAAA;EAAA,KACH,mCAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,SAAA;EAAA,KAChB,6CAAA,GACV,oBAAA,CAAqB,IAAA,CAAK,KAAA,CAAM,aAAa;AAAA"}
|