@orangecheck/pledge-core / wrapPledgeEnvelope
Function: wrapPledgeEnvelope()
function wrapPledgeEnvelope(
input: PledgeCanonicalInput,
sigValue: string,
opts?: {
sigPubkey?: string;
viaDelegation?: {
agentAddress: string;
delegationId: string;
};
}): PledgeEnvelope;
Defined in: pledge-core/src/pledge.ts:146
Build a pledge envelope from a canonical input + an externally-obtained
BIP-322 signature. Companion to createPledge for callers who sign
outside the SDK — typically web apps that use a wallet-extension's
signMessage API directly rather than wrapping it as a Bip322Signer.
The caller is responsible for:
- Producing
sigValueover the lowercase-hex pledge id (SPEC §3.5). Compute the id viacomputePledgeId(input)first; pass that exact hex string to the wallet's signMessage. - Identifying which address signed (
sigPubkey). For non-agent pledges this MUST equalinput.swearer. For agent pledges (viaDelegation set),sigPubkeySHOULD equalviaDelegation.agentAddresssince that's the cryptographic signer; verifiers under SPEC §7.3 useagent_addressfrom the envelope as the BIP-322 verification key regardless of what's insig.pubkey.
Throws PledgeError if the canonical input is invalid (same gates as
createPledge).
Parameters
| Parameter | Type |
|---|---|
input | PledgeCanonicalInput |
sigValue | string |
opts? | { sigPubkey?: string; viaDelegation?: { agentAddress: string; delegationId: string; }; } |
opts.sigPubkey? | string |
opts.viaDelegation? | { agentAddress: string; delegationId: string; } |
opts.viaDelegation.agentAddress? | string |
opts.viaDelegation.delegationId? | string |